Skip to content

Commit

Permalink
machine: qemu only remove connection after confirmation
Browse files Browse the repository at this point in the history
the connection remove call must be done inside the function that is
returned so that we wait until the user confirmed it.

Fixes containers#18330

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Apr 26, 2023
1 parent 846e7aa commit 2296e71
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,13 +964,6 @@ func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func()
files = append(files, socketPath.Path)
files = append(files, v.archRemovalFiles()...)

if err := machine.RemoveConnection(v.Name); err != nil {
logrus.Error(err)
}
if err := machine.RemoveConnection(v.Name + "-root"); err != nil {
logrus.Error(err)
}

vmConfigDir, err := machine.GetConfDir(vmtype)
if err != nil {
return "", nil, err
Expand Down Expand Up @@ -1001,6 +994,12 @@ func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func()
logrus.Error(err)
}
}
if err := machine.RemoveConnection(v.Name); err != nil {
logrus.Error(err)
}
if err := machine.RemoveConnection(v.Name + "-root"); err != nil {
logrus.Error(err)
}
return nil
}, nil
}
Expand Down

0 comments on commit 2296e71

Please sign in to comment.