mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xend: Refactor vmmetrics destruction.
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
This commit is contained in:
1 parent
b57d0354bf
commit
11825aea19
2 files changed
+12
-10
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||