mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
hyperv: use StopWithForce with remove
When doing a machine rm -f (force removal of a machine) or a machine reset (force removal of all machines), there is no need to use a "polite/soft" stop. this will also speed up pkg/machine/e2e tests. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -212,11 +212,8 @@ func (v HyperVVirtualization) RemoveAndCleanMachines() error {
|
|||||||
prevErr = handlePrevError(err, prevErr)
|
prevErr = handlePrevError(err, prevErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the VM is not stopped, we need to stop it
|
|
||||||
// TODO stop might not be enough if the state is dorked. we may need
|
|
||||||
// something like forceoff hard switch
|
|
||||||
if vm.State() != hypervctl.Disabled {
|
if vm.State() != hypervctl.Disabled {
|
||||||
if err := vm.Stop(); err != nil {
|
if err := vm.StopWithForce(); err != nil {
|
||||||
prevErr = handlePrevError(err, prevErr)
|
prevErr = handlePrevError(err, prevErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,8 @@ func (m *HyperVMachine) Remove(_ string, opts machine.RemoveOptions) (string, fu
|
|||||||
if !opts.Force {
|
if !opts.Force {
|
||||||
return "", nil, &machine.ErrVMRunningCannotDestroyed{Name: m.Name}
|
return "", nil, &machine.ErrVMRunningCannotDestroyed{Name: m.Name}
|
||||||
}
|
}
|
||||||
if err := vm.Stop(); err != nil {
|
// force stop bc we are destroying
|
||||||
|
if err := vm.StopWithForce(); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user