aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-09-22 11:15:39 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-09-22 11:15:39 +0100
commit11825aea195819b1b59bb622ad96db4803d17c6f (patch)
treebb97d8ca865a3b786fc0f34e93e037ee08b73fca /tools
parentb57d0354bfa2d3c3f7f515fee7243f2a68a9c76a (diff)
downloadxen-11825aea195819b1b59bb622ad96db4803d17c6f.tar.gz
xen-11825aea195819b1b59bb622ad96db4803d17c6f.tar.bz2
xen-11825aea195819b1b59bb622ad96db4803d17c6f.zip
xend: Refactor vmmetrics destruction.
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/xend/XendDomain.py5
-rw-r--r--tools/python/xen/xend/XendDomainInfo.py17
2 files changed, 12 insertions, 10 deletions
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")