aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.md2
-rw-r--r--TODO.md2
-rwxr-xr-xkvmx16
-rw-r--r--kvmxfile4
4 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index 7a0c8a4..cc04608 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -2,6 +2,8 @@
## 0.3.0 - unreleased
+* Per-mountpoint mode option (ro, rw).
+
* Inotify action for watching a folder in the host and issuing commands in the
guest upon change.
diff --git a/TODO.md b/TODO.md
index 68823f5..9b3297f 100644
--- a/TODO.md
+++ b/TODO.md
@@ -39,8 +39,6 @@
## Folder sharing
-* Per-mountpoint mode option (ro, rw).
-
* Try to umount all sshfs volumes in the host when powering off.
* Remount 9p shared folders and reinitialize spice-vdagent upon resume from
diff --git a/kvmx b/kvmx
index 27cb93e..6a796d8 100755
--- a/kvmx
+++ b/kvmx
@@ -367,12 +367,19 @@ function kvmx_up {
local id="`echo $shared_item | cut -d ':' -f 1`"
local shared_folder="`echo $shared_item | cut -d ':' -f 2`"
local shared_folder_mountpoint="`echo $shared_item | cut -d ':' -f 3`"
+ local shared_folder_mode="`echo $shared_item | cut -d ':' -f 4`"
+
+ if [ "$shared_folder_mode" == "ro" ]; then
+ shared_folder_mode=",readonly=on"
+ else
+ shared_folder_mode=""
+ fi
# Get absolute path of shared folder relative to project path
mkdir -p $shared_folder
shared_folder="`cd $KVMX_PROJECT_FOLDER && cd $shared_folder &> /dev/null && pwd`"
- shared="$shared -fsdev local,id=$id,path=$shared_folder,security_model=none -device virtio-9p-pci,fsdev=$id,mount_tag=$id"
+ shared="$shared -fsdev local,id=$id,path=$shared_folder,security_model=none${shared_folder_mode} -device virtio-9p-pci,fsdev=$id,mount_tag=$id"
unset shared_folder
unset shared_folder_mountpoint
@@ -703,15 +710,20 @@ function kvmx_up {
local id="`echo $shared_item | cut -d ':' -f 1`"
local shared_folder="`echo $shared_item | cut -d ':' -f 2`"
local shared_folder_mountpoint="`echo $shared_item | cut -d ':' -f 3`"
+ local shared_folder_mode="`echo $shared_item | cut -d ':' -f 4`"
# Get absolute path of shared folder relative to project path
shared_folder="`cd $KVMX_PROJECT_FOLDER && cd $shared_folder &> /dev/null && pwd`"
+ if [ "$shared_folder_mode" == "ro" ]; then
+ shared_folder_mode=",ro"
+ fi
+
# Restore IFS for a while or kvmx_ssh won't work
IFS="$old_ifs"
echo "Mounting $shared_folder on $shared_folder_mountpoint ($id) on guest using 9p..."
echo "sudo mkdir -p $shared_folder_mountpoint" | kvmx_ssh
- echo "sudo mount -t 9p -o trans=virtio,msize=$shared_folders_msize $id $shared_folder_mountpoint -oversion=9p2000.L,posixacl,cache=$shared_folders_cache -o sync -o dirsync" | kvmx_ssh
+ echo "sudo mount -t 9p -o trans=virtio,msize=${shared_folders_msize}${shared_folder_mode} $id $shared_folder_mountpoint -oversion=9p2000.L,posixacl,cache=$shared_folders_cache -o sync -o dirsync" | kvmx_ssh
IFS=","
unset shared_folder
diff --git a/kvmxfile b/kvmxfile
index d6bca39..4b96346 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -40,8 +40,10 @@ net="user"
# Set this is you want to be able to share multiple folders between host and guest using 9p.
# Needs ssh_support set to "y" and a workable SSH connection to the guest.
-# Format: <id1>:<host-folder1>:<guest-mountpoint1>,<id2>:<host-folder2>:<guest-mountpoint2>[,...]
+# Mode defaults to "rw"; set to "ro" to ensure volume is shared and mounted read-only.
+# Format: <id1>:<host-folder1>:<guest-mountpoint1>[:mode1],<id2>:<host-folder2>:<guest-mountpoint2>[:mode2][,...]
#shared_folders="shared1:.:/home/$user/code/$VM,shared2:$HOME/.local/share/app:/home/$user/.local/share/app"
+#shared_folders="shared1:.:/home/$user/code/$VM,shared2:ro:$HOME/.local/share/app:/home/$user/.local/share/app:rw"
# Maximum packet size in bytex including any headers for shared folders using 9p
# In the past this was limited to 500kB: https://lwn.net/Articles/901523/