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. Bug-Url: https://bugzilla.redhat.com/557125 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/02/31902/1 diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index abc6182..6d70f25 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -1887,7 +1887,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 @@ -1943,6 +1942,7 @@ self._powerDownEvent = threading.Event() self._liveMergeCleanupThreads = {} + self._shutdownReason = None def _get_lastStatus(self): PAUSED_STATES = (vmstatus.POWERING_DOWN, vmstatus.REBOOT_IN_PROGRESS, @@ -2363,12 +2363,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): @@ -4868,11 +4866,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): @@ -5405,7 +5405,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/31902 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id03e38fe897d3b36fa7fedc016c2420f67d28385 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
