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 May 23, 2023
1 parent 02b9f4f commit dc21698
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 @@ -940,13 +940,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 @@ -977,6 +970,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 dc21698

Please sign in to comment.