Change in vdsm[master]: vm: add stopVmStats method

fromani at redhat.com fromani at redhat.com
Mon Mar 23 11:58:55 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: vm: add stopVmStats method
......................................................................

vm: add stopVmStats method

Add a method to allow clients of Vm class to shutdown
the VmStatsThread.

Change-Id: I008b94a65dc2f24426f1c3ecdb256005b74b3bde
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 12 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/39037/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 80911c6..55dae3f 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1673,10 +1673,7 @@
             self.guestAgent.stop()
         except Exception:
             pass
-        try:
-            self._vmStats.stop()
-        except Exception:
-            pass
+        self.stopVmStats()
         self.saveState()
 
     def status(self, fullStatus=True):
@@ -2004,6 +2001,16 @@
         self._vmStats = VmStatsThread(self)
         self._vmStats.start()
         self._guestEventTime = self._startTime
+
+    def stopVmStats(self):
+        # this is less clean that it could be, but we can get here from
+        # many flows and with various locks held
+        # (_releaseLock, _shutdownLock)
+        # _vmStats may be None already, and we're good with that.
+        try:
+            self._vmStats.stop()
+        except AttributeError:
+            pass
 
     @staticmethod
     def _guestSockCleanup(sock):
@@ -3866,8 +3873,7 @@
             self.lastStatus = vmstatus.POWERING_DOWN
             # Terminate the VM's creation thread.
             self._incomingMigrationFinished.set()
-            if self._vmStats:
-                self._vmStats.stop()
+            self.stopVmStats()
             self.guestAgent.stop()
             if self._dom:
                 result = self._destroyVmGraceful()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I008b94a65dc2f24426f1c3ecdb256005b74b3bde
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