Skip to content

Commit 6063416

Browse files
authored
Merge pull request #1195 from balajiv113/fix-mount
mount virtiofs directory only if mountType matches
2 parents 69d032b + 831e3fb commit 6063416

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

pkg/vz/vm_darwin.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -316,34 +316,36 @@ func attachConsole(_ *driver.BaseDriver, vmConfig *vz.VirtualMachineConfiguratio
316316

317317
func attachFolderMounts(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfiguration) error {
318318
mounts := make([]vz.DirectorySharingDeviceConfiguration, len(driver.Yaml.Mounts))
319-
for i, mount := range driver.Yaml.Mounts {
320-
expandedPath, err := localpathutil.Expand(mount.Location)
321-
if err != nil {
322-
return err
323-
}
324-
if _, err := os.Stat(expandedPath); errors.Is(err, os.ErrNotExist) {
325-
err := os.MkdirAll(expandedPath, 0750)
319+
if *driver.Yaml.MountType == limayaml.VIRTIOFS {
320+
for i, mount := range driver.Yaml.Mounts {
321+
expandedPath, err := localpathutil.Expand(mount.Location)
326322
if err != nil {
327323
return err
328324
}
329-
}
325+
if _, err := os.Stat(expandedPath); errors.Is(err, os.ErrNotExist) {
326+
err := os.MkdirAll(expandedPath, 0750)
327+
if err != nil {
328+
return err
329+
}
330+
}
330331

331-
directory, err := vz.NewSharedDirectory(expandedPath, !*mount.Writable)
332-
if err != nil {
333-
return err
334-
}
335-
share, err := vz.NewSingleDirectoryShare(directory)
336-
if err != nil {
337-
return err
338-
}
332+
directory, err := vz.NewSharedDirectory(expandedPath, !*mount.Writable)
333+
if err != nil {
334+
return err
335+
}
336+
share, err := vz.NewSingleDirectoryShare(directory)
337+
if err != nil {
338+
return err
339+
}
339340

340-
tag := fmt.Sprintf("mount%d", i)
341-
config, err := vz.NewVirtioFileSystemDeviceConfiguration(tag)
342-
if err != nil {
343-
return err
341+
tag := fmt.Sprintf("mount%d", i)
342+
config, err := vz.NewVirtioFileSystemDeviceConfiguration(tag)
343+
if err != nil {
344+
return err
345+
}
346+
config.SetDirectoryShare(share)
347+
mounts[i] = config
344348
}
345-
config.SetDirectoryShare(share)
346-
mounts[i] = config
347349
}
348350

349351
if driver.Yaml.Rosetta.Enabled {

0 commit comments

Comments
 (0)