Change in vdsm[master]: WIP virt: add and use vm.acpiReboot() method

fromani at redhat.com fromani at redhat.com
Mon Aug 17 12:52:02 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: WIP virt: add and use vm.acpiReboot() method
......................................................................

WIP virt: add and use vm.acpiReboot() method

WRITEME

Change-Id: I5d6dd3a81cd4ad981a839849a4a2914e35a53fa6
Related-To: https://bugzilla.redhat.com/1154389
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
M vdsm/virt/vmpowerdown.py
2 files changed, 14 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/44923/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 8fc185f..c9f23d2 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3811,6 +3811,18 @@
         else:
             return response.success()
 
+    def acpiReboot(self):
+        try:
+            self._dom.reboot(libvirt.VIR_DOMAIN_REBOOT_ACPI_POWER_BTN)
+        except NotConnectedError:
+            # the VM was already shut off asynchronously,
+            # so ignore error and quickly exit
+            self.log.warning('failed to invoke acpiReboot: '
+                             'domain not connected')
+            return response.error('down')
+        else:
+            return response.success()
+
     def setBalloonTarget(self, target):
 
         if not self._dom.connected:
diff --git a/vdsm/virt/vmpowerdown.py b/vdsm/virt/vmpowerdown.py
index ffa10c9..0d46b71 100644
--- a/vdsm/virt/vmpowerdown.py
+++ b/vdsm/virt/vmpowerdown.py
@@ -106,8 +106,8 @@
         return self.event.wait(self.delay + self.timeout)
 
     def acpiCallback(self):
-        # TODO: fix like acpiShutdown
-        self.vm._dom.reboot(libvirt.VIR_DOMAIN_REBOOT_ACPI_POWER_BTN)
+        if response.is_error(self.vm.acpiReboot()):
+            return False
         return self.event.wait(self.timeout)
 
     def forceCallback(self):


-- 
To view, visit https://gerrit.ovirt.org/44923
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d6dd3a81cd4ad981a839849a4a2914e35a53fa6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list