ia64/xen-unstable

changeset 18401:c8377b335fbe

xend: Cleanup destroy and destroyDomain methods

When domains are destroyed, _prepare_phantom_paths() method
and _cleanup_phantom_devs() method are called twice as follows.

destroy()@XendDomainInfo.py
_prepare_phantom_paths() --------------- 1
_cleanupVm()
destroyDomain()
_prepare_phantom_paths() ----------- 2
xc.domain_destroy_hook()
xc.domain_pause()
do_FLR()
xc.domain_destroy()
XendDomain.remove_domain()
cleanupDomain()
_cleanup_phantom_devs() ------------ 1
_cleanup_phantom_devs() ---------------- 2
XendDomain.domain_delete_by_dominfo()

This is a cleanup patch. It combines destroyDomain() method
into destroy() method, then _prepare_phantom_paths() method and
_cleanup_phantom_devs() method are called only once.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Aug 28 09:44:13 2008 +0100 (2008-08-28)
parents ab50f558a6f3
children 266758b689e0
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Aug 28 09:40:10 2008 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Aug 28 09:44:13 2008 +0100
     1.3 @@ -2408,29 +2408,14 @@ class XendDomainInfo:
     1.4          if self.domid is None:
     1.5              return
     1.6  
     1.7 +        from xen.xend import XendDomain
     1.8          log.debug("XendDomainInfo.destroy: domid=%s", str(self.domid))
     1.9  
    1.10          paths = self._prepare_phantom_paths()
    1.11  
    1.12          self._cleanupVm()
    1.13          if self.dompath is not None:
    1.14 -            self.destroyDomain()
    1.15 -
    1.16 -        self._cleanup_phantom_devs(paths)
    1.17 -
    1.18 -        if "transient" in self.info["other_config"] \
    1.19 -           and bool(self.info["other_config"]["transient"]):
    1.20 -            from xen.xend import XendDomain
    1.21 -            XendDomain.instance().domain_delete_by_dominfo(self)
    1.22 -
    1.23 -
    1.24 -    def destroyDomain(self):
    1.25 -        log.debug("XendDomainInfo.destroyDomain(%s)", str(self.domid))
    1.26 -
    1.27 -        paths = self._prepare_phantom_paths()
    1.28 -
    1.29 -        try:
    1.30 -            if self.domid is not None:
    1.31 +            try:
    1.32                  xc.domain_destroy_hook(self.domid)
    1.33                  xc.domain_pause(self.domid)
    1.34                  do_FLR(self.domid)
    1.35 @@ -2438,15 +2423,18 @@ class XendDomainInfo:
    1.36                  for state in DOM_STATES_OLD:
    1.37                      self.info[state] = 0
    1.38                  self._stateSet(DOM_STATE_HALTED)
    1.39 -        except:
    1.40 -            log.exception("XendDomainInfo.destroy: xc.domain_destroy failed.")
    1.41 -
    1.42 -        from xen.xend import XendDomain
    1.43 -        XendDomain.instance().remove_domain(self)
    1.44 -
    1.45 -        self.cleanupDomain()
    1.46 +            except:
    1.47 +                log.exception("XendDomainInfo.destroy: domain destruction failed.")
    1.48 +
    1.49 +            XendDomain.instance().remove_domain(self)
    1.50 +            self.cleanupDomain()
    1.51 +
    1.52          self._cleanup_phantom_devs(paths)
    1.53  
    1.54 +        if "transient" in self.info["other_config"] \
    1.55 +           and bool(self.info["other_config"]["transient"]):
    1.56 +            XendDomain.instance().domain_delete_by_dominfo(self)
    1.57 +
    1.58  
    1.59      def resetDomain(self):
    1.60          log.debug("XendDomainInfo.resetDomain(%s)", str(self.domid))