Make it possible to select the volume driver

Use the same type of mounts for all the machine volumes.

The default could change in the future, depending on OS.

[NO NEW TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
This commit is contained in:
Anders F Björklund
2021-12-13 20:34:37 +01:00
parent a3326e23d8
commit 6630e5cf66
4 changed files with 19 additions and 2 deletions

View File

@ -92,6 +92,10 @@ func init() {
flags.StringArrayVarP(&initOpts.Volumes, VolumeFlagName, "v", []string{}, "Volumes to mount, source:target") flags.StringArrayVarP(&initOpts.Volumes, VolumeFlagName, "v", []string{}, "Volumes to mount, source:target")
_ = initCmd.RegisterFlagCompletionFunc(VolumeFlagName, completion.AutocompleteDefault) _ = initCmd.RegisterFlagCompletionFunc(VolumeFlagName, completion.AutocompleteDefault)
VolumeDriverFlagName := "volume-driver"
flags.StringVar(&initOpts.VolumeDriver, VolumeDriverFlagName, "", "Optional volume driver")
_ = initCmd.RegisterFlagCompletionFunc(VolumeDriverFlagName, completion.AutocompleteDefault)
IgnitionPathFlagName := "ignition-path" IgnitionPathFlagName := "ignition-path"
flags.StringVar(&initOpts.IgnitionPath, IgnitionPathFlagName, "", "Path to ignition file") flags.StringVar(&initOpts.IgnitionPath, IgnitionPathFlagName, "", "Path to ignition file")
_ = initCmd.RegisterFlagCompletionFunc(IgnitionPathFlagName, completion.AutocompleteDefault) _ = initCmd.RegisterFlagCompletionFunc(IgnitionPathFlagName, completion.AutocompleteDefault)

View File

@ -71,6 +71,10 @@ Podman mounts _host-dir_ in the host to _machine-dir_ in the Podman machine.
The root filesystem is mounted read-only in the default operating system, The root filesystem is mounted read-only in the default operating system,
so mounts must be created under the /mnt directory. so mounts must be created under the /mnt directory.
#### **--volume-driver**
Driver to use for mounting volumes from the host, such as `virtfs`.
#### **--help** #### **--help**
Print usage statement. Print usage statement.

View File

@ -19,6 +19,7 @@ type InitOptions struct {
IgnitionPath string IgnitionPath string
ImagePath string ImagePath string
Volumes []string Volumes []string
VolumeDriver string
IsDefault bool IsDefault bool
Memory uint64 Memory uint64
Name string Name string

View File

@ -172,8 +172,16 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
// Add arch specific options including image location // Add arch specific options including image location
v.CmdLine = append(v.CmdLine, v.addArchOptions()...) v.CmdLine = append(v.CmdLine, v.addArchOptions()...)
// TODO: add to opts var volumeType string
volumeType := VolumeTypeVirtfs switch opts.VolumeDriver {
case "virtfs":
volumeType = VolumeTypeVirtfs
case "": // default driver
volumeType = VolumeTypeVirtfs
default:
err := fmt.Errorf("unknown volume driver: %s", opts.VolumeDriver)
return false, err
}
mounts := []Mount{} mounts := []Mount{}
for i, volume := range opts.Volumes { for i, volume := range opts.Volumes {