From bee50a66e4c4471e5943db741ef6d73d37e6a170 Mon Sep 17 00:00:00 2001 From: bouyer Date: Thu, 5 Mar 2009 19:43:32 +0000 Subject: pci.py: add a parser for our kernfs pciback interface pciquirk.py: fix uninitialized variable when there's no PERMISSIVE_CONFIG_FILE add a note about exported PCI devices in netbsd1 example file Python hacking by Pierre-Emmanuel Le Roux at LIP6 (thanks !) PKGREVISION++ --- sysutils/xentools3/Makefile | 4 +- sysutils/xentools3/distinfo | 4 +- sysutils/xentools3/files/netbsd1-nbsd | 13 +++ sysutils/xentools3/patches/patch-dm | 186 ++++++++++++++++++++++++++++++++++ sysutils/xentools3/patches/patch-dn | 21 ++++ 5 files changed, 225 insertions(+), 3 deletions(-) create mode 100644 sysutils/xentools3/patches/patch-dm create mode 100644 sysutils/xentools3/patches/patch-dn (limited to 'sysutils/xentools3') diff --git a/sysutils/xentools3/Makefile b/sysutils/xentools3/Makefile index ab9b9deea3e..db8642bea80 100644 --- a/sysutils/xentools3/Makefile +++ b/sysutils/xentools3/Makefile @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.18 2009/02/09 22:56:27 joerg Exp $ +# $NetBSD: Makefile,v 1.19 2009/03/05 19:43:32 bouyer Exp $ # VERSION= 3.1.4 DISTNAME= xen-${VERSION} PKGNAME= xentools3-${VERSION} -PKGREVISION= 3 +PKGREVISION= 4 CATEGORIES= sysutils MASTER_SITES= http://bits.xensource.com/oss-xen/release/${VERSION}/ EXTRACT_SUFX= .tar.gz diff --git a/sysutils/xentools3/distinfo b/sysutils/xentools3/distinfo index e0a98e73a8c..bdda88a6b59 100644 --- a/sysutils/xentools3/distinfo +++ b/sysutils/xentools3/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.11 2008/09/16 19:39:06 bouyer Exp $ +$NetBSD: distinfo,v 1.12 2009/03/05 19:43:32 bouyer Exp $ SHA1 (xen-3.1.4.tar.gz) = 0d784662776239195df10b3f29d40350f9d0644d RMD160 (xen-3.1.4.tar.gz) = c02ad2bd64e6306b127a4f37a8aa370dadc11859 @@ -60,3 +60,5 @@ SHA1 (patch-di) = 9d6a5acde713e0b7471adbea2d55e55b3ac77881 SHA1 (patch-dj) = 354ee3ceb1b5ba9b02091de916c328e5a062cb87 SHA1 (patch-dk) = 5685f52835885635eacd305945653f817bbe8a2a SHA1 (patch-dl) = 480b515da8773e4d3cfc305d74f833f16bb12750 +SHA1 (patch-dm) = af4b849dfb54454e08acd0618afc0a81572bcbc3 +SHA1 (patch-dn) = 1b6490b8f75ab9fe4d66d444fdacdde7db38131d diff --git a/sysutils/xentools3/files/netbsd1-nbsd b/sysutils/xentools3/files/netbsd1-nbsd index 90883c018d1..d56ff0634b9 100644 --- a/sysutils/xentools3/files/netbsd1-nbsd +++ b/sysutils/xentools3/files/netbsd1-nbsd @@ -41,6 +41,19 @@ vif = [ 'mac=00:16:3e:00:00:11, bridge=bridge0' ] disk = [ 'file:/home/domains/netbsd1,0x1,w' ] +#---------------------------------------------------------------------------- +# exported PCI devices +# these devices have to be attched to the pciback driver; use +# pciback.hide=(bus:dev1.fun1)(bus:dev2.fun2)(...) +# on the dom0's kernel command line to force attach of PCI devices to +# pciback. bus and dev are 2-digit hex number, fun is a single digit +# the domU needs to be built with +# xpci* at xenbus ? +# pci* at xpci ? +# and the pci drivers to be used by the domU +# +# pci = [ 'bus:dev1.fun1', 'bus:dev2.fun2' ] + #---------------------------------------------------------------------------- # Boot parameters (e.g. -s, -a, ...) extra = "" diff --git a/sysutils/xentools3/patches/patch-dm b/sysutils/xentools3/patches/patch-dm new file mode 100644 index 00000000000..745e7d0bf23 --- /dev/null +++ b/sysutils/xentools3/patches/patch-dm @@ -0,0 +1,186 @@ +$NetBSD: patch-dm,v 1.1 2009/03/05 19:43:32 bouyer Exp $ + +--- python/xen/util/pci.py.orig 2008-04-25 13:03:12.000000000 +0000 ++++ python/xen/util/pci.py 2009-03-05 15:48:44.000000000 +0000 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/pkg/bin/python2.4 + # + # PCI Device Information Class + # - Helps obtain information about which I/O resources a PCI device needs +@@ -6,52 +6,8 @@ + # Author: Ryan Wilson + + import sys +-import os, os.path + +-PROC_MNT_PATH = '/proc/mounts' +-PROC_PCI_PATH = '/proc/bus/pci/devices' +-PROC_PCI_NUM_RESOURCES = 7 +- +-SYSFS_PCI_DEVS_PATH = '/bus/pci/devices' +-SYSFS_PCI_DEV_RESOURCE_PATH = '/resource' +-SYSFS_PCI_DEV_IRQ_PATH = '/irq' +-SYSFS_PCI_DEV_DRIVER_DIR_PATH = '/driver' +-SYSFS_PCI_DEV_VENDOR_PATH = '/vendor' +-SYSFS_PCI_DEV_DEVICE_PATH = '/device' +-SYSFS_PCI_DEV_SUBVENDOR_PATH = '/subsystem_vendor' +-SYSFS_PCI_DEV_SUBDEVICE_PATH = '/subsystem_device' +- +-PCI_BAR_IO = 0x01 +-PCI_BAR_IO_MASK = ~0x03 +-PCI_BAR_MEM_MASK = ~0x0f +- +-# Definitions from Linux: include/linux/pci.h +-def PCI_DEVFN(slot, func): +- return ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +- +-def find_sysfs_mnt(): +- mounts_file = open(PROC_MNT_PATH,'r') +- +- for line in mounts_file: +- sline = line.split() +- if len(sline)<3: +- continue +- +- if sline[2]=='sysfs': +- return sline[1] +- +- return None +- +-class PciDeviceNotFoundError(Exception): +- def __init__(self,domain,bus,slot,func): +- self.domain = domain +- self.bus = bus +- self.slot = slot +- self.func = func +- self.name = "%04x:%02x:%02x.%01x"%(domain, bus, slot, func) +- +- def __str__(self): +- return ('PCI Device %s Not Found' % (self.name)) ++KERN_PATH = '/kern/xen/pci/' + + class PciDeviceParseError(Exception): + def __init__(self,msg): +@@ -69,94 +25,45 @@ + self.irq = 0 + self.iomem = [] + self.ioports = [] +- self.driver = None ++ self.driver = 'pciback' + self.vendor = None + self.device = None + self.subvendor = None + self.subdevice = None + +- self.get_info_from_sysfs() ++ self.get_info_from_kern() + +- def get_info_from_sysfs(self): +- try: +- sysfs_mnt = find_sysfs_mnt() +- except IOError, (errno, strerr): +- raise PciDeviceParseError(('Failed to locate sysfs mount: %s (%d)' % +- (PROC_PCI_PATH, strerr, errno))) ++ def get_info_from_kern(self): + +- if sysfs_mnt == None: +- return False +- +- path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \ +- self.name+SYSFS_PCI_DEV_RESOURCE_PATH ++ path = KERN_PATH + self.name ++ + try: + resource_file = open(path,'r') + +- for i in range(PROC_PCI_NUM_RESOURCES): +- line = resource_file.readline() +- sline = line.split() +- if len(sline)<3: +- continue +- +- start = int(sline[0],16) +- end = int(sline[1],16) +- flags = int(sline[2],16) +- size = end-start+1 +- +- if start!=0: +- if flags&PCI_BAR_IO: +- self.ioports.append( (start,size) ) ++ for line in resource_file.readlines(): ++ k, v = line.strip().split(':') ++ if k == 'vendor': ++ self.vendor = int(v.strip(), 16) ++ elif k == 'product': ++ self.device = int(v.strip(), 16) ++ elif k == 'subsys_vendor': ++ self.subvendor = int(v.strip(), 16) ++ elif k == 'subsys_product': ++ self.subdevice = int(v.strip(), 16) ++ elif k in ('I/O', 'mem'): ++ sline = map(str.strip, v.split('-')) ++ ++ start = int(sline[0], 16) ++ end = int(sline[1], 16) ++ size = end - start + 1 ++ ++ if k == 'I/O': ++ self.ioports.append((start, size)) + else: +- self.iomem.append( (start,size) ) +- +- except IOError, (errno, strerr): +- raise PciDeviceParseError(('Failed to open & read %s: %s (%d)' % +- (path, strerr, errno))) +- +- path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \ +- self.name+SYSFS_PCI_DEV_IRQ_PATH +- try: +- self.irq = int(open(path,'r').readline()) +- except IOError, (errno, strerr): +- raise PciDeviceParseError(('Failed to open & read %s: %s (%d)' % +- (path, strerr, errno))) ++ self.iomem.append((start, size)) ++ elif k == 'irq': ++ self.irq = int(v.strip()) + +- path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \ +- self.name+SYSFS_PCI_DEV_DRIVER_DIR_PATH +- try: +- self.driver = os.path.basename(os.readlink(path)) +- except IOError, (errno, strerr): +- raise PciDeviceParseError(('Failed to read %s: %s (%d)' % +- (path, strerr, errno))) +- +- path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \ +- self.name+SYSFS_PCI_DEV_VENDOR_PATH +- try: +- self.vendor = int(open(path,'r').readline(), 16) +- except IOError, (errno, strerr): +- raise PciDeviceParseError(('Failed to open & read %s: %s (%d)' % +- (path, strerr, errno))) +- +- path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \ +- self.name+SYSFS_PCI_DEV_DEVICE_PATH +- try: +- self.device = int(open(path,'r').readline(), 16) +- except IOError, (errno, strerr): +- raise PciDeviceParseError(('Failed to open & read %s: %s (%d)' % +- (path, strerr, errno))) +- +- path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \ +- self.name+SYSFS_PCI_DEV_SUBVENDOR_PATH +- try: +- self.subvendor = int(open(path,'r').readline(), 16) +- except IOError, (errno, strerr): +- raise PciDeviceParseError(('Failed to open & read %s: %s (%d)' % +- (path, strerr, errno))) +- +- path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \ +- self.name+SYSFS_PCI_DEV_SUBDEVICE_PATH +- try: +- self.subdevice = int(open(path,'r').readline(), 16) + except IOError, (errno, strerr): + raise PciDeviceParseError(('Failed to open & read %s: %s (%d)' % + (path, strerr, errno))) diff --git a/sysutils/xentools3/patches/patch-dn b/sysutils/xentools3/patches/patch-dn new file mode 100644 index 00000000000..e8d09c58715 --- /dev/null +++ b/sysutils/xentools3/patches/patch-dn @@ -0,0 +1,21 @@ +$NetBSD: patch-dn,v 1.1 2009/03/05 19:43:32 bouyer Exp $ + +--- python/xen/xend/server/pciquirk.py.orig 2009-03-05 16:24:01.000000000 +0000 ++++ python/xen/xend/server/pciquirk.py 2009-03-05 16:25:22.000000000 +0000 +@@ -115,14 +115,14 @@ + pci_perm_dev_config = [''] + else: + pci_perm_dev_config.insert(0, '') +- self.pci_perm_dev_config = pci_perm_dev_config + except Exception, ex: + raise XendError("Reading config file %s: %s" % + (PERMISSIVE_CONFIG_FILE,str(ex))) + else: + log.info("Config file does not exist: %s" % PERMISSIVE_CONFIG_FILE) +- self.pci_perm_dev_config = ['xend-pci-perm-devs'] ++ pci_perm_dev_config = ['xend-pci-perm-devs'] + ++ self.pci_perm_dev_config = pci_perm_dev_config + devices = child_at(child(pci_perm_dev_config, 'unconstrained_dev_ids'),0) + if self.__matchPCIdev( devices ): + log.debug("Permissive mode enabled for PCI device [%s]" % -- cgit v1.2.3