VirtualBox

Ignore:
Timestamp:
Apr 8, 2010 4:45:59 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59822
Message:

Main: Added machinery to query, set and use NIC boot priority.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r27976 r28106  
    192192
    193193/*
     194 * Simple class for storing network boot information.
     195 */
     196struct BootNic {
     197    ULONG       mInstance;
     198    unsigned    mPciDev;
     199    unsigned    mPciFn;
     200    ULONG       mBootPrio;
     201    bool operator < (const BootNic &rhs) const
     202    {
     203        int lval = mBootPrio ? mBootPrio : INT_MAX;
     204        int rval = rhs.mBootPrio ? rhs.mBootPrio : INT_MAX;
     205        return lval < rval; /* Zero compares as highest number (lowest prio). */
     206    }
     207};
     208
     209/*
    194210 * VC++ 8 / amd64 has some serious trouble with this function.
    195211 * As a temporary measure, we'll drop global optimizations.
     
    14501466    rc = CFGMR3InsertNode(pDevices, "virtio-net", &pDevVirtioNet);                  RC_CHECK();
    14511467#endif /* VBOX_WITH_VIRTIO */
     1468    std::list<BootNic> llNics;
    14521469    for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ++ulInstance)
    14531470    {
     
    15291546        }
    15301547#endif
    1531         /*
    1532          * Transfer boot device information to the BIOS.
     1548        /* 
     1549         * Collect information needed for network booting and add it to the list.
    15331550         */
    1534         if (ulInstance == 0)
    1535         {
    1536             unsigned    uBootIdx = 0;
    1537 
    1538             if (pNetBootCfg)    /* NetBoot node doesn't exist for EFI! */
    1539             {
    1540                 PCFGMNODE   pNetBtDevCfg;
    1541                 char        achBootIdx[] = "0";
    1542 
    1543                 achBootIdx[0] = '0' + uBootIdx;     /* Boot device order. */
    1544                 rc = CFGMR3InsertNode(pNetBootCfg, achBootIdx, &pNetBtDevCfg);      RC_CHECK();
    1545                 rc = CFGMR3InsertInteger(pNetBtDevCfg, "NIC", ulInstance);          RC_CHECK();
    1546                 rc = CFGMR3InsertInteger(pNetBtDevCfg, "PCIDeviceNo", iPciDeviceNo);RC_CHECK();
    1547                 rc = CFGMR3InsertInteger(pNetBtDevCfg, "PCIFunctionNo", 0);         RC_CHECK();
    1548             }
    1549         }
     1551        BootNic     nic;
     1552
     1553        nic.mInstance = ulInstance;
     1554        nic.mPciDev   = iPciDeviceNo;
     1555        nic.mPciFn    = 0;
     1556
     1557        hrc = networkAdapter->COMGETTER(BootPriority)(&nic.mBootPrio);              H();
     1558
     1559        llNics.push_back(nic);
    15501560
    15511561        /*
     
    16221632        rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter,
    16231633                           pCfg, pLunL0, pInst, false /*fAttachDetach*/);           RC_CHECK();
     1634    }
     1635
     1636    /*
     1637     * Build network boot information and transfer it to the BIOS.
     1638     */
     1639    if (pNetBootCfg && !llNics.empty())  /* NetBoot node doesn't exist for EFI! */
     1640    {
     1641        llNics.sort();  /* Sort the list by boot priority. */
     1642
     1643        PCFGMNODE   pNetBtDevCfg;
     1644        char        achBootIdx[] = "0";
     1645        unsigned    uBootIdx = 0;
     1646
     1647        std::list<BootNic>::iterator it;
     1648
     1649        for (it = llNics.begin(); it != llNics.end(); ++it)
     1650        {
     1651            Assert(iter);
     1652
     1653            /* A NIC with priority 0 is only used if it's first in the list. */
     1654            if (it->mBootPrio == 0 && uBootIdx != 0)
     1655                break;
     1656
     1657            achBootIdx[0] = '0' + uBootIdx++;   /* Boot device order. */
     1658            rc = CFGMR3InsertNode(pNetBootCfg, achBootIdx, &pNetBtDevCfg);      RC_CHECK();
     1659            rc = CFGMR3InsertInteger(pNetBtDevCfg, "NIC", it->mInstance);       RC_CHECK();
     1660            rc = CFGMR3InsertInteger(pNetBtDevCfg, "PCIDeviceNo", it->mPciDev); RC_CHECK();
     1661            rc = CFGMR3InsertInteger(pNetBtDevCfg, "PCIFunctionNo", it->mPciFn);RC_CHECK();
     1662        }
    16241663    }
    16251664
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette