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:
Keir Fraser committed 2008-01-30 09:35:49 +00:00
1 parent 0ccfc15fae
commit 0f63bb058b
3 files changed
+12 -4

No files matched your search

+9 -1
View File
@@ -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:
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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()
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.