From: Christoph Egger Subject: [PATCH] tools: implement balloon stat and cpuinfo for NetBSD Date: Tue, 21 Jul 2009 17:39:39 +0200 Message-ID: <200907211739.39873.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_7EeZK8KXX3FJ1JF" 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-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_7EeZK8KXX3FJ1JF Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi! Attached patch implements balloon stat and cpuinfo for NetBSD in python osdep. Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --Boundary-00=_7EeZK8KXX3FJ1JF Content-Type: text/x-diff; charset="us-ascii"; name="xen_tools_osdep.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_tools_osdep.diff" diff -r 534d3716bbbe tools/python/xen/xend/osdep.py --- a/tools/python/xen/xend/osdep.py Tue Jul 21 12:06:52 2009 +0100 +++ b/tools/python/xen/xend/osdep.py Tue Jul 21 16:59:21 2009 +0200 @@ -78,6 +78,19 @@ def _linux_balloon_stat(label): return _linux_balloon_stat_sysfs(label) return None +def _netbsd_balloon_stat(label): + """Returns the value for the named label, or None if an error occurs.""" + + import commands + + if label != 'current': + return None + cmd = "/sbin/sysctl hw.physmem64" + sysctloutput = commands.getoutput(cmd) + (name, value) = sysctloutput.split('=') + """Return value in KB.""" + return int(value) / 1024 + def _solaris_balloon_stat(label): """Returns the value for the named label, or None if an error occurs.""" @@ -106,7 +119,8 @@ def _solaris_balloon_stat(label): f.close() _balloon_stat = { - "SunOS": _solaris_balloon_stat + "SunOS": _solaris_balloon_stat, + "NetBSD": _netbsd_balloon_stat, } def _linux_get_cpuinfo(): @@ -178,8 +192,32 @@ def _solaris_get_cpuinfo(): # return the hash table return cpuinfo +def _netbsd_get_cpuinfo(): + import commands + cpuinfo = {} + + cmd = "/sbin/sysctl hw.ncpu" + sysctloutput = commands.getoutput(cmd) + (name, ncpu) = sysctloutput.split('=') + + for i in range(int(ncpu)): + if not cpuinfo.has_key(i): + cpuinfo[i] = {} + + # Translate NetBSD tokens into what xend expects + for key in cpuinfo.keys(): + cpuinfo[key]['flags'] = "" + cpuinfo[key]['vendor_id'] = "" + cpuinfo[key]['model name'] = "" + cpuinfo[key]['stepping'] = "" + cpuinfo[key]['cpu MHz'] = 0 + + return cpuinfo + + _get_cpuinfo = { - "SunOS": _solaris_get_cpuinfo + "SunOS": _solaris_get_cpuinfo, + "NetBSD": _netbsd_get_cpuinfo } def _default_prefork(name): --Boundary-00=_7EeZK8KXX3FJ1JF 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 --Boundary-00=_7EeZK8KXX3FJ1JF--