aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IDEAS.md2
-rwxr-xr-xkvmx47
-rw-r--r--kvmxfile4
3 files changed, 45 insertions, 8 deletions
diff --git a/IDEAS.md b/IDEAS.md
index 588b1a4..d78ecb0 100644
--- a/IDEAS.md
+++ b/IDEAS.md
@@ -14,8 +14,6 @@
* Support for multiple source/targets pairs (analogous to `shared_folders`) at:
* `provision_rsync`
- * `startup_rsync_to_guest`
- * `poweroff_rsync_from_guest`
## Virtualization
diff --git a/kvmx b/kvmx
index 0581da9..dca6ad9 100755
--- a/kvmx
+++ b/kvmx
@@ -361,8 +361,10 @@ function kvmx_up {
unset shared_folder
unset shared_folder_mountpoint
+ unset id
done
IFS="$old_ifs"
+ unset shared_item
fi
if [ ! -z "$port_mapping" ]; then
@@ -670,8 +672,13 @@ function kvmx_up {
echo "sudo mkdir -p $shared_folder_mountpoint" | kvmx_ssh
echo "sudo mount -t 9p -o trans=virtio $id $shared_folder_mountpoint -oversion=9p2000.L,posixacl,cache=$shared_folders_cache -o sync -o dirsync" | kvmx_ssh
IFS=","
+
+ unset shared_folder
+ unset shared_folder_mountpoint
+ unset id
done
IFS="$old_ifs"
+ unset shared_item
fi
# Shall we add an umount hook when powering off the guest?
@@ -692,8 +699,10 @@ function kvmx_up {
unset shared_folder
unset shared_folder_mountpoint
+ unset id
done
IFS="$old_ifs"
+ unset shared_item
fi
if [ "$xrandr" == "1" ] && [ "$run_spice_client" == "1" ]; then
@@ -717,8 +726,23 @@ function kvmx_up {
fi
if [ ! -z "$startup_rsync_to_guest" ] && [ "$ssh_support" == "y" ]; then
- echo "Rsyncing to guest: $startup_rsync_to_guest..."
- kvmx_rsync_to $startup_rsync_to_guest
+ local old_ifs="$IFS"
+ local item
+ IFS=","
+ for item in $startup_rsync_to_guest; do
+ local id="`echo $item | cut -d ':' -f 1`"
+ local startup_rsync_to_guest_orig="`echo $item | cut -d ':' -f 2`"
+ local startup_rsync_to_guest_dest="`echo $item | cut -d ':' -f 3`"
+
+ echo "Rsyncing to guest: $startup_rsync_to_guest ($id)..."
+ kvmx_rsync_to $startup_rsync_to_guest_orig $startup_rsync_to_guest_dest
+
+ unset startup_rsync_to_guest_orig
+ unset startup_rsync_to_guest_dest
+ unset id
+ done
+ IFS="$old_ifs"
+ unset item
fi
kvmx_status
@@ -992,8 +1016,23 @@ function kvmx_poweroff {
fi
if [ ! -z "$poweroff_rsync_from_guest" ] && [ "$ssh_support" == "y" ]; then
- echo "Rsyncing to guest: $poweroff_rsync_from_guest..."
- kvmx_rsync_from $poweroff_rsync_from_guest
+ local old_ifs="$IFS"
+ local item
+ IFS=","
+ for item in $poweroff_rsync_from_guest; do
+ local id="`echo $item | cut -d ':' -f 1`"
+ local poweroff_rsync_from_guest_orig="`echo $item | cut -d ':' -f 2`"
+ local poweroff_rsync_from_guest_dest="`echo $item | cut -d ':' -f 3`"
+
+ echo "Rsyncing from guest: $poweroff_rsync_from_guest ($id)..."
+ kvmx_rsync_from $poweroff_rsync_from_guest_orig $poweroff_rsync_from_guest_dest
+
+ unset poweroff_rsync_from_guest_orig
+ unset poweroff_rsync_from_guest_dest
+ unset id
+ done
+ IFS="$old_ifs"
+ unset item
fi
if [ "$run_xpra" == "1" ]; then
diff --git a/kvmxfile b/kvmxfile
index 8d0a07a..56f0647 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -83,8 +83,8 @@ shared_folder_mountpoint="/home/$user/code/$VM"
#poweroff_pre_command="/path/to/custom/command"
# Rsync commands to be run on startup or poweroff, useful to keep files synced between host and guest
-#startup_rsync_to_guest="data /var/data"
-#poweroff_rsync_from_guest="/var/data data"
+#startup_rsync_to_guest="data:data:/var/data,code:$HOME/code:/home/user/code"
+#poweroff_rsync_from_guest="data:/var/data:data,code:/home/user/code:$HOME/code"
# Graphics
# See https://wiki.archlinux.org/index.php/QEMU#Graphics