Change in vdsm[master]: virt: migration: use running() for downtime thread

fromani at redhat.com fromani at redhat.com
Thu Sep 18 06:58:04 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: virt: migration: use running() for downtime thread
......................................................................

virt: migration: use running() for downtime thread

Now that migration.DowntimeThread() conforms to the
interface required by utils.running(), we can make
use of this context manager and make the code a little
nicer and shorter.

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


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/33032/1

diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index da1465e..232a5ea 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -311,14 +311,12 @@
             self._vm.log.debug('starting migration to %s '
                                'with miguri %s', duri, muri)
 
-            t = DowntimeThread(self._vm, int(self._downtime))
-            t.start()
+            downtimeThread = DowntimeThread(self._vm, int(self._downtime))
             self._monitorThread = MonitorThread(self._vm, startTime)
-            with utils.running(self._monitorThread):
-                try:
+            with utils.running(downtimeThread):
+                with utils.running(self._monitorThread):
+                    # we need to support python 2.6, so two nested with-s.
                     self._perform_migration(duri, muri)
-                finally:
-                    t.stop()
 
     def _perform_migration(self, duri, muri):
         if self._vm.hasSpice and self._vm.conf.get('clientIp'):


-- 
To view, visit http://gerrit.ovirt.org/33032
To unsubscribe, visit http://gerrit.ovirt.org/settings

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