crc-org / vfkit

Apache License 2.0
123 stars 24 forks source link

VirtIoFs devices can have []sharedDirs #41

Closed baude closed 1 year ago

baude commented 1 year ago

In vz and the applehv, you can have multiple shared directories under a mount tag. If you dig deeper into the code, there is a use of []shared buried in there.

I discovered this bug because I was trying to pass multiple virtio-fs devices and when doing so, none of them work.

i.e. --device virtio-fs,sharedDir=/Users/brentbaude/foobar1,mountTag=Users. --device virtio-fs,sharedDir=/Users/brentbaude/foobar2,mountTag=somedir

I then tried putting them all under a single mountTag, but multiple devices.

i.e. --device virtio-fs,sharedDir=/Users/brentbaude/foobar1,mountTag=podmanHomeDir --device virtio-fs,sharedDir=/Users/brentbaude/foobar2,mountTag=podmanHomeDir

i guess we need to either parse all virtfs devices to keep the command line the same and when we have multiple sharedDirs under the same mountTag, we would need to group them?

cfergeau commented 1 year ago

--device virtio-fs,sharedDir=/Users/brentbaude/foobar1,mountTag=Users. --device virtio-fs,sharedDir=/Users/brentbaude/foobar2,mountTag=somedir

I've created a PR fixing this

I then tried putting them all under a single mountTag, but multiple devices. i.e. --device virtio-fs,sharedDir=/Users/brentbaude/foobar1,mountTag=podmanHomeDir --device virtio-fs,sharedDir=/Users/brentbaude/foobar2,mountTag=podmanHomeDir i guess we need to either parse all virtfs devices to keep the command line the same and when we have multiple sharedDirs under the same mountTag, we would need to group them?

The virtualization framework directory sharing API has both VZSingleDirectoryShare and VZMultipleDirectoryShare.

Not fully sure why they have both. Imo one instance of --device virtio-fs on the command line should map to one virtio-fs device inside the guest, so I'd avoid doing some automatic grouping of multiple --device virtio-fs occurrences (but maybe the virtualization framework does that under the hood? I did not check). What is missing is a way to use VZMultipleDirectoryShare, ie a way of specifying a set of (tag, dir) after a single --device virtio-fs option. Fwiw, I don't think using the same tag for 2 different directories will work, as I don't know how you would mount this in the guest.

cfergeau commented 1 year ago

Keeping it open for the support of multiple directories assigned to a single virtio-fs device.