Changeset 25194 in vbox
- Timestamp:
- Dec 4, 2009 3:59:34 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 55674
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r25184 r25194 8248 8248 * unsaved. 8249 8249 */ 8250 void Machine::copyFrom 8250 void Machine::copyFrom(Machine *aThat) 8251 8251 { 8252 8252 AssertReturnVoid (mType == IsMachine || mType == IsSessionMachine); … … 8270 8270 } 8271 8271 8272 mBIOSSettings->copyFrom 8272 mBIOSSettings->copyFrom(aThat->mBIOSSettings); 8273 8273 #ifdef VBOX_WITH_VRDP 8274 mVRDPServer->copyFrom 8274 mVRDPServer->copyFrom(aThat->mVRDPServer); 8275 8275 #endif 8276 mAudioAdapter->copyFrom 8277 mUSBController->copyFrom 8276 mAudioAdapter->copyFrom(aThat->mAudioAdapter); 8277 mUSBController->copyFrom(aThat->mUSBController); 8278 8278 8279 8279 /* create private copies of all controllers */ … … 8535 8535 /* create another USB controller object that will be mutable */ 8536 8536 unconst(mUSBController).createObject(); 8537 mUSBController->init 8537 mUSBController->init(this, aMachine->mUSBController); 8538 8538 8539 8539 /* create a list of network adapters that will be mutable */ 8540 for (ULONG slot = 0; slot < RT_ELEMENTS (mNetworkAdapters); slot++)8540 for (ULONG slot = 0; slot < RT_ELEMENTS(mNetworkAdapters); slot++) 8541 8541 { 8542 8542 unconst(mNetworkAdapters [slot]).createObject(); 8543 mNetworkAdapters 8543 mNetworkAdapters[slot]->init (this, aMachine->mNetworkAdapters [slot]); 8544 8544 } 8545 8545 -
trunk/src/VBox/Main/SnapshotImpl.cpp
r25152 r25194 884 884 885 885 unconst(mUSBController).createObject(); 886 mUSBController->init Copy(this, mPeer->mUSBController);887 888 for (ULONG slot = 0; slot < RT_ELEMENTS (mNetworkAdapters); slot 889 { 890 unconst(mNetworkAdapters 891 mNetworkAdapters 892 } 893 894 for (ULONG slot = 0; slot < RT_ELEMENTS (mSerialPorts); slot 886 mUSBController->init(this, mPeer->mUSBController); 887 888 for (ULONG slot = 0; slot < RT_ELEMENTS (mNetworkAdapters); slot++) 889 { 890 unconst(mNetworkAdapters[slot]).createObject(); 891 mNetworkAdapters[slot]->initCopy (this, mPeer->mNetworkAdapters [slot]); 892 } 893 894 for (ULONG slot = 0; slot < RT_ELEMENTS (mSerialPorts); slot++) 895 895 { 896 896 unconst(mSerialPorts [slot]).createObject(); 897 mSerialPorts [slot]->initCopy (this, mPeer->mSerialPorts[slot]);898 } 899 900 for (ULONG slot = 0; slot < RT_ELEMENTS (mParallelPorts); slot 901 { 902 unconst(mParallelPorts 903 mParallelPorts [slot]->initCopy (this, mPeer->mParallelPorts[slot]);897 mSerialPorts[slot]->initCopy (this, mPeer->mSerialPorts[slot]); 898 } 899 900 for (ULONG slot = 0; slot < RT_ELEMENTS (mParallelPorts); slot++) 901 { 902 unconst(mParallelPorts[slot]).createObject(); 903 mParallelPorts[slot]->initCopy (this, mPeer->mParallelPorts[slot]); 904 904 } 905 905 -
trunk/src/VBox/Main/USBControllerImpl.cpp
r25149 r25194 40 40 41 41 #include <algorithm> 42 #include "objectslist.h" 42 43 43 44 // defines 44 45 ///////////////////////////////////////////////////////////////////////////// 45 46 47 typedef std::list< ComObjPtr<USBDeviceFilter> > DeviceFilterList; 48 49 struct USBController::Data 50 { 51 struct BackupableData 52 { 53 /* Constructor. */ 54 BackupableData() 55 : fEnabled(false), 56 fEnabledEHCI(false) 57 { } 58 59 bool operator==(const BackupableData &that) const 60 { 61 return this == &that || (fEnabled == that.fEnabled && fEnabledEHCI == that.fEnabledEHCI); 62 } 63 64 bool fEnabled; 65 bool fEnabledEHCI; 66 }; 67 68 /** Parent object. */ 69 const ComObjPtr<Machine, ComWeakRef> pParent; 70 /** Peer object. */ 71 const ComObjPtr<USBController> pPeer; 72 73 Backupable<BackupableData> bd; 74 #ifdef VBOX_WITH_USB 75 // the following fields need special backup/rollback/commit handling, 76 // so they cannot be a part of BackupableData 77 Backupable<DeviceFilterList> llDeviceFilters; 78 #endif 79 }; 80 81 82 46 83 // constructor / destructor 47 84 ///////////////////////////////////////////////////////////////////////////// … … 68 105 * @param aParent Pointer to our parent object. 69 106 */ 70 HRESULT USBController::init 107 HRESULT USBController::init(Machine *aParent) 71 108 { 72 109 LogFlowThisFunc(("aParent=%p\n", aParent)); … … 78 115 AssertReturn(autoInitSpan.isOk(), E_FAIL); 79 116 80 unconst(mParent) = aParent; 117 m = new Data(); 118 119 unconst(m->pParent) = aParent; 81 120 /* mPeer is left null */ 82 121 83 m Data.allocate();84 #ifdef VBOX_WITH_USB 85 m DeviceFilters.allocate();122 m->bd.allocate(); 123 #ifdef VBOX_WITH_USB 124 m->llDeviceFilters.allocate(); 86 125 #endif 87 126 … … 104 143 * it shares data with is destroyed. 105 144 */ 106 HRESULT USBController::init 145 HRESULT USBController::init(Machine *aParent, USBController *aPeer) 107 146 { 108 147 LogFlowThisFunc(("aParent=%p, aPeer=%p\n", aParent, aPeer)); … … 114 153 AssertReturn(autoInitSpan.isOk(), E_FAIL); 115 154 116 unconst(mParent) = aParent; 117 unconst(mPeer) = aPeer; 118 119 AutoWriteLock thatlock (aPeer); 120 mData.share (aPeer->mData); 155 m = new Data(); 156 157 unconst(m->pParent) = aParent; 158 unconst(m->pPeer) = aPeer; 159 160 AutoWriteLock thatlock(aPeer); 161 m->bd.share(aPeer->m->bd); 121 162 122 163 #ifdef VBOX_WITH_USB 123 164 /* create copies of all filters */ 124 m DeviceFilters.allocate();125 DeviceFilterList::const_iterator it = aPeer->m DeviceFilters->begin();126 while (it != aPeer->m DeviceFilters->end())165 m->llDeviceFilters.allocate(); 166 DeviceFilterList::const_iterator it = aPeer->m->llDeviceFilters->begin(); 167 while (it != aPeer->m->llDeviceFilters->end()) 127 168 { 128 169 ComObjPtr<USBDeviceFilter> filter; 129 170 filter.createObject(); 130 171 filter->init (this, *it); 131 m DeviceFilters->push_back(filter);172 m->llDeviceFilters->push_back(filter); 132 173 ++ it; 133 174 } … … 146 187 * of the original object passed as an argument. 147 188 */ 148 HRESULT USBController::initCopy 189 HRESULT USBController::initCopy(Machine *aParent, USBController *aPeer) 149 190 { 150 191 LogFlowThisFunc(("aParent=%p, aPeer=%p\n", aParent, aPeer)); … … 156 197 AssertReturn(autoInitSpan.isOk(), E_FAIL); 157 198 158 unconst(mParent) = aParent; 199 m = new Data(); 200 201 unconst(m->pParent) = aParent; 159 202 /* mPeer is left null */ 160 203 161 204 AutoWriteLock thatlock (aPeer); 162 m Data.attachCopy (aPeer->mData);205 m->bd.attachCopy(aPeer->m->bd); 163 206 164 207 #ifdef VBOX_WITH_USB 165 208 /* create private copies of all filters */ 166 m DeviceFilters.allocate();167 DeviceFilterList::const_iterator it = aPeer->m DeviceFilters->begin();168 while (it != aPeer->m DeviceFilters->end())209 m->llDeviceFilters.allocate(); 210 DeviceFilterList::const_iterator it = aPeer->m->llDeviceFilters->begin(); 211 while (it != aPeer->m->llDeviceFilters->end()) 169 212 { 170 213 ComObjPtr<USBDeviceFilter> filter; 171 214 filter.createObject(); 172 filter->initCopy 173 m DeviceFilters->push_back(filter);215 filter->initCopy(this, *it); 216 m->llDeviceFilters->push_back(filter); 174 217 ++ it; 175 218 } … … 196 239 return; 197 240 198 /* uninit all filters (including those still referenced by clients) */ 199 uninitDependentChildren(); 200 201 #ifdef VBOX_WITH_USB 202 mDeviceFilters.free(); 241 #ifdef VBOX_WITH_USB 242 // uninit all device filters on the list (it's a standard std::list not an ObjectsList 243 // so we must uninit() manually) 244 for (DeviceFilterList::iterator it = m->llDeviceFilters->begin(); 245 it != m->llDeviceFilters->end(); 246 ++it) 247 (*it)->uninit(); 248 249 m->llDeviceFilters.free(); 203 250 #endif 204 mData.free(); 205 206 unconst(mPeer).setNull(); 207 unconst(mParent).setNull(); 251 m->bd.free(); 252 253 unconst(m->pPeer).setNull(); 254 unconst(m->pParent).setNull(); 255 256 delete m; 257 m = NULL; 208 258 } 209 259 … … 221 271 AutoReadLock alock(this); 222 272 223 *aEnabled = m Data->mEnabled;273 *aEnabled = m->bd->fEnabled; 224 274 225 275 return S_OK; … … 235 285 236 286 /* the machine needs to be mutable */ 237 Machine::AutoMutableStateDependency adep(m Parent);287 Machine::AutoMutableStateDependency adep(m->pParent); 238 288 if (FAILED(adep.rc())) return adep.rc(); 239 289 240 290 AutoWriteLock alock(this); 241 291 242 if (m Data->mEnabled != aEnabled)243 { 244 m Data.backup();245 m Data->mEnabled = aEnabled;292 if (m->bd->fEnabled != aEnabled) 293 { 294 m->bd.backup(); 295 m->bd->fEnabled = aEnabled; 246 296 247 297 /* leave the lock for safety */ 248 298 alock.leave(); 249 299 250 m Parent->onUSBControllerChange();300 m->pParent->onUSBControllerChange(); 251 301 } 252 302 … … 263 313 AutoReadLock alock(this); 264 314 265 *aEnabled = m Data->mEnabledEhci;315 *aEnabled = m->bd->fEnabledEHCI; 266 316 267 317 return S_OK; … … 276 326 277 327 /* the machine needs to be mutable */ 278 Machine::AutoMutableStateDependency adep(m Parent);328 Machine::AutoMutableStateDependency adep(m->pParent); 279 329 if (FAILED(adep.rc())) return adep.rc(); 280 330 281 331 AutoWriteLock alock(this); 282 332 283 if (m Data->mEnabledEhci!= aEnabled)284 { 285 m Data.backup();286 m Data->mEnabledEhci= aEnabled;333 if (m->bd->fEnabledEHCI != aEnabled) 334 { 335 m->bd.backup(); 336 m->bd->fEnabledEHCI = aEnabled; 287 337 288 338 /* leave the lock for safety */ 289 339 alock.leave(); 290 340 291 m Parent->onUSBControllerChange();341 m->pParent->onUSBControllerChange(); 292 342 } 293 343 … … 368 418 AutoReadLock alock(this); 369 419 370 SafeIfaceArray<IUSBDeviceFilter> collection (*m DeviceFilters.data());420 SafeIfaceArray<IUSBDeviceFilter> collection (*m->llDeviceFilters.data()); 371 421 collection.detachTo(ComSafeArrayOutArg(aDevicesFilters)); 372 422 … … 396 446 397 447 /* the machine needs to be mutable */ 398 Machine::AutoMutableStateDependency adep(m Parent);448 Machine::AutoMutableStateDependency adep(m->pParent); 399 449 if (FAILED(adep.rc())) return adep.rc(); 400 450 … … 427 477 428 478 /* the machine needs to be mutable */ 429 Machine::AutoMutableStateDependency adep(m Parent);479 Machine::AutoMutableStateDependency adep(m->pParent); 430 480 if (FAILED(adep.rc())) return adep.rc(); 431 481 432 482 AutoWriteLock alock(this); 433 483 434 ComObjPtr<USBDeviceFilter> filter = getDependentChild (aFilter); 435 if (!filter) 436 return setError (E_INVALIDARG, 437 tr ("The given USB device filter is not created within " 438 "this VirtualBox instance")); 484 ComObjPtr<USBDeviceFilter> filter = static_cast<USBDeviceFilter*>(aFilter); 485 // @todo r=dj make sure the input object is actually from us 486 // ComObjPtr<USBDeviceFilter> filter = getDependentChild(aFilter); 487 // if (!filter) 488 // return setError (E_INVALIDARG, 489 // tr ("The given USB device filter is not created within " 490 // "this VirtualBox instance")); 439 491 440 492 if (filter->mInList) … … 443 495 444 496 /* backup the list before modification */ 445 m DeviceFilters.backup();497 m->llDeviceFilters.backup(); 446 498 447 499 /* iterate to the position... */ 448 500 DeviceFilterList::iterator it; 449 if (aPosition < m DeviceFilters->size())450 { 451 it = m DeviceFilters->begin();501 if (aPosition < m->llDeviceFilters->size()) 502 { 503 it = m->llDeviceFilters->begin(); 452 504 std::advance (it, aPosition); 453 505 } 454 506 else 455 it = m DeviceFilters->end();507 it = m->llDeviceFilters->end(); 456 508 /* ...and insert */ 457 m DeviceFilters->insert (it, filter);509 m->llDeviceFilters->insert (it, filter); 458 510 filter->mInList = true; 459 511 … … 461 513 if (filter->getData().mActive && Global::IsOnline(adep.machineState())) 462 514 { 463 USBProxyService *service = m Parent->getVirtualBox()->host()->usbProxyService();515 USBProxyService *service = m->pParent->getVirtualBox()->host()->usbProxyService(); 464 516 ComAssertRet (service, E_FAIL); 465 517 … … 479 531 } 480 532 481 STDMETHODIMP USBController::RemoveDeviceFilter 482 533 STDMETHODIMP USBController::RemoveDeviceFilter(ULONG aPosition, 534 IUSBDeviceFilter **aFilter) 483 535 { 484 536 #ifdef VBOX_WITH_USB … … 490 542 491 543 /* the machine needs to be mutable */ 492 Machine::AutoMutableStateDependency adep(m Parent);544 Machine::AutoMutableStateDependency adep(m->pParent); 493 545 if (FAILED(adep.rc())) return adep.rc(); 494 546 495 547 AutoWriteLock alock(this); 496 548 497 if (!m DeviceFilters->size())549 if (!m->llDeviceFilters->size()) 498 550 return setError (E_INVALIDARG, 499 551 tr ("The USB device filter list is empty")); 500 552 501 if (aPosition >= m DeviceFilters->size())553 if (aPosition >= m->llDeviceFilters->size()) 502 554 return setError (E_INVALIDARG, 503 555 tr ("Invalid position: %lu (must be in range [0, %lu])"), 504 aPosition, m DeviceFilters->size() - 1);556 aPosition, m->llDeviceFilters->size() - 1); 505 557 506 558 /* backup the list before modification */ 507 m DeviceFilters.backup();559 m->llDeviceFilters.backup(); 508 560 509 561 ComObjPtr<USBDeviceFilter> filter; 510 562 { 511 563 /* iterate to the position... */ 512 DeviceFilterList::iterator it = m DeviceFilters->begin();564 DeviceFilterList::iterator it = m->llDeviceFilters->begin(); 513 565 std::advance (it, aPosition); 514 566 /* ...get an element from there... */ … … 516 568 /* ...and remove */ 517 569 filter->mInList = false; 518 m DeviceFilters->erase (it);570 m->llDeviceFilters->erase (it); 519 571 } 520 572 … … 527 579 if (filter->getData().mActive && Global::IsOnline(adep.machineState())) 528 580 { 529 USBProxyService *service = m Parent->getVirtualBox()->host()->usbProxyService();581 USBProxyService *service = m->pParent->getVirtualBox()->host()->usbProxyService(); 530 582 ComAssertRet (service, E_FAIL); 531 583 … … 575 627 * default to B. */ 576 628 577 m Data->mEnabled = data.fEnabled;578 m Data->mEnabledEhci= data.fEnabledEHCI;629 m->bd->fEnabled = data.fEnabled; 630 m->bd->fEnabledEHCI = data.fEnabledEHCI; 579 631 580 632 #ifdef VBOX_WITH_USB … … 590 642 if (FAILED(rc)) return rc; 591 643 592 m DeviceFilters->push_back(pFilter);644 m->llDeviceFilters->push_back(pFilter); 593 645 pFilter->mInList = true; 594 646 } … … 612 664 AutoReadLock alock(this); 613 665 614 data.fEnabled = !!m Data->mEnabled;615 data.fEnabledEHCI = !!m Data->mEnabledEhci;666 data.fEnabled = !!m->bd->fEnabled; 667 data.fEnabledEHCI = !!m->bd->fEnabledEHCI; 616 668 617 669 #ifdef VBOX_WITH_USB 618 670 data.llDeviceFilters.clear(); 619 671 620 for (DeviceFilterList::const_iterator it = m DeviceFilters->begin();621 it != m DeviceFilters->end();672 for (DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 673 it != m->llDeviceFilters->end(); 622 674 ++it) 623 675 { … … 662 714 AutoReadLock alock(this); 663 715 664 if (m Data.isBackedUp()665 #ifdef VBOX_WITH_USB 666 || m DeviceFilters.isBackedUp()716 if (m->bd.isBackedUp() 717 #ifdef VBOX_WITH_USB 718 || m->llDeviceFilters.isBackedUp() 667 719 #endif 668 720 ) … … 672 724 /* see whether any of filters has changed its data */ 673 725 for (DeviceFilterList::const_iterator 674 it = m DeviceFilters->begin();675 it != m DeviceFilters->end();726 it = m->llDeviceFilters->begin(); 727 it != m->llDeviceFilters->end(); 676 728 ++ it) 677 729 { … … 692 744 AutoReadLock alock(this); 693 745 694 if (m Data.hasActualChanges())746 if (m->bd.hasActualChanges()) 695 747 return true; 696 748 697 749 #ifdef VBOX_WITH_USB 698 if (!m DeviceFilters.isBackedUp())750 if (!m->llDeviceFilters.isBackedUp()) 699 751 { 700 752 /* see whether any of filters has changed its data */ 701 753 for (DeviceFilterList::const_iterator 702 it = m DeviceFilters->begin();703 it != m DeviceFilters->end();754 it = m->llDeviceFilters->begin(); 755 it != m->llDeviceFilters->end(); 704 756 ++ it) 705 757 { … … 711 763 } 712 764 713 if (m DeviceFilters->size() != mDeviceFilters.backedUpData()->size())765 if (m->llDeviceFilters->size() != m->llDeviceFilters.backedUpData()->size()) 714 766 return true; 715 767 716 if (m DeviceFilters->size() == 0)768 if (m->llDeviceFilters->size() == 0) 717 769 return false; 718 770 719 771 /* Make copies to speed up comparison */ 720 DeviceFilterList devices = *m DeviceFilters.data();721 DeviceFilterList backDevices = *m DeviceFilters.backedUpData();772 DeviceFilterList devices = *m->llDeviceFilters.data(); 773 DeviceFilterList backDevices = *m->llDeviceFilters.backedUpData(); 722 774 723 775 DeviceFilterList::iterator it = devices.begin(); … … 756 808 757 809 /* we need the machine state */ 758 Machine::AutoAnyStateDependency adep (mParent);810 Machine::AutoAnyStateDependency adep(m->pParent); 759 811 AssertComRCReturn (adep.rc(), false); 760 812 … … 763 815 bool dataChanged = false; 764 816 765 if (m Data.isBackedUp())817 if (m->bd.isBackedUp()) 766 818 { 767 819 /* we need to check all data to see whether anything will be changed 768 820 * after rollback */ 769 dataChanged = m Data.hasActualChanges();770 m Data.rollback();771 } 772 773 #ifdef VBOX_WITH_USB 774 775 if (m DeviceFilters.isBackedUp())776 { 777 USBProxyService *service = m Parent->getVirtualBox()->host()->usbProxyService();821 dataChanged = m->bd.hasActualChanges(); 822 m->bd.rollback(); 823 } 824 825 #ifdef VBOX_WITH_USB 826 827 if (m->llDeviceFilters.isBackedUp()) 828 { 829 USBProxyService *service = m->pParent->getVirtualBox()->host()->usbProxyService(); 778 830 ComAssertRet (service, false); 779 831 780 832 /* uninitialize all new filters (absent in the backed up list) */ 781 DeviceFilterList::const_iterator it = m DeviceFilters->begin();782 DeviceFilterList *backedList = m DeviceFilters.backedUpData();783 while (it != m DeviceFilters->end())833 DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 834 DeviceFilterList *backedList = m->llDeviceFilters.backedUpData(); 835 while (it != m->llDeviceFilters->end()) 784 836 { 785 837 if (std::find (backedList->begin(), backedList->end(), *it) == … … 808 860 while (it != backedList->end()) 809 861 { 810 if (std::find (m DeviceFilters->begin(), mDeviceFilters->end(), *it) ==811 m DeviceFilters->end())862 if (std::find (m->llDeviceFilters->begin(), m->llDeviceFilters->end(), *it) == 863 m->llDeviceFilters->end()) 812 864 { 813 865 /* notify the proxy (only when necessary) */ … … 824 876 825 877 /* restore the list */ 826 m DeviceFilters.rollback();878 m->llDeviceFilters.rollback(); 827 879 } 828 880 … … 831 883 832 884 /* rollback any changes to filters after restoring the list */ 833 DeviceFilterList::const_iterator it = m DeviceFilters->begin();834 while (it != m DeviceFilters->end())885 DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 886 while (it != m->llDeviceFilters->end()) 835 887 { 836 888 if ((*it)->isModified()) … … 859 911 860 912 /* sanity too */ 861 AutoCaller peerCaller (mPeer);913 AutoCaller peerCaller(m->pPeer); 862 914 AssertComRCReturnVoid (peerCaller.rc()); 863 915 864 916 /* lock both for writing since we modify both (mPeer is "master" so locked 865 917 * first) */ 866 AutoMultiWriteLock2 alock (m Peer, this);867 868 if (m Data.isBackedUp())869 { 870 m Data.commit();871 if (m Peer)918 AutoMultiWriteLock2 alock (m->pPeer, this); 919 920 if (m->bd.isBackedUp()) 921 { 922 m->bd.commit(); 923 if (m->pPeer) 872 924 { 873 925 /* attach new data to the peer and reshare it */ 874 AutoWriteLock peerlock (mPeer);875 m Peer->mData.attach (mData);926 AutoWriteLock peerlock(m->pPeer); 927 m->pPeer->m->bd.attach(m->bd); 876 928 } 877 929 } … … 880 932 bool commitFilters = false; 881 933 882 if (m DeviceFilters.isBackedUp())883 { 884 m DeviceFilters.commit();934 if (m->llDeviceFilters.isBackedUp()) 935 { 936 m->llDeviceFilters.commit(); 885 937 886 938 /* apply changes to peer */ 887 if (m Peer)939 if (m->pPeer) 888 940 { 889 AutoWriteLock peerlock (mPeer);941 AutoWriteLock peerlock(m->pPeer); 890 942 891 943 /* commit all changes to new filters (this will reshare data with 892 944 * peers for those who have peers) */ 893 945 DeviceFilterList *newList = new DeviceFilterList(); 894 DeviceFilterList::const_iterator it = m DeviceFilters->begin();895 while (it != m DeviceFilters->end())946 DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 947 while (it != m->llDeviceFilters->end()) 896 948 { 897 949 (*it)->commit(); … … 904 956 * create a peer owning data this filter share it with */ 905 957 peer.createObject(); 906 peer->init (mPeer, *it, true /* aReshare */);958 peer->init(m->pPeer, *it, true /* aReshare */); 907 959 } 908 960 else 909 961 { 910 962 /* remove peer from the old list */ 911 m Peer->mDeviceFilters->remove(peer);963 m->pPeer->m->llDeviceFilters->remove(peer); 912 964 } 913 965 /* and add it to the new list */ … … 918 970 919 971 /* uninit old peer's filters that are left */ 920 it = m Peer->mDeviceFilters->begin();921 while (it != m Peer->mDeviceFilters->end())972 it = m->pPeer->m->llDeviceFilters->begin(); 973 while (it != m->pPeer->m->llDeviceFilters->end()) 922 974 { 923 975 (*it)->uninit(); … … 926 978 927 979 /* attach new list of filters to our peer */ 928 m Peer->mDeviceFilters.attach(newList);980 m->pPeer->m->llDeviceFilters.attach(newList); 929 981 } 930 982 else … … 944 996 if (commitFilters) 945 997 { 946 DeviceFilterList::const_iterator it = m DeviceFilters->begin();947 while (it != m DeviceFilters->end())998 DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 999 while (it != m->llDeviceFilters->end()) 948 1000 { 949 1001 (*it)->commit(); … … 971 1023 972 1024 /* even more sanity */ 973 Machine::AutoAnyStateDependency adep (mParent);1025 Machine::AutoAnyStateDependency adep(m->pParent); 974 1026 AssertComRCReturnVoid (adep.rc()); 975 1027 /* Machine::copyFrom() may not be called when the VM is running */ … … 981 1033 982 1034 /* this will back up current data */ 983 m Data.assignCopy (aThat->mData);1035 m->bd.assignCopy(aThat->m->bd); 984 1036 985 1037 #ifdef VBOX_WITH_USB … … 989 1041 990 1042 /* create private copies of all filters */ 991 m DeviceFilters.backup();992 m DeviceFilters->clear();993 for (DeviceFilterList::const_iterator it = aThat->m DeviceFilters->begin();994 it != aThat->m DeviceFilters->end();1043 m->llDeviceFilters.backup(); 1044 m->llDeviceFilters->clear(); 1045 for (DeviceFilterList::const_iterator it = aThat->m->llDeviceFilters->begin(); 1046 it != aThat->m->llDeviceFilters->end(); 995 1047 ++ it) 996 1048 { … … 998 1050 filter.createObject(); 999 1051 filter->initCopy (this, *it); 1000 m DeviceFilters->push_back (filter);1052 m->llDeviceFilters->push_back (filter); 1001 1053 } 1002 1054 … … 1018 1070 1019 1071 /* we need the machine state */ 1020 Machine::AutoAnyStateDependency adep (mParent);1072 Machine::AutoAnyStateDependency adep(m->pParent); 1021 1073 AssertComRCReturnRC(adep.rc()); 1022 1074 … … 1027 1079 /* we don't modify our data fields -- no need to lock */ 1028 1080 1029 if (aFilter->mInList && m Parent->isRegistered())1030 { 1031 USBProxyService *service = m Parent->getVirtualBox()->host()->usbProxyService();1081 if (aFilter->mInList && m->pParent->isRegistered()) 1082 { 1083 USBProxyService *service = m->pParent->getVirtualBox()->host()->usbProxyService(); 1032 1084 ComAssertRet (service, E_FAIL); 1033 1085 … … 1078 1130 1079 1131 /* Disabled USB controllers cannot actually work with USB devices */ 1080 if (!m Data->mEnabled)1132 if (!m->bd->fEnabled) 1081 1133 return false; 1082 1134 1083 1135 /* apply self filters */ 1084 for (DeviceFilterList::const_iterator it = m DeviceFilters->begin();1085 it != m DeviceFilters->end();1136 for (DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 1137 it != m->llDeviceFilters->end(); 1086 1138 ++ it) 1087 1139 { … … 1119 1171 1120 1172 /* Disabled USB controllers cannot actually work with USB devices */ 1121 if (!m Data->mEnabled)1173 if (!m->bd->fEnabled) 1122 1174 return false; 1123 1175 … … 1179 1231 1180 1232 /* apply self filters */ 1181 for (DeviceFilterList::const_iterator it = m DeviceFilters->begin();1182 it != m DeviceFilters->end();1233 for (DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 1234 it != m->llDeviceFilters->end(); 1183 1235 ++ it) 1184 1236 { … … 1221 1273 AutoReadLock alock(this); 1222 1274 1223 USBProxyService *service = m Parent->getVirtualBox()->host()->usbProxyService();1275 USBProxyService *service = m->pParent->getVirtualBox()->host()->usbProxyService(); 1224 1276 AssertReturn(service, E_FAIL); 1225 1277 1226 DeviceFilterList::const_iterator it = m DeviceFilters->begin();1227 while (it != m DeviceFilters->end())1278 DeviceFilterList::const_iterator it = m->llDeviceFilters->begin(); 1279 while (it != m->llDeviceFilters->end()) 1228 1280 { 1229 1281 USBDeviceFilter *flt = *it; /* resolve ambiguity (for ComPtr below) */ … … 1255 1307 } 1256 1308 1309 Machine* USBController::getMachine() 1310 { 1311 return m->pParent; 1312 } 1313 1257 1314 #endif /* VBOX_WITH_USB */ 1258 1315 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r25184 r25194 139 139 //////////////////////////////////////////////////////////////////////////////// 140 140 // 141 // VirtualBox data definition141 // VirtualBox private member data definition 142 142 // 143 143 //////////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Main/include/USBControllerImpl.h
r24989 r25194 48 48 49 49 class ATL_NO_VTABLE USBController : 50 public VirtualBoxBase WithChildrenNEXT,50 public VirtualBoxBase, 51 51 public VirtualBoxSupportErrorInfoImpl<USBController, IUSBController>, 52 52 public VirtualBoxSupportTranslation<USBController>, 53 53 VBOX_SCRIPTABLE_IMPL(IUSBController) 54 54 { 55 private:56 57 struct Data58 {59 /* Constructor. */60 Data() : mEnabled (FALSE), mEnabledEhci (FALSE) { }61 62 bool operator== (const Data &that) const63 {64 return this == &that || (mEnabled == that.mEnabled && mEnabledEhci == that.mEnabledEhci);65 }66 67 /** Enabled indicator. */68 BOOL mEnabled;69 70 /** Enabled indicator for EHCI. */71 BOOL mEnabledEhci;72 };73 74 55 public: 75 76 56 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController) 77 57 … … 133 113 // public methods for internal purposes only 134 114 // (ensure there is a caller and a read lock before calling them!) 135 136 /** @note this doesn't require a read lock since mParent is constant. */ 137 const ComObjPtr<Machine, ComWeakRef> &parent() { return mParent; }; 138 139 const Backupable<Data>& getData() { return mData; } 115 Machine* getMachine(); 140 116 141 117 // for VirtualBoxSupportErrorInfoImpl … … 144 120 private: 145 121 146 #ifdef VBOX_WITH_USB147 /** specialization for IUSBDeviceFilter */148 ComObjPtr<USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)149 {150 VirtualBoxBase *child = VirtualBoxBaseWithChildrenNEXT::151 getDependentChild (ComPtr<IUnknown> (aFilter));152 return child ? static_cast <USBDeviceFilter *> (child)153 : NULL;154 }155 #endif /* VBOX_WITH_USB */156 157 122 void printList(); 158 123 159 /** Parent object. */ 160 const ComObjPtr<Machine, ComWeakRef> mParent; 161 /** Peer object. */ 162 const ComObjPtr<USBController> mPeer; 163 /** Data. */ 164 Backupable<Data> mData; 165 166 #ifdef VBOX_WITH_USB 167 // the following fields need special backup/rollback/commit handling, 168 // so they cannot be a part of Data 169 170 typedef std::list <ComObjPtr<USBDeviceFilter> > DeviceFilterList; 171 Backupable <DeviceFilterList> mDeviceFilters; 172 #endif /* VBOX_WITH_USB */ 124 struct Data; 125 Data *m; 173 126 }; 174 127 -
trunk/src/VBox/Main/include/objectslist.h
r25184 r25194 67 67 } 68 68 69 private: 70 // prohibit copying and assignment 71 ObjectsList(const ObjectsList &d); 72 ObjectsList& operator=(const ObjectsList &d); 73 74 public: 75 69 76 /** 70 77 * Returns the lock handle which protects this list, for use with … … 113 120 m_ll.push_back(*it); 114 121 } 115 }116 117 /**118 * Returns the no. of objects on the list (std::list compatibility)119 * with locking.120 */121 size_t size()122 {123 AutoReadLock al(m_lock);124 return m_ll.size();125 }126 127 /**128 * Returns the first object on the list (std::list compatibility)129 * with locking.130 */131 MyType front()132 {133 AutoReadLock al(m_lock);134 return m_ll.front();135 }136 137 /**138 * Returns a raw pointer to the member list of objects.139 * Does not lock!140 * @return141 */142 MyList& getList()143 {144 return m_ll;145 }146 147 /**148 * Returns the begin iterator from the list (std::list compatibility).149 * Does not lock!150 * @return151 */152 iterator begin()153 {154 return m_ll.begin();155 }156 157 /**158 * Returns the end iterator from the list (std::list compatibility).159 * Does not lock!160 */161 iterator end()162 {163 return m_ll.end();164 122 } 165 123 … … 181 139 } 182 140 141 /** 142 * Returns the no. of objects on the list (std::list compatibility) 143 * with locking. 144 */ 145 size_t size() 146 { 147 AutoReadLock al(m_lock); 148 return m_ll.size(); 149 } 150 151 /** 152 * Returns a raw pointer to the member list of objects. 153 * Does not lock! 154 * @return 155 */ 156 MyList& getList() 157 { 158 return m_ll; 159 } 160 161 /** 162 * Returns the first object on the list (std::list compatibility) 163 * with locking. 164 */ 165 MyType front() 166 { 167 AutoReadLock al(m_lock); 168 return m_ll.front(); 169 } 170 171 /** 172 * Returns the begin iterator from the list (std::list compatibility). 173 * Does not lock! 174 * @return 175 */ 176 iterator begin() 177 { 178 return m_ll.begin(); 179 } 180 181 /** 182 * Returns the end iterator from the list (std::list compatibility). 183 * Does not lock! 184 */ 185 iterator end() 186 { 187 return m_ll.end(); 188 } 189 190 void insert(iterator it, MyType &p) 191 { 192 m_ll.insert(it, p); 193 } 194 195 void erase(iterator it) 196 { 197 m_ll.erase(it); 198 } 199 183 200 private: 184 201 MyList m_ll;
Note:
See TracChangeset
for help on using the changeset viewer.