ia64/xen-unstable

changeset 18518:a1e86caf83a3

xend: Refactor vmmetrics destruction.

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Sep 22 11:15:39 2008 +0100 (2008-09-22)
parents 2e8ad0c35792
children ad79f7af3916
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Sep 18 10:43:08 2008 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Mon Sep 22 11:15:39 2008 +0100
     1.3 @@ -344,6 +344,7 @@ class XendDomain:
     1.4              if self.is_domain_managed(dom):
     1.5                  self._managed_config_remove(dom.get_uuid())
     1.6                  del self.managed_domains[dom.get_uuid()]
     1.7 +                dom.destroy_xapi_instances()
     1.8          except ValueError:
     1.9              log.warn("Domain is not registered: %s" % dom.get_uuid())
    1.10  
    1.11 @@ -481,7 +482,7 @@ class XendDomain:
    1.12              if domid in self.domains:
    1.13                  del self.domains[domid]
    1.14  
    1.15 -            info.destroy_xapi_device_instances()
    1.16 +            info.destroy_xapi_instances()
    1.17          else:
    1.18              log.warning("Attempted to remove non-existent domain.")
    1.19  
    1.20 @@ -1091,11 +1092,9 @@ class XendDomain:
    1.21          log.info("Domain %s (%s) deleted." %
    1.22                   (dominfo.getName(), dominfo.info.get('uuid')))
    1.23                  
    1.24 -        dominfo.metrics.destroy()
    1.25          self._managed_domain_unregister(dominfo)
    1.26          self._remove_domain(dominfo)
    1.27          XendDevices.destroy_device_state(dominfo)
    1.28 -        dominfo.destroy_xapi_device_instances()
    1.29  
    1.30  
    1.31      def domain_configure(self, config):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Sep 18 10:43:08 2008 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Sep 22 11:15:39 2008 +0100
     2.3 @@ -2642,9 +2642,6 @@ class XendDomainInfo:
     2.4      def _cleanupVm(self):
     2.5          """Cleanup VM resources.  Idempotent.  Nothrow guarantee."""
     2.6  
     2.7 -        from xen.xend import XendDomain
     2.8 -        if not XendDomain.instance().is_domain_managed(self):
     2.9 -            self.metrics.destroy()
    2.10          self._unwatchVm()
    2.11  
    2.12          try:
    2.13 @@ -3507,12 +3504,12 @@ class XendDomainInfo:
    2.14              except Exception, exn:
    2.15                  raise XendError('Failed to destroy device')
    2.16  
    2.17 -    def destroy_xapi_device_instances(self):
    2.18 -        """Destroy Xen-API device instances stored in XendAPIStore.
    2.19 +    def destroy_xapi_instances(self):
    2.20 +        """Destroy Xen-API instances stored in XendAPIStore.
    2.21          """
    2.22          # Xen-API classes based on XendBase have their instances stored
    2.23 -        # in XendAPIStore. Cleanup these virtual device instances here
    2.24 -        # if they are supposed to be destroyed when the parent domain is dead.
    2.25 +        # in XendAPIStore. Cleanup these instances here, if they are supposed
    2.26 +        # to be destroyed when the parent domain is dead.
    2.27          #
    2.28          # Most of the virtual devices (vif, vbd, vfb, etc) are not based on
    2.29          # XendBase and there's no need to remove them from XendAPIStore.
    2.30 @@ -3522,6 +3519,12 @@ class XendDomainInfo:
    2.31              # domain still exists.
    2.32              return
    2.33  
    2.34 +        # Destroy the VMMetrics instance.
    2.35 +        if XendAPIStore.get(self.metrics.get_uuid(), self.metrics.getClass()) \
    2.36 +                is not None:
    2.37 +            self.metrics.destroy()
    2.38 +
    2.39 +        # Destroy DPCI instances.
    2.40          for dpci_uuid in XendDPCI.get_by_VM(self.info.get('uuid')):
    2.41              XendAPIStore.deregister(dpci_uuid, "DPCI")
    2.42