From dc21698d60edf52df1af38c84c488a8ea3328542 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 26 Apr 2023 16:44:28 +0200 Subject: [PATCH] machine: qemu only remove connection after confirmation the connection remove call must be done inside the function that is returned so that we wait until the user confirmed it. Fixes #18330 Signed-off-by: Paul Holzinger --- pkg/machine/qemu/machine.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index f39cbd8abc..d4a72ed240 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -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 @@ -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 }