summaryrefslogtreecommitdiff
path: root/pkg/machine/wsl
diff options
context:
space:
mode:
authorAshley Cui <acui@redhat.com>2022-04-21 09:09:49 -0400
committerAshley Cui <acui@redhat.com>2022-04-27 13:56:14 -0400
commite7390f30b95daf90c0f32e8cf963dce3f8d5cf9d (patch)
treec0b962e598a1643f6f91cfd365c04cf0dc2a2d86 /pkg/machine/wsl
parent5ac00a7287e4a9e6292f4a6ca5dfa9a02e5ca907 (diff)
downloadpodman-e7390f30b95daf90c0f32e8cf963dce3f8d5cf9d.tar.gz
podman-e7390f30b95daf90c0f32e8cf963dce3f8d5cf9d.tar.bz2
podman-e7390f30b95daf90c0f32e8cf963dce3f8d5cf9d.zip
Allow changing of CPUs, Memory, and Disk Size
Allow podman machine set to change CPUs, Memory and Disk size of a QEMU machine after its been created. Disk size can only be increased. If one setting fails to be changed, the other settings will still be applied. Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'pkg/machine/wsl')
-rw-r--r--pkg/machine/wsl/machine.go57
1 files changed, 41 insertions, 16 deletions
diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go
index f57dbd299..1f1f2dcaf 100644
--- a/pkg/machine/wsl/machine.go
+++ b/pkg/machine/wsl/machine.go
@@ -736,28 +736,34 @@ func pipeCmdPassThrough(name string, input string, arg ...string) error {
return cmd.Run()
}
-func (v *MachineVM) Set(name string, opts machine.SetOptions) error {
- if v.Rootful == opts.Rootful {
- return nil
+func (v *MachineVM) Set(_ string, opts machine.SetOptions) ([]error, error) {
+ // If one setting fails to be applied, the others settings will not fail and still be applied.
+ // The setting(s) that failed to be applied will have its errors returned in setErrors
+ var setErrors []error
+
+ if opts.Rootful != nil && v.Rootful != *opts.Rootful {
+ err := v.setRootful(*opts.Rootful)
+ if err != nil {
+ setErrors = append(setErrors, errors.Wrapf(err, "error setting rootful option"))
+ } else {
+ v.Rootful = *opts.Rootful
+ }
}
- changeCon, err := machine.AnyConnectionDefault(v.Name, v.Name+"-root")
- if err != nil {
- return err
+ if opts.CPUs != nil {
+ setErrors = append(setErrors, errors.Errorf("changing CPUs not suppored for WSL machines"))
}
- if changeCon {
- newDefault := v.Name
- if opts.Rootful {
- newDefault += "-root"
- }
- if err := machine.ChangeDefault(newDefault); err != nil {
- return err
- }
+ if opts.Memory != nil {
+ setErrors = append(setErrors, errors.Errorf("changing memory not suppored for WSL machines"))
+
}
- v.Rootful = opts.Rootful
- return v.writeConfig()
+ if opts.DiskSize != nil {
+ setErrors = append(setErrors, errors.Errorf("changing Disk Size not suppored for WSL machines"))
+ }
+
+ return setErrors, v.writeConfig()
}
func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
@@ -1362,3 +1368,22 @@ func (p *Provider) IsValidVMName(name string) (bool, error) {
func (p *Provider) CheckExclusiveActiveVM() (bool, string, error) {
return false, "", nil
}
+
+func (v *MachineVM) setRootful(rootful bool) error {
+ changeCon, err := machine.AnyConnectionDefault(v.Name, v.Name+"-root")
+ if err != nil {
+ return err
+ }
+
+ if changeCon {
+ newDefault := v.Name
+ if rootful {
+ newDefault += "-root"
+ }
+ err := machine.ChangeDefault(newDefault)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}