Changeset 35885 in vbox
- Timestamp:
- Feb 8, 2011 1:20:04 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69897
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/log.h
r34219 r35885 120 120 /** PCI Device group. */ 121 121 LOG_GROUP_DEV_PCI, 122 /** PCI Raw Device group. */ 123 LOG_GROUP_DEV_PCI_RAW, 122 124 /** PCNet Device group. */ 123 125 LOG_GROUP_DEV_PCNET, … … 395 397 "DEV_PC_BIOS", \ 396 398 "DEV_PCI", \ 399 "DEV_PCI_RAW", \ 397 400 "DEV_PCNET", \ 398 401 "DEV_PIC", \ -
trunk/include/VBox/settings.h
r35146 r35885 693 693 694 694 /** 695 * NOTE: If you add any fields in here, you must update a) the constructor and b) 696 * the operator== which is used by MachineConfigFile::operator==(), or otherwise 697 * your settings might never get saved. 698 */ 699 struct HostPciDeviceAttachment 700 { 701 HostPciDeviceAttachment() 702 : uHostAddress(0), 703 uGuestAddress(0) 704 {} 705 706 bool operator==(const HostPciDeviceAttachment &a) const 707 { 708 return ( (uHostAddress == a.uHostAddress) 709 && (uGuestAddress == a.uGuestAddress) 710 && (strDeviceName == a.strDeviceName) 711 ); 712 } 713 714 com::Utf8Str strDeviceName; 715 uint32_t uHostAddress; 716 uint32_t uGuestAddress; 717 }; 718 typedef std::list<HostPciDeviceAttachment> HostPciDeviceAttachmentList; 719 720 /** 695 721 * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine 696 722 * field. … … 761 787 762 788 IoSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2) 789 HostPciDeviceAttachmentList pciAttachments; // requires settings version 1.12 (VirtualBox 4.1) 763 790 }; 764 791 -
trunk/src/VBox/Devices/Makefile.kmk
r35855 r35885 160 160 ifdef VBOX_WITH_VDE 161 161 VBoxDD_DEFS += VBOX_WITH_VDE 162 endif 163 ifdef VBOX_WITH_PCI_PASSTHROUGH 164 VBoxDD_DEFS += VBOX_WITH_PCI_PASSTHROUGH 162 165 endif 163 166 … … 261 264 VBOX_HGCM_HOST_CODE \ 262 265 VBOX_WITH_HGCM \ 263 $(if $(VBOX_BIOS_DMI_FALLBACK),VBOX_BIOS_DMI_FALLBACK,) 266 $(if $(VBOX_BIOS_DMI_FALLBACK),VBOX_BIOS_DMI_FALLBACK,) \ 267 $(if $(VBOX_WITH_PCI_PASSTHROUGH),VBOX_WITH_PCI_PASSTHROUGH,) 268 264 269 DevicesR3_DEFS.linux += _GNU_SOURCE 265 270 DevicesR3_DEFS.l4 += _GNU_SOURCE … … 541 546 Bus/MsiCommon.cpp \ 542 547 Bus/MsixCommon.cpp \ 543 $(if $(VBOX_WITH_PCI_PASSTHROUGH),Bus/DevPciRaw.cpp,) \544 548 Graphics/DevVGA.cpp \ 545 549 Input/DevPS2.cpp \ -
trunk/src/VBox/Devices/testcase/Makefile.kmk
r35353 r35885 40 40 $(if $(VBOX_WITH_VDMA),VBOX_WITH_VDMA,) \ 41 41 $(if $(VBOX_WITH_WDDM),VBOX_WITH_WDDM,) \ 42 $(if $(VBOX_WITH_VIDEOHWACCEL),VBOX_WITH_VIDEOHWACCEL,) 42 $(if $(VBOX_WITH_VIDEOHWACCEL),VBOX_WITH_VIDEOHWACCEL,) \ 43 $(if $(VBOX_WITH_PCI_PASSTHROUGH),VBOX_WITH_PCI_PASSTHROUGH,) 44 43 45 44 46 # -
trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp
r32471 r35885 85 85 # undef LOG_GROUP 86 86 # include "../Storage/DevLsiLogicSCSI.cpp" 87 #endif 88 89 #ifdef VBOX_WITH_PCI_PASSTHROUGH 90 # undef LOG_GROUP 91 # include "../Bus/DevPciRaw.cpp" 87 92 #endif 88 93 … … 317 322 CHECK_MEMBER_ALIGNMENT(VPCISTATE, Queues, 8); 318 323 #endif 324 #ifdef VBOX_WITH_PCI_PASSTHROUGH 325 CHECK_MEMBER_ALIGNMENT(PCIRAWSENDREQ, u.aGetRegionInfo.u64RegionSize, 8); 326 #endif 319 327 320 328 #ifdef VBOX_WITH_RAW_MODE … … 335 343 return rc; 336 344 } 337 -
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r35783 r35885 3103 3103 return 3104 3104 3105 def parsePci(str): 3106 pcire = re.compile(r'(?P<b>\d+):(?P<d>\d+)\.(?P<f>\d)') 3107 m = pcire.search(str) 3108 if m is None: 3109 return -1 3110 dict = m.groupdict() 3111 return ((int(dict['b'])) << 8) | ((int(dict['d'])) << 3) | int(dict['f']) 3105 3112 3106 3113 def lspciCmd(ctx, args): … … 3112 3119 return 0 3113 3120 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx,mach,console,args: lspci(ctx, console)]) 3121 return 0 3122 3123 def attachpciCmd(ctx, args): 3124 if (len(args) < 3): 3125 print "usage: attachpci vm hostpci <guestpci>" 3126 return 0 3127 mach = argsToMach(ctx,args) 3128 if mach == None: 3129 return 0 3130 hostaddr = parsePci(args[2]) 3131 if hostaddr == -1: 3132 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" %(args[2]) 3133 return 0 3134 3135 if (len(args) > 3): 3136 guestaddr = parsePci(args[3]) 3137 if guestaddr == -1: 3138 print "invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" %(args[3]) 3139 return 0 3140 else: 3141 guestaddr = hostaddr 3142 cmdClosedVm(ctx, mach, lambda ctx,mach,a: mach.attachHostPciDevice(hostaddr, guestaddr, True)) 3143 return 0 3144 3145 def detachpciCmd(ctx, args): 3146 if (len(args) < 3): 3147 print "usage: detachpci vm hostpci" 3148 return 0 3149 mach = argsToMach(ctx,args) 3150 if mach == None: 3151 return 0 3152 hostaddr = parsePci(args[2]) 3153 if hostaddr == -1: 3154 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" %(args[2]) 3155 return 0 3156 3157 cmdClosedVm(ctx, mach, 'guestlambda', lambda ctx,mach,a: mach.detachHostPciDevice(hostaddr)) 3114 3158 return 0 3115 3159 … … 3200 3244 'recordDemo':['Record demo: recordDemo Win32 file.dmo 10', recordDemoCmd, 0], 3201 3245 'playbackDemo':['Playback demo: playbackDemo Win32 file.dmo 10', playbackDemoCmd, 0], 3202 'lspci': ['List PCI devices attached to the VM: lspci Win32', lspciCmd] 3246 'lspci': ['List PCI devices attached to the VM: lspci Win32', lspciCmd, 0], 3247 'attachpci': ['Attach host PCI device to the VM: attachpci Win32 01:00.0', attachpciCmd, 0], 3248 'detachpci': ['Detach host PCI device from the VM: detachpci Win32 01:00.0', detachpciCmd, 0] 3203 3249 } 3204 3250 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r35765 r35885 481 481 --> 482 482 </const> 483 <const name="v1_12" value="14"> 484 <desc>Settings version "1.12", written by VirtualBox 4.1.x.</desc> 485 <!-- 486 Machine changes: raw PCI device atatchment. 487 --> 488 </const> 489 483 490 <const name="Future" value="99999"> 484 491 <desc>Settings version greater than "1.11", written by a future VirtualBox version.</desc> -
trunk/src/VBox/Main/include/PciDeviceAttachmentImpl.h
r35684 r35885 22 22 23 23 #include "VirtualBoxBase.h" 24 #include <VBox/settings.h> 24 25 25 26 class ATL_NO_VTABLE PciAddress : … … 109 110 LONG aGuestAddress, 110 111 BOOL fPhysical); 112 111 113 void uninit(); 114 115 // settings 116 HRESULT loadSettings(IMachine * aParent, 117 const settings::HostPciDeviceAttachment& aHpda); 118 HRESULT saveSettings(settings::HostPciDeviceAttachment &data); 112 119 113 120 HRESULT FinalConstruct(); … … 122 129 private: 123 130 struct Data; 124 Data *m;131 Data* m; 125 132 }; 126 133 -
trunk/src/VBox/Main/src-all/PciDeviceAttachmentImpl.cpp
r35684 r35885 33 33 fPhysical(afPhysical) 34 34 { 35 (void)aParent; 35 36 DevName = aDevName; 36 37 } … … 69 70 70 71 return m != NULL ? S_OK : E_FAIL; 72 } 73 74 HRESULT PciDeviceAttachment::loadSettings(IMachine *aParent, 75 const settings::HostPciDeviceAttachment &hpda) 76 { 77 Bstr bname(hpda.strDeviceName); 78 return init(aParent, bname, hpda.uHostAddress, hpda.uGuestAddress, TRUE); 79 } 80 81 82 HRESULT PciDeviceAttachment::saveSettings(settings::HostPciDeviceAttachment &data) 83 { 84 Assert(m); 85 data.uHostAddress = m->HostAddress; 86 data.uGuestAddress = m->GuestAddress; 87 data.strDeviceName = m->DevName; 88 89 return S_OK; 71 90 } 72 91 -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r35875 r35885 1734 1734 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1735 1735 1736 mBusMgr->listAttachedPciDevices(ComSafeArrayOutArg(aAttachments)); 1736 if (mBusMgr) 1737 mBusMgr->listAttachedPciDevices(ComSafeArrayOutArg(aAttachments)); 1738 else 1739 { 1740 com::SafeIfaceArray<IPciDeviceAttachment> result(0); 1741 result.detachTo(ComSafeArrayOutArg(aAttachments)); 1742 } 1737 1743 1738 1744 return S_OK; -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r35838 r35885 5829 5829 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5830 5830 5831 //HRESULT rc = checkStateDependency(MutableStateDep);5832 //if (FAILED(rc)) return rc;5831 HRESULT rc = checkStateDependency(MutableStateDep); 5832 if (FAILED(rc)) return rc; 5833 5833 5834 5834 ComObjPtr<PciDeviceAttachment> pda; … … 5843 5843 mHWData->mPciDeviceAssignments.push_back(pda); 5844 5844 } 5845 5846 // do we need it?5847 //saveSettings(NULL);5848 mHWData.commit();5849 5845 5850 5846 return S_OK; … … 5887 5883 } 5888 5884 } 5889 // Indeed under lock?5890 mHWData.commit();5891 5892 // do we need it?5893 // saveSettings(NULL);5894 5885 } 5895 5886 … … 7451 7442 rc = mBandwidthControl->loadSettings(data.ioSettings); 7452 7443 if (FAILED(rc)) return rc; 7444 7445 // Host PCI devices 7446 for (settings::HostPciDeviceAttachmentList::const_iterator it = data.pciAttachments.begin(); 7447 it != data.pciAttachments.end(); 7448 ++it) 7449 { 7450 const settings::HostPciDeviceAttachment &hpda = *it; 7451 ComObjPtr<PciDeviceAttachment> pda; 7452 7453 pda.createObject(); 7454 pda->loadSettings(this, hpda); 7455 mHWData->mPciDeviceAssignments.push_back(pda); 7456 } 7453 7457 7454 7458 #ifdef VBOX_WITH_GUEST_PROPS … … 8530 8534 rc = mBandwidthControl->saveSettings(data.ioSettings); 8531 8535 if (FAILED(rc)) throw rc; 8536 8537 /* Host PCI devices */ 8538 for (HWData::PciDeviceAssignmentList::const_iterator it = mHWData->mPciDeviceAssignments.begin(); 8539 it != mHWData->mPciDeviceAssignments.end(); 8540 ++it) 8541 { 8542 ComObjPtr<PciDeviceAttachment> pda = *it; 8543 settings::HostPciDeviceAttachment hpda; 8544 8545 rc = pda->saveSettings(hpda); 8546 if (FAILED(rc)) throw rc; 8547 8548 data.pciAttachments.push_back(hpda); 8549 } 8550 8532 8551 8533 8552 // guest properties -
trunk/src/VBox/Main/xml/Settings.cpp
r35818 r35885 91 91 92 92 /** VirtualBox XML settings version number substring ("x.y") */ 93 #define VBOX_XML_VERSION "1.1 1"93 #define VBOX_XML_VERSION "1.12" 94 94 95 95 /** VirtualBox XML settings version platform substring */ … … 320 320 else if (ulMinor == 11) 321 321 m->sv = SettingsVersion_v1_11; 322 else if (ulMinor > 11) 322 else if (ulMinor == 12) 323 m->sv = SettingsVersion_v1_12; 324 else if (ulMinor > 12) 323 325 m->sv = SettingsVersion_Future; 324 326 } … … 340 342 // creating new settings file: 341 343 m->strSettingsVersionFull = VBOX_XML_VERSION_FULL; 342 m->sv = SettingsVersion_v1_1 1;344 m->sv = SettingsVersion_v1_12; 343 345 } 344 346 } … … 818 820 break; 819 821 822 case SettingsVersion_v1_12: 823 pcszVersion = "1.12"; 824 break; 825 820 826 case SettingsVersion_Future: 821 827 // can be set if this code runs on XML files that were created by a future version of VBox; 822 828 // in that case, downgrade to current version when writing since we can't write future versions... 823 pcszVersion = "1.1 1";824 m->sv = SettingsVersion_v1_1 0;829 pcszVersion = "1.12"; 830 m->sv = SettingsVersion_v1_12; 825 831 break; 826 832 … … 846 852 * set the "sv" member to the required settings version that is to 847 853 * be written. For newly created files, the settings version will be 848 * the latest (1.1 1); for files read in from disk earlier, it will be854 * the latest (1.12); for files read in from disk earlier, it will be 849 855 * the settings version indicated in the file. However, this method 850 856 * will silently make sure that the settings version is always … … 1648 1654 && (strNotificationPatterns == h.strNotificationPatterns) 1649 1655 && (ioSettings == h.ioSettings) 1656 && (pciAttachments == h.pciAttachments) 1650 1657 ) 1651 1658 ); … … 2717 2724 pelmBandwidthGroup->getAttributeValue("maxMbPerSec", gr.cMaxMbPerSec); 2718 2725 hw.ioSettings.llBandwidthGroups.push_back(gr); 2726 } 2727 } 2728 } else if (pelmHwChild->nameEquals("HostPci")) { 2729 const xml::ElementNode *pelmDevices; 2730 2731 if ((pelmDevices = pelmHwChild->findChildElement("Devices"))) 2732 { 2733 xml::NodesLoop nl2(*pelmDevices, "Device"); 2734 const xml::ElementNode *pelmDevice; 2735 while ((pelmDevice = nl2.forAllNodes())) 2736 { 2737 HostPciDeviceAttachment hpda; 2738 2739 if (!pelmDevice->getAttributeValue("host", hpda.uHostAddress)) 2740 throw ConfigFileError(this, pelmDevice, N_("Missing Device/@host attribute")); 2741 2742 if (!pelmDevice->getAttributeValue("host", hpda.uGuestAddress)) 2743 throw ConfigFileError(this, pelmDevice, N_("Missing Device/@guest attribute")); 2744 2745 /* name is optional */ 2746 pelmDevice->getAttributeValue("name", hpda.strDeviceName); 2747 2748 hw.pciAttachments.push_back(hpda); 2719 2749 } 2720 2750 } … … 3863 3893 } 3864 3894 3895 if (m->sv >= SettingsVersion_v1_12) 3896 { 3897 xml::ElementNode *pelmPci = pelmHardware->createChild("HostPci"); 3898 xml::ElementNode *pelmPciDevices = pelmPci->createChild("Devices"); 3899 3900 for (HostPciDeviceAttachmentList::const_iterator it = hw.pciAttachments.begin(); 3901 it != hw.pciAttachments.end(); 3902 ++it) 3903 { 3904 const HostPciDeviceAttachment &hpda = *it; 3905 3906 xml::ElementNode *pelmThis = pelmPciDevices->createChild("Device"); 3907 3908 pelmThis->setAttribute("host", hpda.uHostAddress); 3909 pelmThis->setAttribute("guest", hpda.uGuestAddress); 3910 pelmThis->setAttribute("name", hpda.strDeviceName); 3911 } 3912 } 3913 3865 3914 xml::ElementNode *pelmGuest = pelmHardware->createChild("Guest"); 3866 3915 pelmGuest->setAttribute("memoryBalloonSize", hw.ulMemoryBalloonSize); … … 4418 4467 void MachineConfigFile::bumpSettingsVersionIfNeeded() 4419 4468 { 4469 if (m->sv < SettingsVersion_v1_12) 4470 { 4471 // VirtualBox 4.1 adds PCI passthrough 4472 if (hardwareMachine.pciAttachments.size()) 4473 m->sv = SettingsVersion_v1_12; 4474 } 4475 4420 4476 if (m->sv < SettingsVersion_v1_11) 4421 4477 { -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r35856 r35885 143 143 } 144 144 } 145 145 146 146 /* bail out */ 147 147 LogFlow(("ModuleTerm: returns %Rrc\n", rc)); … … 192 192 PGMR0DynMapTerm(); 193 193 #endif 194 194 195 195 #ifdef VBOX_WITH_PCI_PASSTHROUGH 196 196 /*
Note:
See TracChangeset
for help on using the changeset viewer.