mirror of https://github.com/apache/cloudstack.git
Backport ScaleIO VM template copy fix for non-direct download (#181)
* Backport ScaleIO VM template copy fix for non-direct download * Update plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> * Update plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> * build fixes Co-authored-by: Marcus Sorensen <mls@apple.com> Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> Co-authored-by: Suresh Kumar Anaparti <suresh.anaparti@shapeblue.com>
This commit is contained in:
parent
41d6dd6a23
commit
7899f5cce6
|
|
@ -23,6 +23,7 @@ public class KVMPhysicalDisk {
|
|||
private String path;
|
||||
private String name;
|
||||
private KVMStoragePool pool;
|
||||
private boolean isTemplate;
|
||||
|
||||
public static String RBDStringBuilder(String monHost, int monPort, String authUserName, String authSecret, String image) {
|
||||
String rbdOpts;
|
||||
|
|
@ -111,4 +112,7 @@ public class KVMPhysicalDisk {
|
|||
this.qemuEncryptFormat = format;
|
||||
}
|
||||
|
||||
public void setAsTemplate() { isTemplate = true; }
|
||||
|
||||
public boolean isTemplate() { return this.isTemplate; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
}
|
||||
|
||||
/* Copy volume to primary storage */
|
||||
tmplVol.setAsTemplate();
|
||||
s_logger.debug("Copying template to primary storage, template format is " + tmplVol.getFormat() );
|
||||
final KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
|
||||
|
||||
|
|
|
|||
|
|
@ -313,7 +313,15 @@ public class ScaleIOStorageAdaptor implements StorageAdaptor {
|
|||
throw new CloudRuntimeException("Failed to find the disk: " + name + " of the storage pool: " + destPool.getUuid());
|
||||
}
|
||||
|
||||
destDisk.setFormat(QemuImg.PhysicalDiskFormat.RAW);
|
||||
// golden copies of templates should be kept as qcow2 in the PowerFlex storage pool
|
||||
if (disk.isTemplate()) {
|
||||
LOGGER.debug("This is a template copy, storing in powerflex as QCOW2");
|
||||
destDisk.setFormat(QemuImg.PhysicalDiskFormat.QCOW2);
|
||||
} else {
|
||||
LOGGER.debug("This is not a template copy, storing in powerflex as RAW");
|
||||
destDisk.setFormat(QemuImg.PhysicalDiskFormat.RAW);
|
||||
}
|
||||
|
||||
destDisk.setVirtualSize(disk.getVirtualSize());
|
||||
destDisk.setSize(disk.getSize());
|
||||
|
||||
|
|
@ -357,6 +365,11 @@ public class ScaleIOStorageAdaptor implements StorageAdaptor {
|
|||
|
||||
boolean forceSourceFormat = srcFile.getFormat() == QemuImg.PhysicalDiskFormat.RAW;
|
||||
LOGGER.debug(String.format("Starting copy from source disk %s(%s) to PowerFlex volume %s(%s), forcing source format is %b", srcFile.getFileName(), srcFile.getFormat(), destFile.getFileName(), destFile.getFormat(), forceSourceFormat));
|
||||
if (destFile.getFormat() == QemuImg.PhysicalDiskFormat.QCOW2) {
|
||||
destFile.setSize(disk.getVirtualSize());
|
||||
LOGGER.debug(String.format("Pre-formatting qcow2 block device %s to size %s", destFile.getFileName(), destFile.getSize()));
|
||||
qemu.create(destFile);
|
||||
}
|
||||
qemu.convert(srcFile, destFile, options, qemuObjects, qemuImageOpts,null, forceSourceFormat);
|
||||
LOGGER.debug("Succesfully converted source disk image " + srcFile.getFileName() + " to PowerFlex volume: " + destDisk.getPath());
|
||||
} catch (QemuImgException | LibvirtException | IOException | CryptSetupException e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue