mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
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>
This commit is contained in:
1 parent
0ccfc15fae
commit
0f63bb058b
3 files changed
+12
-4
No files matched your search
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||