]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Adds support for backing_file
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 23 Oct 2018 23:32:58 +0000 (20:32 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 23 Oct 2018 23:32:58 +0000 (20:32 -0300)
kvmx
kvmxfile

diff --git a/kvmx b/kvmx
index 43ea2f28c649e6f80e8b86c60d26779f30742539..a1d2012d116811a812f79b6a38534bc74b905588 100755 (executable)
--- 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
index 115d15099d65a268f87445b2e41034a14be2739f..5f09dafd87e5830e0c69cd2ef2a345d3d9866e30 100644 (file)
--- a/kvmxfile
+++ b/kvmxfile
@@ -119,6 +119,10 @@ xrandr="0"
 # Where the guest image is stored
 #image="$HOME/.local/share/kvmx/$VM/box.img"
 
+# Backing file for overlay images
+# See https://wiki.archlinux.org/index.php/QEMU#Overlay_storage_images
+#backing_file="$HOME/.local/share/kvmx/$basebox/box.img"
+
 # Where datafiles are stored: just set this if you know what you're doing
 #datadir="$HOME/.local/share/kvmx/$VM"