Skip to content

Commit cfd8056

Browse files
committed
remove a call path that cause NullPointerException
QemuImg.convert expects the arguments not null.
1 parent 4a563b6 commit cfd8056

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -911,20 +911,20 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
911911
Script.runSimpleBashScript("cp -f " + sourcePath + " " + destPath);
912912
} else {
913913
destFile = new QemuImgFile(destPath, destFormat);
914+
try {
915+
qemu.convert(srcFile, destFile);
916+
} catch (QemuImgException e) {
917+
s_logger.error("Failed to convert " + srcFile.getFileName() + " to "
918+
+ destFile.getFileName() + " the error was: " + e.getMessage());
919+
newDisk = null;
920+
}
914921
}
915922
} catch (QemuImgException e) {
916923
s_logger.error("Failed to fetch the information of file "
917924
+ srcFile.getFileName() + " the error was: " + e.getMessage());
925+
newDisk = null;
918926
}
919927
}
920-
921-
try {
922-
qemu.convert(srcFile, destFile);
923-
} catch (QemuImgException e) {
924-
s_logger.error("Failed to convert " + srcFile.getFileName() + " to "
925-
+ destFile.getFileName() + " the error was: " + e.getMessage());
926-
}
927-
928928
} else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD)) {
929929
/**
930930
* Qemu doesn't support writing to RBD format 2 directly, so we have to write to a temporary RAW file first

0 commit comments

Comments
 (0)