VirtualBox

Changeset 38406 in vbox


Ignore:
Timestamp:
Aug 10, 2011 3:40:47 PM (13 years ago)
Author:
vboxsync
Message:

vboxnetadp: moved SetExtraData calls to Host::CreateHostOnlyNetworkInterface (#5817)

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r37955 r38406  
    11021102    int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, aHostNetworkInterface, aProgress);
    11031103    if (RT_SUCCESS(r))
     1104    {
     1105#if !defined(RT_OS_WINDOWS)
     1106        Bstr tmpAddr, tmpMask, tmpName;
     1107        HRESULT hrc;
     1108        hrc = (*aHostNetworkInterface)->COMGETTER(Name)(tmpName.asOutParam());
     1109        ComAssertComRCRet(hrc, hrc);
     1110        hrc = (*aHostNetworkInterface)->COMGETTER(IPAddress)(tmpAddr.asOutParam());
     1111        ComAssertComRCRet(hrc, hrc);
     1112        hrc = (*aHostNetworkInterface)->COMGETTER(NetworkMask)(tmpMask.asOutParam());
     1113        ComAssertComRCRet(hrc, hrc);
     1114        /*
     1115         * We need to write the default IP address and mask to extra data now,
     1116         * so the interface gets re-created after vboxnetadp.ko reload.
     1117         * Note that we avoid calling EnableStaticIpConfig since it would
     1118         * change the address on host's interface as well and we want to
     1119         * postpone the change until VM actually starts.
     1120         */
     1121        hrc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPAddress",
     1122                                               tmpName.raw()).raw(),
     1123                                       tmpAddr.raw());
     1124        ComAssertComRCRet(hrc, hrc);
     1125
     1126        hrc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPNetMask",
     1127                                               tmpName.raw()).raw(),
     1128                                       tmpMask.raw());
     1129        ComAssertComRCRet(hrc, hrc);
     1130#endif
    11041131        return S_OK;
     1132    }
    11051133
    11061134    return r == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL;
  • trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp

    r37353 r38406  
    564564        hrc = mVBox->GetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw()).raw(), tmpMask.asOutParam());
    565565        if (tmpAddr.isEmpty())
    566         {
    567566            tmpAddr = getDefaultIPv4Address(mInterfaceName);
    568             /*
    569              * We need to write the default IP address and mask to extra data now,
    570              * so the interface gets re-created after vboxnetadp.ko reload.
    571              * Note that we avoid calling EnableStaticIpConfig since it would
    572              * change the address on host's interface as well and we want to
    573              * postpone the change until VM actually starts.
    574              */
    575             hrc = mVBox->SetExtraData(BstrFmt("HostOnly/%ls/IPAddress",
    576                                               mInterfaceName.raw()).raw(),
    577                                       tmpAddr.raw());
    578             ComAssertComRCRet(hrc, hrc);
    579         }
    580567
    581568        if (tmpMask.isEmpty())
    582         {
    583569            tmpMask = Bstr(VBOXNET_IPV4MASK_DEFAULT);
    584             hrc = mVBox->SetExtraData(BstrFmt("HostOnly/%ls/IPNetMask",
    585                                               mInterfaceName.raw()).raw(),
    586                                       Bstr(VBOXNET_IPV4MASK_DEFAULT).raw());
    587             ComAssertComRCRet(hrc, hrc);
    588         }
     570
    589571        m.IPAddress = inet_addr(Utf8Str(tmpAddr).c_str());
    590572        m.networkMask = inet_addr(Utf8Str(tmpMask).c_str());
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