All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH][TOOLS] xend: portability cleanup
Date: Fri, 18 Jul 2008 15:11:08 +0200	[thread overview]
Message-ID: <200807181511.08629.Christoph.Egger@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]


Hi,

parse_proc_cpuinfo in xend is linux specific. Attached patch
moves it into osdep.py where os specific functions belong to.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

[-- Attachment #2: tools_xend.diff --]
[-- Type: text/x-diff, Size: 2774 bytes --]

diff -r a8603b2fb786 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py	Thu Jul 17 15:37:09 2008 +0100
+++ b/tools/python/xen/xend/XendNode.py	Fri Jul 18 15:02:07 2008 +0200
@@ -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 a8603b2fb786 tools/python/xen/xend/osdep.py
--- a/tools/python/xen/xend/osdep.py	Thu Jul 17 15:37:09 2008 +0100
+++ b/tools/python/xen/xend/osdep.py	Fri Jul 18 15:02:07 2008 +0200
@@ -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)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

                 reply	other threads:[~2008-07-18 13:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200807181511.08629.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.