Changeset 21961 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 4, 2009 2:59:48 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r21929 r21961 3272 3272 * @note Locks this object for writing. 3273 3273 */ 3274 HRESULT Console::onNetworkAdapterChange (INetworkAdapter *aNetworkAdapter )3274 HRESULT Console::onNetworkAdapterChange (INetworkAdapter *aNetworkAdapter, BOOL changeAdapter) 3275 3275 { 3276 3276 LogFlowThisFunc(("\n")); … … 3289 3289 CheckComRCReturnRC(autoVMCaller.rc()); 3290 3290 3291 #ifdef VBOX_DYNAMIC_NET_ATTACH3292 /* Get the current network attachment type */3293 HRESULT rc;3294 NetworkAttachmentType_T eAttachmentType;3295 Bstr eHostInterface;3296 Bstr eInternalNetwork;3297 3298 rc = aNetworkAdapter->COMGETTER (AttachmentType) (&eAttachmentType);3299 ComAssertComRCRetRC (rc);3300 rc = aNetworkAdapter->COMGETTER (HostInterface) (eHostInterface.asOutParam());3301 ComAssertComRCRetRC (rc);3302 rc = aNetworkAdapter->COMGETTER (InternalNetwork) (eInternalNetwork.asOutParam());3303 ComAssertComRCRetRC (rc);3304 #endif /* VBOX_DYNAMIC_NET_ATTACH */3305 3306 3291 /* Get the properties we need from the adapter */ 3307 3292 BOOL fCableConnected; 3308 #ifdef VBOX_DYNAMIC_NET_ATTACH3309 rc = aNetworkAdapter->COMGETTER(CableConnected) (&fCableConnected);3310 #else /* !VBOX_DYNAMIC_NET_ATTACH */3311 3293 HRESULT rc = aNetworkAdapter->COMGETTER(CableConnected) (&fCableConnected); 3312 #endif /* !VBOX_DYNAMIC_NET_ATTACH */3313 3294 AssertComRC(rc); 3314 3295 if (SUCCEEDED(rc)) … … 3358 3339 3359 3340 #ifdef VBOX_DYNAMIC_NET_ATTACH 3360 if ( VBOX_SUCCESS (vrc))3341 if ((VBOX_SUCCESS (vrc)) && (changeAdapter == TRUE)) 3361 3342 { 3362 3343 VMSTATE enmVMState = VMR3GetState (mpVM); 3363 if ( (enmVMState == VMSTATE_RUNNING) 3364 || (enmVMState == VMSTATE_SUSPENDED)) 3365 { 3366 bool changeAdaptor = false; 3367 3368 if ( !( (eAttachmentType == NetworkAttachmentType_Null) 3369 && (meAttachmentType[ulInstance] == NetworkAttachmentType_Null))) 3370 changeAdaptor = true; 3371 3372 /** @todo pritesh: Need to check for mNATNetwork as well here 3373 * when NAT is shifted to use IntNet, till then just compare 3374 * if the current and next attachment types are not same 3375 */ 3376 if ( !( (eAttachmentType == NetworkAttachmentType_NAT) 3377 && (meAttachmentType[ulInstance] == NetworkAttachmentType_NAT))) 3378 changeAdaptor = true; 3379 3380 if ( !( (eAttachmentType == NetworkAttachmentType_Bridged) 3381 && (meAttachmentType[ulInstance] == NetworkAttachmentType_Bridged) 3382 && (mHostInterface[ulInstance] == eHostInterface))) 3383 changeAdaptor = true; 3384 3385 if ( !( (eAttachmentType == NetworkAttachmentType_HostOnly) 3386 && (meAttachmentType[ulInstance] == NetworkAttachmentType_HostOnly) 3387 && (mHostInterface[ulInstance] == eHostInterface))) 3388 changeAdaptor = true; 3389 3390 if ( !( (eAttachmentType == NetworkAttachmentType_Internal) 3391 && (meAttachmentType[ulInstance] == NetworkAttachmentType_Internal) 3392 && (mInternalNetwork[ulInstance] == eInternalNetwork))) 3393 changeAdaptor = true; 3394 3395 if (changeAdaptor) 3396 rc = doNetworkAdapterChange(pszAdapterName, ulInstance, 0, aNetworkAdapter); 3397 } 3344 3345 if ((enmVMState == VMSTATE_RUNNING) || (enmVMState == VMSTATE_SUSPENDED)) 3346 rc = doNetworkAdapterChange(pszAdapterName, ulInstance, 0, aNetworkAdapter); 3398 3347 } 3399 3348 #endif /* VBOX_DYNAMIC_NET_ATTACH */ … … 7678 7627 */ 7679 7628 NetworkAttachmentType_T Console::meAttachmentType[] = {}; 7680 #ifdef VBOX_DYNAMIC_NET_ATTACH7681 Bstr Console::mHostInterface[];7682 Bstr Console::mInternalNetwork[];7683 Bstr Console::mNATNetwork[];7684 #endif7685 7629 7686 7630 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r21916 r21961 2216 2216 /* NAT uses its own DHCP implementation */ 2217 2217 //networkName = Bstr(psz); 2218 #ifdef VBOX_DYNAMIC_NET_ATTACH2219 mNATNetwork[uInstance] = str;2220 #endif2221 2218 } 2222 2219 … … 2574 2571 # error "Port me" 2575 2572 #endif 2576 #ifdef VBOX_DYNAMIC_NET_ATTACH2577 mHostInterface[uInstance] = HifName;2578 #endif2579 2573 break; 2580 2574 } … … 2609 2603 networkName = Bstr(psz); 2610 2604 trunkType = Bstr(TRUNKTYPE_WHATEVER); 2611 #ifdef VBOX_DYNAMIC_NET_ATTACH2612 mInternalNetwork[uInstance] = str;2613 #endif2614 2605 } 2615 2606 STR_FREE(); … … 2827 2818 hrc = hostInterface->EnableStaticIpConfigV6(tmpAddr, Utf8Str(tmpMask).toUInt32()); 2828 2819 #endif 2829 #ifdef VBOX_DYNAMIC_NET_ATTACH2830 mHostInterface[uInstance] = HifName;2831 #endif2832 2820 break; 2833 2821 } -
trunk/src/VBox/Main/MachineImpl.cpp
r21878 r21961 7857 7857 for (ULONG slot = 0; slot < RT_ELEMENTS (networkAdapters); slot ++) 7858 7858 if (networkAdapters [slot]) 7859 that->onNetworkAdapterChange (networkAdapters [slot] );7859 that->onNetworkAdapterChange (networkAdapters [slot], FALSE); 7860 7860 for (ULONG slot = 0; slot < RT_ELEMENTS (serialPorts); slot ++) 7861 7861 if (serialPorts [slot]) … … 9745 9745 * @note Locks this object for reading. 9746 9746 */ 9747 HRESULT SessionMachine::onNetworkAdapterChange (INetworkAdapter *networkAdapter )9747 HRESULT SessionMachine::onNetworkAdapterChange (INetworkAdapter *networkAdapter, BOOL changeAdapter) 9748 9748 { 9749 9749 LogFlowThisFunc(("\n")); … … 9762 9762 return S_OK; 9763 9763 9764 return directControl->OnNetworkAdapterChange (networkAdapter );9764 return directControl->OnNetworkAdapterChange (networkAdapter, changeAdapter); 9765 9765 } 9766 9766 -
trunk/src/VBox/Main/NetworkAdapterImpl.cpp
r21878 r21961 226 226 alock.unlock(); 227 227 228 mParent->onNetworkAdapterChange (this );228 mParent->onNetworkAdapterChange (this, FALSE); 229 229 } 230 230 … … 279 279 alock.unlock(); 280 280 281 mParent->onNetworkAdapterChange (this );281 mParent->onNetworkAdapterChange (this, FALSE); 282 282 } 283 283 … … 375 375 alock.unlock(); 376 376 377 mParent->onNetworkAdapterChange (this );377 mParent->onNetworkAdapterChange (this, FALSE); 378 378 } 379 379 … … 435 435 alock.unlock(); 436 436 437 mParent->onNetworkAdapterChange (this );437 mParent->onNetworkAdapterChange (this, FALSE); 438 438 } 439 439 … … 483 483 alock.unlock(); 484 484 485 mParent->onNetworkAdapterChange (this );485 mParent->onNetworkAdapterChange (this, FALSE); 486 486 } 487 487 … … 522 522 alock.unlock(); 523 523 524 mParent->onNetworkAdapterChange (this );524 mParent->onNetworkAdapterChange (this, FALSE); 525 525 } 526 526 … … 561 561 alock.unlock(); 562 562 563 mParent->onNetworkAdapterChange (this );563 mParent->onNetworkAdapterChange (this, FALSE); 564 564 } 565 565 … … 600 600 alock.unlock(); 601 601 602 mParent->onNetworkAdapterChange (this );602 mParent->onNetworkAdapterChange (this, FALSE); 603 603 } 604 604 … … 638 638 alock.unlock(); 639 639 640 mParent->onNetworkAdapterChange (this );640 mParent->onNetworkAdapterChange (this, FALSE); 641 641 } 642 642 … … 677 677 alock.unlock(); 678 678 679 mParent->onNetworkAdapterChange (this );679 mParent->onNetworkAdapterChange (this, FALSE); 680 680 } 681 681 … … 710 710 alock.unlock(); 711 711 712 mParent->onNetworkAdapterChange (this); 712 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); 713 if (FAILED (rc)) 714 { 715 /* If changing the attachment failed then we can't assume 716 * that the previous attachment will attach correctly 717 * and thus return error along with dettaching all 718 * attachments. 719 */ 720 Detach(); 721 return rc; 722 } 713 723 } 714 724 … … 742 752 alock.unlock(); 743 753 744 mParent->onNetworkAdapterChange (this); 754 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); 755 if (FAILED (rc)) 756 { 757 /* If changing the attachment failed then we can't assume 758 * that the previous attachment will attach correctly 759 * and thus return error along with dettaching all 760 * attachments. 761 */ 762 Detach(); 763 return rc; 764 } 745 765 } 746 766 … … 782 802 alock.unlock(); 783 803 784 mParent->onNetworkAdapterChange (this); 804 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); 805 if (FAILED (rc)) 806 { 807 /* If changing the attachment failed then we can't assume 808 * that the previous attachment will attach correctly 809 * and thus return error along with dettaching all 810 * attachments. 811 */ 812 Detach(); 813 return rc; 814 } 785 815 } 786 816 … … 814 844 alock.unlock(); 815 845 816 mParent->onNetworkAdapterChange (this); 846 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); 847 if (FAILED (rc)) 848 { 849 /* If changing the attachment failed then we can't assume 850 * that the previous attachment will attach correctly 851 * and thus return error along with dettaching all 852 * attachments. 853 */ 854 Detach(); 855 return rc; 856 } 817 857 } 818 858 … … 840 880 alock.unlock(); 841 881 842 mParent->onNetworkAdapterChange (this );882 mParent->onNetworkAdapterChange (this, TRUE); 843 883 } 844 884 -
trunk/src/VBox/Main/SessionImpl.cpp
r21878 r21961 532 532 } 533 533 534 STDMETHODIMP Session::OnNetworkAdapterChange(INetworkAdapter *networkAdapter )534 STDMETHODIMP Session::OnNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter) 535 535 { 536 536 LogFlowThisFunc(("\n")); … … 543 543 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 544 544 545 return mConsole->onNetworkAdapterChange(networkAdapter );545 return mConsole->onNetworkAdapterChange(networkAdapter, changeAdapter); 546 546 } 547 547 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r21818 r21961 12119 12119 <interface 12120 12120 name="IInternalSessionControl" extends="$unknown" 12121 uuid=" b26552e7-9534-4f47-b766-98eac648a90d"12121 uuid="e28e19fb-23c2-4d1a-b6bf-ce147fa37b24" 12122 12122 internal="yes" 12123 12123 wsmap="suppress" … … 12249 12249 </desc> 12250 12250 <param name="networkAdapter" type="INetworkAdapter" dir="in"/> 12251 <param name="changeAdapter" type="boolean" dir="in"/> 12251 12252 </method> 12252 12253 -
trunk/src/VBox/Main/include/ConsoleImpl.h
r21878 r21961 177 177 HRESULT onDVDDriveChange(); 178 178 HRESULT onFloppyDriveChange(); 179 HRESULT onNetworkAdapterChange (INetworkAdapter *aNetworkAdapter );179 HRESULT onNetworkAdapterChange (INetworkAdapter *aNetworkAdapter, BOOL changeAdapter); 180 180 HRESULT onSerialPortChange (ISerialPort *aSerialPort); 181 181 HRESULT onParallelPortChange (IParallelPort *aParallelPort); … … 557 557 DriveState_T meFloppyState; 558 558 559 /** The current network attachment type /namein the VM.560 * Th ese don't have to match the network attachment type/name561 * maintained in the NetworkAdapter. Th ese areneeded to559 /** The current network attachment type in the VM. 560 * This doesn't have to match the network attachment type 561 * maintained in the NetworkAdapter. This is needed to 562 562 * change the network attachment dynamically. 563 563 */ 564 564 static NetworkAttachmentType_T meAttachmentType[SchemaDefs::NetworkAdapterCount]; 565 #ifdef VBOX_DYNAMIC_NET_ATTACH566 static Bstr mHostInterface[SchemaDefs::NetworkAdapterCount];567 static Bstr mInternalNetwork[SchemaDefs::NetworkAdapterCount];568 static Bstr mNATNetwork[SchemaDefs::NetworkAdapterCount];569 #endif570 565 571 566 VMMDev * const mVMMDev; -
trunk/src/VBox/Main/include/MachineImpl.h
r21878 r21961 639 639 virtual HRESULT onDVDDriveChange() { return S_OK; } 640 640 virtual HRESULT onFloppyDriveChange() { return S_OK; } 641 virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */ ) { return S_OK; }641 virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; } 642 642 virtual HRESULT onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; } 643 643 virtual HRESULT onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; } … … 964 964 HRESULT onDVDDriveChange(); 965 965 HRESULT onFloppyDriveChange(); 966 HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter );966 HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter); 967 967 HRESULT onStorageControllerChange(); 968 968 HRESULT onSerialPortChange(ISerialPort *serialPort); -
trunk/src/VBox/Main/include/SessionImpl.h
r21878 r21961 95 95 STDMETHOD(OnDVDDriveChange)(); 96 96 STDMETHOD(OnFloppyDriveChange)(); 97 STDMETHOD(OnNetworkAdapterChange)(INetworkAdapter *networkAdapter );97 STDMETHOD(OnNetworkAdapterChange)(INetworkAdapter *networkAdapter, BOOL changeAdapter); 98 98 STDMETHOD(OnSerialPortChange)(ISerialPort *serialPort); 99 99 STDMETHOD(OnParallelPortChange)(IParallelPort *parallelPort);
Note:
See TracChangeset
for help on using the changeset viewer.