Changeset 35357 in vbox for trunk/src/VBox/Main/MachineImpl.cpp
- Timestamp:
- Dec 27, 2010 10:38:34 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69217
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r35346 r35357 50 50 #include "DisplayUtils.h" 51 51 #include "BandwidthControlImpl.h" 52 #include "VBoxEvents.h" 52 53 53 54 #ifdef VBOX_WITH_USB … … 5810 5811 } 5811 5812 5812 5813 STDMETHODIMP Machine::AttachHostPciDevice(LONG hostAddress, LONG desiredGuestAddress, IEventContext * /*eventContext*/, BOOL /*tryToUnbind*/) 5814 { 5815 AutoCaller autoCaller(this); 5816 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 5817 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5818 5819 ComObjPtr<PciDeviceAttachment> pda; 5820 char name[32]; 5821 5822 pda.createObject(); 5823 RTStrPrintf(name, sizeof(name), "host%02x:%02x.%x", (hostAddress>>8) & 0xff, (hostAddress & 0xf8) >> 3, hostAddress & 7); 5824 Bstr bname(name); 5825 pda.createObject(); 5826 pda->init(this, bname, hostAddress, desiredGuestAddress, TRUE); 5827 5828 mPciDeviceAssignments.push_back(pda); 5829 return S_OK; 5830 } 5831 5832 STDMETHODIMP Machine::DetachHostPciDevice(LONG /*hostAddress*/) 5833 { 5834 AutoCaller autoCaller(this); 5835 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 5836 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5837 5838 return E_NOTIMPL; 5813 /** 5814 * Currently this method doesn't attach device to the running VM, 5815 * just makes sure it's plugged on next VM start. 5816 */ 5817 STDMETHODIMP Machine::AttachHostPciDevice(LONG hostAddress, LONG desiredGuestAddress, BOOL /*tryToUnbind*/) 5818 { 5819 AutoCaller autoCaller(this); 5820 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 5821 5822 // lock scope 5823 { 5824 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5825 5826 //HRESULT rc = checkStateDependency(MutableStateDep); 5827 //if (FAILED(rc)) return rc; 5828 5829 ComObjPtr<PciDeviceAttachment> pda; 5830 char name[32]; 5831 5832 RTStrPrintf(name, sizeof(name), "host%02x:%02x.%x", (hostAddress>>8) & 0xff, (hostAddress & 0xf8) >> 3, hostAddress & 7); 5833 Bstr bname(name); 5834 pda.createObject(); 5835 pda->init(this, bname, hostAddress, desiredGuestAddress, TRUE); 5836 setModified(IsModified_MachineData); 5837 mHWData.backup(); 5838 mHWData->mPciDeviceAssignments.push_back(pda); 5839 } 5840 5841 // do we need it? 5842 //saveSettings(NULL); 5843 mHWData.commit(); 5844 5845 return S_OK; 5846 } 5847 5848 /** 5849 * Currently this method doesn't detach device from the running VM, 5850 * just makes sure it's not plugged on next VM start. 5851 */ 5852 STDMETHODIMP Machine::DetachHostPciDevice(LONG hostAddress) 5853 { 5854 AutoCaller autoCaller(this); 5855 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 5856 5857 ComObjPtr<PciDeviceAttachment> pAttach; 5858 bool fRemoved = false; 5859 HRESULT rc; 5860 5861 // lock scope 5862 { 5863 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5864 5865 rc = checkStateDependency(MutableStateDep); 5866 if (FAILED(rc)) return rc; 5867 5868 for (HWData::PciDeviceAssignmentList::iterator it = mHWData->mPciDeviceAssignments.begin(); 5869 it != mHWData->mPciDeviceAssignments.end(); 5870 ++it) 5871 { 5872 LONG iHostAddress = -1; 5873 pAttach = *it; 5874 pAttach->COMGETTER(HostAddress)(&iHostAddress); 5875 if (iHostAddress != -1 && iHostAddress == hostAddress) 5876 { 5877 setModified(IsModified_MachineData); 5878 mHWData.backup(); 5879 mHWData->mPciDeviceAssignments.remove(pAttach); 5880 fRemoved = true; 5881 break; 5882 } 5883 } 5884 // Indeed under lock? 5885 mHWData.commit(); 5886 5887 // do we need it? 5888 // saveSettings(NULL); 5889 } 5890 5891 5892 /* Fire event outside of the lock */ 5893 if (fRemoved) 5894 { 5895 Assert(!pAttach.isNull()); 5896 ComPtr<IEventSource> es; 5897 rc = mParent->COMGETTER(EventSource)(es.asOutParam()); 5898 Assert(SUCCEEDED(rc)); 5899 Bstr mid; 5900 rc = this->COMGETTER(Id)(mid.asOutParam()); 5901 Assert(SUCCEEDED(rc)); 5902 fireHostPciDevicePlugEvent(es, mid.raw(), false /* unplugged */, true /* success */, pAttach, NULL); 5903 } 5904 5905 return S_OK; 5839 5906 } 5840 5907 … … 5848 5915 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 5849 5916 5850 SafeIfaceArray<IPciDeviceAttachment> assignments(m PciDeviceAssignments);5917 SafeIfaceArray<IPciDeviceAttachment> assignments(mHWData->mPciDeviceAssignments); 5851 5918 assignments.detachTo(ComSafeArrayOutArg(aAssignments)); 5852 5919 … … 6462 6529 6463 6530 HRESULT rc = S_OK; 6464 6465 6531 // Ensure the settings are saved. If we are going to be registered and 6466 6532 // no config file exists yet, create it by calling saveSettings() too.
Note:
See TracChangeset
for help on using the changeset viewer.