From 3962577329ea2561fe8dd9db1281e7a6a2ea62cf Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Tue, 29 Apr 2014 14:19:03 +0200 Subject: [PATCH] CLOUDSTACK-4549: Do not force RBD snapshot backups to RAW format Since we use qemu-img to copy from RBD to Secondary Storage we no longer have to force to RAW images, but can stick with QCOW2 When the snapshot backups are QCOW2 format they can easily be deployed again when restoring from a backup --- .../hypervisor/kvm/storage/KVMStorageProcessor.java | 10 ++-------- .../hypervisor/kvm/storage/LibvirtStorageAdaptor.java | 8 +++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java index 89270c10a62..22575ee8eed 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java @@ -709,7 +709,7 @@ public class KVMStorageProcessor implements StorageProcessor { srcFile.setFormat(PhysicalDiskFormat.RAW); QemuImgFile destFile = new QemuImgFile(snapshotFile); - destFile.setFormat(srcFile.getFormat()); + destFile.setFormat(snapshotDisk.getFormat()); s_logger.debug("Backing up RBD snapshot " + rbdSnapshot + " to " + snapshotFile); QemuImg q = new QemuImg(cmd.getWaitInMillSeconds()); @@ -1225,13 +1225,7 @@ public class KVMStorageProcessor implements StorageProcessor { VolumeObjectTO newVol = new VolumeObjectTO(); newVol.setPath(disk.getName()); newVol.setSize(disk.getVirtualSize()); - - /** - * We have to force the format of RBD volumes to RAW - */ - if (primaryPool.getType() == StoragePoolType.RBD) { - newVol.setFormat(ImageFormat.RAW); - } + newVol.setFormat(ImageFormat.valueOf(disk.getFormat().toString().toUpperCase())); return new CopyCmdAnswer(newVol); } catch (CloudRuntimeException e) { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index 503c51b5520..09400c77c30 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@ -1150,7 +1150,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { if (srcPool.getType() != StoragePoolType.RBD) { newDisk = destPool.createPhysicalDisk(name, Storage.ProvisioningType.THIN, disk.getVirtualSize()); } else { - newDisk = destPool.createPhysicalDisk(name, sourceFormat, Storage.ProvisioningType.THIN, disk.getVirtualSize()); + newDisk = destPool.createPhysicalDisk(name, Storage.ProvisioningType.THIN, disk.getVirtualSize()); } } } else { @@ -1201,10 +1201,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } } else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD)) { /** - * Qemu doesn't support writing to RBD format 2 directly, so we have to write to a temporary RAW file first - * which we then convert to RBD format 2. - * - * A HUGE performance gain can be achieved here if QCOW2 -> RBD format 2 can be done in one step + * Using qemu-img we copy the QCOW2 disk to RAW (on RBD) directly. + * To do so it's mandatory that librbd on the system is at least 0.67.7 (Ceph Dumpling) */ s_logger.debug("The source image is not RBD, but the destination is. We will convert into RBD format 2"); String sourceFile;