diff options
author | cl <cl@pkgsrc.org> | 2004-05-08 18:24:00 +0000 |
---|---|---|
committer | cl <cl@pkgsrc.org> | 2004-05-08 18:24:00 +0000 |
commit | 05e1952f640a036156e124d5142574493a325a3e (patch) | |
tree | f648e005ec3da1f8b0a3d1a8aa8e31bdb089cec8 /sysutils/xentools12/patches | |
parent | c46bc87019394fcfe85c224fd59a60b226e0ddb1 (diff) | |
download | pkgsrc-05e1952f640a036156e124d5142574493a325a3e.tar.gz |
add xentools12 package:
The Xen virtual machine monitor allows running several virtual machines
on a single physical machine. The xentools12 package contains the
tools to create, destroy and control the virtual machines.
The xentools12 package contains the tools for Xen v1.2.
Diffstat (limited to 'sysutils/xentools12/patches')
-rw-r--r-- | sysutils/xentools12/patches/patch-aa | 14 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ab | 16 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ac | 28 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ad | 13 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ae | 33 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-af | 23 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ag | 27 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ah | 26 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ai | 13 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-aj | 26 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-ak | 29 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-al | 34 | ||||
-rw-r--r-- | sysutils/xentools12/patches/patch-am | 214 |
13 files changed, 496 insertions, 0 deletions
diff --git a/sysutils/xentools12/patches/patch-aa b/sysutils/xentools12/patches/patch-aa new file mode 100644 index 00000000000..c05a1739861 --- /dev/null +++ b/sysutils/xentools12/patches/patch-aa @@ -0,0 +1,14 @@ +$NetBSD: patch-aa,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- balloon/Makefile.orig 2004-04-18 04:29:14.000000000 +0200 ++++ balloon/Makefile +@@ -5,8 +5,7 @@ $(TARGET): balloon.c + $(CC) -O2 -Wall -o $(TARGET) balloon.c + + install: $(TARGET) +- mkdir -p $(prefix)/usr/bin +- cp -a $(TARGET) $(prefix)/usr/bin ++ ${BSD_INSTALL_PROGRAM} $(TARGET) ${PREFIX}/bin + + dist: $(TARGET) + mkdir -p ../../../install/bin diff --git a/sysutils/xentools12/patches/patch-ab b/sysutils/xentools12/patches/patch-ab new file mode 100644 index 00000000000..96402d73eee --- /dev/null +++ b/sysutils/xentools12/patches/patch-ab @@ -0,0 +1,16 @@ +$NetBSD: patch-ab,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- balloon/balloon.c.orig 2004-04-18 04:29:13.000000000 +0200 ++++ balloon/balloon.c +@@ -31,7 +31,11 @@ typedef struct user_balloon_op { + + static int open_balloon_proc() + { ++#if defined(__linux__) + return open("/proc/xeno/balloon", O_RDWR); ++#elif defined(__NetBSD__) ++ return open("/kern/xen/balloon", O_RDWR); ++#endif + } + + /* inflate balloon function signals to kernel it should relinquish memory */ diff --git a/sysutils/xentools12/patches/patch-ac b/sysutils/xentools12/patches/patch-ac new file mode 100644 index 00000000000..5bba5215666 --- /dev/null +++ b/sysutils/xentools12/patches/patch-ac @@ -0,0 +1,28 @@ +$NetBSD: patch-ac,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- examples/Makefile.orig 2004-04-18 04:29:14.000000000 +0200 ++++ examples/Makefile +@@ -12,15 +12,16 @@ ETC = defaults democd netbsd + INITD = xendomains + + all: ++ [ -f xc_dom_create.py-pre ] || ${MV} xc_dom_create.py xc_dom_create.py-pre ++ ${SED} -e 's|@PKG_SYSCONFDIR@|${PKG_SYSCONFDIR}|g' \ ++ xc_dom_create.py-pre > xc_dom_create.py + + install: all +- mkdir -p $(prefix)/usr/bin +- cp -a $(INSTALL) $(prefix)/usr/bin +- #chmod 755 $(INSTALL) +- mkdir -p $(prefix)/etc/xc +- for i in $(ETC) ; do [ ! -e $(prefix)/etc/xc/$$i ] && echo Install $$i && cp $$i $(prefix)/etc/xc/ ; done || true +- mkdir -p $(prefix)/etc/xc/auto +- for i in $(INITD) ; do [ -e $(prefix)/etc/init.d/ ] && [ ! -e $(prefix)/etc/init.d/$$i ] && cp $$i $(prefix)/etc/init.d/ ; done || true ++ ${BSD_INSTALL_SCRIPT} $(INSTALL) ${PREFIX}/bin ++ ${BSD_INSTALL_DATA_DIR} ${EGDIR} ++ ${BSD_INSTALL_DATA} $(ETC) ${EGDIR} ++ #mkdir -p $(prefix)/etc/xc/auto ++ #for i in $(INITD) ; do [ -e $(prefix)/etc/init.d/ ] && [ ! -e $(prefix)/etc/init.d/$$i ] && cp $$i $(prefix)/etc/init.d/ ; done || true + + dist: all + mkdir -p ../../../install/bin diff --git a/sysutils/xentools12/patches/patch-ad b/sysutils/xentools12/patches/patch-ad new file mode 100644 index 00000000000..6102f862ef4 --- /dev/null +++ b/sysutils/xentools12/patches/patch-ad @@ -0,0 +1,13 @@ +$NetBSD: patch-ad,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- examples/xc_dom_create.py.orig 2004-04-18 04:29:16.000000000 +0200 ++++ examples/xc_dom_create.py +@@ -2,7 +2,7 @@ + + import Xc, XenoUtil, string, sys, os, time, socket, getopt, signal, syslog + +-config_dir = '/etc/xc/' ++config_dir = '@PKG_SYSCONFDIR@/' + config_file = xc_config_file = config_dir + 'defaults' + + def main_usage (): diff --git a/sysutils/xentools12/patches/patch-ae b/sysutils/xentools12/patches/patch-ae new file mode 100644 index 00000000000..1d346ce70c5 --- /dev/null +++ b/sysutils/xentools12/patches/patch-ae @@ -0,0 +1,33 @@ +$NetBSD: patch-ae,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- misc/Makefile.orig 2004-04-18 04:29:10.000000000 +0200 ++++ misc/Makefile +@@ -2,6 +2,7 @@ + CC = gcc + CFLAGS = -Wall -O3 + EXTRA_INC = -I../../xen/include -I../../xenolinux-sparse/include -I../xc/lib ++EXTRA_INC += -I../../../netbsd-xen-kernel-headers + + HDRS = $(wildcard *.h) + SRCS = $(wildcard *.c) +@@ -9,18 +10,12 @@ OBJS = $(patsubst %.c,%.o,$(SRCS)) + + TARGETS = xen_read_console xen_cpuperf + +-INSTALL = $(TARGETS) xen-mkdevnodes xen_nat_enable xen-clone ++INSTALL = $(TARGETS) # xen-mkdevnodes xen_nat_enable xen-clone + + all: $(TARGETS) +- $(MAKE) -C miniterm + + install: all +- mkdir -p $(prefix)/usr/bin +- cp -a $(INSTALL) $(prefix)/usr/bin +- chmod 755 $(prefix)/usr/bin/xen-mkdevnodes +- chmod 755 $(prefix)/usr/bin/xen_nat_enable +- chmod 755 $(prefix)/usr/bin/xen-clone +- $(MAKE) -C miniterm install ++ ${BSD_INSTALL_PROGRAM} $(INSTALL) ${PREFIX}/bin + + dist: all + mkdir -p ../../../install/bin diff --git a/sysutils/xentools12/patches/patch-af b/sysutils/xentools12/patches/patch-af new file mode 100644 index 00000000000..f675467a69c --- /dev/null +++ b/sysutils/xentools12/patches/patch-af @@ -0,0 +1,23 @@ +$NetBSD: patch-af,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- misc/xen_cpuperf.c.orig 2004-04-18 04:29:11.000000000 +0200 ++++ misc/xen_cpuperf.c +@@ -9,7 +9,9 @@ + + #include <sys/types.h> + #include <sched.h> ++#if defined(__linux__) + #include <error.h> ++#endif + #include <stdio.h> + #include <unistd.h> + #include <stdlib.h> +@@ -217,7 +219,7 @@ int main(int argc, char **argv) + } + } + +- if ( (privfd = open("/proc/xeno/privcmd", O_RDWR)) == -1 ) ++ if ( (privfd = open(PRIVCMD_PATH, O_RDWR)) == -1 ) + { + fprintf(stderr, "Could not open privileged Xen control interface.\n"); + exit(1); diff --git a/sysutils/xentools12/patches/patch-ag b/sysutils/xentools12/patches/patch-ag new file mode 100644 index 00000000000..1bf47932317 --- /dev/null +++ b/sysutils/xentools12/patches/patch-ag @@ -0,0 +1,27 @@ +$NetBSD: patch-ag,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- xc/lib/Makefile.orig 2004-04-18 04:29:11.000000000 +0200 ++++ xc/lib/Makefile +@@ -6,6 +6,7 @@ SONAME = libxc.so.$(MAJOR) + CC = gcc + CFLAGS = -c -Wall -O3 + CFLAGS += -I../../../xen/include -I../../../xenolinux-sparse/include ++CFLAGS += -I../../../../netbsd-xen-kernel-headers + + HDRS = $(wildcard *.h) + OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) +@@ -23,12 +24,8 @@ check-for-zlib: + fi + + install: all +- mkdir -p $(prefix)/usr/lib +- mkdir -p $(prefix)/usr/include +- cp -a $(LIB) $(prefix)/usr/lib +- chmod 755 $(prefix)/usr/lib/$(LIB) +- cp xc.h $(prefix)/usr/include +- chmod 644 $(prefix)/usr/include/xc.h ++ ${BSD_INSTALL_PROGRAM} $(LIB) ${PREFIX}/lib ++ ${BSD_INSTALL_DATA} xc.h ${PREFIX}/include + + dist: all + mkdir -p ../../../../install/lib diff --git a/sysutils/xentools12/patches/patch-ah b/sysutils/xentools12/patches/patch-ah new file mode 100644 index 00000000000..244eff6ee1f --- /dev/null +++ b/sysutils/xentools12/patches/patch-ah @@ -0,0 +1,26 @@ +$NetBSD: patch-ah,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- xc/lib/xc_linux_build.c.orig 2004-04-18 04:29:15.000000000 +0200 ++++ xc/lib/xc_linux_build.c +@@ -222,6 +222,10 @@ static int setup_guestos(int xc_handle, + if ( (vl2tab = map_pfn(pm_handle, l2tab >> PAGE_SHIFT)) == NULL ) + goto error_out; + memset(vl2tab, 0, PAGE_SIZE); ++ unmap_pfn(pm_handle, vl2tab); ++ if ( (vl2tab = map_pfn_ro(pm_handle, l2tab >> PAGE_SHIFT)) == NULL ) ++ goto error_out; ++ mlock(vl2tab, PAGE_SIZE); + vl2e = vl2tab + l2_table_offset(virt_load_addr); + for ( count = 0; count < tot_pages; count++ ) + { +@@ -231,6 +235,10 @@ static int setup_guestos(int xc_handle, + if ( (vl1tab = map_pfn(pm_handle, l1tab >> PAGE_SHIFT)) == NULL ) + goto error_out; + memset(vl1tab, 0, PAGE_SIZE); ++ unmap_pfn(pm_handle, vl1tab); ++ if ( (vl1tab = map_pfn_ro(pm_handle, l1tab >> PAGE_SHIFT)) == NULL ) ++ goto error_out; ++ mlock(vl1tab, PAGE_SIZE); + alloc_index--; + + vl1e = vl1tab + l1_table_offset(virt_load_addr + diff --git a/sysutils/xentools12/patches/patch-ai b/sysutils/xentools12/patches/patch-ai new file mode 100644 index 00000000000..69d8093da97 --- /dev/null +++ b/sysutils/xentools12/patches/patch-ai @@ -0,0 +1,13 @@ +$NetBSD: patch-ai,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- xc/lib/xc_misc.c.orig 2004-04-18 04:29:12.000000000 +0200 ++++ xc/lib/xc_misc.c +@@ -8,7 +8,7 @@ + + int xc_interface_open(void) + { +- int fd = open("/proc/xeno/privcmd", O_RDWR); ++ int fd = open(PRIVCMD_PATH, O_RDWR); + if ( fd == -1 ) + PERROR("Could not obtain handle on privileged command interface"); + return fd; diff --git a/sysutils/xentools12/patches/patch-aj b/sysutils/xentools12/patches/patch-aj new file mode 100644 index 00000000000..514e8d5d4c7 --- /dev/null +++ b/sysutils/xentools12/patches/patch-aj @@ -0,0 +1,26 @@ +$NetBSD: patch-aj,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- xc/lib/xc_netbsd_build.c.orig 2004-04-18 04:29:16.000000000 +0200 ++++ xc/lib/xc_netbsd_build.c +@@ -157,6 +157,10 @@ static int setup_guestos(int xc_handle, + if ( (vl2tab = map_pfn(pm_handle, l2tab >> PAGE_SHIFT)) == NULL ) + goto error_out; + memset(vl2tab, 0, PAGE_SIZE); ++ unmap_pfn(pm_handle, vl2tab); ++ if ( (vl2tab = map_pfn_ro(pm_handle, l2tab >> PAGE_SHIFT)) == NULL ) ++ goto error_out; ++ mlock(vl2tab, PAGE_SIZE); + vl2e = vl2tab + l2_table_offset(*virt_load_addr); + for ( count = 0; count < tot_pages; count++ ) + { +@@ -166,6 +170,10 @@ static int setup_guestos(int xc_handle, + if ( (vl1tab = map_pfn(pm_handle, l1tab >> PAGE_SHIFT)) == NULL ) + goto error_out; + memset(vl1tab, 0, PAGE_SIZE); ++ unmap_pfn(pm_handle, vl1tab); ++ if ( (vl1tab = map_pfn_ro(pm_handle, l1tab >> PAGE_SHIFT)) == NULL ) ++ goto error_out; ++ mlock(vl1tab, PAGE_SIZE); + alloc_index--; + + vl1e = vl1tab + l1_table_offset(*virt_load_addr + diff --git a/sysutils/xentools12/patches/patch-ak b/sysutils/xentools12/patches/patch-ak new file mode 100644 index 00000000000..9191870df24 --- /dev/null +++ b/sysutils/xentools12/patches/patch-ak @@ -0,0 +1,29 @@ +$NetBSD: patch-ak,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- xc/lib/xc_private.c.orig 2004-04-18 04:29:09.000000000 +0200 ++++ xc/lib/xc_private.c +@@ -8,7 +8,7 @@ + + int init_pfn_mapper(void) + { +- return open("/dev/mem", O_RDWR); ++ return open("/kern/xen/machmem", O_RDWR); + } + + int close_pfn_mapper(int pm_handle) +@@ -25,6 +25,15 @@ void *map_pfn(int pm_handle, unsigned lo + return vaddr; + } + ++void *map_pfn_ro(int pm_handle, unsigned long pfn) ++{ ++ void *vaddr = mmap(NULL, PAGE_SIZE, PROT_READ, ++ MAP_SHARED, pm_handle, pfn << PAGE_SHIFT); ++ if ( vaddr == MAP_FAILED ) ++ return NULL; ++ return vaddr; ++} ++ + void unmap_pfn(int pm_handle, void *vaddr) + { + (void)munmap(vaddr, PAGE_SIZE); diff --git a/sysutils/xentools12/patches/patch-al b/sysutils/xentools12/patches/patch-al new file mode 100644 index 00000000000..2af708a7f0c --- /dev/null +++ b/sysutils/xentools12/patches/patch-al @@ -0,0 +1,34 @@ +$NetBSD: patch-al,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- xc/lib/xc_private.h.orig 2004-04-18 04:29:14.000000000 +0200 ++++ xc/lib/xc_private.h +@@ -16,11 +16,21 @@ + + #include "xc.h" + ++#if defined(__linux__) + #include <asm-xeno/proc_cmd.h> ++#elif defined(__NetBSD__) ++#include <sys/xenio.h> ++#endif + #include <hypervisor-ifs/hypervisor-if.h> + #include <hypervisor-ifs/dom0_ops.h> + #include <hypervisor-ifs/vbd.h> + ++#if defined(__linux__) ++#define PRIVCMD_PATH "/proc/xeno/privcmd" ++#elif defined(__NetBSD__) ++#define PRIVCMD_PATH "/kern/xen/privcmd" ++#endif ++ + #define _PAGE_PRESENT 0x001 + #define _PAGE_RW 0x002 + #define _PAGE_USER 0x004 +@@ -149,6 +159,7 @@ static inline int do_block_io_op(int xc_ + int init_pfn_mapper(void); + int close_pfn_mapper(int pm_handle); + void *map_pfn(int pm_handle, unsigned long pfn); ++void *map_pfn_ro(int pm_handle, unsigned long pfn); + void unmap_pfn(int pm_handle, void *vaddr); + + #endif /* __XC_PRIVATE_H__ */ diff --git a/sysutils/xentools12/patches/patch-am b/sysutils/xentools12/patches/patch-am new file mode 100644 index 00000000000..42e6ff0cfad --- /dev/null +++ b/sysutils/xentools12/patches/patch-am @@ -0,0 +1,214 @@ +$NetBSD: patch-am,v 1.1 2004/05/08 18:24:00 cl Exp $ + +--- xc/py/XenoUtil.py.orig 2004-04-18 04:29:13.000000000 +0200 ++++ xc/py/XenoUtil.py +@@ -25,26 +25,40 @@ except ImportError: + # on failure, just catch the error, don't do anything + pass + ++os_ifs = {'Linux' : 'eth0', 'NetBSD' : 'xennet0'} ++default_if = os_ifs[os.uname()[0]] ++ ++os_vfr_paths = {'Linux' : '/proc/xeno/vfr', 'NetBSD' : '/kern/xen/vfr'} ++vfr_path = os_vfr_paths[os.uname()[0]] ++ ++os_ipgw_cmds = {'Linux' : '/sbin/route -n', ++ 'NetBSD' : '/sbin/route -n get default'} ++ipgw_cmd = os_ipgw_cmds[os.uname()[0]] ++ ++os_ipgw_res = {'Linux' : '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' + ++ '\s+\S+\s+\S*G.*%s.*', ++ 'NetBSD' : 'gateway:\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(?:%s)?'} ++ipgw_re = os_ipgw_res[os.uname()[0]] + + ##### Networking-related functions + +-def get_current_ipaddr(dev='eth0'): ++def get_current_ipaddr(dev=default_if): + """Return a string containing the primary IP address for the given +- network interface (default 'eth0'). +- """ ++ network interface (default '%s'). ++ """ % default_if + fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' ) + lines = fd.readlines() + for line in lines: +- m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*', ++ m = re.search( '^\s+inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*', + line ) + if m: + return m.group(1) + return None + +-def get_current_ipmask(dev='eth0'): ++def get_current_ipmask(dev=default_if): + """Return a string containing the primary IP netmask for the given +- network interface (default 'eth0'). +- """ ++ network interface (default '%s'). ++ """ % default_if + fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' ) + lines = fd.readlines() + for line in lines: +@@ -52,17 +66,22 @@ def get_current_ipmask(dev='eth0'): + line ) + if m: + return m.group(1) ++ m = re.search( '^.+netmask (0x[0-9a-f]+)\s', ++ line ) ++ if m: ++ a = int(m.group(1), 16) ++ return '%d.%d.%d.%d' % ( ((a>>24)&0xff), ((a>>16)&0xff), ++ ((a>>8)&0xff), (a&0xff) ) + return None + +-def get_current_ipgw(dev='eth0'): ++def get_current_ipgw(dev=default_if): + """Return a string containing the IP gateway for the given +- network interface (default 'eth0'). +- """ +- fd = os.popen( '/sbin/route -n' ) ++ network interface (default '%s'). ++ """ % default_if ++ fd = os.popen( ipgw_cmd ) + lines = fd.readlines() + for line in lines: +- m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' + +- '\s+\S+\s+\S*G.*' + dev + '.*', line ) ++ m = re.search( ipgw_re % dev, line ) + if m: + return m.group(1) + return None +@@ -72,7 +91,7 @@ def setup_vfr_rules_for_vif(dom,vif,addr + is expressed as a textual dotted quad, and set up appropriate routing + rules in Xen. No return value. + """ +- fd = os.open( '/proc/xeno/vfr', os.O_WRONLY ) ++ fd = os.open( vfr_path, os.O_WRONLY ) + if ( re.search( '169\.254', addr) ): + os.write( fd, 'ADD ACCEPT srcaddr=' + addr + + ' srcaddrmask=255.255.255.255' + +@@ -117,14 +136,42 @@ def check_subnet( ip, network, netmask ) + + ##### VBD-related Functions + ++# ls -l /dev/hd[a-z] /dev/sd[a-z] /dev/scd* | sed -e 's#/dev/##' -e 's#,##' ++# | awk -v ORS=" " '{print "'\''" $10 "'\'':" $5 * 256 + $6 "," }'; ++blkdev_name_to_number_dict = { ++ 'hda':768, 'hdb':832, 'hdc':5632, 'hdd':5696, 'hde':8448, ++ 'hdf':8512, 'hdg':8704, 'hdh':8768, 'hdi':14336, 'hdj':14400, ++ 'hdk':14592, 'hdl':14656, ++ 'sda':2048, 'sdb':2064, 'sdc':2080, 'sdd':2096, ++ 'sde':2112, 'sdf':2128, 'sdg':2144, 'sdh':2160, ++ 'scd0':2816, 'scd1':2817, 'scd10':2826, 'scd11':2827, ++ 'scd12':2828, 'scd13':2829, 'scd14':2830, 'scd15':2831, ++ 'scd16':2832, 'scd2':2818, 'scd3':2819, 'scd4':2820, ++ 'scd5':2821, 'scd6':2822, 'scd7':2823, 'scd8':2824, ++ 'scd9':2825 ++ } ++ + def blkdev_name_to_number(name): + """Take the given textual block-device name (e.g., '/dev/sda1', +- 'hda') and return the device number used by the OS. """ ++ 'hda') and return the device number used by Xen. """ + +- if not re.match( '/dev/', name ): +- name = '/dev/' + name +- +- return os.stat(name).st_rdev ++ m = re.search( '/dev/(.+)', name ) ++ if m: ++ name = m.group(1) ++ ++ try: ++ return blkdev_name_to_number_dict[name] ++ except KeyError: ++ pass ++ ++ m = re.search( '^(...)([0-9]+)', name ) ++ if not m: ++ return None ++ ++ try: ++ return blkdev_name_to_number_dict[m.group(1)] + int( m.group(2) ) ++ except KeyError: ++ return None + + # lookup_blkdev_partn_info( '/dev/sda3' ) + def lookup_raw_partn(partition): +@@ -137,6 +184,11 @@ def lookup_raw_partn(partition): + type: 'Disk' or identifying name for partition type + """ + ++ os_lookup = { 'Linux' : lookup_raw_partn_linux, ++ 'NetBSD' : lookup_raw_partn_netbsd } ++ return os_lookup[os.uname()[0]](partition) ++ ++def lookup_raw_partn_linux(partition): + if not re.match( '/dev/', partition ): + partition = '/dev/' + partition + +@@ -168,6 +220,37 @@ def lookup_raw_partn(partition): + + return None + ++def lookup_raw_partn_netbsd(partition): ++ m = re.search( '^(?:/dev/)?([a-z]+[0-9]+)([a-z]*)', partition ) ++ if not m: ++ return None ++ ++ drive = m.group(1) ++ partition = m.group(2) ++ ++ fd = os.popen( '/sbin/sysctl -n ' + ++ 'machdep.domain0.diskcookie.%s' % drive ) ++ try: ++ cookie = int(fd.readline()) ++ except ValueError: ++ cookie = -1 ++ fd.close() ++ ++ fd = os.popen( '/sbin/disklabel %s' % drive ) ++ lines = fd.readlines() ++ for line in lines: ++ # # size offset fstype [fsize bsize cpg/sgs] ++ # a: 80555328 9514512 4.2BSD 2048 16384 28624 ++ m = re.search( '^\s+%s:\s*([0-9]+)\s+([0-9]+)\s+' % partition, ++ line ) ++ if m: ++ return [ { 'device' : int(cookie), ++ 'start_sector' : long(m.group(2)), ++ 'nr_sectors' : long(m.group(1)), ++ 'type' : '0' } ] ++ ++ return None ++ + def lookup_disk_uname( uname ): + """Lookup a list of segments for either a physical or a virtual device. + uname [string]: name of the device in the format \'vd:id\' for a virtual +@@ -905,11 +988,12 @@ def vd_extents_validate(new_extents,new_ + vbd_ext['writeable'] = vbd['writeable'] + old_extents.append(vbd_ext) + +- ##### Now scan /proc/mounts for compile a list of extents corresponding to ++ ##### Now scan /bin/mount for compile a list of extents corresponding to + ##### any devices mounted in DOM0. This list is added on to old_extents + +- regexp = re.compile("/dev/(\S*) \S* \S* (..).*") +- fd = open('/proc/mounts', "r") ++ mount_cmd = { 'Linux' : '/bin/mount', 'NetBSD' : '/sbin/mount' } ++ regexp = re.compile("/dev/(\S*) on \S* type \S* \(([^\),]*)") ++ fd = os.popen(mount_cmd[os.uname()[0]]) + + while True: + line = fd.readline() +@@ -932,7 +1016,8 @@ def vd_extents_validate(new_extents,new_ + + # set a writeable flag as appropriate + for ext in ext_list: +- ext['writeable'] = m.group(2) == 'rw' ++ ext['writeable'] = (m.group(2) != 'ro' and ++ m.group(2) != 'read-only') + + # now we've got here, the contents of ext_list are in a + # suitable format to be added onto the old_extents list, ready |