Changeset 26818 in vbox for trunk/src/VBox/Main
- Timestamp:
- Feb 26, 2010 8:35:45 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/NetworkAdapterImpl.cpp
r26753 r26818 239 239 mlock.release(); 240 240 241 /* Changing the network adapter type during runtime is not allowed, 242 * therefore no immediate change in CFGM logic => changeAdapter=FALSE. */ 241 243 mParent->onNetworkAdapterChange(this, FALSE); 242 244 } … … 297 299 mlock.release(); 298 300 301 /* Disabling the network adapter during runtime is not allowed 302 * therefore no immediate change in CFGM logic => changeAdapter=FALSE. */ 299 303 mParent->onNetworkAdapterChange(this, FALSE); 300 304 } … … 408 412 409 413 if (emitChangeEvent) 414 { 415 /* Changing the MAC via the Main API during runtime is not allowed, 416 * therefore no immediate change in CFGM logic => changeAdapter=FALSE. */ 410 417 mParent->onNetworkAdapterChange(this, FALSE); 418 } 411 419 412 420 return rc; … … 470 478 mlock.release(); 471 479 472 mParent->onNetworkAdapterChange(this, FALSE); 480 /* When changing the host adapter, adapt the CFGM logic to make this 481 * change immediately effect and to notifiy the guest that the network 482 * might have changed, therefore changeAdapter=TRUE. */ 483 mParent->onNetworkAdapterChange(this, TRUE); 473 484 } 474 485 … … 523 534 mlock.release(); 524 535 525 mParent->onNetworkAdapterChange(this, FALSE); 536 /* When changing the internal network, adapt the CFGM logic to make this 537 * change immediately effect and to notifiy the guest that the network 538 * might have changed, therefore changeAdapter=TRUE. */ 539 mParent->onNetworkAdapterChange(this, TRUE); 526 540 } 527 541 … … 571 585 mlock.release(); 572 586 587 /* Changing the NAT network isn't allowed during runtime, therefore 588 * no immediate replug in CFGM logic => changeAdapter=FALSE */ 573 589 mParent->onNetworkAdapterChange(this, FALSE); 574 590 } … … 615 631 mlock.release(); 616 632 633 /* No change in CFGM logic => changeAdapter=FALSE. */ 617 634 mParent->onNetworkAdapterChange(this, FALSE); 618 635 } … … 659 676 mlock.release(); 660 677 678 /* No change in CFGM logic => changeAdapter=FALSE. */ 661 679 mParent->onNetworkAdapterChange(this, FALSE); 662 680 } … … 702 720 mlock.release(); 703 721 722 /* Adapt the CFGM logic changeAdapter=TRUE */ 704 723 mParent->onNetworkAdapterChange(this, TRUE); 705 724 } … … 746 765 mlock.release(); 747 766 767 /* No change in CFGM logic => changeAdapter=FALSE. */ 748 768 mParent->onNetworkAdapterChange(this, FALSE); 749 769 } … … 784 804 mlock.release(); 785 805 806 /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */ 786 807 HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE); 787 808 if (FAILED(rc)) … … 831 852 mlock.release(); 832 853 854 /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */ 855 HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE); 856 if (FAILED(rc)) 857 { 858 /* If changing the attachment failed then we can't assume that the 859 * previous attachment will attach correctly and thus return error 860 * along with dettaching all attachments. 861 */ 862 Detach(); 863 return rc; 864 } 865 } 866 867 return S_OK; 868 } 869 870 STDMETHODIMP NetworkAdapter::AttachToInternalNetwork() 871 { 872 AutoCaller autoCaller(this); 873 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 874 875 /* the machine needs to be mutable */ 876 AutoMutableStateDependency adep(mParent); 877 if (FAILED(adep.rc())) return adep.rc(); 878 879 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 880 881 /* don't do anything if we're already internal network attached */ 882 if (mData->mAttachmentType != NetworkAttachmentType_Internal) 883 { 884 mData.backup(); 885 886 /* first detach the current attachment */ 887 // Commented this for now as it reset the parameter mData->mInternalNetwork 888 // which is essential while changing the Attachment dynamically. 889 //detach(); 890 891 /* there must an internal network name */ 892 if (mData->mInternalNetwork.isEmpty()) 893 { 894 LogRel (("Internal network name not defined, " 895 "setting to default \"intnet\"\n")); 896 mData->mInternalNetwork = "intnet"; 897 } 898 899 mData->mAttachmentType = NetworkAttachmentType_Internal; 900 901 m_fModified = true; 902 // leave the lock before informing callbacks 903 alock.release(); 904 905 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 906 mParent->setModified(Machine::IsModified_NetworkAdapters); 907 mlock.release(); 908 909 /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */ 833 910 HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE); 834 911 if (FAILED(rc)) … … 847 924 } 848 925 849 STDMETHODIMP NetworkAdapter::AttachTo InternalNetwork()850 { 851 AutoCaller autoCaller(this); 852 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 853 854 /* the machine needs to be mutable */ 855 AutoMutableStateDependency adep(mParent); 856 if (FAILED(adep.rc())) return adep.rc(); 857 858 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 859 860 /* don't do anything if we're already internal networkattached */861 if (mData->mAttachmentType != NetworkAttachmentType_ Internal)926 STDMETHODIMP NetworkAdapter::AttachToHostOnlyInterface() 927 { 928 AutoCaller autoCaller(this); 929 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 930 931 /* the machine needs to be mutable */ 932 AutoMutableStateDependency adep(mParent); 933 if (FAILED(adep.rc())) return adep.rc(); 934 935 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 936 937 /* don't do anything if we're already host interface attached */ 938 if (mData->mAttachmentType != NetworkAttachmentType_HostOnly) 862 939 { 863 940 mData.backup(); 864 941 865 942 /* first detach the current attachment */ 866 // Commented this for now as it reset the parameter mData->m InternalNetwork943 // Commented this for now as it reset the parameter mData->mHostInterface 867 944 // which is essential while changing the Attachment dynamically. 868 945 //detach(); 869 946 870 /* there must an internal network name */ 871 if (mData->mInternalNetwork.isEmpty()) 872 { 873 LogRel (("Internal network name not defined, " 874 "setting to default \"intnet\"\n")); 875 mData->mInternalNetwork = "intnet"; 876 } 877 878 mData->mAttachmentType = NetworkAttachmentType_Internal; 879 880 m_fModified = true; 881 // leave the lock before informing callbacks 882 alock.release(); 883 884 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 885 mParent->setModified(Machine::IsModified_NetworkAdapters); 886 mlock.release(); 887 947 mData->mAttachmentType = NetworkAttachmentType_HostOnly; 948 949 m_fModified = true; 950 // leave the lock before informing callbacks 951 alock.release(); 952 953 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 954 mParent->setModified(Machine::IsModified_NetworkAdapters); 955 mlock.release(); 956 957 /* Adapt the CFGM logic and notify the guest => changeAdpater=TRUE. */ 888 958 HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE); 889 959 if (FAILED(rc)) … … 902 972 } 903 973 904 STDMETHODIMP NetworkAdapter::AttachToHostOnlyInterface()905 {906 AutoCaller autoCaller(this);907 if (FAILED(autoCaller.rc())) return autoCaller.rc();908 909 /* the machine needs to be mutable */910 AutoMutableStateDependency adep(mParent);911 if (FAILED(adep.rc())) return adep.rc();912 913 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);914 915 /* don't do anything if we're already host interface attached */916 if (mData->mAttachmentType != NetworkAttachmentType_HostOnly)917 {918 mData.backup();919 920 /* first detach the current attachment */921 // Commented this for now as it reset the parameter mData->mHostInterface922 // which is essential while changing the Attachment dynamically.923 //detach();924 925 mData->mAttachmentType = NetworkAttachmentType_HostOnly;926 927 m_fModified = true;928 // leave the lock before informing callbacks929 alock.release();930 931 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock932 mParent->setModified(Machine::IsModified_NetworkAdapters);933 mlock.release();934 935 HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);936 if (FAILED(rc))937 {938 /* If changing the attachment failed then we can't assume939 * that the previous attachment will attach correctly940 * and thus return error along with dettaching all941 * attachments.942 */943 Detach();944 return rc;945 }946 }947 948 return S_OK;949 }950 951 974 STDMETHODIMP NetworkAdapter::Detach() 952 975 { … … 974 997 mlock.release(); 975 998 999 /* adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */ 976 1000 mParent->onNetworkAdapterChange(this, TRUE); 977 1001 }
Note:
See TracChangeset
for help on using the changeset viewer.