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:
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:
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
"""
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
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()