multipass
multipass copied to clipboard
Fix bugs of force stop
close #3624
close #3606
The fix basically swallows the VMStateInvalidException
throw from void mp::BaseVirtualMachine::check_state_for_shutdown(bool force)
function. The new behavior of multipass delete
(non-purge) is to do nothing if the VM state is suspending, suspended, starting, restarting. If the VM is running, the shutdown(purge)
still applies.
The fix seems to be solid based on behavior. But it does get the exception catching and branching messy. If we want to treat the root cause of the bug, we have to restructure the code a bit. The root cause is that the check_state_for_shutdown
function is essentially checking and throwing for the invocation of shutdown(force)
in daemon::stop
, but resides in shutdown
function. As a result, it also throws the incorrect exception for daemon::delete
.
So a more thorough fix would be moving the function void mp::BaseVirtualMachine::check_state_for_shutdown(bool force)
to daemon::delete
and daemon::stop
. Both operations should have their respective state check. But this involves more code change. It is open for discussion.