CLOUDSTACK-4641: fix create volume from snapshot timeout issue
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3420f2d0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3420f2d0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3420f2d0 Branch: refs/heads/master Commit: 3420f2d0167341011d994cddb98a94a79b5eb308 Parents: 7d8a7f8 Author: Edison Su <sudi...@gmail.com> Authored: Wed Sep 11 18:07:47 2013 -0700 Committer: Edison Su <sudi...@gmail.com> Committed: Wed Sep 25 16:32:55 2013 -0700 ---------------------------------------------------------------------- .../cloudstack/storage/command/CopyCommand.java | 4 +++ .../kvm/resource/LibvirtComputingResource.java | 14 +++++------ .../kvm/storage/KVMStoragePoolManager.java | 14 +++++------ .../kvm/storage/KVMStorageProcessor.java | 26 ++++++++++---------- .../kvm/storage/LibvirtStorageAdaptor.java | 25 ++++++++++--------- .../hypervisor/kvm/storage/StorageAdaptor.java | 4 +-- .../apache/cloudstack/utils/qemu/QemuImg.java | 11 ++++++--- .../cloudstack/utils/qemu/QemuImgTest.java | 20 +++++++-------- 8 files changed, 65 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/core/src/org/apache/cloudstack/storage/command/CopyCommand.java ---------------------------------------------------------------------- diff --git a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java index 629fafe..e9ec0b3 100644 --- a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java @@ -63,4 +63,8 @@ public final class CopyCommand extends Command implements StorageSubSystemComman this.cacheTO = cacheTO; } + public int getWaitInMillSeconds() { + return this.getWait() * 1000; + } + } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 04499d5..e07d122 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -1365,7 +1365,7 @@ ServerResource { secondaryStorageUrl + volumeDestPath); _storagePoolMgr.copyPhysicalDisk(volume, - destVolumeName,secondaryStoragePool); + destVolumeName,secondaryStoragePool, 0); return new CopyVolumeAnswer(cmd, true, null, null, volumeName); } else { volumePath = "/volumes/" + cmd.getVolumeId() + File.separator; @@ -1375,7 +1375,7 @@ ServerResource { KVMPhysicalDisk volume = secondaryStoragePool .getPhysicalDisk(cmd.getVolumePath() + ".qcow2"); _storagePoolMgr.copyPhysicalDisk(volume, volumeName, - primaryPool); + primaryPool, 0); return new CopyVolumeAnswer(cmd, true, null, null, volumeName); } } catch (CloudRuntimeException e) { @@ -1461,7 +1461,7 @@ ServerResource { } else { BaseVol = primaryPool.getPhysicalDisk(cmd.getTemplateUrl()); vol = _storagePoolMgr.createDiskFromTemplate(BaseVol, UUID - .randomUUID().toString(), primaryPool); + .randomUUID().toString(), primaryPool, 0); } if (vol == null) { return new Answer(cmd, false, @@ -1522,7 +1522,7 @@ ServerResource { /* Copy volume to primary storage */ - KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, UUID.randomUUID().toString(), primaryPool); + KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, UUID.randomUUID().toString(), primaryPool, 0); return primaryVol; } catch (CloudRuntimeException e) { s_logger.error("Failed to download template to primary storage",e); @@ -2347,7 +2347,7 @@ ServerResource { primaryUuid); String volUuid = UUID.randomUUID().toString(); KVMPhysicalDisk disk = _storagePoolMgr.copyPhysicalDisk(snapshot, - volUuid, primaryPool); + volUuid, primaryPool, 0); return new CreateVolumeFromSnapshotAnswer(cmd, true, "", disk.getName()); } catch (CloudRuntimeException e) { @@ -2498,7 +2498,7 @@ ServerResource { QemuImgFile destFile = new QemuImgFile(tmpltPath + "/" + cmd.getUniqueName() + ".qcow2"); destFile.setFormat(PhysicalDiskFormat.QCOW2); - QemuImg q = new QemuImg(); + QemuImg q = new QemuImg(0); try { q.convert(srcFile, destFile); } catch (QemuImgException e) { @@ -2601,7 +2601,7 @@ ServerResource { cmd.getPoolUuid()); KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk( - tmplVol, UUID.randomUUID().toString(), primaryPool); + tmplVol, UUID.randomUUID().toString(), primaryPool, 0); return new PrimaryStorageDownloadAnswer(primaryVol.getName(), primaryVol.getSize()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java index e09c9ba..945243a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java @@ -206,25 +206,25 @@ public class KVMStoragePoolManager { } public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template, String name, - KVMStoragePool destPool) { + KVMStoragePool destPool, int timeout) { StorageAdaptor adaptor = getStorageAdaptor(destPool.getType()); // LibvirtStorageAdaptor-specific statement if (destPool.getType() == StoragePoolType.RBD) { return adaptor.createDiskFromTemplate(template, name, - PhysicalDiskFormat.RAW, template.getSize(), destPool); + PhysicalDiskFormat.RAW, template.getSize(), destPool, timeout); } else if (destPool.getType() == StoragePoolType.CLVM) { return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.RAW, template.getSize(), - destPool); + destPool, timeout); } else if (template.getFormat() == PhysicalDiskFormat.DIR) { return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.DIR, - template.getSize(), destPool); + template.getSize(), destPool, timeout); } else { return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.QCOW2, - template.getSize(), destPool); + template.getSize(), destPool, timeout); } } @@ -237,9 +237,9 @@ public class KVMStoragePoolManager { } public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, - KVMStoragePool destPool) { + KVMStoragePool destPool, int timeout) { StorageAdaptor adaptor = getStorageAdaptor(destPool.getType()); - return adaptor.copyPhysicalDisk(disk, name, destPool); + return adaptor.copyPhysicalDisk(disk, name, destPool, timeout); } public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java ---------------------------------------------------------------------- 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 a74df19..82fd2ce 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 @@ -194,7 +194,7 @@ public class KVMStorageProcessor implements StorageProcessor { primaryStore.getUuid()); KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(), - primaryPool); + primaryPool, cmd.getWaitInMillSeconds()); DataTO data = null; @@ -232,7 +232,7 @@ public class KVMStorageProcessor implements StorageProcessor { } // this is much like PrimaryStorageDownloadCommand, but keeping it separate - private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool) { + private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, int timeout) { int index = templateUrl.lastIndexOf("/"); String mountpoint = templateUrl.substring(0, index); String templateName = null; @@ -269,7 +269,7 @@ public class KVMStorageProcessor implements StorageProcessor { /* Copy volume to primary storage */ KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(templateVol, UUID.randomUUID().toString(), - primaryPool); + primaryPool, timeout); return primaryVol; } catch (CloudRuntimeException e) { s_logger.error("Failed to download template to primary storage", e); @@ -300,14 +300,14 @@ public class KVMStorageProcessor implements StorageProcessor { if (primaryPool.getType() == StoragePoolType.CLVM) { templatePath = ((NfsTO)imageStore).getUrl() + File.separator + templatePath; - vol = templateToPrimaryDownload(templatePath, primaryPool); + vol = templateToPrimaryDownload(templatePath, primaryPool, cmd.getWaitInMillSeconds()); } else { if (templatePath.contains("/mnt")) { //upgrade issue, if the path contains path, need to extract the volume uuid from path templatePath = templatePath.substring(templatePath.lastIndexOf(File.separator) + 1); } BaseVol = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), templatePath); - vol = storagePoolMgr.createDiskFromTemplate(BaseVol, UUID.randomUUID().toString(), BaseVol.getPool()); + vol = storagePoolMgr.createDiskFromTemplate(BaseVol, UUID.randomUUID().toString(), BaseVol.getPool(), cmd.getWaitInMillSeconds()); } if (vol == null) { return new CopyCmdAnswer(" Can't create storage volume on storage pool"); @@ -378,7 +378,7 @@ public class KVMStorageProcessor implements StorageProcessor { .getPhysicalDisk(srcVolumeName); volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString())); KVMPhysicalDisk newDisk = storagePoolMgr.copyPhysicalDisk(volume, volumeName, - primaryPool); + primaryPool, cmd.getWaitInMillSeconds()); VolumeObjectTO newVol = new VolumeObjectTO(); newVol.setFormat(ImageFormat.valueOf(newDisk.getFormat().toString().toUpperCase())); newVol.setPath(volumeName); @@ -426,7 +426,7 @@ public class KVMStorageProcessor implements StorageProcessor { secondaryStoragePool = storagePoolMgr.getStoragePoolByURI( secondaryStorageUrl + File.separator + destVolumePath); storagePoolMgr.copyPhysicalDisk(volume, - destVolumeName,secondaryStoragePool); + destVolumeName,secondaryStoragePool, cmd.getWaitInMillSeconds()); VolumeObjectTO newVol = new VolumeObjectTO(); newVol.setPath(destVolumePath + File.separator + destVolumeName); newVol.setFormat(destFormat); @@ -444,7 +444,7 @@ public class KVMStorageProcessor implements StorageProcessor { public Answer createTemplateFromVolume(CopyCommand cmd) { DataTO srcData = cmd.getSrcTO(); DataTO destData = cmd.getDestTO(); - int wait = cmd.getWait(); + int wait = cmd.getWaitInMillSeconds(); TemplateObjectTO template = (TemplateObjectTO) destData; DataStoreTO imageStore = template.getDataStore(); VolumeObjectTO volume = (VolumeObjectTO) srcData; @@ -470,7 +470,7 @@ public class KVMStorageProcessor implements StorageProcessor { String templateName = UUID.randomUUID().toString(); if (primary.getType() != StoragePoolType.RBD) { - Script command = new Script(_createTmplPath, wait * 1000, s_logger); + Script command = new Script(_createTmplPath, wait, s_logger); command.add("-f", disk.getPath()); command.add("-t", tmpltPath); command.add("-n", templateName + ".qcow2"); @@ -491,7 +491,7 @@ public class KVMStorageProcessor implements StorageProcessor { QemuImgFile destFile = new QemuImgFile(tmpltPath + "/" + templateName + ".qcow2"); destFile.setFormat(PhysicalDiskFormat.QCOW2); - QemuImg q = new QemuImg(); + QemuImg q = new QemuImg(cmd.getWaitInMillSeconds()); try { q.convert(srcFile, destFile); } catch (QemuImgException e) { @@ -619,7 +619,7 @@ public class KVMStorageProcessor implements StorageProcessor { SnapshotObjectTO snapshotOnCacheStore = (SnapshotObjectTO)answer.getNewData(); snapshotOnCacheStore.setDataStore(cacheStore); ((SnapshotObjectTO) destData).setDataStore(imageStore); - CopyCommand newCpyCmd = new CopyCommand(snapshotOnCacheStore, destData, cmd.getWait(), cmd.executeInSequence()); + CopyCommand newCpyCmd = new CopyCommand(snapshotOnCacheStore, destData, cmd.getWaitInMillSeconds(), cmd.executeInSequence()); return copyToObjectStore(newCpyCmd); } @Override @@ -723,7 +723,7 @@ public class KVMStorageProcessor implements StorageProcessor { return new CopyCmdAnswer(e.toString()); } } else { - Script command = new Script(_manageSnapshotPath, cmd.getWait() * 1000, s_logger); + Script command = new Script(_manageSnapshotPath, cmd.getWaitInMillSeconds(), s_logger); command.add("-b", snapshotDisk.getPath()); command.add("-n", snapshotName); command.add("-p", snapshotDestPath); @@ -1185,7 +1185,7 @@ public class KVMStorageProcessor implements StorageProcessor { String primaryUuid = pool.getUuid(); KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(pool.getPoolType(), primaryUuid); String volUuid = UUID.randomUUID().toString(); - KVMPhysicalDisk disk = storagePoolMgr.copyPhysicalDisk(snapshotDisk, volUuid, primaryPool); + KVMPhysicalDisk disk = storagePoolMgr.copyPhysicalDisk(snapshotDisk, volUuid, primaryPool, cmd.getWaitInMillSeconds()); VolumeObjectTO newVol = new VolumeObjectTO(); newVol.setPath(disk.getName()); newVol.setSize(disk.getVirtualSize()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java ---------------------------------------------------------------------- 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 b2bdd5b..51e3363 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 @@ -766,7 +766,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { */ @Override public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template, - String name, PhysicalDiskFormat format, long size, KVMStoragePool destPool) { + String name, PhysicalDiskFormat format, long size, KVMStoragePool destPool, int timeout) { String newUuid = UUID.randomUUID().toString(); KVMStoragePool srcPool = template.getPool(); @@ -783,20 +783,20 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { if (destPool.getType() != StoragePoolType.RBD) { disk = destPool.createPhysicalDisk(newUuid, format, template.getVirtualSize()); if (template.getFormat() == PhysicalDiskFormat.TAR) { - Script.runSimpleBashScript("tar -x -f " + template.getPath() + " -C " + disk.getPath()); + Script.runSimpleBashScript("tar -x -f " + template.getPath() + " -C " + disk.getPath(), timeout); } else if (template.getFormat() == PhysicalDiskFormat.DIR) { Script.runSimpleBashScript("mkdir -p " + disk.getPath()); Script.runSimpleBashScript("chmod 755 " + disk.getPath()); - Script.runSimpleBashScript("cp -p -r " + template.getPath() + "/* " + disk.getPath()); + Script.runSimpleBashScript("cp -p -r " + template.getPath() + "/* " + disk.getPath(), timeout); } else if (format == PhysicalDiskFormat.QCOW2) { QemuImgFile backingFile = new QemuImgFile(template.getPath(), template.getFormat()); QemuImgFile destFile = new QemuImgFile(disk.getPath()); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(timeout); qemu.create(destFile, backingFile); } else if (format == PhysicalDiskFormat.RAW) { QemuImgFile sourceFile = new QemuImgFile(template.getPath(), template.getFormat()); QemuImgFile destFile = new QemuImgFile(disk.getPath(), PhysicalDiskFormat.RAW); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(timeout); qemu.convert(sourceFile, destFile); } } else { @@ -806,7 +806,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { disk.setSize(template.getVirtualSize()); disk.setVirtualSize(disk.getSize()); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(timeout); QemuImgFile srcFile; QemuImgFile destFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(), destPool.getSourcePort(), @@ -960,7 +960,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { */ @Override public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, - KVMStoragePool destPool) { + KVMStoragePool destPool, int timeout) { /** With RBD you can't run qemu-img convert with an existing RBD image as destination @@ -999,24 +999,27 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { String destPath = newDisk.getPath(); PhysicalDiskFormat destFormat = newDisk.getFormat(); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(timeout); QemuImgFile srcFile = null; QemuImgFile destFile = null; if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() != StoragePoolType.RBD)) { if (sourceFormat == PhysicalDiskFormat.TAR) { - Script.runSimpleBashScript("tar -x -f " + sourcePath + " -C " + destPath); + Script.runSimpleBashScript("tar -x -f " + sourcePath + " -C " + destPath, timeout); } else if (sourceFormat == PhysicalDiskFormat.DIR) { Script.runSimpleBashScript("mkdir -p " + destPath); Script.runSimpleBashScript("chmod 755 " + destPath); - Script.runSimpleBashScript("cp -p -r " + sourcePath + "/* " + destPath); + Script.runSimpleBashScript("cp -p -r " + sourcePath + "/* " + destPath, timeout); } else { srcFile = new QemuImgFile(sourcePath, sourceFormat); try { Map<String, String> info = qemu.info(srcFile); String backingFile = info.get(new String("backing_file")); if (sourceFormat.equals(destFormat) && backingFile == null) { - Script.runSimpleBashScript("cp -f " + sourcePath + " " + destPath); + String result = Script.runSimpleBashScript("cp -f " + sourcePath + " " + destPath, timeout); + if (result != null) { + throw new CloudRuntimeException("Failed to create disk: " + result); + } } else { destFile = new QemuImgFile(destPath, destFormat); try { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java index 4956d8d..44e0691 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java @@ -40,7 +40,7 @@ public interface StorageAdaptor { public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template, String name, PhysicalDiskFormat format, long size, - KVMStoragePool destPool); + KVMStoragePool destPool, int timeout); public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk, String name, PhysicalDiskFormat format, long size, @@ -50,7 +50,7 @@ public interface StorageAdaptor { KVMStoragePool pool); public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, - KVMStoragePool destPools); + KVMStoragePool destPools, int timeout); public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot, String snapshotName, String name, KVMStoragePool destPool); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java index 4ed8593..0e83bc9 100644 --- a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java +++ b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java @@ -31,6 +31,7 @@ public class QemuImg { /* The qemu-img binary. We expect this to be in $PATH */ public String _qemuImgPath = "qemu-img"; + private int timeout; /* Shouldn't we have KVMPhysicalDisk and LibvirtVMDef read this? */ public static enum PhysicalDiskFormat { @@ -46,8 +47,12 @@ public class QemuImg { } } - public QemuImg() { + public QemuImg(int timeout) { + this.timeout = timeout; + } + public void setTimeout(int timeout) { + this.timeout = timeout; } /** @@ -84,7 +89,7 @@ public class QemuImg { * @return void */ public void create(QemuImgFile file, QemuImgFile backingFile, Map<String, String> options) throws QemuImgException { - Script s = new Script(_qemuImgPath); + Script s = new Script(_qemuImgPath, timeout); s.add("create"); if (options != null && !options.isEmpty()) { @@ -181,7 +186,7 @@ public class QemuImg { * @return void */ public void convert(QemuImgFile srcFile, QemuImgFile destFile, Map<String, String> options) throws QemuImgException { - Script s = new Script(_qemuImgPath); + Script s = new Script(_qemuImgPath, timeout); s.add("convert"); s.add("-f"); s.add(srcFile.getFormat().toString()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3420f2d0/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java b/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java index 9c6ac8b..5244dda 100644 --- a/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java +++ b/plugins/hypervisors/kvm/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java @@ -38,7 +38,7 @@ public class QemuImgTest { long size = 10995116277760l; QemuImgFile file = new QemuImgFile(filename, size, PhysicalDiskFormat.QCOW2); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(file); Map<String, String> info = qemu.info(file); @@ -69,7 +69,7 @@ public class QemuImgTest { options.put("cluster_size", clusterSize); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(file, options); Map<String, String> info = qemu.info(file); @@ -96,7 +96,7 @@ public class QemuImgTest { QemuImgFile file = new QemuImgFile(filename, startSize, PhysicalDiskFormat.QCOW2); try { - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(file); qemu.resize(file, endSize); Map<String, String> info = qemu.info(file); @@ -125,7 +125,7 @@ public class QemuImgTest { QemuImgFile file = new QemuImgFile(filename, startSize, PhysicalDiskFormat.RAW); try { - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(file); qemu.resize(file, increment, true); Map<String, String> info = qemu.info(file); @@ -153,7 +153,7 @@ public class QemuImgTest { QemuImgFile file = new QemuImgFile(filename, startSize, PhysicalDiskFormat.RAW); try { - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(file); qemu.resize(file, increment, true); Map<String, String> info = qemu.info(file); @@ -182,7 +182,7 @@ public class QemuImgTest { long endSize = -1; QemuImgFile file = new QemuImgFile(filename, startSize, PhysicalDiskFormat.QCOW2); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); try { qemu.create(file); qemu.resize(file, endSize); @@ -199,7 +199,7 @@ public class QemuImgTest { long startSize = 20480; QemuImgFile file = new QemuImgFile(filename, 20480, PhysicalDiskFormat.QCOW2); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(file); qemu.resize(file, 0); @@ -216,7 +216,7 @@ public class QemuImgTest { QemuImgFile firstFile = new QemuImgFile(firstFileName, 20480, PhysicalDiskFormat.QCOW2); QemuImgFile secondFile = new QemuImgFile(secondFileName, PhysicalDiskFormat.QCOW2); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(firstFile); qemu.create(secondFile, firstFile); @@ -240,7 +240,7 @@ public class QemuImgTest { QemuImgFile srcFile = new QemuImgFile(srcFileName, srcSize); QemuImgFile destFile = new QemuImgFile(destFileName); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(srcFile); qemu.convert(srcFile, destFile); Map<String, String> info = qemu.info(destFile); @@ -267,7 +267,7 @@ public class QemuImgTest { QemuImgFile srcFile = new QemuImgFile(srcFileName, srcSize, srcFormat); QemuImgFile destFile = new QemuImgFile(destFileName, destFormat); - QemuImg qemu = new QemuImg(); + QemuImg qemu = new QemuImg(0); qemu.create(srcFile); qemu.convert(srcFile, destFile);