mirror of
https://github.com/containers/podman.git
synced 2025-06-25 03:52:15 +08:00
Add ability for machine rm -f for WSL
When passing the force flag to machine rm, wsl needs to stop the VM if it is running before attempting to remove it. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -1522,8 +1522,13 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
|
|||||||
var files []string
|
var files []string
|
||||||
|
|
||||||
if v.isRunning() {
|
if v.isRunning() {
|
||||||
|
if !opts.Force {
|
||||||
return "", nil, fmt.Errorf("running vm %q cannot be destroyed", v.Name)
|
return "", nil, fmt.Errorf("running vm %q cannot be destroyed", v.Name)
|
||||||
}
|
}
|
||||||
|
if err := v.Stop(v.Name, machine.StopOptions{}); err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Collect all the files that need to be destroyed
|
// Collect all the files that need to be destroyed
|
||||||
if !opts.SaveKeys {
|
if !opts.SaveKeys {
|
||||||
|
Reference in New Issue
Block a user