ia64/xen-unstable
changeset 12598:445db3980f61
When suspending and resuming, look up the managed path using the domain's UUID.
Add a resumed domain to the self.domains list after XendCheckpoint.restore,
to ensure that it does not get recreated immediately afterwards.
Perform domain_resume under the domains_lock, given that the domain needs to
be added.
These fixes together should fix xm suspend and xm resume.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Add a resumed domain to the self.domains list after XendCheckpoint.restore,
to ensure that it does not get recreated immediately afterwards.
Perform domain_resume under the domains_lock, given that the domain needs to
be added.
These fixes together should fix xm suspend and xm resume.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | Ewan Mellor <ewan@xensource.com> |
---|---|
date | Mon Nov 27 14:52:41 2006 +0000 (2006-11-27) |
parents | 1c09d1d195e7 |
children | 93e657836d07 |
files | tools/python/xen/xend/XendDomain.py |
line diff
1.1 --- a/tools/python/xen/xend/XendDomain.py Mon Nov 27 14:48:38 2006 +0000 1.2 +++ b/tools/python/xen/xend/XendDomain.py Mon Nov 27 14:52:41 2006 +0000 1.3 @@ -564,8 +564,7 @@ class XendDomain: 1.4 log.debug('Shutting down domain: %s' % dom.getName()) 1.5 dom.shutdown("poweroff") 1.6 elif shutdownAction == 'suspend': 1.7 - chkfile = self._managed_check_point_path(dom.getName()) 1.8 - self.domain_save(dom.domid, chkfile) 1.9 + self.domain_suspend(dom.getName()) 1.10 finally: 1.11 self.domains_lock.release() 1.12 1.13 @@ -751,11 +750,13 @@ class XendDomain: 1.14 if dominfo.state != DOM_STATE_RUNNING: 1.15 raise XendError("Cannot suspend domain that is not running.") 1.16 1.17 - if not os.path.exists(self._managed_config_path(domname)): 1.18 + dom_uuid = dominfo.get_uuid() 1.19 + 1.20 + if not os.path.exists(self._managed_config_path(dom_uuid)): 1.21 raise XendError("Domain is not managed by Xend lifecycle " + 1.22 "support.") 1.23 - 1.24 - path = self._managed_check_point_path(domname) 1.25 + 1.26 + path = self._managed_check_point_path(dom_uuid) 1.27 fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC) 1.28 try: 1.29 # For now we don't support 'live checkpoint' 1.30 @@ -774,36 +775,42 @@ class XendDomain: 1.31 @rtype: None 1.32 @raise XendError: If failed to restore. 1.33 """ 1.34 + self.domains_lock.acquire() 1.35 try: 1.36 - dominfo = self.domain_lookup_nr(domname) 1.37 - 1.38 - if not dominfo: 1.39 - raise XendInvalidDomain(domname) 1.40 + try: 1.41 + dominfo = self.domain_lookup_nr(domname) 1.42 1.43 - if dominfo.getDomid() == DOM0_ID: 1.44 - raise XendError("Cannot save privileged domain %s" % domname) 1.45 + if not dominfo: 1.46 + raise XendInvalidDomain(domname) 1.47 1.48 - if dominfo.state != DOM_STATE_HALTED: 1.49 - raise XendError("Cannot suspend domain that is not running.") 1.50 + if dominfo.getDomid() == DOM0_ID: 1.51 + raise XendError("Cannot save privileged domain %s" % domname) 1.52 + 1.53 + if dominfo.state != DOM_STATE_HALTED: 1.54 + raise XendError("Cannot suspend domain that is not running.") 1.55 1.56 - chkpath = self._managed_check_point_path(domname) 1.57 - if not os.path.exists(chkpath): 1.58 - raise XendError("Domain was not suspended by Xend") 1.59 + dom_uuid = dominfo.get_uuid() 1.60 + chkpath = self._managed_check_point_path(dom_uuid) 1.61 + if not os.path.exists(chkpath): 1.62 + raise XendError("Domain was not suspended by Xend") 1.63 1.64 - # Restore that replaces the existing XendDomainInfo 1.65 - try: 1.66 - log.debug('Current DomainInfo state: %d' % dominfo.state) 1.67 - XendCheckpoint.restore(self, 1.68 - os.open(chkpath, os.O_RDONLY), 1.69 - dominfo) 1.70 - os.unlink(chkpath) 1.71 - except OSError, ex: 1.72 - raise XendError("Failed to read stored checkpoint file") 1.73 - except IOError, ex: 1.74 - raise XendError("Failed to delete checkpoint file") 1.75 - except Exception, ex: 1.76 - log.exception("Exception occurred when resuming") 1.77 - raise XendError("Error occurred when resuming: %s" % str(ex)) 1.78 + # Restore that replaces the existing XendDomainInfo 1.79 + try: 1.80 + log.debug('Current DomainInfo state: %d' % dominfo.state) 1.81 + XendCheckpoint.restore(self, 1.82 + os.open(chkpath, os.O_RDONLY), 1.83 + dominfo) 1.84 + self._add_domain(dominfo) 1.85 + os.unlink(chkpath) 1.86 + except OSError, ex: 1.87 + raise XendError("Failed to read stored checkpoint file") 1.88 + except IOError, ex: 1.89 + raise XendError("Failed to delete checkpoint file") 1.90 + except Exception, ex: 1.91 + log.exception("Exception occurred when resuming") 1.92 + raise XendError("Error occurred when resuming: %s" % str(ex)) 1.93 + finally: 1.94 + self.domains_lock.release() 1.95 1.96 1.97 def domain_create(self, config):