WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-tools

[Xen-tools] [PATCH] Clean up dom_get() usage

To: Xen Developers <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-tools] [PATCH] Clean up dom_get() usage
From: Dan Smith <danms@xxxxxxxxxx>
Date: Thu, 15 Sep 2005 10:15:28 -0700
Cc: Xen Tools Developers <xen-tools@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 15 Sep 2005 17:13:17 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-tools-request@lists.xensource.com?subject=help>
List-id: Xen control tools developers <xen-tools.lists.xensource.com>
List-post: <mailto:xen-tools@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-tools>, <mailto:xen-tools-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-tools>, <mailto:xen-tools-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-tools-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)
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 <danms@xxxxxxxxxx>

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@xxxxxxxxxx
_______________________________________________
Xen-tools mailing list
Xen-tools@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-tools
<Prev in Thread] Current Thread [Next in Thread>