diff -r d1cbfaf804d9 tools/python/xen/xend/XendCheckpoint.py --- a/tools/python/xen/xend/XendCheckpoint.py Mon Sep 19 17:10:20 2005 +++ b/tools/python/xen/xend/XendCheckpoint.py Mon Sep 19 14:07:40 2005 @@ -87,7 +87,7 @@ xd.domain_destroy(dominfo.domid) return None -def restore(xd, fd): +def getSavedConfig(fd): signature = read_exact(fd, len(SIGNATURE), "not a valid guest state file: signature read") if signature != SIGNATURE: @@ -105,8 +105,9 @@ if not p.ready: raise XendError("not a valid guest state file: config parse") - vmconfig = p.get_val() - dominfo = xd.domain_configure(vmconfig) + return p.get_val() + +def restore(fd, dominfo): l = read_exact(fd, sizeof_unsigned_long, "not a valid guest state file: pfn count read") diff -r d1cbfaf804d9 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Mon Sep 19 17:10:20 2005 +++ b/tools/python/xen/xend/XendDomain.py Mon Sep 19 14:07:40 2005 @@ -275,6 +275,11 @@ @param config: configuration @return: domain """ + + name = sxp.child_value(config, 'name') + if self.domains.get_by_name(name): + raise XendError("Domain %s already exists!" % name) + dominfo = XendDomainInfo.create(self.dbmap, config) self._add_domain(dominfo) return dominfo @@ -322,7 +327,18 @@ try: fd = os.open(src, os.O_RDONLY) - return XendCheckpoint.restore(self, fd) + + config = sxp.child_value(XendCheckpoint.getSavedConfig(fd), + 'config') + name = sxp.child_value(config, 'name') + + if self.domains.get_by_name(name): + raise XendError("Domain %s already exists!" % name) + + dominfo = XendDomainInfo.restore(self.dbmap, config) + dominfo = XendCheckpoint.restore(fd, dominfo) + self._add_domain(dominfo) + return dominfo except OSError, ex: raise XendError("can't read guest state file %s: %s" % (src, ex[1])) diff -r d1cbfaf804d9 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Mon Sep 19 17:10:20 2005 +++ b/tools/python/xen/xend/XendDomainInfo.py Mon Sep 19 14:07:40 2005 @@ -98,11 +98,6 @@ xend = SrvDaemon.instance() - -def domain_exists(name): - # See comment in XendDomain constructor. - xd = get_component('xen.xend.XendDomain') - return xd.domain_lookup_by_name(name) def shutdown_reason(code): """Get a shutdown reason from a code. @@ -512,16 +507,6 @@ if c in '_-.:/+': continue if c in string.ascii_letters: continue raise VmError('invalid vm name') - dominfo = domain_exists(name) - # When creating or rebooting, a domain with my name should not exist. - # When restoring, a domain with my name will exist, but it should have - # my domain id. - if not dominfo: - return - if dominfo.is_terminated(): - return - if not self.domid or (dominfo.domid != self.domid): - raise VmError('vm name clash: ' + name) def construct(self, config): """Construct the vm instance from its configuration.