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-changelog

[Xen-changelog] [xen-unstable] xend: portability cleanup

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: portability cleanup
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Jul 2008 11:30:13 -0700
Delivery-date: Fri, 18 Jul 2008 11:30:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1216386852 -3600
# Node ID f8221241d18712bd40dd7cb640199b96bc133322
# Parent  f4135a620f59f8c91aa721337e95b2dfbf9aacf9
xend: portability cleanup

Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
---
 tools/python/xen/xend/XendNode.py |   28 ++--------------------------
 tools/python/xen/xend/osdep.py    |   28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 26 deletions(-)

diff -r f4135a620f59 -r f8221241d187 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Fri Jul 18 14:09:14 2008 +0100
+++ b/tools/python/xen/xend/XendNode.py Fri Jul 18 14:14:12 2008 +0100
@@ -23,6 +23,7 @@ from xen.util import Brctl
 from xen.util import Brctl
 from xen.util import pci as PciUtil
 from xen.xend import XendAPIStore
+from xen.xend import osdep
 
 import uuid, arch
 from XendPBD import XendPBD
@@ -91,7 +92,7 @@ class XendNode:
         for cpu_uuid, cpu in saved_cpus.items():
             self.cpus[cpu_uuid] = cpu
 
-        cpuinfo = parse_proc_cpuinfo()
+        cpuinfo = osdep.get_cpuinfo()
         physinfo = self.physinfo_dict()
         cpu_count = physinfo['nr_cpus']
         cpu_features = physinfo['hw_caps']
@@ -743,31 +744,6 @@ class XendNode:
     def info_dict(self):
         return dict(self.info())
 
-def parse_proc_cpuinfo():
-    cpuinfo = {}
-    f = file('/proc/cpuinfo', 'r')
-    try:
-        p = -1
-        d = {}
-        for line in f:
-            keyvalue = line.split(':')
-            if len(keyvalue) != 2:
-                continue
-            key = keyvalue[0].strip()
-            val = keyvalue[1].strip()
-            if key == 'processor':
-                if p != -1:
-                    cpuinfo[p] = d
-                p = int(val)
-                d = {}
-            else:
-                d[key] = val
-        cpuinfo[p] = d
-        return cpuinfo
-    finally:
-        f.close()
-
-
 def instance():
     global inst
     try:
diff -r f4135a620f59 -r f8221241d187 tools/python/xen/xend/osdep.py
--- a/tools/python/xen/xend/osdep.py    Fri Jul 18 14:09:14 2008 +0100
+++ b/tools/python/xen/xend/osdep.py    Fri Jul 18 14:14:12 2008 +0100
@@ -87,6 +87,33 @@ _balloon_stat = {
     "SunOS": _solaris_balloon_stat
 }
 
+def _linux_get_cpuinfo():
+    cpuinfo = {}
+    f = file('/proc/cpuinfo', 'r')
+    try:    
+        p = -1  
+        d = {}  
+        for line in f:
+            keyvalue = line.split(':')
+            if len(keyvalue) != 2:
+                continue 
+            key = keyvalue[0].strip()
+            val = keyvalue[1].strip()
+            if key == 'processor':
+                if p != -1:
+                    cpuinfo[p] = d
+                p = int(val)
+                d = {}
+            else:
+                d[key] = val
+        cpuinfo[p] = d
+        return cpuinfo
+    finally:
+        f.close()
+
+_get_cpuinfo = {
+}
+
 def _get(var, default=None):
     return var.get(os.uname()[0], default)
 
@@ -95,3 +122,4 @@ pygrub_path = _get(_pygrub_path, "/usr/b
 pygrub_path = _get(_pygrub_path, "/usr/bin/pygrub")
 vif_script = _get(_vif_script, "vif-bridge")
 lookup_balloon_stat = _get(_balloon_stat, _linux_balloon_stat)
+get_cpuinfo = _get(_get_cpuinfo, _linux_get_cpuinfo)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: portability cleanup, Xen patchbot-unstable <=