summaryrefslogtreecommitdiff
path: root/pkg/machine
diff options
context:
space:
mode:
authorShane Smith <shane.smith@shopify.com>2022-06-02 16:34:02 -0400
committerShane Smith <shane.smith@shopify.com>2022-06-02 16:58:43 -0400
commitb8de285a428cf410ad487678dc04b9953646d5ac (patch)
tree76128fe5bc3a4b6a462c9f5b8dbc24695094a6ac /pkg/machine
parent570c2492a3cc596e0ac4e2cc208d1fe26166e016 (diff)
downloadpodman-b8de285a428cf410ad487678dc04b9953646d5ac.tar.gz
podman-b8de285a428cf410ad487678dc04b9953646d5ac.tar.bz2
podman-b8de285a428cf410ad487678dc04b9953646d5ac.zip
Stop machine before force removing files
In #13466 the ability to force remove a machine while it's running was added but it did not first stop the machine, all files get deleted but the qemu VM would essentially be orphaned. [NO NEW TESTS NEEDED] Signed-off-by: Shane Smith <shane.smith@shopify.com>
Diffstat (limited to 'pkg/machine')
-rw-r--r--pkg/machine/qemu/machine.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index b9f23662e..0a85ff5ce 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -831,8 +831,14 @@ func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func()
if err != nil {
return "", nil, err
}
- if state == machine.Running && !opts.Force {
- return "", nil, errors.Errorf("running vm %q cannot be destroyed", v.Name)
+ if state == machine.Running {
+ if !opts.Force {
+ return "", nil, errors.Errorf("running vm %q cannot be destroyed", v.Name)
+ }
+ err := v.Stop(v.Name, machine.StopOptions{})
+ if err != nil {
+ return "", nil, err
+ }
}
// Collect all the files that need to be destroyed