Re: Ethernet Probe order?

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

 



On Fri, 12 Sep 2003, Jeremy Katz wrote:

> On Fri, 2003-09-12 at 12:58, Brian Long wrote:
> > We have a large problem determining which NICS in a multiple-NIC machine
> > will come up as eth0 for kickstart to proceed?
> 
> It's all based off of the kernel's scan order.  Which is basically PCI
> scan order but when you start throwing ACPI in, it can change I believe.

I just realized Brian was asking about doing this for kickstart, and not 
as a normal part of the installer.  That's a little trickier, but you 
still can reorder the way that devices are detected and potentially "pin" 
certain devices to come up earlier than others.  Maybe have a 
"deviceorder" tag in the ks file which looks like:

'deviceorder foo.o,bar.o'

Here's a fairly simple device detection routine which I added to iutil.py 
which uses lspci.  It just builds up a hash of pci entries based on what 
is detected in the machine.  It needs a little bit of work (it would be 
more efficient to not re-read the pcitable every time the function is 
run), but it illustrates how to do it.


def getDevices(pciclass = None):

    # load the pci table

    if(os.path.isfile('/modules/pcitable')):
        fn = '/modules/pcitable'
    elif(os.path.isfile('pcitable')):
        fn = 'pcitable'
    elif(os.path.isfile('/usr/share/kudzu/pcitable')):
        fn = '/usr/share/kudzu/pcitable'

    # search for the pci ids

    pat = re.compile(r'^(0x.*?)\s*"(.*?)"\s*"(.*?)"')

    f = open(fn, 'r')
    lines = f.readlines()
    f.close()

    # hash whatever we find

    pcitable = {}

    for l in lines:
        pciobj = pat.match(l)
        if pciobj:
            (pci) = pciobj.group
            pcitable[pci(1)] = [pci(2), pci(3)]

    # get output from lspci

    try:
        argv = [ "/sbin/lspci", "-nv" ]
        output = os.open("/tmp/devices", os.O_WRONLY | os.O_TRUNC | os.O_CREAT)
        execWithRedirect(argv[0], argv, stdout = output)
        os.close(output)
    except:
        try:
            argv = [ "/mnt/runtime/usr/sbin/lspci", "-nv" ]
            output = os.open("/tmp/devices", os.O_WRONLY | os.O_TRUNC | os.O_CREAT)
            execWithRedirect(argv[0], argv, stdout = output)
            os.close(output)
        except:
            log("Couldn't run lspci")
            return []

    # parse output to find out pci ids
    # this could probably be cleaned up a little

    f = open("/tmp/devices", 'r')
    lines = f.readlines()
    f.close()
    subvendor = ""
    subdevice = ""
    subid = ""
    skip = 0
    pciids = []

    for line in lines:
        fields = string.split(line)
        if line[0] == '\n':
            continue
        elif line[0] != '\t':
            skip = 0
            (vendor, device) = string.split(fields[3], ':')
            idclass = fields[2]
            idclass = idclass[:-1]

            #print "* %s:%s" % (pciclass, idclass)

            if pciclass and pciclass != idclass:
                skip = 1
                continue

        elif fields[0] == "Subsystem:":
            if skip:
                continue
            (subvendor, subdevice) = string.split(fields[1], ':')
            key = "0x%s\t0x%s\t0x%s\t0x%s" % (vendor, device,
                                              subvendor, subdevice)
            # search first for the full pci id

            if pcitable.has_key(key):
                v = pcitable[key]
                pciids.append(key, v[0], v[1])
            else:
                key = "0x%s\t0x%s" % (vendor, device)
                if pcitable.has_key(key):
                    v = pcitable[key]
                    pciids.append(key, v[0], v[1])

    return pciids








[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux