diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2020-09-05 08:56:10 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2020-09-05 08:56:10 -0300 |
commit | 5de7986be57e10c4a05d8179a97f42ac998c1e56 (patch) | |
tree | 314e1799233214ed4eeb2fafafc5d447bc38b693 | |
parent | e9a698f7e360238be612ce8a8e1f23e23d1e3152 (diff) | |
download | kvmx-5de7986be57e10c4a05d8179a97f42ac998c1e56.tar.gz kvmx-5de7986be57e10c4a05d8179a97f42ac998c1e56.tar.bz2 |
Feat: support for multiple source/targets pairs at startup_rsync_to_guest / poweroff_rsync_from_guest
-rw-r--r-- | IDEAS.md | 2 | ||||
-rwxr-xr-x | kvmx | 47 | ||||
-rw-r--r-- | kvmxfile | 4 |
3 files changed, 45 insertions, 8 deletions
@@ -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 @@ -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 @@ -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 |