Skip to content

Commit 77d11eb

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

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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
@@ -1840,7 +1840,7 @@ private String getResizeScriptType(KVMStoragePool pool, KVMPhysicalDisk vol) {
18401840
&& volFormat == PhysicalDiskFormat.QCOW2 ) {
18411841
return "QCOW2";
18421842
}
1843-
return null;
1843+
throw new CloudRuntimeException("Cannot determine resize type from pool type " + pool.getType());
18441844
}
18451845

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

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

0 commit comments

Comments
 (0)