From: Keir Fraser Date: Mon, 22 Sep 2008 10:15:39 +0000 (+0100) Subject: xend: Refactor vmmetrics destruction. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14101^2~52 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=11825aea195819b1b59bb622ad96db4803d17c6f;p=xen.git xend: Refactor vmmetrics destruction. Signed-off-by: Yosuke Iwamatsu --- diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 8e20152a95..9faebe95aa 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -344,6 +344,7 @@ class XendDomain: if self.is_domain_managed(dom): self._managed_config_remove(dom.get_uuid()) del self.managed_domains[dom.get_uuid()] + dom.destroy_xapi_instances() except ValueError: log.warn("Domain is not registered: %s" % dom.get_uuid()) @@ -481,7 +482,7 @@ class XendDomain: if domid in self.domains: del self.domains[domid] - info.destroy_xapi_device_instances() + info.destroy_xapi_instances() else: log.warning("Attempted to remove non-existent domain.") @@ -1091,11 +1092,9 @@ class XendDomain: log.info("Domain %s (%s) deleted." % (dominfo.getName(), dominfo.info.get('uuid'))) - dominfo.metrics.destroy() self._managed_domain_unregister(dominfo) self._remove_domain(dominfo) XendDevices.destroy_device_state(dominfo) - dominfo.destroy_xapi_device_instances() def domain_configure(self, config): diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 3cbdc03287..b025d609f7 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -2642,9 +2642,6 @@ class XendDomainInfo: def _cleanupVm(self): """Cleanup VM resources. Idempotent. Nothrow guarantee.""" - from xen.xend import XendDomain - if not XendDomain.instance().is_domain_managed(self): - self.metrics.destroy() self._unwatchVm() try: @@ -3507,12 +3504,12 @@ class XendDomainInfo: except Exception, exn: raise XendError('Failed to destroy device') - def destroy_xapi_device_instances(self): - """Destroy Xen-API device instances stored in XendAPIStore. + def destroy_xapi_instances(self): + """Destroy Xen-API instances stored in XendAPIStore. """ # Xen-API classes based on XendBase have their instances stored - # in XendAPIStore. Cleanup these virtual device instances here - # if they are supposed to be destroyed when the parent domain is dead. + # in XendAPIStore. Cleanup these instances here, if they are supposed + # to be destroyed when the parent domain is dead. # # Most of the virtual devices (vif, vbd, vfb, etc) are not based on # XendBase and there's no need to remove them from XendAPIStore. @@ -3522,6 +3519,12 @@ class XendDomainInfo: # domain still exists. return + # Destroy the VMMetrics instance. + if XendAPIStore.get(self.metrics.get_uuid(), self.metrics.getClass()) \ + is not None: + self.metrics.destroy() + + # Destroy DPCI instances. for dpci_uuid in XendDPCI.get_by_VM(self.info.get('uuid')): XendAPIStore.deregister(dpci_uuid, "DPCI")