Prevent set command from updating a running instance

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:
Jason T. Greene 2022-04-06 20:39:59 -05:00
parent 6a9c21c456
commit 90ac1ba2a6
1 changed files with 13 additions and 0 deletions

View File

@ -439,6 +439,19 @@ func (v *MachineVM) Set(_ string, opts machine.SetOptions) error {
return nil
}
running, err := v.isRunning()
if err != nil {
return err
}
if running {
suffix := ""
if v.Name != machine.DefaultMachineName {
suffix = " " + v.Name
}
return errors.Errorf("cannot change setting while the vm is running, run 'podman machine stop%s' first", suffix)
}
changeCon, err := machine.AnyConnectionDefault(v.Name, v.Name+"-root")
if err != nil {
return err