mirror of
https://github.com/containers/podman.git
synced 2025-12-01 18:49:18 +08:00
feat: Add support for configuring swap in Podman machine
Add `--swap` argument to `podman machine init` command. Passing an int64 value to this flag will trigger the Podman machine ignition file to be generated with a zram-generator.conf file containing the --swap value as the zram-size argument. This file is read by the zram-generator systemd service on boot resulting in a zram swap device being created. Fixes: https://github.com/containers/podman/issues/15980 Signed-off-by: Lewis Roy <lewis@redhat.com>
This commit is contained in:
@@ -30,9 +30,7 @@ import (
|
||||
// List is done at the host level to allow for a *possible* future where
|
||||
// more than one provider is used
|
||||
func List(vmstubbers []vmconfigs.VMProvider, _ machine.ListOptions) ([]*machine.ListResponse, error) {
|
||||
var (
|
||||
lrs []*machine.ListResponse
|
||||
)
|
||||
var lrs []*machine.ListResponse
|
||||
|
||||
for _, s := range vmstubbers {
|
||||
dirs, err := env.GetMachineDirs(s.VMType())
|
||||
@@ -49,15 +47,15 @@ func List(vmstubbers []vmconfigs.VMProvider, _ machine.ListOptions) ([]*machine.
|
||||
return nil, err
|
||||
}
|
||||
lr := machine.ListResponse{
|
||||
Name: name,
|
||||
CreatedAt: mc.Created,
|
||||
LastUp: mc.LastUp,
|
||||
Running: state == machineDefine.Running,
|
||||
Starting: mc.Starting,
|
||||
//Stream: "", // No longer applicable
|
||||
Name: name,
|
||||
CreatedAt: mc.Created,
|
||||
LastUp: mc.LastUp,
|
||||
Running: state == machineDefine.Running,
|
||||
Starting: mc.Starting,
|
||||
VMType: s.VMType().String(),
|
||||
CPUs: mc.Resources.CPUs,
|
||||
Memory: mc.Resources.Memory,
|
||||
Swap: mc.Swap,
|
||||
DiskSize: mc.Resources.DiskSize,
|
||||
Port: mc.SSH.Port,
|
||||
RemoteUsername: mc.SSH.RemoteUsername,
|
||||
@@ -204,13 +202,13 @@ func Init(opts machineDefine.InitOptions, mp vmconfigs.VMProvider) error {
|
||||
VMType: mp.VMType(),
|
||||
WritePath: ignitionFile.GetPath(),
|
||||
Rootful: opts.Rootful,
|
||||
Swap: opts.Swap,
|
||||
})
|
||||
|
||||
// If the user provides an ignition file, we need to
|
||||
// copy it into the conf dir
|
||||
if len(opts.IgnitionPath) > 0 {
|
||||
err = ignBuilder.BuildWithIgnitionFile(opts.IgnitionPath)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user