You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2012/12/06 01:56:00 UTC
git commit: Summary: master - Copy qcow2 instead of converting if
source and dest are qcow2
Updated Branches:
refs/heads/master a91df8f32 -> 7ce222710
Summary: master - Copy qcow2 instead of converting if source and dest are qcow2
Detail: If source image is qcow2, and we want a qcow2 image, then doing a
convert strips off compression and any snapshots the user had in that image. If
a backing file exists, we stick with convert so we can pull in both the backing
file and the COW image, otherwise we just cp the qcow2 file. This is also faster
Signed-off-by: Marcus Sorensen <ma...@betterservers.com> 1354755241 -0700
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7ce22271
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7ce22271
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7ce22271
Branch: refs/heads/master
Commit: 7ce2227108dd0ffe9d2f7bd75ab1b36190053266
Parents: a91df8f
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Wed Dec 5 17:54:01 2012 -0700
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Wed Dec 5 17:54:01 2012 -0700
----------------------------------------------------------------------
.../kvm/storage/LibvirtStorageAdaptor.java | 14 ++++++++++----
scripts/storage/qcow2/create_private_template.sh | 8 +++++++-
scripts/storage/qcow2/createtmplt.sh | 6 ++++++
scripts/storage/qcow2/createvolume.sh | 6 ++++++
4 files changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ce22271/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 6c55743..2a603cb 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
@@ -688,10 +688,16 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
PhysicalDiskFormat destFormat = newDisk.getFormat();
if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() != StoragePoolType.RBD)) {
- Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
- + " -O " + destFormat
- + " " + sourcePath
- + " " + destPath);
+ if (sourceFormat.equals(destFormat) &&
+ Script.runSimpleBashScript("qemu-img info " + sourcePath + "|grep backing") == null) {
+ Script.runSimpleBashScript("cp -f " + sourcePath + " " + destPath);
+
+ } else {
+ Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
+ + " -O " + destFormat
+ + " " + sourcePath
+ + " " + destPath);
+ }
} else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD)) {
Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
+ " -O " + destFormat
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ce22271/scripts/storage/qcow2/create_private_template.sh
----------------------------------------------------------------------
diff --git a/scripts/storage/qcow2/create_private_template.sh b/scripts/storage/qcow2/create_private_template.sh
index 4b93380..8e9e26c 100755
--- a/scripts/storage/qcow2/create_private_template.sh
+++ b/scripts/storage/qcow2/create_private_template.sh
@@ -31,7 +31,13 @@ create_template() {
local fspath=$1
local destpath=$2
- qemu-img convert -O qcow2 /$fspath $destpath
+ # if backing image exists, we need to combine them, otherwise
+ # copy the image to preserve snapshots/compression
+ if $qemu_img info "$tmpltimg" | grep -q backing; then
+ qemu-img convert -O qcow2 /$fspath $destpath
+ else
+ cp -f /$fspath $destpath
+ fi
if [ $? -gt 0 ]; then
printf " Failed to export template $destpath\n" >&2
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ce22271/scripts/storage/qcow2/createtmplt.sh
----------------------------------------------------------------------
diff --git a/scripts/storage/qcow2/createtmplt.sh b/scripts/storage/qcow2/createtmplt.sh
index 84d2ba8..152268f 100755
--- a/scripts/storage/qcow2/createtmplt.sh
+++ b/scripts/storage/qcow2/createtmplt.sh
@@ -100,7 +100,13 @@ create_from_file() {
if [ -b $tmpltimg ]; then
$qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname
else
+ # if backing image exists, we need to combine them, otherwise
+ # copy the image to preserve snapshots/compression
+ if $qemu_img info "$tmpltimg" | grep -q backing; then
$qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null
+ else
+ cp -f $tmpltimg /$tmpltfs/$tmpltname
+ fi
fi
if [ "$cleanup" == "true" ]
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ce22271/scripts/storage/qcow2/createvolume.sh
----------------------------------------------------------------------
diff --git a/scripts/storage/qcow2/createvolume.sh b/scripts/storage/qcow2/createvolume.sh
index 10fa6dd..527aa68 100755
--- a/scripts/storage/qcow2/createvolume.sh
+++ b/scripts/storage/qcow2/createvolume.sh
@@ -101,7 +101,13 @@ create_from_file() {
if [ -b $volimg ]; then
$qemu_img convert -f raw -O qcow2 "$volimg" /$volfs/$volname
else
+ # if backing image exists, we need to combine them, otherwise
+ # copy the image to preserve snapshots/compression
+ if $qemu_img info "$volimg" | grep -q backing; then
$qemu_img convert -f qcow2 -O qcow2 "$volimg" /$volfs/$volname >& /dev/null
+ else
+ cp -f $volimg /$volfs/$volname
+ fi
fi
if [ "$cleanup" == "true" ]