From: Keir Fraser Date: Wed, 30 Jan 2008 09:35:49 +0000 (+0000) Subject: xend: Perform uuid/name uniqueness check on restore. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14352 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0f63bb058b446ca614b5cbb341bd4bc0762e2900;p=xen.git xend: Perform uuid/name uniqueness check on restore. From: Zhigang Wang Signed-off-by: Keir Fraser --- diff --git a/tools/python/xen/xend/XendCheckpoint.py b/tools/python/xen/xend/XendCheckpoint.py index d3b409f7de..a70df6f785 100644 --- a/tools/python/xen/xend/XendCheckpoint.py +++ b/tools/python/xen/xend/XendCheckpoint.py @@ -151,7 +151,7 @@ def save(fd, dominfo, network, live, dst, checkpoint=False): 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: @@ -171,6 +171,14 @@ def restore(xd, fd, dominfo = None, paused = False): 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: diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 1dca606ad6..087fe57e37 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -1123,7 +1123,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 @@ -1133,7 +1133,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 diff --git a/tools/python/xen/xend/server/relocate.py b/tools/python/xen/xend/server/relocate.py index 8a28c85c0a..8f6a376bc4 100644 --- a/tools/python/xen/xend/server/relocate.py +++ b/tools/python/xen/xend/server/relocate.py @@ -108,7 +108,7 @@ class RelocationProtocol(protocol.Protocol): 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()