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 filesharing support #3269

Merged
merged 7 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/macos-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
go-version: ${{ matrix.go }}
- name: Build macOS installer
run: make NO_CODESIGN=1 out/macos-universal/crc-macos-installer.pkg
- name: Upload macOS installer artifact
uses: actions/upload-artifact@v2
with:
name: macOS Installer (${{ matrix.os }})
path: "./out/macos-universal/crc-macos-installer.pkg"
- name: Install crc pkg
run: sudo installer -pkg out/macos-universal/crc-macos-installer.pkg -target /
- name: Set podman preset as part of config
Expand All @@ -47,8 +52,3 @@ jobs:
run: sleep 10
- name: Run crc with podman preset
run: crc start
- name: Upload macOS installer artifact
uses: actions/upload-artifact@v2
with:
name: macOS Installer (${{ matrix.os }})
path: "./out/macos-amd64/crc-macos-amd64.pkg"
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ require (
github.com/cheggaaa/pb/v3 v3.0.8
github.com/code-ready/admin-helper v0.0.10
github.com/code-ready/clicumber v0.0.0-20210817053019-08963a832984
github.com/code-ready/machine v0.0.0-20210902065103-07b1904d5147
github.com/code-ready/vfkit v0.0.1
github.com/code-ready/machine v0.0.0-20220727160217-7bf0dd8c2d7b
github.com/code-ready/vfkit v0.0.2
github.com/containers/gvisor-tap-vsock v0.3.1-0.20220228052040-b735d4413359
github.com/containers/image/v5 v5.15.0
github.com/coreos/go-systemd/v22 v22.3.2
Expand Down Expand Up @@ -43,19 +43,19 @@ require (
github.com/pkg/errors v0.9.1
github.com/segmentio/analytics-go/v3 v3.2.1
github.com/shirou/gopsutil/v3 v3.22.4
github.com/sirupsen/logrus v1.8.1
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.11.0
github.com/stretchr/testify v1.7.1
github.com/stretchr/testify v1.8.0
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
github.com/yusufpapurcu/wmi v1.2.2
github.com/zalando/go-keyring v0.2.1
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/net v0.0.0-20220708220712-1185a9018129
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467
golang.org/x/text v0.3.7
k8s.io/api v0.23.2
Expand Down Expand Up @@ -155,7 +155,6 @@ require (
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
Expand Down
24 changes: 13 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBp
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Code-Hex/vz v0.0.5-0.20211218053248-d70a0533bf8e/go.mod h1:BMgSoDpuZx8xZe5Ycxf5DJ5OewlWadVu40v/O1ZmVuQ=
github.com/Code-Hex/vz v0.0.5-0.20220406150231-a2ebc854a261/go.mod h1:BMgSoDpuZx8xZe5Ycxf5DJ5OewlWadVu40v/O1ZmVuQ=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
github.com/Masterminds/glide v0.13.2/go.mod h1:STyF5vcenH/rUqTEv+/hBXlSTo7KYwg2oc2f4tzPWic=
Expand Down Expand Up @@ -248,10 +248,10 @@ github.com/code-ready/admin-helper v0.0.10 h1:J7z6cu8owR9UemZlHQXL2W1aCOfo1nGhY1
github.com/code-ready/admin-helper v0.0.10/go.mod h1:8ACGWyeBXkVcQ53idgXhYzLGrK/+xjabcGVCtPtKaRQ=
github.com/code-ready/clicumber v0.0.0-20210817053019-08963a832984 h1:drafV7Hm9vnZqaUMzeSNc8IAbRQH8JrV8eRIb/jCtWU=
github.com/code-ready/clicumber v0.0.0-20210817053019-08963a832984/go.mod h1:ZPZUcYGpv/FQGnwakUuhiHP9x/IIcU2SKbn8xPe4ROc=
github.com/code-ready/machine v0.0.0-20210902065103-07b1904d5147 h1:226mb0ZSRmbaHVjz1sBF03Jj7kKxCcGgrz5fokg2R3Q=
github.com/code-ready/machine v0.0.0-20210902065103-07b1904d5147/go.mod h1:4JgMqho7KuxFifYCIi7cKVmh4yA2l0QHOPftv9f5PNc=
github.com/code-ready/vfkit v0.0.1 h1:wfzPYKPJKeL96VTaN3tXYMrKgMuV0tm2b2aQ58Exol0=
github.com/code-ready/vfkit v0.0.1/go.mod h1:Bji64b8rWo1BJS5IBsphP+1dyiwcPyRRtwRbb0tXo94=
github.com/code-ready/machine v0.0.0-20220727160217-7bf0dd8c2d7b h1:Eev9Enne43B+k6s2gfYxaSh0f0/+owLbrAyk8+7eoeM=
github.com/code-ready/machine v0.0.0-20220727160217-7bf0dd8c2d7b/go.mod h1:zeUHkDy+CASmOmTcbvv9m5SlkXmhp0MAtcs6f7EMp68=
github.com/code-ready/vfkit v0.0.2 h1:DA7wnPVXjs8bwa3ksNd8JtKzXsZ1oC1F7JanVoDyzCw=
github.com/code-ready/vfkit v0.0.2/go.mod h1:rjWQeMUISswhWXeBp5LEzwVjv8aN3Gn1QxIHDCmxu40=
github.com/codegangsta/cli v1.20.0/go.mod h1:/qJNoX69yVSKu5o4jLyXAENLRyk1uhi7zkbQ3slBdOA=
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
Expand Down Expand Up @@ -1179,7 +1179,7 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down Expand Up @@ -1211,8 +1211,9 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
Expand Down Expand Up @@ -1280,8 +1281,9 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
Expand Down Expand Up @@ -1722,17 +1724,17 @@ golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220519141025-dcacdad47464/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e h1:NHvCuwuS43lGnYhten69ZWqi2QOj/CiDNcKbVqwVoew=
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
Expand Down
1 change: 1 addition & 0 deletions pkg/crc/machine/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type MachineConfig struct {
ImageFormat string
SSHKeyPath string
KubeConfig string
SharedDirs []string

// macOS specific configuration
KernelCmdLine string
Expand Down
11 changes: 11 additions & 0 deletions pkg/crc/machine/config/driver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package config

import (
"fmt"

"github.com/code-ready/machine/libmachine/drivers"
)

Expand All @@ -15,4 +17,13 @@ func InitVMDriverFromMachineConfig(machineConfig MachineConfig, driver *drivers.
driver.BundleName = machineConfig.BundleName
driver.ImageSourcePath = machineConfig.ImageSourcePath
driver.ImageFormat = machineConfig.ImageFormat

for i, dir := range machineConfig.SharedDirs {
sharedDir := drivers.SharedDir{
Source: dir,
Target: dir,
Tag: fmt.Sprintf("dir%d", i),
}
driver.SharedDirs = append(driver.SharedDirs, sharedDir)
}
}
2 changes: 1 addition & 1 deletion pkg/crc/machine/libvirt/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (

const (
MachineDriverCommand = "crc-driver-libvirt"
MachineDriverVersion = "0.13.3"
MachineDriverVersion = "0.13.5"
)

var (
Expand Down
56 changes: 56 additions & 0 deletions pkg/crc/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,52 @@ func growRootFileSystem(sshRunner *crcssh.Runner) error {

return nil
}

func configureSharedDirs(vm *virtualMachine, sshRunner *crcssh.Runner) error {
logging.Debugf("Configuring shared directories")
sharedDirs, err := vm.Driver.GetSharedDirs()
if err != nil {
// the libvirt machine driver uses net/rpc, which wraps errors
// in rpc.ServerError, but without using golang 1.13 error
// wrapping feature. Moreover this package is marked as
// frozen/not accepting new features, so it's unlikely we'll
// ever be able to use errors.Is()
if err.Error() == drivers.ErrNotSupported.Error() || err.Error() == drivers.ErrNotImplemented.Error() {
return nil
}
return err
}
if len(sharedDirs) == 0 {
return nil
}
logging.Infof("Configuring shared directories")
for _, mount := range sharedDirs {
// CoreOS makes / immutable, we need to handle this if we need to create a directory outside of /home and /mnt
isHomeOrMnt := strings.HasPrefix(mount.Target, "/home") || strings.HasPrefix(mount.Target, "/mnt")
if !isHomeOrMnt {
if _, _, err := sshRunner.RunPrivileged("Making / mutable", "chattr", "-i", "/"); err != nil {
return err
}
}
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Creating %s", mount.Target), "mkdir", "-p", mount.Target); err != nil {
return err
}
if !isHomeOrMnt {
if _, _, err := sshRunner.RunPrivileged("Making / immutable again", "chattr", "+i", "/"); err != nil {
return err
}
}
logging.Debugf("Mounting tag %s at %s", mount.Tag, mount.Target)
//FIXME: do not hardcode this
mount.Type = "virtiofs"
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Mounting %s", mount.Target), "mount", "-o", "context=\"system_u:object_r:container_file_t:s0\"", "-t", mount.Type, mount.Tag, mount.Target); err != nil {
return err
}
}

return nil
}

func (client *client) Start(ctx context.Context, startConfig types.StartConfig) (*types.StartResult, error) {
telemetry.SetCPUs(ctx, startConfig.CPUs)
telemetry.SetMemory(ctx, uint64(startConfig.Memory)*1024*1024)
Expand Down Expand Up @@ -174,6 +220,11 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
logging.Infof("Creating CRC VM for Podman %s...", crcBundleMetadata.GetPodmanVersion())
}

sharedDirs := []string{}
if homeDir, err := os.UserHomeDir(); err == nil {
sharedDirs = append(sharedDirs, homeDir)
}

machineConfig := config.MachineConfig{
Name: client.name,
BundleName: bundleName,
Expand All @@ -187,6 +238,7 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
KernelCmdLine: crcBundleMetadata.GetKernelCommandLine(),
Initramfs: crcBundleMetadata.GetInitramfsPath(),
Kernel: crcBundleMetadata.GetKernelPath(),
SharedDirs: sharedDirs,
}
if crcBundleMetadata.IsOpenShift() {
machineConfig.KubeConfig = crcBundleMetadata.GetKubeConfigPath()
Expand Down Expand Up @@ -316,6 +368,10 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
}
}

if err := configureSharedDirs(vm, sshRunner); err != nil {
return nil, err
}

if _, _, err := sshRunner.RunPrivileged("make root Podman socket accessible", "chmod 777 /run/podman/ /run/podman/podman.sock"); err != nil {
return nil, errors.Wrap(err, "Failed to change permissions to root podman socket")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/machine/vfkit/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
VfkitVersion = "0.0.1"
VfkitVersion = "0.0.2"
VfkitCommand = "vfkit"
)

Expand Down
4 changes: 4 additions & 0 deletions pkg/drivers/none/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ func (d *Driver) Start() error {
func (d *Driver) Stop() error {
return fmt.Errorf("hosts without a driver cannot be stopped")
}

func (d *Driver) GetSharedDirs() ([]drivers.SharedDir, error) {
return []drivers.SharedDir{}, nil
}
32 changes: 32 additions & 0 deletions pkg/drivers/vfkit/driver_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,22 @@ func (d *Driver) Start() error {
}
}

// shared directories
if d.supportsVirtiofs() {
for _, sharedDir := range d.SharedDirs {
// TODO: add support for 'mount.ReadOnly'
// TODO: check format
dev, err := client.VirtioFsNew(sharedDir.Source, sharedDir.Tag)
if err != nil {
return err
}
err = vm.AddDevice(dev)
if err != nil {
return err
}
}
}

// entropy
dev, err = client.VirtioRNGNew()
if err != nil {
Expand Down Expand Up @@ -264,6 +280,14 @@ func (d *Driver) Start() error {
return nil
}

func (d *Driver) GetSharedDirs() ([]drivers.SharedDir, error) {
if !d.supportsVirtiofs() {
return nil, drivers.ErrNotSupported
}
// check if host supports file sharing, return drivers.ErrNotSupported if not
return d.SharedDirs, nil
}

// GetState returns the state that the host is in (running, stopped, etc)
func (d *Driver) GetState() (state.State, error) {
p, err := d.findVfkitProcess()
Expand Down Expand Up @@ -442,3 +466,11 @@ func (d *Driver) sendSignal(s syscall.Signal) error {

return proc.SendSignal(s)
}

func (d *Driver) supportsVirtiofs() bool {
macosVersion, _, err := crcos.RunWithDefaultLocale("sw_vers", "-productVersion")
if err != nil {
return false
}
return strings.HasPrefix(macosVersion, "12.")
Copy link
Member

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

Copy link
Contributor Author

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 :)

}
13 changes: 13 additions & 0 deletions vendor/github.com/code-ready/machine/libmachine/drivers/base.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading