diff --git a/docs/containers.conf.5.md b/docs/containers.conf.5.md index b7b606ffc..d770f839f 100644 --- a/docs/containers.conf.5.md +++ b/docs/containers.conf.5.md @@ -446,11 +446,6 @@ Indicates if Podman is running inside a VM via Podman Machine. Podman uses this value to do extra setup around networking from the container inside the VM to to host. -**machine_image**="testing" - -Default image used when creating a new VM using `podman machine init`. -Options: `testing`, `stable`, or a custom path or download URL to an image - **multi_image_archive**=false Allows for creating archives (e.g., tarballs) with more than one image. Some container engines, such as Podman, interpret additional arguments as tags for one image and hence do not store more than one image. The default behavior can be altered with this option. @@ -607,6 +602,19 @@ Currently valid values are: The driver specific options object. +## MACHINE TABLE +The `machine` table contains configurations for podman machine VMs + +**image**="testing" + +Default image used when creating a new VM using `podman machine init`. +Options: `testing`, `stable`, `next`, or a custom path or download URL to an image + +**disk_size**=10 + +The size of the disk in GB created when init-ing a podman-machine VM + + # FILES **containers.conf** diff --git a/pkg/config/config.go b/pkg/config/config.go index c1f63577a..8d5f075d8 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -54,6 +54,8 @@ type Config struct { Containers ContainersConfig `toml:"containers"` // Engine specifies how the container engine based on Engine will run Engine EngineConfig `toml:"engine"` + // Machine specifies configurations of podman machine VMs + Machine MachineConfig `toml:"machine"` // Network section defines the configuration of CNI Plugins Network NetworkConfig `toml:"network"` // Secret section defines configurations for the secret management @@ -281,9 +283,6 @@ type EngineConfig struct { // MachineEnabled indicates if Podman is running in a podman-machine VM MachineEnabled bool `toml:"machine_enabled,omitempty"` - // MachineImage is the image used when creating a podman-machine VM - MachineImage string `toml:"machine_image,omitempty"` - // MultiImageArchive - if true, the container engine allows for storing // archives (e.g., of the docker-archive transport) with multiple // images. By default, Podman creates single-image archives. @@ -490,6 +489,14 @@ type SecretConfig struct { Opts map[string]string `toml:"opts,omitempty"` } +// MachineConfig represents the "machine" TOML config table +type MachineConfig struct { + // DiskSize is the size of the disk in GB created when init-ing a podman-machine VM + DiskSize uint64 `toml:"disk_size,omitempty"` + // MachineImage is the image used when init-ing a podman-machine VM + Image string `toml:"image,omitempty"` +} + // Destination represents destination for remote service type Destination struct { // URI, required. Example: ssh://root@example.com:22/run/podman/podman.sock diff --git a/pkg/config/config_local_test.go b/pkg/config/config_local_test.go index 5b0ba6aa7..53cbd0671 100644 --- a/pkg/config/config_local_test.go +++ b/pkg/config/config_local_test.go @@ -374,12 +374,24 @@ var _ = Describe("Config Local", func() { // Given config, err := NewConfig("") gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(config.Engine.MachineImage).To(gomega.Equal("testing")) + gomega.Expect(config.Machine.Image).To(gomega.Equal("testing")) // When config2, err := NewConfig("testdata/containers_default.conf") // Then gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(config2.Engine.MachineImage).To(gomega.Equal("stable")) + gomega.Expect(config2.Machine.Image).To(gomega.Equal("stable")) + }) + + It("Set machine disk", func() { + // Given + config, err := NewConfig("") + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(config.Machine.DiskSize).To(gomega.Equal(uint64(10))) + // When + config2, err := NewConfig("testdata/containers_default.conf") + // Then + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(config2.Machine.DiskSize).To(gomega.Equal(uint64(20))) }) }) diff --git a/pkg/config/containers.conf b/pkg/config/containers.conf index 7c72ec79f..3d2414780 100644 --- a/pkg/config/containers.conf +++ b/pkg/config/containers.conf @@ -396,10 +396,6 @@ default_sysctls = [ # #machine_enabled = false -# The image used when creating a podman-machine VM. -# -#machine_image = "testing" - # MultiImageArchive - if true, the container engine allows for storing archives # (e.g., of the docker-archive transport) with multiple images. By default, # Podman creates single-image archives. @@ -559,8 +555,17 @@ default_sysctls = [ [engine.volume_plugins] #testplugin = "/run/podman/plugins/test.sock" -# The [engine.volume_plugins] table MUST be the last entry in this file. +[machine] +# The image used when creating a podman-machine VM. +# +#image = "testing" +# +# The size of the disk in GB created when init-ing a podman-machine VM +# +#disk_size=10 + +# The [machine] table MUST be the last entry in this file. # (Unless another table is added) # TOML does not provide a way to end a table other than a further table being -# defined, so every key hereafter will be part of [volume_plugins] and not the +# defined, so every key hereafter will be part of [machine] and not the # main config. diff --git a/pkg/config/default.go b/pkg/config/default.go index 34d17d72c..b50329159 100644 --- a/pkg/config/default.go +++ b/pkg/config/default.go @@ -208,6 +208,7 @@ func DefaultConfig() (*Config, error) { }, Engine: *defaultEngineConfig, Secrets: defaultSecretConfig(), + Machine: defaultMachineConfig(), }, nil } @@ -219,6 +220,14 @@ func defaultSecretConfig() SecretConfig { } } +// defaultMachineConfig returns the default machine configuration. +func defaultMachineConfig() MachineConfig { + return MachineConfig{ + Image: "testing", + DiskSize: 10, + } +} + // defaultConfigFromMemory returns a default engine configuration. Note that the // config is different for root and rootless. It also parses the storage.conf. func defaultConfigFromMemory() (*EngineConfig, error) { @@ -345,8 +354,6 @@ func defaultConfigFromMemory() (*EngineConfig, error) { // constants. c.LockType = "shm" c.MachineEnabled = false - c.MachineImage = "testing" - c.ChownCopiedFiles = true return c, nil @@ -566,9 +573,3 @@ func (c *Config) MachineEnabled() bool { func (c *Config) RootlessNetworking() string { return c.Containers.RootlessNetworking } - -// MachineImage returns the image to be -// used when creating a podman-machine VM -func (c *Config) MachineImage() string { - return c.Engine.MachineImage -} diff --git a/pkg/config/testdata/containers_default.conf b/pkg/config/testdata/containers_default.conf index c494da052..4d2667c76 100644 --- a/pkg/config/testdata/containers_default.conf +++ b/pkg/config/testdata/containers_default.conf @@ -153,9 +153,6 @@ tmp_dir = "/run/libpod" machine_enabled = true -# The image used when creating a podman-machine VM. -machine_image = "stable" - # Whether to use chroot instead of pivot_root in the runtime no_pivot_root = false @@ -246,8 +243,15 @@ crun = [ "/usr/local/bin/crun", ] -# The [engine.runtimes] table MUST be the last thing in this file. +[machine] +# The image used when creating a podman-machine VM. +image = "stable" + +# The size of the disk in GB created when init-ing a podman-machine VM +disk_size = 20 + +# The [machine] table MUST be the last thing in this file. # (Unless another table is added) # TOML does not provide a way to end a table other than a further table being -# defined, so every key hereafter will be part of [runtimes] and not the main +# defined, so every key hereafter will be part of [machine] and not the main # config.