This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit def65ec873b6dd4e14b913076fba2b8ac7133969 Merge: d4635e3 0942838 Author: Rohit Yadav <[email protected]> AuthorDate: Sun Apr 4 13:09:41 2021 +0530 Merge remote-tracking branch 'origin/4.15' .../kvm/resource/LibvirtComputingResource.java | 6 +++--- .../kvm/storage/LibvirtStorageAdaptor.java | 6 +++--- .../org/apache/cloudstack/utils/qemu/QemuImg.java | 6 ++++++ .../apache/cloudstack/utils/qemu/QemuImgTest.java | 24 +++++++++++----------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --cc plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 64a2883,7b4872b..52cda63 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@@ -4312,11 -4274,11 +4312,11 @@@ public class LibvirtComputingResource e s_logger.info("Setting backing file format of " + volPath); QemuImgFile backingFile = new QemuImgFile(backingFilePath); Map<String, String> backingFileinfo = qemu.info(backingFile); - String backingFileFmt = backingFileinfo.get(new String("file_format")); + String backingFileFmt = backingFileinfo.get(QemuImg.FILE_FORMAT); qemu.rebase(file, backingFile, backingFileFmt, false); } - } catch (QemuImgException e) { - s_logger.error("Failed to set backing file format of " + volPath + " due to : " + e.getMessage()); + } catch (QemuImgException | LibvirtException e) { + s_logger.error("Failed to set backing file format of " + volPath + " due to : " + e.getMessage(), e); } } diff --cc plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index c17cd44,c9f806d..3532996 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@@ -808,9 -809,9 +808,9 @@@ public class LibvirtStorageAdaptor impl try{ qemu.create(destFile, options); Map<String, String> info = qemu.info(destFile); - virtualSize = Long.parseLong(info.get(new String("virtual_size"))); + virtualSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE)); actualSize = new File(destFile.getFileName()).length(); - } catch (QemuImgException e) { + } catch (QemuImgException | LibvirtException e) { s_logger.error("Failed to create " + volPath + " due to a failed executing of qemu-img: " + e.getMessage()); } @@@ -1297,10 -1299,10 +1297,10 @@@ try { qemu.convert(srcFile, destFile); Map<String, String> destInfo = qemu.info(destFile); - Long virtualSize = Long.parseLong(destInfo.get(new String("virtual_size"))); + Long virtualSize = Long.parseLong(destInfo.get(QemuImg.VIRTUAL_SIZE)); newDisk.setVirtualSize(virtualSize); newDisk.setSize(virtualSize); - } catch (QemuImgException e) { + } catch (QemuImgException | LibvirtException e) { s_logger.error("Failed to convert " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage()); newDisk = null; } diff --cc plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuImg.java index 44ef71a,0e5da48..fb254af --- a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuImg.java +++ b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuImg.java @@@ -24,11 -26,14 +24,17 @@@ import com.cloud.hypervisor.kvm.resourc import com.cloud.storage.Storage; import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.NotImplementedException; +import org.libvirt.LibvirtException; public class QemuImg { + public final static String BACKING_FILE = "backing_file"; + public final static String BACKING_FILE_FORMAT = "backing_file_format"; + public final static String CLUSTER_SIZE = "cluster_size"; + public final static String FILE_FORMAT = "file_format"; + public final static String IMAGE = "image"; + public final static String VIRTUAL_SIZE = "virtual_size"; /* The qemu-img binary. We expect this to be in $PATH */ public String _qemuImgPath = "qemu-img";
