VirtualBox

Changeset 28287 in vbox


Ignore:
Timestamp:
Apr 14, 2010 10:10:40 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60036
Message:

Devices, Main, FE/Qt: added support for VDE virtual network switches for Linux and FreeBSD hosts. Contributed by Renzo Davoli, VirtualSquare, University of Bologna

Location:
trunk/src/VBox
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Builtins.cpp

    r27559 r28287  
    238238        return rc;
    239239#endif
     240               /* ENABLE VDE */
     241#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
     242    rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvVDE);
     243    if (RT_FAILURE(rc))
     244        return rc;
     245#endif
     246               /* /ENABLE VDE */
    240247    rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvIntNet);
    241248    if (RT_FAILURE(rc))
  • trunk/src/VBox/Devices/Builtins.h

    r27559 r28287  
    107107extern const PDMDRVREG g_DrvHostInterface;
    108108#endif
     109#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
     110extern const PDMDRVREG g_DrvVDE;
     111#endif
    109112extern const PDMDRVREG g_DrvIntNet;
    110113extern const PDMDRVREG g_DrvNAT;
  • trunk/src/VBox/Devices/Makefile.kmk

    r28228 r28287  
    10041004Drivers_SOURCES.linux = \
    10051005        Network/DrvTAP.cpp \
     1006        Network/DrvVDE.cpp \
    10061007        Audio/ossaudio.c \
    10071008        Parallel/DrvHostParallel.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r28205 r28287  
    21552155                    attType = attType.arg (tr ("Host-only adapter, '%1'",
    21562156                        "details report (network)").arg (adapter.GetHostInterface()));
     2157                                                               /* ENABLE VDE */
     2158                else if (type == KNetworkAttachmentType_VDE)
     2159                    attType = attType.arg (tr ("VDE network, '%1'",
     2160                        "details report (network)").arg (adapter.GetVDENetwork()));
     2161                                                               /* /ENABLE VDE */
    21572162                else
    21582163                    attType = attType.arg (vboxGlobal().toString (type));
     
    31133118    mNetworkAttachmentTypes [KNetworkAttachmentType_HostOnly] =
    31143119        tr ("Host-only Adapter", "NetworkAttachmentType");
     3120               /* ENABLE VDE */
     3121    mNetworkAttachmentTypes [KNetworkAttachmentType_VDE] =
     3122        tr ("VDE Adapter", "NetworkAttachmentType");
     3123               /* /ENABLE VDE */
    31153124
    31163125    mClipboardTypes [KClipboardMode_Disabled] =
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsNetwork.cpp

    r26714 r28287  
    105105            if (mHoiName.isEmpty()) mHoiName = QString::null;
    106106            break;
     107                                               /* ENABLE VDE */
     108        case KNetworkAttachmentType_VDE:
     109            mVDEName = mAdapter.GetVDENetwork();
     110            if (mVDEName.isEmpty()) mVDEName = QString::null;
     111            break;
     112                                               /* /ENABLE VDE */
    107113        default:
    108114            break;
     
    145151            mAdapter.AttachToHostOnlyInterface();
    146152            break;
     153                                               /* ENABLE VDE */
     154                               case KNetworkAttachmentType_VDE:
     155                                               mAdapter.SetVDENetwork (alternativeName());
     156                                               mAdapter.AttachToVDE();
     157                                               break;
     158                                               /* /ENABLE VDE */
    147159        default:
    148160            break;
     
    257269            result = mHoiName;
    258270            break;
     271                                               /* ENABLE VDE*/
     272        case KNetworkAttachmentType_VDE:
     273            result = mVDEName;
     274            break;
     275                                               /* /ENABLE VDE*/
    259276        default:
    260277            break;
     
    333350            mCbAdapterName->setEditable (false);
    334351            break;
     352                                               /* ENABLE VDE */
     353        case KNetworkAttachmentType_VDE:
     354                                               mCbAdapterName->insertItem(0, alternativeName());
     355            mCbAdapterName->setEditable (true);
     356            mCbAdapterName->setCompleter (0);
     357            break;
     358                                               /* /ENABLE VDE */
    335359        default:
    336360            break;
     
    432456            break;
    433457        }
     458                               /* ENABLE VDE */
     459        case KNetworkAttachmentType_VDE:
     460        {
     461            QString newName ((mCbAdapterName->itemData (mCbAdapterName->currentIndex()).toString() ==
     462                              QString (emptyItemCode) &&
     463                              mCbAdapterName->currentText() ==
     464                              mCbAdapterName->itemText (mCbAdapterName->currentIndex())) ||
     465                              mCbAdapterName->currentText().isEmpty() ?
     466                              QString::null : mCbAdapterName->currentText());
     467            if (mVDEName != newName)
     468                mVDEName = newName;
     469            break;
     470        }
     471                               /* /ENABLE VDE */
    434472        default:
    435473            break;
     
    548586    mCbAttachmentType->setItemData (4,
    549587        mCbAttachmentType->itemText (4), Qt::ToolTipRole);
     588               /* ENABLE VDE */
     589    mCbAttachmentType->insertItem (5,
     590        vboxGlobal().toString (KNetworkAttachmentType_VDE));
     591    mCbAttachmentType->setItemData (5,
     592        KNetworkAttachmentType_VDE);
     593    mCbAttachmentType->setItemData (5,
     594        mCbAttachmentType->itemText (5), Qt::ToolTipRole);
     595               /* /ENABLE VDE */
    550596
    551597    /* Set the old value */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsNetwork.h

    r25177 r28287  
    7777    QString mIntName;
    7878    QString mHoiName;
     79               /* ENABLE VDE */
     80    QString mVDEName;
     81               /* /ENABLE VDE */
    7982
    8083    bool mPolished;
     
    9396    QStringList intList (bool aRefresh = false);
    9497    QStringList hoiList (bool aRefresh = false);
     98    QStringList vdeList (bool aRefresh = false);
    9599
    96100protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsNetwork.ui

    r25196 r28287  
    111111        </property>
    112112        <property name="whatsThis" >
    113          <string>Selects the name of the network adapter for &lt;b&gt;Bridged Adapter&lt;/b&gt; or &lt;b&gt;Host-only Adapter&lt;/b&gt; attachments and the name of the network &lt;b&gt;Internal Network&lt;/b&gt; attachments.</string>
     113         <string>Selects the name of the network adapter for &lt;b&gt;Bridged Adapter&lt;/b&gt; or &lt;b&gt;Host-only Adapter&lt;/b&gt; attachments and the name of the network &lt;b&gt;Internal Network&lt;/b&gt; or the switch for &lt;b&gt;VDE&lt;/b&gt; attachments.</string>
    114114        </property>
    115115       </widget>
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r28286 r28287  
    34163416        }
    34173417
     3418                               /* ENABLE VDE */
     3419        case NetworkAttachmentType_VDE:
     3420        {
     3421            hrc = aNetworkAdapter->COMGETTER(VDENetwork)(&str);    H();
     3422#if 0
     3423                                               if (str) {
     3424                                                       Utf8Str strUtf8 = str;
     3425                                                       LogRel(("VDE Network %s\n",(char *)strUtf8.raw()));
     3426                                               }
     3427#endif
     3428                                               rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
     3429                                               rc = CFGMR3InsertString(pLunL0, "Driver", "VDE");    RC_CHECK();
     3430                                               rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg);         RC_CHECK();
     3431            if (str && *str) {
     3432                rc = CFGMR3InsertStringW(pCfg, "Network", str);         RC_CHECK();
     3433                                                               networkName = str;
     3434                                               }
     3435                                               rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_WhateverNone); RC_CHECK();
     3436                                               STR_FREE();
     3437            break;
     3438                               }
     3439                               /* /ENABLE VDE */
     3440
    34183441        default:
    34193442            AssertMsgFailed(("should not get here!\n"));
     
    34333456        case NetworkAttachmentType_HostOnly:
    34343457        case NetworkAttachmentType_NAT:
     3458        case NetworkAttachmentType_VDE:
    34353459        {
    34363460            if (SUCCEEDED(hrc) && SUCCEEDED(rc))
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r28106 r28287  
    610610}
    611611
     612/* ENABLE VDE */
     613STDMETHODIMP NetworkAdapter::COMGETTER(VDENetwork) (BSTR *aVDENetwork)
     614{
     615    CheckComArgOutPointerValid(aVDENetwork);
     616
     617    AutoCaller autoCaller(this);
     618    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     619
     620    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     621
     622    mData->mVDENetwork.cloneTo(aVDENetwork);
     623
     624    return S_OK;
     625}
     626
     627STDMETHODIMP NetworkAdapter::COMSETTER(VDENetwork) (IN_BSTR aVDENetwork)
     628{
     629    Bstr bstrEmpty("");
     630    if (!aVDENetwork)
     631        aVDENetwork = bstrEmpty;
     632
     633    AutoCaller autoCaller(this);
     634    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     635
     636    /* the machine needs to be mutable */
     637    AutoMutableStateDependency adep (mParent);
     638    if (FAILED(adep.rc())) return adep.rc();
     639
     640    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     641
     642    if (mData->mVDENetwork != aVDENetwork)
     643    {
     644        mData.backup();
     645        mData->mVDENetwork = aVDENetwork;
     646
     647        /* leave the lock before informing callbacks */
     648        alock.release();
     649
     650        mParent->onNetworkAdapterChange (this, FALSE);
     651    }
     652
     653    return S_OK;
     654}
     655
     656/* /ENABLE VDE */
     657
    612658STDMETHODIMP NetworkAdapter::COMGETTER(CableConnected) (BOOL *aConnected)
    613659{
     
    10471093    return S_OK;
    10481094}
     1095
     1096/* ENABLE VDE */
     1097STDMETHODIMP NetworkAdapter::AttachToVDE()
     1098{
     1099       AutoCaller autoCaller(this);
     1100       if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1101
     1102       /* the machine needs to be mutable */
     1103       AutoMutableStateDependency adep (mParent);
     1104       if (FAILED(adep.rc())) return adep.rc();
     1105
     1106       AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     1107
     1108       /* don't do anything if we're already host interface attached */
     1109       if (mData->mAttachmentType != NetworkAttachmentType_VDE)
     1110       {
     1111               mData.backup();
     1112
     1113               /* first detach the current attachment */
     1114               // Commented this for now as it reset the parameter mData->mHostInterface
     1115               // which is essential while changing the Attachment dynamically.
     1116               //detach();
     1117
     1118               mData->mAttachmentType = NetworkAttachmentType_VDE;
     1119
     1120               /* leave the lock before informing callbacks */
     1121               alock.release();
     1122
     1123               HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE);
     1124               if (FAILED (rc))
     1125               {
     1126                       /* If changing the attachment failed then we can't assume
     1127                        * that the previous attachment will attach correctly
     1128                        * and thus return error along with dettaching all
     1129                        * attachments.
     1130                        */
     1131                       Detach();
     1132                       return rc;
     1133               }
     1134       }
     1135
     1136       return S_OK;
     1137}
     1138
     1139/* /ENABLE VDE */
    10491140
    10501141STDMETHODIMP NetworkAdapter::Detach()
     
    11561247        break;
    11571248
     1249                               /* ENABLE VDE */
     1250        case NetworkAttachmentType_VDE:
     1251                                   mData->mVDENetwork = data.strName;
     1252                                   rc = AttachToVDE();
     1253                                   if (FAILED(rc)) return rc;
     1254                               break;
     1255                               /* ENABLE VDE */
     1256
     1257
    11581258        case NetworkAttachmentType_Null:
    11591259            rc = Detach();
     
    12191319        case NetworkAttachmentType_HostOnly:
    12201320            data.strName = mData->mHostInterface;
     1321        break;
     1322
     1323        case NetworkAttachmentType_VDE:
     1324            data.strName = mData->mVDENetwork;
    12211325        break;
    12221326    }
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r28235 r28287  
    1153711537    <const name="Internal"              value="3"/>
    1153811538    <const name="HostOnly"              value="4"/>
     11539               <!-- ENABLE VDE -->
     11540    <const name="VDE"                   value="5"/>
     11541               <!-- /ENABLE VDE -->
    1153911542  </enum>
    1154011543
     
    1163911642    </attribute>
    1164011643
     11644               <!-- ENABLE VDE -->
     11645    <attribute name="VDENetwork" type="wstring">
     11646      <desc>
     11647        Name of the VDE switch the VM is attached to.
     11648      </desc>
     11649    </attribute>
     11650               <!-- /ENABLE VDE -->
     11651
    1164111652    <attribute name="cableConnected" type="boolean">
    1164211653      <desc>
     
    1170411715      </desc>
    1170511716    </method>
     11717
     11718               <!-- ENABLE VDE -->
     11719    <method name="attachToVDE">
     11720      <desc>
     11721        Attach the network adapter to a VDE network.
     11722      </desc>
     11723    </method>
     11724               <!-- /ENABLE VDE -->
    1170611725
    1170711726    <method name="detach">
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r28106 r28287  
    5050                 mHostInterface("") /* cannot be null */,
    5151                 mNATNetwork("") /* cannot be null */
     52                                                                /* ENABLE VDE */
     53                 , mVDENetwork("") /* can be null */
     54                                                                /* /ENABLE VDE */
    5255        {}
    5356
     
    6467        Bstr mInternalNetwork;
    6568        Bstr mNATNetwork;
     69        /* ENABLE VDE */
     70        Bstr mVDENetwork;
    6671        ULONG mBootPriority;
    6772    };
     
    105110    STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
    106111    STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
     112               /* ENABLE VDE */
     113    STDMETHOD(COMGETTER(VDENetwork)) (BSTR *aVDENetwork);
     114    STDMETHOD(COMSETTER(VDENetwork)) (IN_BSTR aVDENetwork);
     115               /* /ENABLE VDE */
    107116    STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
    108117    STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
     
    122131    STDMETHOD(AttachToInternalNetwork)();
    123132    STDMETHOD(AttachToHostOnlyInterface)();
     133               /* ENABLE VDE */
     134    STDMETHOD(AttachToVDE)();
     135               /* /ENABLE VDE */
    124136    STDMETHOD(Detach)();
    125137
  • trunk/src/VBox/Main/xml/Settings.cpp

    r28204 r28287  
    18891889                throw ConfigFileError(this, pelmAdapterChild, N_("Required HostOnlyInterface/@name element is missing"));
    18901890        }
     1891                               /* ENABLE VDE */
     1892        else if ((pelmAdapterChild = pelmAdapter->findChildElement("VDE")))
     1893        {
     1894            nic.mode = NetworkAttachmentType_VDE;
     1895            pelmAdapterChild->getAttributeValue("network", nic.strName);    // optional network name
     1896        }
     1897                               /* /ENABLE VDE */
    18911898        // else: default is NetworkAttachmentType_Null
    18921899
     
    33883395            break;
    33893396
     3397                                               /* ENABLE VDE */
     3398            case NetworkAttachmentType_VDE:
     3399                pelmNAT = pelmAdapter->createChild("VDE");
     3400                if (nic.strName.length())
     3401                    pelmNAT->setAttribute("network", nic.strName);
     3402            break;
     3403                                               /* /ENABLE VDE */
     3404
    33903405            default: /*case NetworkAttachmentType_Null:*/
    33913406            break;
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