debuggers.hg
changeset 20009:4fc621f62ed1
tools: implement balloon stat and cpuinfo for NetBSD
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Wed Jul 22 14:04:14 2009 +0100 (2009-07-22) |
parents | 6c8964bbde24 |
children | 091036b8dbb9 |
files | tools/python/xen/xend/osdep.py |
line diff
1.1 --- a/tools/python/xen/xend/osdep.py Wed Jul 22 14:03:32 2009 +0100 1.2 +++ b/tools/python/xen/xend/osdep.py Wed Jul 22 14:04:14 2009 +0100 1.3 @@ -78,6 +78,19 @@ def _linux_balloon_stat(label): 1.4 return _linux_balloon_stat_sysfs(label) 1.5 return None 1.6 1.7 +def _netbsd_balloon_stat(label): 1.8 + """Returns the value for the named label, or None if an error occurs.""" 1.9 + 1.10 + import commands 1.11 + 1.12 + if label != 'current': 1.13 + return None 1.14 + cmd = "/sbin/sysctl hw.physmem64" 1.15 + sysctloutput = commands.getoutput(cmd) 1.16 + (name, value) = sysctloutput.split('=') 1.17 + """Return value in KB.""" 1.18 + return int(value) / 1024 1.19 + 1.20 def _solaris_balloon_stat(label): 1.21 """Returns the value for the named label, or None if an error occurs.""" 1.22 1.23 @@ -106,7 +119,8 @@ def _solaris_balloon_stat(label): 1.24 f.close() 1.25 1.26 _balloon_stat = { 1.27 - "SunOS": _solaris_balloon_stat 1.28 + "SunOS": _solaris_balloon_stat, 1.29 + "NetBSD": _netbsd_balloon_stat, 1.30 } 1.31 1.32 def _linux_get_cpuinfo(): 1.33 @@ -178,8 +192,32 @@ def _solaris_get_cpuinfo(): 1.34 # return the hash table 1.35 return cpuinfo 1.36 1.37 +def _netbsd_get_cpuinfo(): 1.38 + import commands 1.39 + cpuinfo = {} 1.40 + 1.41 + cmd = "/sbin/sysctl hw.ncpu" 1.42 + sysctloutput = commands.getoutput(cmd) 1.43 + (name, ncpu) = sysctloutput.split('=') 1.44 + 1.45 + for i in range(int(ncpu)): 1.46 + if not cpuinfo.has_key(i): 1.47 + cpuinfo[i] = {} 1.48 + 1.49 + # Translate NetBSD tokens into what xend expects 1.50 + for key in cpuinfo.keys(): 1.51 + cpuinfo[key]['flags'] = "" 1.52 + cpuinfo[key]['vendor_id'] = "" 1.53 + cpuinfo[key]['model name'] = "" 1.54 + cpuinfo[key]['stepping'] = "" 1.55 + cpuinfo[key]['cpu MHz'] = 0 1.56 + 1.57 + return cpuinfo 1.58 + 1.59 + 1.60 _get_cpuinfo = { 1.61 - "SunOS": _solaris_get_cpuinfo 1.62 + "SunOS": _solaris_get_cpuinfo, 1.63 + "NetBSD": _netbsd_get_cpuinfo 1.64 } 1.65 1.66 def _default_prefork(name):