From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Smith Subject: [PATCH] Clean up dom_get() usage Date: Thu, 15 Sep 2005 10:15:28 -0700 Message-ID: <87irx2xnf3.fsf@us.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 Developers Cc: Xen Tools Developers List-Id: xen-devel@lists.xenproject.org --=-=-= This patch adds sanity checks everywhere dom_get() is used. In the case of XendDomainInfo.update(), if we get None back from dom_get(), we destroy ourselves. I believe that this should be the desired behavior, but arguments to the contrary are welcome. Signed-off-by: Dan Smith --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=xend-domget.patch diff -r c27431cf81f9 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Thu Sep 15 13:17:24 2005 +++ b/tools/python/xen/xend/XendDomainInfo.py Thu Sep 15 10:08:16 2005 @@ -117,6 +117,7 @@ except Exception, err: # ignore missing domain log.exception("domain_getinfo(%d) failed, ignoring", dom) + return None class XendDomainInfo: @@ -356,9 +357,15 @@ if info: self.info = info else: - di = dom_get(self.domid) - if not di: - return + self.info = dom_get(self.domid) + # If we try to update and fail, we must have been + # deleted from the hypervisor + if not self.info: + log.debug("failed to get info for myself(%s); destroying..."% + self.name) + self.destroy() + return + self.memory = self.info['mem_kb'] / 1024 self.ssidref = self.info['ssidref'] @@ -1116,7 +1123,11 @@ else: raise # get run-time value of vcpus and update store - self.configure_vcpus(dom_get(self.domid)['vcpus']) + dom0 = dom_get(self.domid) + if not dom0: + log.error("Failed to get info for dom0 while trying to configure VCPUs!") + else: + self.configure_vcpus(dom0['vcpus']) def vm_field_ignore(_, _1, _2, _3): --=-=-= -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com --=-=-= 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 --=-=-=--