Francesco Romani has uploaded a new change for review. Change subject: vm: extract the vm destroy in a method ......................................................................
vm: extract the vm destroy in a method this patch extracts the sequence of calls to vm._dom.destroy() in a separate method, with no functional changes, with the intent of clean up and modularize the code. Change-Id: I91de9dc310cd563396e0f646533ba986bcb7e35e Signed-off-by: Francesco Romani <from...@redhat.com> --- M vdsm/virt/vm.py 1 file changed, 21 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/28026/1 diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index e299654..43a2acd 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -4298,6 +4298,7 @@ 'vmPayload' in drive.specParams): supervdsm.getProxy().removeFs(drive.path) + response = {'status': doneCode} with self._releaseLock: if self._released: return {'status': doneCode} @@ -4310,21 +4311,10 @@ self._vmStats.stop() if self.guestAgent: self.guestAgent.stop() - try: - if self._dom: - try: - self._dom.destroyFlags( - libvirt.VIR_DOMAIN_DESTROY_GRACEFUL) - except libvirt.libvirtError as e: - self.log.warning("Failed to destroy VM '%s' " - "gracefully", self.conf['vmId']) - if (e.get_error_code() == - libvirt.VIR_ERR_OPERATION_FAILED): - self._dom.destroy() - except libvirt.libvirtError as e: - self.log.warning("Failed to destroy VM '%s'", - self.conf['vmId']) - return errCode['destroyErr'] + + response = self._destroyVm() + if response['status']['code']: + return response if not self.cif.mom: self.cif.ksmMonitor.adjust() @@ -4339,6 +4329,22 @@ self._released = True + return response + + def _destroyVm(self): + if self._dom: + try: + try: + self._dom.destroyFlags(libvirt.VIR_DOMAIN_DESTROY_GRACEFUL) + except libvirt.libvirtError as e: + self.log.warning("Failed to destroy VM '%s' gracefully", + self.conf['vmId']) + if e.get_error_code() == libvirt.VIR_ERR_OPERATION_FAILED: + self._dom.destroy() + except libvirt.libvirtError as e: + self.log.warning("Failed to destroy VM '%s'", + self.conf['vmId']) + return errCode['destroyErr'] return {'status': doneCode} def deleteVm(self): -- To view, visit http://gerrit.ovirt.org/28026 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I91de9dc310cd563396e0f646533ba986bcb7e35e Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches