[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Recover from name uniqueness violation by renaming. Fixes bug #277.



# HG changeset patch
# User emellor@ewan
# Node ID b4800e204757f1e5a6b85ca5aba6fe1c4b6597c6
# Parent  c60036fe7418d52b7cbbec4862933233b87b9660
Recover from name uniqueness violation by renaming.  Fixes bug #277.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r c60036fe7418 -r b4800e204757 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Wed Oct  5 10:43:23 2005
+++ b/tools/python/xen/xend/XendDomain.py       Wed Oct  5 13:38:19 2005
@@ -309,10 +309,12 @@
             if n == 1:
                 return matching[0]
             elif n > 1:
-                raise XendError(
-                    'Name uniqueness has been violated for name %s' % name)
-            else:
-                return None
+                log.error('Name uniqueness has been violated for name %s!  '
+                          'Recovering by renaming:', name)
+                for d in matching:
+                    d.renameUniquely()
+
+            return None
         finally:
             self.domains_lock.release()
 
diff -r c60036fe7418 -r b4800e204757 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Oct  5 10:43:23 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Oct  5 13:38:19 2005
@@ -1288,7 +1288,7 @@
         preserving the restart semantics (name and UUID preserved).
         """
         
-        new_name = self.generateShutdownName()
+        new_name = self.generateUniqueName()
         new_uuid = getUuid()
         log.info("Renaming dead domain %s (%d, %s) to %s (%s).",
                  self.info['name'], self.domid, self.uuid, new_name, new_uuid)
@@ -1307,7 +1307,23 @@
         self.state_set(STATE_VM_TERMINATED)
 
 
-    def generateShutdownName(self):
+    ## public:
+
+    def renameUniquely(self):
+        """Rename this domain so that it has a unique name.  This is used by
+        XendDomain to recover from non-uniqueness errors; we should never have
+        allowed the system to reach this state in the first place."""
+        new_name = self.generateUniqueName()
+        
+        log.error('Renaming %s (%d, %s) to %s', self.info['name'], self.domid,
+                  self.uuid, new_name)
+
+        self.setName(new_name)
+
+
+    # private:
+
+    def generateUniqueName(self):
         n = 1
         while True:
             name = "%s-%d" % (self.info['name'], n)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.