Francesco Romani has uploaded a new change for review. Change subject: vm: simplify the shutdown exit reason ......................................................................
vm: simplify the shutdown exit reason A VM could be cleanly shutdown in two ways, either from inside (user shutdown) or from engine (admin shutdown). In turn, the shutdown process can involve various shutdown methods (guest agent, acpi, forced). Currently we use a couple of booleans to detect all the various cases, but this is clumsy and some paths aren't well covered, so wrong states may be reported. This patch simplify the reporting by adding an explicit, private, 'shutdownReason' field. Change-Id: Id03e38fe897d3b36fa7fedc016c2420f67d28385 Signed-off-by: Francesco Romani <[email protected]> --- M vdsm/virt/vm.py 1 file changed, 9 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/31354/1 diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index a485cd9..564dfa4 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -1477,7 +1477,6 @@ self.destroyed = False self._recoveryFile = constants.P_VDSM_RUN + \ str(self.conf['vmId']) + '.recovery' - self.user_destroy = False self._monitorResponse = 0 self.conf['clientIp'] = '' self.memCommitted = 0 @@ -1533,6 +1532,7 @@ self._powerDownEvent = threading.Event() self._liveMergeCleanupThreads = {} + self._shutdownReason = None def _get_lastStatus(self): PAUSED_STATES = (vmstatus.POWERING_DOWN, vmstatus.REBOOT_IN_PROGRESS, @@ -1953,12 +1953,10 @@ # state response = self.releaseVm() if not response['status']['code']: - if self.destroyed: - self.setDownStatus(NORMAL, vmexitreason.ADMIN_SHUTDOWN) - elif self.user_destroy: - self.setDownStatus(NORMAL, vmexitreason.USER_SHUTDOWN) - else: + if self._shutdownReason is None: self.setDownStatus(ERROR, vmexitreason.LOST_QEMU_CONNECTION) + else: + self.setDownStatus(NORMAL, self._shutdownReason) self._powerDownEvent.set() def _loadCorrectedTimeout(self, base, doubler=20, load=None): @@ -4611,11 +4609,13 @@ dev.custom) hooks.before_vm_destroy(self._lastXMLDesc, self.conf) + self._shutdownReason = vmexitreason.ADMIN_SHUTDOWN self.destroyed = True return self.releaseVm() def acpiShutdown(self): + self._shutdownReason = vmexitreason.ADMIN_SHUTDOWN self._dom.shutdownFlags(libvirt.VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN) def setBalloonTarget(self, target): @@ -5151,7 +5151,9 @@ hooks.after_vm_hibernate(self._lastXMLDesc, self.conf) else: if detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN: - self.user_destroy = True + if self._shutdownReason is None: + # do not overwrite admin shutdown, if present + self._shutdownReason = vmexitreason.USER_SHUTDOWN self._onQemuDeath() elif event == libvirt.VIR_DOMAIN_EVENT_SUSPENDED: self._guestCpuRunning = False -- To view, visit http://gerrit.ovirt.org/31354 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id03e38fe897d3b36fa7fedc016c2420f67d28385 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
