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

[Xen-devel] [PATCH] Add support for cpuinfo data on Solaris

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Add support for cpuinfo data on Solaris
From: John Levon <john.levon@xxxxxxx>
Date: Wed, 11 Mar 2009 18:40:16 -0700
Delivery-date: Wed, 11 Mar 2009 18:49:13 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User John Levon <john.levon@xxxxxxx>
# Date 1236821986 25200
# Node ID c4e1d1b3840452209ad59a00445b8e1718d469da
# Parent  1c21089405bfa50278680c5f4d40c4956325b377
Add support for cpuinfo data on Solaris

Signed-off-by: Russell Blaine <russell.blaine@xxxxxxx>

diff --git a/tools/python/xen/xend/osdep.py b/tools/python/xen/xend/osdep.py
--- a/tools/python/xen/xend/osdep.py
+++ b/tools/python/xen/xend/osdep.py
@@ -18,6 +18,7 @@
 # Use is subject to license terms.
 
 import os
+import commands
 
 _scripts_dir = {
     "Linux": "/etc/xen/scripts",
@@ -142,7 +143,53 @@ def _linux_get_cpuinfo():
     finally:
         f.close()
 
+def _solaris_get_cpuinfo():
+    cpuinfo = {}
+
+    # call kstat to extrace specific cpu_info output
+    cmd = "/usr/bin/kstat -p -c misc -m cpu_info"
+    kstatoutput = commands.getoutput (cmd)
+
+    # walk each line
+    for kstatline in kstatoutput.split('\n'):
+
+        # split the line on 
+        # module:cpu #:module#:name value
+        (module, cpunum, combo, namevalue) = kstatline.split (":")
+
+        # check to see if this cpunum is already a key.  If not,
+        # initialize an empty hash table
+        if not cpuinfo.has_key (int(cpunum)):
+            cpuinfo[int(cpunum)] = {}
+
+        # split the namevalue output on whitespace
+        data = namevalue.split()
+
+        # the key will be data[0]
+        key = data[0]
+
+        # check the length of the data list.  If it's larger than
+        # 2, join the rest of the list together with a space.
+        # Otherwise, value is just data[1]
+        if len (data) > 2:
+            value = ' '.join (data[1:])
+        else:
+            value = data[1]
+
+        # add this key/value pair to the cpuhash
+        cpuinfo[int(cpunum)][key] = value
+    
+    # Translate Solaris tokens into what Xend expects
+    for key in cpuinfo.keys():
+        cpuinfo[key]["flags"] = ""
+        cpuinfo[key]["model name"] = cpuinfo[key]["brand"]
+        cpuinfo[key]["cpu MHz"] = cpuinfo[key]["clock_MHz"]
+
+    # return the hash table
+    return cpuinfo
+
 _get_cpuinfo = {
+    "SunOS": _solaris_get_cpuinfo
 }
 
 def _get(var, default=None):

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Add support for cpuinfo data on Solaris, John Levon <=