mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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 <marcus@betterservers.com> 1354755241 -0700
This commit is contained in:
parent
a91df8f32d
commit
7ce2227108
@ -688,10 +688,16 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
|||||||
PhysicalDiskFormat destFormat = newDisk.getFormat();
|
PhysicalDiskFormat destFormat = newDisk.getFormat();
|
||||||
|
|
||||||
if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() != StoragePoolType.RBD)) {
|
if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() != StoragePoolType.RBD)) {
|
||||||
|
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
|
Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
|
||||||
+ " -O " + destFormat
|
+ " -O " + destFormat
|
||||||
+ " " + sourcePath
|
+ " " + sourcePath
|
||||||
+ " " + destPath);
|
+ " " + destPath);
|
||||||
|
}
|
||||||
} else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD)) {
|
} else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD)) {
|
||||||
Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
|
Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
|
||||||
+ " -O " + destFormat
|
+ " -O " + destFormat
|
||||||
|
|||||||
@ -31,7 +31,13 @@ create_template() {
|
|||||||
local fspath=$1
|
local fspath=$1
|
||||||
local destpath=$2
|
local destpath=$2
|
||||||
|
|
||||||
|
# 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
|
qemu-img convert -O qcow2 /$fspath $destpath
|
||||||
|
else
|
||||||
|
cp -f /$fspath $destpath
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
printf " Failed to export template $destpath\n" >&2
|
printf " Failed to export template $destpath\n" >&2
|
||||||
|
|||||||
@ -100,7 +100,13 @@ create_from_file() {
|
|||||||
if [ -b $tmpltimg ]; then
|
if [ -b $tmpltimg ]; then
|
||||||
$qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname
|
$qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname
|
||||||
else
|
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
|
$qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null
|
||||||
|
else
|
||||||
|
cp -f $tmpltimg /$tmpltfs/$tmpltname
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$cleanup" == "true" ]
|
if [ "$cleanup" == "true" ]
|
||||||
|
|||||||
@ -101,7 +101,13 @@ create_from_file() {
|
|||||||
if [ -b $volimg ]; then
|
if [ -b $volimg ]; then
|
||||||
$qemu_img convert -f raw -O qcow2 "$volimg" /$volfs/$volname
|
$qemu_img convert -f raw -O qcow2 "$volimg" /$volfs/$volname
|
||||||
else
|
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
|
$qemu_img convert -f qcow2 -O qcow2 "$volimg" /$volfs/$volname >& /dev/null
|
||||||
|
else
|
||||||
|
cp -f $volimg /$volfs/$volname
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$cleanup" == "true" ]
|
if [ "$cleanup" == "true" ]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user