VirtualBox

Changeset 26818 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Feb 26, 2010 8:35:45 AM (15 years ago)
Author:
vboxsync
Message:

xtracker 3573 / public #5781: when changing the host adapter or the internal network we are attached to, then immediately change the CFGM attachment logic to make this change effect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r26753 r26818  
    239239        mlock.release();
    240240
     241        /* Changing the network adapter type during runtime is not allowed,
     242         * therefore no immediate change in CFGM logic => changeAdapter=FALSE. */
    241243        mParent->onNetworkAdapterChange(this, FALSE);
    242244    }
     
    297299        mlock.release();
    298300
     301        /* Disabling the network adapter during runtime is not allowed
     302         * therefore no immediate change in CFGM logic => changeAdapter=FALSE. */
    299303        mParent->onNetworkAdapterChange(this, FALSE);
    300304    }
     
    408412
    409413    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. */
    410417        mParent->onNetworkAdapterChange(this, FALSE);
     418    }
    411419
    412420    return rc;
     
    470478        mlock.release();
    471479
    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);
    473484    }
    474485
     
    523534        mlock.release();
    524535
    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);
    526540    }
    527541
     
    571585        mlock.release();
    572586
     587        /* Changing the NAT network isn't allowed during runtime, therefore
     588         * no immediate replug in CFGM logic => changeAdapter=FALSE */
    573589        mParent->onNetworkAdapterChange(this, FALSE);
    574590    }
     
    615631        mlock.release();
    616632
     633        /* No change in CFGM logic => changeAdapter=FALSE. */
    617634        mParent->onNetworkAdapterChange(this, FALSE);
    618635    }
     
    659676        mlock.release();
    660677
     678        /* No change in CFGM logic => changeAdapter=FALSE. */
    661679        mParent->onNetworkAdapterChange(this, FALSE);
    662680    }
     
    702720        mlock.release();
    703721
     722        /* Adapt the CFGM logic changeAdapter=TRUE */
    704723        mParent->onNetworkAdapterChange(this, TRUE);
    705724    }
     
    746765        mlock.release();
    747766
     767        /* No change in CFGM logic => changeAdapter=FALSE. */
    748768        mParent->onNetworkAdapterChange(this, FALSE);
    749769    }
     
    784804        mlock.release();
    785805
     806        /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
    786807        HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);
    787808        if (FAILED(rc))
     
    831852        mlock.release();
    832853
     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
     870STDMETHODIMP 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. */
    833910        HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);
    834911        if (FAILED(rc))
     
    847924}
    848925
    849 STDMETHODIMP NetworkAdapter::AttachToInternalNetwork()
    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 network attached */
    861     if (mData->mAttachmentType != NetworkAttachmentType_Internal)
     926STDMETHODIMP 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)
    862939    {
    863940        mData.backup();
    864941
    865942        /* first detach the current attachment */
    866         // Commented this for now as it reset the parameter mData->mInternalNetwork
     943        // Commented this for now as it reset the parameter mData->mHostInterface
    867944        // which is essential while changing the Attachment dynamically.
    868945        //detach();
    869946
    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. */
    888958        HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);
    889959        if (FAILED(rc))
     
    902972}
    903973
    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->mHostInterface
    922         // 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 callbacks
    929         alock.release();
    930 
    931         AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
    932         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 assume
    939              * that the previous attachment will attach correctly
    940              * and thus return error along with dettaching all
    941              * attachments.
    942              */
    943             Detach();
    944             return rc;
    945         }
    946     }
    947 
    948     return S_OK;
    949 }
    950 
    951974STDMETHODIMP NetworkAdapter::Detach()
    952975{
     
    974997        mlock.release();
    975998
     999        /* adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
    9761000        mParent->onNetworkAdapterChange(this, TRUE);
    9771001    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette