ia64/xen-unstable

changeset 16937:4942f9909ec8

xend: Perform uuid/name uniqueness check on restore.
From: Zhigang Wang <zhigang.x.wang@oracle.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jan 30 09:35:49 2008 +0000 (2008-01-30)
parents 3daab9b636c1
children 92aa029e7cb1
files tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/relocate.py
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Wed Jan 30 09:33:26 2008 +0000
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Wed Jan 30 09:35:49 2008 +0000
     1.3 @@ -151,7 +151,7 @@ def save(fd, dominfo, network, live, dst
     1.4          raise exn
     1.5  
     1.6  
     1.7 -def restore(xd, fd, dominfo = None, paused = False):
     1.8 +def restore(xd, fd, dominfo = None, paused = False, relocating = False):
     1.9      signature = read_exact(fd, len(SIGNATURE),
    1.10          "not a valid guest state file: signature read")
    1.11      if signature != SIGNATURE:
    1.12 @@ -171,6 +171,14 @@ def restore(xd, fd, dominfo = None, paus
    1.13  
    1.14      vmconfig = p.get_val()
    1.15  
    1.16 +    if not relocating:
    1.17 +        domconfig = XendConfig(sxp_obj = vmconfig)
    1.18 +        othervm = xd.domain_lookup_nr(domconfig["name_label"])
    1.19 +        if othervm is None or othervm.domid is None:
    1.20 +            othervm = xd.domain_lookup_nr(domconfig["uuid"])
    1.21 +        if othervm is not None and othervm.domid is not None: 
    1.22 +            raise VmError("Domain '%s' already exists with ID '%d'" % (domconfig["name_label"], othervm.domid))
    1.23 +
    1.24      if dominfo:
    1.25          dominfo.resume()
    1.26      else:
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Jan 30 09:33:26 2008 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Wed Jan 30 09:35:49 2008 +0000
     2.3 @@ -1123,7 +1123,7 @@ class XendDomain:
     2.4              raise XendError("can't read guest state file %s: %s" %
     2.5                              (src, ex[1]))
     2.6  
     2.7 -    def domain_restore_fd(self, fd, paused=False):
     2.8 +    def domain_restore_fd(self, fd, paused=False, relocating=False):
     2.9          """Restore a domain from the given file descriptor.
    2.10  
    2.11          @param fd: file descriptor of the checkpoint file
    2.12 @@ -1133,7 +1133,7 @@ class XendDomain:
    2.13          """
    2.14  
    2.15          try:
    2.16 -            return XendCheckpoint.restore(self, fd, paused=paused)
    2.17 +            return XendCheckpoint.restore(self, fd, paused=paused, relocating=relocating)
    2.18          except XendError, e:
    2.19              log.exception("Restore failed")
    2.20              raise
     3.1 --- a/tools/python/xen/xend/server/relocate.py	Wed Jan 30 09:33:26 2008 +0000
     3.2 +++ b/tools/python/xen/xend/server/relocate.py	Wed Jan 30 09:35:49 2008 +0000
     3.3 @@ -108,7 +108,7 @@ class RelocationProtocol(protocol.Protoc
     3.4              self.send_reply(["ready", name])
     3.5              try:
     3.6                  XendDomain.instance().domain_restore_fd(
     3.7 -                    self.transport.sock.fileno())
     3.8 +                    self.transport.sock.fileno(), relocating=True)
     3.9              except:
    3.10                  self.send_error()
    3.11                  self.close()