-
Notifications
You must be signed in to change notification settings - Fork 241
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 filesharing support #3269
Add filesharing support #3269
Conversation
macOS CI is currently failing because it's trying to use the released vfkit binary which does not have virtiofs support. |
Can you publish a pre-release version for testing purposes? |
Now that the vfkit changes have been merged, I've made such a release on my personal vfkit repo. |
f08d6f1
to
c9da2d2
Compare
Trying to run on windows, it tries to mount the home dir, i think this should only try to mount when the driver is vfkit or libvirt maybe (not sure if the libvirt driver already has implementation for virtiofs)
on macOS its working as expected |
More work is needed on platforms not supporting shared directories, either because they are too old (rhel7, macos11), or because the driver does not implement file sharing/does not support it. At the moment rhel7/macos11 are detected at the machine driver level, but I'm not even sure how crc behaves on these platforms. I hadn't thought at all of Windows, so I'll also need to take a look. |
The latest push uses upstream |
found a workaround/solution to the windows issue, if we add a diff --git a/pkg/drivers/hyperv/hyperv_windows.go b/pkg/drivers/hyperv/hyperv_windows.go
index c8ed4350..7c1d5a71 100644
--- a/pkg/drivers/hyperv/hyperv_windows.go
+++ b/pkg/drivers/hyperv/hyperv_windows.go
@@ -373,3 +373,7 @@ func (d *Driver) GetIP() (string, error) {
return resp[0], nil
}
+
+func (d *Driver) GetSharedDirs() ([]drivers.SharedDir, error) {
+ return []drivers.SharedDir{}, nil
+} this might also work if added to the libvirt driver, but haven't tested |
I'm taking a slightly different approach, make the default GetSharedDirs implementation error out cfergeau/machine@26ae9c5 |
The macos installer is now created as out/macos-universal/crc-macos-installer.pkg The artifact upload action was not updated for the new name
Even if the runtime sanity check for the installer fails, we might want to access the installer which was built for testing. This commit moves the artifact generation before the `crc start` attempt in the macOS installer generation action.
1e14eb3
to
6fca834
Compare
if err != nil { | ||
return false | ||
} | ||
return strings.HasPrefix(macosVersion, "12.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe return true also for macOS 12+ versions? otherwise we'll have to remember to change it when macOS 13 is released
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks, initially wanted to use semver for this, then went with a shortcut. But yeah, definitely not very future proof this way :)
db3336e
to
340464b
Compare
This updates machine and vfkit to their latest versions to get file sharing support.
This adds file sharing support to the vfkit driver. This requires a version of vfkit with file sharing support (0.0.2 or newer).
virtiofs file sharing is only available in macOS 12 and newer. This commit makes use of sw_vers to return a proper error when running on too old macOS versions. This also skips vfkit shared directory configuration so that we can start the VM anyway. For all of this to work, vfkit has to be built on a macOS 11 builder, the file sharing APIs will still be available when this binary is run on macOS 12. Building vfkit on macOS 12 and trying to run the resulting binary on macOS 11 will badly fail though: ``` DEBU Running '/Users/teuf/.crc/bin/vfkit -v' DEBU Command failed: signal: abort trap DEBU stdout: DEBU stderr: dyld: Symbol not found: _OBJC_CLASS_$_VZMultipleDirectoryShare Referenced from: /Users/teuf/.crc/bin/vfkit (which was built for Mac OS X 12.0) Expected in: /System/Library/Frameworks/Virtualization.framework/Versions/A/Virtualization in /Users/teuf/.crc/bin/vfkit DEBU failed to run executable /Users/teuf/.crc/bin/vfkit: signal: abort trap ```
This commit adds file sharing support to `crc start`. This uses the GetSharedDirs API from libmachine, and only supports virtiofs for now. File sharing is meant to be used together for podman support to support `podman-remote -v somedir:/some-dir-in-container registry.example.com/container-image` This is currently implemented similarly to what podman does: $HOME is shared with the VM and mounted at the $HOME mountpoint. This way one can use podman-remote $HOME/hostdir on the host, and the podman instance running in the VM can also access $HOME/hostdir which is mounted in the VM, and share it with the container. We currently need to hardcode a selinux context on $HOME mounted in the VM, mainly to overcome limitations in the macOS virtiofs implementation which vfkit uses. This fixes crc-org#3204
I've updated the PR to make use of the just released vfkit 0.0.2 |
/retest |
the |
@anjannath CI still failing with following issue
|
/test integration-crc |
/test all |
1 similar comment
/test all |
e5f158e
to
6bf731f
Compare
this update adds support for virtiofs directory sharing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on linux, macOS and windows and its working as expected
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anjannath The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR uses vfkit virtiofs support in order to implement file sharing for podman containers.
This allows to use
'podman-remote run --volume /hostpath:/containerpath'
This is done by mounting the full user home dir in the VM through virtiofs. Then when using podman, one can specify a directory located in the user homedir, and it will transparently shared with the container.
Directories located outside of the user's home can't be shared with a container.
This also mounts the virtiofs filesystem using
'-o context="system_u:object_r:container_file_t:s0"'
to avoid selinux issues when accessing the data.Instructions for testing:
(the directory to be shared with the container has to be in your home directory on the host)
podman -v ~/crc-podman:/hello:Z
may or may not work, I had issues with macOS setxattr implementation erroring out on RO files, which was not the behaviour expected by podman. Since usingmount -o context=...
does the job without using:Z
I did not dig further.Fixes: Issue #3204
Relates to: Issue #3205, issue #3180, crc-org/vfkit#4, crc-org/machine#64