mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-08-03 09:48:00 -04:00
91 lines
2.4 KiB
Plaintext
91 lines
2.4 KiB
Plaintext
$NetBSD: patch-cb,v 1.1.1.1 2008/08/07 20:26:58 cegger Exp $
|
|
|
|
--- python/xen/xend/osdep.py.orig 2008-08-01 14:38:07.000000000 +0000
|
|
+++ python/xen/xend/osdep.py
|
|
@@ -22,6 +22,7 @@ import os
|
|
_scripts_dir = {
|
|
"Linux": "/etc/xen/scripts",
|
|
"SunOS": "/usr/lib/xen/scripts",
|
|
+ "NetBSD": "@XENDCONFDIR@/scripts",
|
|
}
|
|
|
|
_xend_autorestart = {
|
|
@@ -31,7 +32,8 @@ _xend_autorestart = {
|
|
}
|
|
|
|
_pygrub_path = {
|
|
- "SunOS": "/usr/lib/xen/bin/pygrub"
|
|
+ "SunOS": "/usr/lib/xen/bin/pygrub",
|
|
+ "NetBSD": "@PREFIX@/bin/pygrub",
|
|
}
|
|
|
|
_vif_script = {
|
|
@@ -62,6 +64,19 @@ def _linux_balloon_stat(label):
|
|
finally:
|
|
f.close()
|
|
|
|
+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."""
|
|
|
|
@@ -90,7 +105,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():
|
|
@@ -117,13 +133,36 @@ def _linux_get_cpuinfo():
|
|
finally:
|
|
f.close()
|
|
|
|
+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 = {
|
|
+ "NetBSD": _netbsd_get_cpuinfo,
|
|
}
|
|
|
|
def _get(var, default=None):
|
|
return var.get(os.uname()[0], default)
|
|
|
|
-scripts_dir = _get(_scripts_dir, "/etc/xen/scripts")
|
|
+scripts_dir = _get(_scripts_dir, "@XENDCONFDIR@/scripts")
|
|
xend_autorestart = _get(_xend_autorestart)
|
|
pygrub_path = _get(_pygrub_path, "/usr/bin/pygrub")
|
|
vif_script = _get(_vif_script, "vif-bridge")
|