aboutsummaryrefslogtreecommitdiff
path: root/kvmx
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-10-23 20:32:58 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-10-23 20:32:58 -0300
commitbc450a5189e4e380a626dd8b1ebdee2497a2d7df (patch)
tree58046b21bd5cdc592cc4508287ba949af9b1c59a /kvmx
parent7faea715fe7c83b1c1d4c1962edad7a6a3f31085 (diff)
downloadkvmx-bc450a5189e4e380a626dd8b1ebdee2497a2d7df.tar.gz
kvmx-bc450a5189e4e380a626dd8b1ebdee2497a2d7df.tar.bz2
Adds support for backing_file
Diffstat (limited to 'kvmx')
-rwxr-xr-xkvmx21
1 files changed, 16 insertions, 5 deletions
diff --git a/kvmx b/kvmx
index 43ea2f2..a1d2012 100755
--- a/kvmx
+++ b/kvmx
@@ -365,12 +365,23 @@ function kvmx_up {
exit 1
fi
- echo "Copying base image $baseimage to $image..."
- if which rsync &> /dev/null; then
- rsync -ah --sparse --progress $baseimage $image
+ if [ ! -z "$backing_file" ]; then
+ if [ -e "$backing_file" ]; then
+ echo "Creating image $image as an overlay of $backing_file..."
+ backing_file_format="`qemu-img info $backing_file | grep "^file format: " | cut -d : -f 2 | sed -e 's/ //g'` "
+ qemu-img create -o backing_file=$backing_file,backing_fmt=$backing_file_format -f $format $image
+ else
+ echo "Backing file not found: $backing_file"
+ exit 1
+ fi
else
- # See https://rwmj.wordpress.com/2010/10/19/tip-making-a-disk-image-sparse/
- cp --sparse=always $baseimage $image
+ echo "Copying base image $baseimage to $image..."
+ if which rsync &> /dev/null; then
+ rsync -ah --sparse --progress $baseimage $image
+ else
+ # See https://rwmj.wordpress.com/2010/10/19/tip-making-a-disk-image-sparse/
+ cp --sparse=always $baseimage $image
+ fi
fi
if [ -e "$basekey" ]; then