From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yosuke Iwamatsu Subject: [PATCH] Xend: Refactor VMMetrics Destruction Date: Fri, 19 Sep 2008 19:09:52 +0900 Message-ID: <48D37A70.7070802@ab.jp.nec.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030400070408000203000501" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: jfehlig@novell.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------030400070408000203000501 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit This is a clean up patch about the destruction of xen-api instances. Xen-api classes based on XendBase class have their instances stored in XendAPIStore. Instances which belong to a domain (such as vmmeetrics and dpci) should be remove from XendAPIStore when the domain is destroyed. I looked into domain destruction code path in xend and it seemed the destruction was essentially done in XendDomain.py by deleting domains from the domain list like: del self.domains[domid] (for normall domains) del self.managed_domains[dom.get_uuid()] (for managed domains) This patch simply invokes destroy_xapi_instances() right after these lines to assure theese instances will be removed at the same time as the domain's disappearance. Regards, ----------------------- Yosuke Iwamatsu NEC Corporation --------------030400070408000203000501 Content-Type: all/allfiles; name="destroy_vmmetrics.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="destroy_vmmetrics.patch" xend: Refactor vmmetrics destruction. Signed-off-by: Yosuke Iwamatsu diff -r 694b7daa353c tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Wed Sep 17 14:16:02 2008 +0100 +++ b/tools/python/xen/xend/XendDomain.py Fri Sep 19 11:38:42 2008 +0900 @@ -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 -r 694b7daa353c tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Wed Sep 17 14:16:02 2008 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Fri Sep 19 11:38:42 2008 +0900 @@ -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") --------------030400070408000203000501 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------030400070408000203000501--