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

Feature Request: Support multiple automount volumes #30

Open
aaronclarke opened this issue Oct 28, 2023 · 0 comments
Open

Feature Request: Support multiple automount volumes #30

aaronclarke opened this issue Oct 28, 2023 · 0 comments

Comments

@aaronclarke
Copy link
Contributor

aaronclarke commented Oct 28, 2023

The virtualization framework supports having multiple automounted volumes with different readonly vs readwrite statuses, as can be seen described in Apple's documentation for VZVirtioFileSystemDeviceConfiguration

But the current support for --vol only allows for one automounted volume. If two are specified, an error is thrown due to reusing the same VZVirtioFileSystemDeviceConfiguration.macOSGuestAutomountTag tag.

I see that there is a method already in macosvm called addAutomountDirectoryShares:readOnly: which does know how to share describe multiple automounted directories, but it forces them all to have the same value for readOnly, and the code is currently unreachable.

Motivating example:

I want to start my VM with two automounted directories, one that is readonly so that the guest VM can't ruin it, and one that has readwrite capabilities so that the guest VM can write some data back to the host.

~/Desktop/macosvm -g \
--vol ~/Desktop/sharedWithVM/fromHost,ro,automount \
--vol ~/Desktop/sharedWithVM/fromGuest,automount \
macos_14.1/vm.json

Potential implementation:

I've got a working implementation of this in my fork:
aaronclarke:feature/multiple_automount

There I've hacked this together by making macosvm loop over the shares twice:

  1. Loop one: Loop over all shares
    • if share is an automount share and automounting is available, add it to a list of automount shares and continue
    • otherwise do normal share specifications
  2. Loop two:
    • Loop over all discovered automount shares. Batch each directory together into a single VZMultipleDirectoryShare and set that as the share for VZVirtioFileSystemDeviceConfiguration with the VZVirtioFileSystemDeviceConfiguration.macOSGuestAutomountTag tag.

If that seems acceptable I could send a pull request.

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

1 participant