VirtualBox

Changeset 36630 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 8, 2011 6:41:51 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71093
Message:

PCI: Main and VBoxManage work

Location:
trunk/src/VBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk

    r34913 r36630  
    2525 VBoxManage_SOURCES = \
    2626        VBoxManage.cpp \
    27         VBoxManageHelp.cpp \
    28         $(if $(VBOX_WITH_GUEST_PROPS),VBoxManageGuestProp.cpp) \
     27        VBoxManageHelp.cpp \
     28        $(if $(VBOX_WITH_GUEST_PROPS),VBoxManageGuestProp.cpp) \
    2929        $(if $(VBOX_WITH_GUEST_CONTROL),VBoxManageGuestCtrl.cpp)
    3030 VBoxManage_LIBS      += $(LIB_RUNTIME)
     
    3333 VBoxManage_DEFS.win   = _WIN32_WINNT=0x0500
    3434 VBoxManage_SOURCES = \
    35         VBoxManage.cpp \
    36         VBoxInternalManage.cpp \
    37         VBoxManageControlVM.cpp \
    38         VBoxManageDebugVM.cpp \
    39         VBoxManageDHCPServer.cpp \
    40         VBoxManageDisk.cpp \
    41         $(if $(VBOX_WITH_GUEST_PROPS),VBoxManageGuestProp.cpp) \
     35        VBoxManage.cpp \
     36        VBoxInternalManage.cpp \
     37        VBoxManageControlVM.cpp \
     38        VBoxManageDebugVM.cpp \
     39        VBoxManageDHCPServer.cpp \
     40        VBoxManageDisk.cpp \
     41        $(if $(VBOX_WITH_GUEST_PROPS),VBoxManageGuestProp.cpp) \
    4242        $(if $(VBOX_WITH_GUEST_CONTROL),VBoxManageGuestCtrl.cpp) \
    43         VBoxManageHelp.cpp \
    44         VBoxManageHostonly.cpp \
    45         VBoxManageAppliance.cpp \
    46         VBoxManageInfo.cpp \
    47         VBoxManageList.cpp \
    48         VBoxManageMetrics.cpp \
    49         VBoxManageMisc.cpp \
    50         VBoxManageModifyVM.cpp \
    51         VBoxManageSnapshot.cpp \
    52         VBoxManageStorageController.cpp \
    53         VBoxManageUSB.cpp \
    54         VBoxManageBandwidthControl.cpp
     43        VBoxManageHelp.cpp \
     44        VBoxManageHostonly.cpp \
     45        VBoxManageAppliance.cpp \
     46        VBoxManageInfo.cpp \
     47        VBoxManageList.cpp \
     48        VBoxManageMetrics.cpp \
     49        VBoxManageMisc.cpp \
     50        VBoxManageModifyVM.cpp \
     51        VBoxManageSnapshot.cpp \
     52        VBoxManageStorageController.cpp \
     53        VBoxManageUSB.cpp \
     54        VBoxManageBandwidthControl.cpp
    5555endif # !VBOX_ONLY_DOCS
    5656
    5757VBoxManage_DEFS      += \
    58         $(if $(VBOX_WITH_AHCI), VBOX_WITH_AHCI) \
    59         $(if $(VBOX_WITH_ALSA), VBOX_WITH_ALSA) \
     58        $(if $(VBOX_WITH_AHCI), VBOX_WITH_AHCI) \
     59        $(if $(VBOX_WITH_ALSA), VBOX_WITH_ALSA) \
    6060        $(if $(VBOX_WITH_COPYTOGUEST),VBOX_WITH_COPYTOGUEST) \
    61         $(if $(VBOX_WITH_E1000),VBOX_WITH_E1000) \
    62         $(if $(VBOX_WITH_GUEST_CONTROL),VBOX_WITH_GUEST_CONTROL) \
    63         $(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS) \
    64         $(if $(VBOX_WITH_HEADLESS), VBOX_WITH_HEADLESS) \
     61        $(if $(VBOX_WITH_E1000),VBOX_WITH_E1000) \
     62        $(if $(VBOX_WITH_GUEST_CONTROL),VBOX_WITH_GUEST_CONTROL) \
     63        $(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS) \
     64        $(if $(VBOX_WITH_HEADLESS), VBOX_WITH_HEADLESS) \
    6565        $(if $(VBOX_WITH_HGCM), VBOX_WITH_HGCM) \
    66         $(if $(VBOX_WITH_HOSTNETIF_API), VBOX_WITH_HOSTNETIF_API) \
     66        $(if $(VBOX_WITH_HOSTNETIF_API), VBOX_WITH_HOSTNETIF_API) \
    6767        $(if $(VBOX_WITH_NETFLT), VBOX_WITH_NETFLT) \
    68         $(if $(VBOX_WITH_PULSE),VBOX_WITH_PULSE) \
    69         $(if $(VBOX_WITH_SCSI), VBOX_WITH_SCSI) \
    70         $(if $(VBOX_WITH_SOLARIS_OSS), VBOX_WITH_SOLARIS_OSS) \
    71         $(if $(VBOX_WITH_VBOXSDL), VBOX_WITH_VBOXSDL) \
    72         $(if $(VBOX_WITH_VDE), VBOX_WITH_VDE) \
     68        $(if $(VBOX_WITH_PULSE),VBOX_WITH_PULSE) \
     69        $(if $(VBOX_WITH_SCSI), VBOX_WITH_SCSI) \
     70        $(if $(VBOX_WITH_SOLARIS_OSS), VBOX_WITH_SOLARIS_OSS) \
     71        $(if $(VBOX_WITH_VBOXSDL), VBOX_WITH_VBOXSDL) \
     72        $(if $(VBOX_WITH_VDE), VBOX_WITH_VDE) \
    7373        $(if $(VBOX_WITH_VIDEOHWACCEL), VBOX_WITH_VIDEOHWACCEL) \
    74         $(if $(VBOX_WITH_VIRTIO),VBOX_WITH_VIRTIO)
     74        $(if $(VBOX_WITH_VIRTIO),VBOX_WITH_VIRTIO) \
     75        $(if $(VBOX_WITH_PCI_PASSTHROUGH),VBOX_WITH_PCI_PASSTHROUGH)
    7576
    7677ifneq ($(KBUILD_TARGET),win)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r36279 r36630  
    151151                     "                            [--vram <vramsize in MB>]\n"
    152152                     "                            [--acpi on|off]\n"
     153#ifdef VBOX_WITH_PCI_PASSTHROUGH
     154                     "                            [--attachpci 03:04.0]\n"
     155                     "                            [--attachpci 03:04.0@02:01.0]\n"
     156                     "                            [--detachpci 03:04.0]\n"
     157#endif
    153158                     "                            [--ioapic on|off]\n"
    154159                     "                            [--pae on|off]\n"
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r36114 r36630  
    2929
    3030#include <VBox/com/VirtualBox.h>
     31
     32#ifdef VBOX_WITH_PCI_PASSTHROUGH
     33#include <VBox/pci.h>
     34#endif
    3135
    3236#include <VBox/log.h>
     
    18031807    } /* USB */
    18041808
     1809#ifdef VBOX_WITH_PCI_PASSTHROUGH
     1810    /* Host PCI passthrough devices */
     1811    {
     1812         SafeIfaceArray <IPciDeviceAttachment> assignments;
     1813         rc = machine->COMGETTER(PciDeviceAssignments)(ComSafeArrayAsOutParam(assignments));
     1814         if (SUCCEEDED(rc))
     1815         {
     1816             if (assignments.size() > 0 && (details != VMINFO_MACHINEREADABLE))
     1817             {
     1818                 RTPrintf("\nAttached physical PCI devices:\n\n");
     1819             }
     1820             
     1821             for (size_t index = 0; index < assignments.size(); ++index)
     1822             {
     1823                 ComPtr<IPciDeviceAttachment> Assignment = assignments[index];
     1824                 char szHostPciAddress[32], szGuestPciAddress[32];
     1825                 int32_t iHostPciAddress = -1, iGuestPciAddress = -1;
     1826                 Bstr DevName;
     1827
     1828                 Assignment->COMGETTER(Name)(DevName.asOutParam());
     1829                 Assignment->COMGETTER(HostAddress)(&iHostPciAddress);
     1830                 Assignment->COMGETTER(GuestAddress)(&iGuestPciAddress);
     1831                 PciBusAddress().fromLong(iHostPciAddress).format(szHostPciAddress, sizeof(szHostPciAddress));
     1832                 PciBusAddress().fromLong(iGuestPciAddress).format(szGuestPciAddress, sizeof(szGuestPciAddress));
     1833
     1834                 if (details == VMINFO_MACHINEREADABLE)
     1835                     RTPrintf("AttachedHostPci=%s,%s\n", szHostPciAddress, szGuestPciAddress);
     1836                 else
     1837                     RTPrintf("   Host device %lS at %s attached as %s\n", DevName.raw(), szHostPciAddress, szGuestPciAddress);
     1838             }
     1839             
     1840             if (assignments.size() > 0 && (details != VMINFO_MACHINEREADABLE))
     1841             {
     1842                 RTPrintf("\n");
     1843             }
     1844         }
     1845    }
     1846    /* Host PCI passthrough devices */
     1847#endif
     1848
    18051849    /*
    18061850     * Shared folders
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r36276 r36630  
    171171    MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL,
    172172    MODIFYVM_CPU_EXECTUION_CAP,
     173#ifdef VBOX_WITH_PCI_PASSTHROUGH
     174    MODIFYVM_ATTACH_PCI,
     175    MODIFYVM_DETACH_PCI,
     176#endif
    173177    MODIFYVM_CHIPSET
    174178};
     
    299303    { "--faulttolerancesyncinterval", MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL, RTGETOPT_REQ_UINT32 },
    300304    { "--chipset",                  MODIFYVM_CHIPSET,                   RTGETOPT_REQ_STRING },
     305#ifdef VBOX_WITH_PCI_PASSTHROUGH
     306    { "--attachpci",                MODIFYVM_ATTACH_PCI,                RTGETOPT_REQ_STRING },
     307    { "--detachpci",                MODIFYVM_DETACH_PCI,                RTGETOPT_REQ_STRING },
     308#endif
    301309};
    302310
     
    306314}
    307315
     316/** Parse PCI address in format 01:02.03 and convert it to the numeric representation. */
     317static int32_t parsePci(const char* szPciAddr)
     318{
     319    char* pszNext = (char*)szPciAddr;
     320    int rc;
     321    uint8_t aVals[3] = {0, 0, 0};
     322   
     323    rc = RTStrToUInt8Ex(pszNext, &pszNext, 16, &aVals[0]);
     324    if (RT_FAILURE(rc) || pszNext == NULL || *pszNext != ':')
     325        return -1;
     326   
     327    rc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[1]);
     328    if (RT_FAILURE(rc) || pszNext == NULL || *pszNext != '.')
     329        return -1;
     330
     331    rc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[2]);
     332    if (RT_FAILURE(rc) || pszNext == NULL)
     333        return -1;
     334
     335    return (aVals[0] << 8) | (aVals[1] << 3) | (aVals[2] << 0);
     336}
    308337
    309338int handleModifyVM(HandlerArg *a)
     
    21782207                break;
    21792208            }
    2180 
     2209#ifdef VBOX_WITH_PCI_PASSTHROUGH
     2210            case MODIFYVM_ATTACH_PCI:
     2211            {
     2212                const char* pAt = strchr(ValueUnion.psz, '@');
     2213                int32_t iHostAddr, iGuestAddr;
     2214
     2215                iHostAddr = parsePci(ValueUnion.psz);
     2216                iGuestAddr = pAt != NULL ? parsePci(pAt + 1) : iHostAddr;
     2217               
     2218                if (iHostAddr == -1 || iGuestAddr == -1)
     2219                {
     2220                    errorArgument("Invalid --attachpci argument '%s' (valid: 'HB:HD.HF@GB:GD.GF' or just 'HB:HD.HF')", ValueUnion.psz);
     2221                    rc = E_FAIL;
     2222                }
     2223                else
     2224                {
     2225                    CHECK_ERROR(machine, AttachHostPciDevice(iHostAddr, iGuestAddr, TRUE));
     2226                }
     2227
     2228                break;
     2229            }
     2230            case MODIFYVM_DETACH_PCI:
     2231            {
     2232                int32_t iHostAddr;
     2233
     2234                iHostAddr = parsePci(ValueUnion.psz);
     2235                if (iHostAddr == -1)
     2236                {
     2237                    errorArgument("Invalid --detachpci argument '%s' (valid: 'HB:HD.HF')", ValueUnion.psz);
     2238                    rc = E_FAIL;
     2239                }
     2240                else
     2241                {
     2242                    CHECK_ERROR(machine, DetachHostPciDevice(iHostAddr));
     2243                }
     2244
     2245                break;
     2246            }
     2247#endif
    21812248            default:
    21822249            {
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r36615 r36630  
    47044704        and most information will be delivered as IHostPciDevicePlugEvent
    47054705        on IVirtualBox event source.
    4706         <note>
    4707           Not yet implemented.
    4708         </note>
    47094706
    47104707        <see>IHostPciDevicePlugEvent</see>
     
    47384735        will be delivered. As currently we don't support hot device
    47394736        unplug, IHostPciDevicePlugEvent event is delivered immediately.
    4740 
    4741         <note>
    4742           Not yet implemented.
    4743         </note>
    47444737
    47454738        <see>IHostPciDevicePlugEvent</see>
  • trunk/src/VBox/Main/src-client/BusAssignmentManager.cpp

    r36107 r36630  
    376376        const DeviceAssignmentRule* rule = matchingRules[iRule];
    377377
    378         Address.iBus = rule->iBus;
    379         Address.iDevice = rule->iDevice;
    380         Address.iFn = rule->iFn;
     378        Address.miBus = rule->iBus;
     379        Address.miDevice = rule->iDevice;
     380        Address.miFn = rule->iFn;
    381381
    382382        if (checkAvailable(Address))
    383383            return S_OK;
    384384    }
    385     AssertMsg(false, ("All possible candidate positions for %s exhausted\n", pszName));
     385    AssertMsgFailed(("All possible candidate positions for %s exhausted\n", pszName));
    386386
    387387    return E_INVALIDARG;
     
    490490        return rc;
    491491
    492     rc = InsertConfigInteger(pCfg, "PCIBusNo",      GuestAddress.iBus);
     492    rc = InsertConfigInteger(pCfg, "PCIBusNo",      GuestAddress.miBus);
    493493    if (FAILED(rc))
    494494        return rc;
    495     rc = InsertConfigInteger(pCfg, "PCIDeviceNo",   GuestAddress.iDevice);
     495    rc = InsertConfigInteger(pCfg, "PCIDeviceNo",   GuestAddress.miDevice);
    496496    if (FAILED(rc))
    497497        return rc;
    498     rc = InsertConfigInteger(pCfg, "PCIFunctionNo", GuestAddress.iFn);
     498    rc = InsertConfigInteger(pCfg, "PCIFunctionNo", GuestAddress.miFn);
    499499    if (FAILED(rc))
    500500        return rc;
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r36559 r36630  
    485485        Assert(GuestPciAddress.valid());
    486486
    487         if (GuestPciAddress.iBus > 0)
     487        if (GuestPciAddress.miBus > 0)
    488488        {
    489489            int iBridgesMissed = 0;
    490             int iBase = GuestPciAddress.iBus - 1;
     490            int iBase = GuestPciAddress.miBus - 1;
    491491
    492492            while (!BusMgr->hasPciDevice("ich9pcibridge", iBase) && iBase > 0)
     
    547547
    548548        InsertConfigInteger(pCfg,      "DetachHostDriver",  1);
    549         InsertConfigInteger(pCfg,      "HostPCIBusNo",      HostPciAddress.iBus);
    550         InsertConfigInteger(pCfg,      "HostPCIDeviceNo",   HostPciAddress.iDevice);
    551         InsertConfigInteger(pCfg,      "HostPCIFunctionNo", HostPciAddress.iFn);
     549        InsertConfigInteger(pCfg,      "HostPCIBusNo",      HostPciAddress.miBus);
     550        InsertConfigInteger(pCfg,      "HostPCIDeviceNo",   HostPciAddress.miDevice);
     551        InsertConfigInteger(pCfg,      "HostPCIFunctionNo", HostPciAddress.miFn);
    552552
    553553        GuestPciAddress.fromLong(guest);
     
    557557            return hrc;
    558558
    559         InsertConfigInteger(pCfg,      "GuestPCIBusNo",      GuestPciAddress.iBus);
    560         InsertConfigInteger(pCfg,      "GuestPCIDeviceNo",   GuestPciAddress.iDevice);
    561         InsertConfigInteger(pCfg,      "GuestPCIFunctionNo", GuestPciAddress.iFn);
     559        InsertConfigInteger(pCfg,      "GuestPCIBusNo",      GuestPciAddress.miBus);
     560        InsertConfigInteger(pCfg,      "GuestPCIDeviceNo",   GuestPciAddress.miDevice);
     561        InsertConfigInteger(pCfg,      "GuestPCIFunctionNo", GuestPciAddress.miFn);
    562562
    563563        /* the Main driver */
     
    18801880                InsertConfigNode(pNetBootCfg, achBootIdx, &pNetBtDevCfg);
    18811881                InsertConfigInteger(pNetBtDevCfg, "NIC", it->mInstance);
    1882                 InsertConfigInteger(pNetBtDevCfg, "PCIBusNo",      it->mPciAddress.iBus);
    1883                 InsertConfigInteger(pNetBtDevCfg, "PCIDeviceNo",   it->mPciAddress.iDevice);
    1884                 InsertConfigInteger(pNetBtDevCfg, "PCIFunctionNo", it->mPciAddress.iFn);
     1882                InsertConfigInteger(pNetBtDevCfg, "PCIBusNo",      it->mPciAddress.miBus);
     1883                InsertConfigInteger(pNetBtDevCfg, "PCIDeviceNo",   it->mPciAddress.miDevice);
     1884                InsertConfigInteger(pNetBtDevCfg, "PCIFunctionNo", it->mPciAddress.miFn);
    18851885            }
    18861886        }
     
    25092509            {
    25102510                BootNic aNic = llBootNics.front();
    2511                 uint32_t u32NicPciAddr = (aNic.mPciAddress.iDevice << 16) | aNic.mPciAddress.iFn;
     2511                uint32_t u32NicPciAddr = (aNic.mPciAddress.miDevice << 16) | aNic.mPciAddress.miFn;
    25122512                InsertConfigInteger(pCfg, "NicPciAddress",    u32NicPciAddr);
    25132513            }
     
    25172517                if (BusMgr->findPciAddress("hda", 0, Address))
    25182518                {
    2519                     uint32_t u32AudioPciAddr = (Address.iDevice << 16) | Address.iFn;
     2519                    uint32_t u32AudioPciAddr = (Address.miDevice << 16) | Address.miFn;
    25202520                    InsertConfigInteger(pCfg, "AudioPciAddress",    u32AudioPciAddr);
    25212521                }
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r36451 r36630  
    59335933        fireHostPciDevicePlugEvent(es, mid.raw(), false /* unplugged */, true /* success */, pAttach, NULL);
    59345934    }
    5935 
    5936     return S_OK;
     5935   
     5936    return fRemoved ? S_OK : setError(VBOX_E_OBJECT_NOT_FOUND,
     5937                                      tr("No host PCI device %08x attached"),
     5938                                      hostAddress
     5939                                      );
    59375940}
    59385941
Note: See TracChangeset for help on using the changeset viewer.

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