Skip to content

Commit 6630e5c

Browse files
committed
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 <[email protected]>
1 parent a3326e2 commit 6630e5c

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

cmd/podman/machine/init.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ func init() {
9292
flags.StringArrayVarP(&initOpts.Volumes, VolumeFlagName, "v", []string{}, "Volumes to mount, source:target")
9393
_ = initCmd.RegisterFlagCompletionFunc(VolumeFlagName, completion.AutocompleteDefault)
9494

95+
VolumeDriverFlagName := "volume-driver"
96+
flags.StringVar(&initOpts.VolumeDriver, VolumeDriverFlagName, "", "Optional volume driver")
97+
_ = initCmd.RegisterFlagCompletionFunc(VolumeDriverFlagName, completion.AutocompleteDefault)
98+
9599
IgnitionPathFlagName := "ignition-path"
96100
flags.StringVar(&initOpts.IgnitionPath, IgnitionPathFlagName, "", "Path to ignition file")
97101
_ = initCmd.RegisterFlagCompletionFunc(IgnitionPathFlagName, completion.AutocompleteDefault)

docs/source/markdown/podman-machine-init.1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ Podman mounts _host-dir_ in the host to _machine-dir_ in the Podman machine.
7171
The root filesystem is mounted read-only in the default operating system,
7272
so mounts must be created under the /mnt directory.
7373

74+
#### **--volume-driver**
75+
76+
Driver to use for mounting volumes from the host, such as `virtfs`.
77+
7478
#### **--help**
7579

7680
Print usage statement.

pkg/machine/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type InitOptions struct {
1919
IgnitionPath string
2020
ImagePath string
2121
Volumes []string
22+
VolumeDriver string
2223
IsDefault bool
2324
Memory uint64
2425
Name string

pkg/machine/qemu/machine.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,16 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
172172
// Add arch specific options including image location
173173
v.CmdLine = append(v.CmdLine, v.addArchOptions()...)
174174

175-
// TODO: add to opts
176-
volumeType := VolumeTypeVirtfs
175+
var volumeType string
176+
switch opts.VolumeDriver {
177+
case "virtfs":
178+
volumeType = VolumeTypeVirtfs
179+
case "": // default driver
180+
volumeType = VolumeTypeVirtfs
181+
default:
182+
err := fmt.Errorf("unknown volume driver: %s", opts.VolumeDriver)
183+
return false, err
184+
}
177185

178186
mounts := []Mount{}
179187
for i, volume := range opts.Volumes {

0 commit comments

Comments
 (0)