Skip to contentSkip to conversation

Prevent changing of the policy while virtual machines are migrating

PATCH New Stefan Berger 1 participant 1 message Nov 4, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Prevent changing of the policy while virtual machines are migrating

This patch uses the reader-writer lock primitive from part 1 to prevent the changing of the policy while guest are migrated to a host. The net changes of this patch are that the reader-side lock is put into the path of the migration code and the writer lock into the path of the code that handles the changing of the policy. Simultaneous migrations of multiple hosts still work after this lock has been added.

---
 xen-unstable.hg/tools/python/xen/xend/XendDomain.py     |   27 ++--
 xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py |  103 ++++++++--------
 2 files changed, 71 insertions(+), 59 deletions(-)
xen-unstable.hg/tools/python/xen/xend/XendDomain.py +18 -11
Index: new-xen/xen-unstable.hg/tools/python/xen/xend/XendDomain.py
===================================================================
@@ -50,7 +50,7 @@ from xen.xend.XendAPIConstants import *
 
 from xen.xend.xenstore.xstransact import xstransact
 from xen.xend.xenstore.xswatch import xswatch
-from xen.util import mkdir
+from xen.util import mkdir, rwlock
 from xen.xend import uuid
 
 xc = xen.lowlevel.xc.xc()
@@ -93,6 +93,8 @@ class XendDomain:
         self.managed_domains = {}
         self.domains_lock = threading.RLock()
 
+        self.policy_lock = rwlock.RWLock()
+
         # xen api instance vars
         # TODO: nothing uses this at the moment
         self._allow_new_domains = True
@@ -1138,16 +1140,21 @@ class XendDomain:
         """
 
         try:
-            return XendCheckpoint.restore(self, fd, paused=paused, relocating=relocating)
-        except XendError, e:
-            log.exception("Restore failed")
-            raise
-        except:
-            # I don't really want to log this exception here, but the error
-            # handling in the relocation-socket handling code (relocate.py) is
-            # poor, so we need to log this for debugging.
-            log.exception("Restore failed")
-            raise XendError("Restore failed")
+            self.policy_lock.acquire_reader()
+
+            try:
+                return XendCheckpoint.restore(self, fd, paused=paused, relocating=relocating)
+            except XendError, e:
+                log.exception("Restore failed")
+                raise
+            except:
+                # I don't really want to log this exception here, but the error
+                # handling in the relocation-socket handling code (relocate.py) is
+                # poor, so we need to log this for debugging.
+                log.exception("Restore failed")
+                raise XendError("Restore failed")
+        finally:
+            self.policy_lock.release()
  
     def domain_unpause(self, domid):
         """Unpause domain execution.
xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py +54 -49

118 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel