diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-06-03 04:29:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-03 04:29:02 -0400 |
commit | f7a54088c30dd71a625527aecd740bac8086ccdb (patch) | |
tree | da288b6b114c06c0a8cfef1c33518b7f1b31c81e /pkg | |
parent | 6edbf3baaa10ff3738519417fbb1b2f9885e8adb (diff) | |
parent | b8de285a428cf410ad487678dc04b9953646d5ac (diff) | |
download | podman-f7a54088c30dd71a625527aecd740bac8086ccdb.tar.gz podman-f7a54088c30dd71a625527aecd740bac8086ccdb.tar.bz2 podman-f7a54088c30dd71a625527aecd740bac8086ccdb.zip |
Merge pull request #14470 from shanesmith/machine-force-remove-doesnt-stop
Stop machine before force removing files
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/machine/qemu/machine.go | 10 |
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 |