pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/xentools3 pci.py: add a parser for our kernfs...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c87fcf99555f
branches:  trunk
changeset: 555580:c87fcf99555f
user:      bouyer <bouyer%pkgsrc.org@localhost>
date:      Thu Mar 05 19:43:32 2009 +0000

description:
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++

diffstat:

 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(-)

diffs (269 lines):

diff -r d585d9d70de0 -r c87fcf99555f sysutils/xentools3/Makefile
--- a/sysutils/xentools3/Makefile       Thu Mar 05 19:08:47 2009 +0000
+++ b/sysutils/xentools3/Makefile       Thu Mar 05 19:43:32 2009 +0000
@@ -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 -r d585d9d70de0 -r c87fcf99555f sysutils/xentools3/distinfo
--- a/sysutils/xentools3/distinfo       Thu Mar 05 19:08:47 2009 +0000
+++ b/sysutils/xentools3/distinfo       Thu Mar 05 19:43:32 2009 +0000
@@ -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-dj) = 354ee3ceb1b5ba9b02091de916c328e5a062cb87
 SHA1 (patch-dk) = 5685f52835885635eacd305945653f817bbe8a2a
 SHA1 (patch-dl) = 480b515da8773e4d3cfc305d74f833f16bb12750
+SHA1 (patch-dm) = af4b849dfb54454e08acd0618afc0a81572bcbc3
+SHA1 (patch-dn) = 1b6490b8f75ab9fe4d66d444fdacdde7db38131d
diff -r d585d9d70de0 -r c87fcf99555f sysutils/xentools3/files/netbsd1-nbsd
--- a/sysutils/xentools3/files/netbsd1-nbsd     Thu Mar 05 19:08:47 2009 +0000
+++ b/sysutils/xentools3/files/netbsd1-nbsd     Thu Mar 05 19:43:32 2009 +0000
@@ -42,6 +42,19 @@
 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 -r d585d9d70de0 -r c87fcf99555f sysutils/xentools3/patches/patch-dm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/xentools3/patches/patch-dm       Thu Mar 05 19:43:32 2009 +0000
@@ -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 <hap9%epoch.ncsc.mil@localhost>
+ 
+ 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 -r d585d9d70de0 -r c87fcf99555f sysutils/xentools3/patches/patch-dn
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/xentools3/patches/patch-dn       Thu Mar 05 19:43:32 2009 +0000
@@ -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]" %



Home | Main Index | Thread Index | Old Index