WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH]restore name/uuid uniqueness check

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH]restore name/uuid uniqueness check
From: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
Date: Wed, 30 Jan 2008 14:34:20 +0800
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 29 Jan 2008 22:35:31 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C3BCA7F3.12B79%Keir.Fraser@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C3BCA7F3.12B79%Keir.Fraser@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.9 (X11/20071031)
Keir Fraser wrote:


On 23/1/08 08:07, "Keir Fraser" <Keir.Fraser@xxxxxxxxxxxx> wrote:

Perhaps you can disable your uniqueness checks on migration?

This is quite sensible actually, because a migration does not create or
restart a new domain. It just relocates an already-running domain, to which
uniqueness checks should already have been applied.

 -- Keir

this is a revised patch. I disable the uniqueness check by adding a extra
parameter to domain_restore_fd.

have tested on xen-3.1-testing.

regards,

zhigang
--- xen-3.1.2-ovs.orig/tools/python/xen/xend/XendDomain.py      2008-01-15 
19:19:14.000000000 +0800
+++ xen-3.1.2-ovs.new/tools/python/xen/xend/XendDomain.py       2008-01-30 
10:54:12.000000000 +0800
@@ -1081,7 +1081,7 @@ class XendDomain:
             raise XendError("can't read guest state file %s: %s" %
                             (src, ex[1]))
 
-    def domain_restore_fd(self, fd, paused=False):
+    def domain_restore_fd(self, fd, paused=False, relocating=False):
         """Restore a domain from the given file descriptor.
 
         @param fd: file descriptor of the checkpoint file
@@ -1091,7 +1091,7 @@ class XendDomain:
         """
 
         try:
-            return XendCheckpoint.restore(self, fd, paused=paused)
+            return XendCheckpoint.restore(self, fd, paused=paused, 
relocating=relocating)
         except XendError, e:
             log.exception("Restore failed")
             raise
--- xen-3.1.2-ovs.orig/tools/python/xen/xend/XendCheckpoint.py  2008-01-15 
19:19:14.000000000 +0800
+++ xen-3.1.2-ovs.new/tools/python/xen/xend/XendCheckpoint.py   2008-01-30 
10:57:15.000000000 +0800
@@ -150,7 +150,7 @@ def save(fd, dominfo, network, live, dst
         raise exn
 
 
-def restore(xd, fd, dominfo = None, paused = False):
+def restore(xd, fd, dominfo = None, paused = False, relocating = False):
     signature = read_exact(fd, len(SIGNATURE),
         "not a valid guest state file: signature read")
     if signature != SIGNATURE:
@@ -170,6 +170,14 @@ def restore(xd, fd, dominfo = None, paus
 
     vmconfig = p.get_val()
 
+    if not relocating:
+        domconfig = XendConfig(sxp_obj = vmconfig)
+        othervm = xd.domain_lookup_nr(domconfig["name_label"])
+        if othervm is None or othervm.domid is None:
+            othervm = xd.domain_lookup_nr(domconfig["uuid"])
+        if othervm is not None and othervm.domid is not None: 
+            raise VmError("Domain '%s' already exists with ID '%d'" % 
(domconfig["name_label"], othervm.domid))
+
     if dominfo:
         dominfo.resume()
     else:
--- xen-3.1.2-ovs.orig/tools/python/xen/xend/server/relocate.py 2008-01-15 
19:19:14.000000000 +0800
+++ xen-3.1.2-ovs.new/tools/python/xen/xend/server/relocate.py  2008-01-30 
10:59:40.000000000 +0800
@@ -108,7 +108,7 @@ class RelocationProtocol(protocol.Protoc
             self.send_reply(["ready", name])
             try:
                 XendDomain.instance().domain_restore_fd(
-                    self.transport.sock.fileno())
+                    self.transport.sock.fileno(), relocating=True)
             except:
                 self.send_error()
                 self.close()
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel