Skip to content

Commit 344a9f9

Browse files
author
Marcus Sorensen
committed
LibvirtComputingResource: Fix coverity scan, recent bugfixes revealed a potential unhandled null in getResizeScriptType
Change-Id: I5715a4424646261f2c43cd5e0a16fd72dd12c753
1 parent b9e0e91 commit 344a9f9

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ private String getResizeScriptType(KVMStoragePool pool, KVMPhysicalDisk vol) {
18391839
&& volFormat == PhysicalDiskFormat.QCOW2 ) {
18401840
return "QCOW2";
18411841
}
1842-
return null;
1842+
throw new CloudRuntimeException("Cannot determine resize type from pool type " + pool.getType());
18431843
}
18441844

18451845
/* uses a local script now, eventually support for virStorageVolResize() will maybe work on
@@ -1866,9 +1866,7 @@ public Answer execute(ResizeVolumeCommand cmd) {
18661866
String type = getResizeScriptType(pool, vol);
18671867

18681868
if (pool.getType() != StoragePoolType.RBD) {
1869-
if (type == null) {
1870-
return new ResizeVolumeAnswer(cmd, false, "Unsupported volume format: pool type '" + pool.getType() + "' and volume format '" + vol.getFormat() + "'");
1871-
} else if (type.equals("QCOW2") && shrinkOk) {
1869+
if (type.equals("QCOW2") && shrinkOk) {
18721870
return new ResizeVolumeAnswer(cmd, false, "Unable to shrink volumes of type " + type);
18731871
}
18741872
} else {

0 commit comments

Comments
 (0)