aboutsummaryrefslogtreecommitdiff
path: root/kvmx-create
diff options
context:
space:
mode:
Diffstat (limited to 'kvmx-create')
-rwxr-xr-xkvmx-create22
1 files changed, 14 insertions, 8 deletions
diff --git a/kvmx-create b/kvmx-create
index 0375cf6..e98f29a 100755
--- a/kvmx-create
+++ b/kvmx-create
@@ -366,18 +366,24 @@ EOF
# Umount image
kvmx_sudo_run umount $WORK
kvmx_sudo_run rmdir $WORK
- kvmx_sudo_run losetup -d $device
- # Image conversion
- if [ "$format" == "qcow2" ]; then
- echo "Converting raw image to qcow2..."
- kvmx_sudo_run mv $image $image.raw
- kvmx_sudo_run qemu-img convert -O qcow2 -p $compression ${image}.raw $image
- kvmx_sudo_run rm ${image}.raw
+ # Pack guest image
+ if [ -z "$image_type" ] || [ "$image_type" == "file" ]; then
+ kvmx_sudo_run losetup -d $device
+
+ # Image conversion
+ if [ "$format" == "qcow2" ]; then
+ echo "Converting raw image to qcow2..."
+ kvmx_sudo_run mv $image $image.raw
+ kvmx_sudo_run qemu-img convert -O qcow2 -p $compression ${image}.raw $image
+ kvmx_sudo_run rm ${image}.raw
+ fi
fi
# Fix permissions
- kvmx_sudo_run chown -R `whoami`. `dirname $image`
+ if [ "`whoami`" != "root" ]; then
+ kvmx_sudo_run chown -R `whoami`. `dirname $image`
+ fi
}
# Second stage procedure