Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add/remove virtio-fs file share after vm started #861

Open
zhaoqpcn opened this issue Feb 18, 2025 · 3 comments
Open

add/remove virtio-fs file share after vm started #861

zhaoqpcn opened this issue Feb 18, 2025 · 3 comments

Comments

@zhaoqpcn
Copy link

I can add a windows file share with the following parameter when starting openvmm.exe:

  • openvmm.exe --virtio-fs "myfs,D:\share"

Is here a way (via interactive mode or RPC call) to add/remove virtio-fs file share after vm started?

@jstarks
Copy link
Member

jstarks commented Feb 18, 2025

Currently, no.

virtiofs uses a device per tag. So to add/remove a share after the VM has started, you will need to dynamically add/remove a device. This is fairly straightforward to implement if you're using the VPCI transport (supported only with Windows hosts due to KVM limitaitons). It's not possible if you're using the MMIO transport.

An alternative approach is to create a single share and dynamically link files into the share as necessary. On Linux, you would probably do this with bind mounts, since virtiofs won't follow symbolic links on the host. On Windows, you could experiment with the bindlink API to do the same: https://learn.microsoft.com/en-us/windows/win32/bindlink/.

A middle ground would be to teach virtiofs to support some kind of virtual file system that would allow you to add/remove sub-file systems (each backed by a real file system directory) as part of a single device. This would be a fair amount of work but would be useful to have.

@zhaoqpcn
Copy link
Author

The single share and dynamically linked solution looks promising.
I tried it, but since we can't perform Admin elevation operations, the result is that virtio-fs can recognize file hard links:

  • mklink /H c:\share\mklink_H c:\testfolder\testfile

but cannot handle directory links as mentioned:

  • mklink /J c:\share\mklink_J c:\testfolderA
  • or mklink /D c:\share\mklink_D c:\testfolderB

Snapshot:
--virtio-fs "myfs,C:\share"
mount -t virtiofs myfs /mnt/testdir
Image

I also tried virtio-9p, the result is the same.

As for Bindlink, it requires Admin privileges, so we can't use it either.

@jstarks
Copy link
Member

jstarks commented Feb 21, 2025

I don't think it would be unreasonable to have an optional virtiofs mode that follows directory junctions (but not symlinks) on Windows. I would probably accept a PR that does this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants