VirtualBox

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


Ignore:
Timestamp:
May 24, 2011 3:34:06 PM (14 years ago)
Author:
vboxsync
Message:

API+Frontends: Generic network attachment driver support which obsoletes the special case for VDE. Big API cleanup in the same area. Adapt all frontends to these changes (full implementation in VBoxManage, minimum implementation in GUI).

Location:
trunk/src/VBox/Main
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r36941 r37200  
    55
    66#
    7 # Copyright (C) 2006-2010 Oracle Corporation
     7# Copyright (C) 2006-2011 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    6262        $(if $(VBOX_WITH_GUEST_PROPS_RDONLY_GUEST),VBOX_WITH_GUEST_PROPS_RDONLY_GUEST,) \
    6363        $(if $(VBOX_WITH_GUEST_CONTROL),VBOX_WITH_GUEST_CONTROL,) \
    64         $(if $(VBOX_WITH_HOSTNETIF_API),VBOX_WITH_HOSTNETIF_API,) \
    65         $(if $(VBOX_WITH_VDE),VBOX_WITH_VDE,)
     64        $(if $(VBOX_WITH_HOSTNETIF_API),VBOX_WITH_HOSTNETIF_API,)
    6665
    6766# Unconditionally enable the new semaphore key generation code
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r37069 r37200  
    272272      <td>
    273273        Returned if a memory pointer for the output argument is invalid (for
    274         example, @c null). Note that when pointers representing input
    275         arguments (such as strings) are invalid, E_INVALIDARG is returned.
     274        example, @c null). When pointers representing input arguments (such
     275        as strings) are invalid, E_INVALIDARG is returned.
    276276      </td>
    277277      </tr>
     
    559559      executed), only a few machine settings can be modified. Methods working
    560560      with such settings contain an explicit note about that. An attempt to
    561       change any oter setting or perform a modifying operation during this time
     561      change any other setting or perform a modifying operation during this time
    562562      will result in the @c VBOX_E_INVALID_VM_STATE error.
    563563
     
    12071207      through a single IVirtualBoxErrorInfo object set after method invocation.
    12081208
    1209       Note that errors are stored to a chain in the reverse order, i.e. the
     1209      <note>errors are stored to a chain in the reverse order, i.e. the
    12101210      initial error object you query right after method invocation is the last
    12111211      error set by the callee, the object it points to in the @a next attribute
    12121212      is the previous error and so on, up to the first error (which is the last
    1213       in the chain).
     1213      in the chain).</note>
    12141214    </desc>
    12151215
     
    17681768        format and location for medium data.
    17691769
    1770         Note that the actual storage unit is not created by this method. In
    1771         order to do it, and before you are able to attach the created medium
    1772         to virtual machines, you must call one of the following methods to
     1770        The actual storage unit is not created by this method. In order to
     1771        do it, and before you are able to attach the created medium to
     1772        virtual machines, you must call one of the following methods to
    17731773        allocate a format-specific storage unit at the specified location:
    17741774        <ul>
     
    1022610226    </method>
    1022710227
    10228     <!-- storage methods -->
     10228    <!-- property methods -->
    1022910229
    1023010230    <method name="getProperty">
     
    1023510235        be obtained with <link to="IMediumFormat::describeProperties"/>.
    1023610236
    10237         Note that if this method returns an empty string in @a value, the
    10238         requested property is supported but currently not assigned any value.
     10237        <note>If this method returns an empty string in @a value, the requested
     10238        property is supported but currently not assigned any value.</note>
    1023910239
    1024010240        <result name="VBOX_E_OBJECT_NOT_FOUND">
     
    1025810258        be obtained with <link to="IMediumFormat::describeProperties"/>.
    1025910259
    10260         Note that setting the property value to @c null or an empty string is
     10260        <note>Setting the property value to @c null or an empty string is
    1026110261        equivalent to deleting the existing value. A default value (if it is
    1026210262        defined for this property) will be used by the format backend in this
    10263         case.
     10263        case.</note>
    1026410264
    1026510265        <result name="VBOX_E_OBJECT_NOT_FOUND">
     
    1028210282        The names of the properties to get are specified using the @a names
    1028310283        argument which is a list of comma-separated property names or
    10284         an empty string if all properties are to be returned. Note that currently
    10285         the value of this argument is ignored and the method always returns all
    10286         existing properties.
     10284        an empty string if all properties are to be returned.
     10285        <note>Currently the value of this argument is ignored and the method
     10286        always returns all existing properties.</note>
    1028710287
    1028810288        The list of all properties supported by the given medium format can
     
    1029110291        The method returns two arrays, the array of property names corresponding
    1029210292        to the @a names argument and the current values of these properties.
    10293         Both arrays have the same number of elements with each elemend at the
     10293        Both arrays have the same number of elements with each element at the
    1029410294        given index in the first array corresponds to an element at the same
    1029510295        index in the second array.
    1029610296
    10297         Note that for properties that do not have assigned values,
    10298         an empty string is returned at the appropriate index in the
    10299         @a returnValues array.
     10297        For properties that do not have assigned values, an empty string is
     10298        returned at the appropriate index in the @a returnValues array.
    1030010299
    1030110300      </desc>
     
    1031910318        The names of the properties to set are passed in the @a names
    1032010319        array along with the new values for them in the @a values array. Both
    10321         arrays have the same number of elements with each elemend at the given
     10320        arrays have the same number of elements with each element at the given
    1032210321        index in the first array corresponding to an element at the same index
    1032310322        in the second array.
     
    1032810327
    1032910328        Using this method over <link to="#setProperty"/> is preferred if you
    10330         need to set several properties at once since it will result into less
    10331         IPC calls.
     10329        need to set several properties at once since it is more efficient.
    1033210330
    1033310331        The list of all properties supported by the given medium format can
    1033410332        be obtained with <link to="IMediumFormat::describeProperties"/>.
    1033510333
    10336         Note that setting the property value to @c null or an empty string is
    10337         equivalent to deleting the existing value. A default value (if it is
    10338         defined for this property) will be used by the format backend in this
    10339         case.
     10334        Setting the property value to @c null or an empty string is equivalent
     10335        to deleting the existing value. A default value (if it is defined for
     10336        this property) will be used by the format backend in this case.
    1034010337      </desc>
    1034110338      <param name="names" type="wstring" safearray="yes" dir="in">
     
    1184511842  <enum
    1184611843    name="NetworkAttachmentType"
    11847     uuid="44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"
     11844    uuid="2ac4bc71-6b82-417a-acd1-f7426d2570d6"
    1184811845    >
    1184911846    <desc>
     
    1185811855    <const name="Internal"              value="3"/>
    1185911856    <const name="HostOnly"              value="4"/>
    11860     <const name="VDE"                   value="5"/>
     11857    <const name="Generic"               value="5"/>
    1186111858  </enum>
    1186211859
     
    1191911916  <interface
    1192011917    name="INetworkAdapter" extends="$unknown"
    11921     uuid="6aa240a1-dd58-478e-92e8-aac001ce5547"
     11918    uuid="b22f71f6-082e-4a1d-aaf2-3ce40e275dd9"
    1192211919    wsmap="managed"
    1192311920    >
     
    1196611963    </attribute>
    1196711964
    11968     <attribute name="attachmentType" type="NetworkAttachmentType" readonly="yes"/>
    11969 
    11970     <attribute name="hostInterface" type="wstring">
    11971       <desc>
    11972         Name of the host network interface the VM is attached to.
     11965    <attribute name="attachmentType" type="NetworkAttachmentType">
     11966      <desc>
     11967        Sets/Gets network attachment type of this network adapter.
     11968      </desc>
     11969    </attribute>
     11970
     11971    <attribute name="bridgedInterface" type="wstring">
     11972      <desc>
     11973        Name of the network interface the VM should be bridged to.
     11974      </desc>
     11975    </attribute>
     11976
     11977    <attribute name="hostOnlyInterface" type="wstring">
     11978      <desc>
     11979        Name of the host only network interface the VM is attached to.
    1197311980      </desc>
    1197411981    </attribute>
     
    1198611993    </attribute>
    1198711994
    11988     <attribute name="VDENetwork" type="wstring">
    11989       <desc>
    11990         Name of the VDE switch the VM is attached to.
     11995    <attribute name="genericDriver" type="wstring">
     11996      <desc>
     11997        Name of the driver to use for the "Generic" network attachment type.
    1199111998      </desc>
    1199211999    </attribute>
     
    1203012037        Points to the NAT engine which handles the network address translation
    1203112038        for this interface. This is active only when the interface actually uses
    12032         NAT (see <link to="#attachToNAT" />).
     12039        NAT.
    1203312040      </desc>
    1203412041    </attribute>
     
    1204512052    </attribute>
    1204612053
    12047     <method name="attachToNAT">
    12048       <desc>
    12049         Attach the network adapter to the Network Address Translation (NAT) interface.
    12050       </desc>
    12051     </method>
    12052 
    12053     <method name="attachToBridgedInterface">
    12054       <desc>
    12055         Attach the network adapter to a bridged host interface.
    12056       </desc>
    12057     </method>
    12058 
    12059     <method name="attachToInternalNetwork">
    12060       <desc>
    12061         Attach the network adapter to an internal network.
    12062       </desc>
    12063     </method>
    12064 
    12065     <method name="attachToHostOnlyInterface">
    12066       <desc>
    12067         Attach the network adapter to the host-only network.
    12068       </desc>
    12069     </method>
    12070 
    12071     <method name="attachToVDE">
    12072       <desc>
    12073         Attach the network adapter to a VDE network.
    12074       </desc>
    12075     </method>
    12076 
    12077     <method name="detach">
    12078       <desc>
    12079         Detach the network adapter
    12080       </desc>
    12081     </method>
     12054    <!-- property methods -->
     12055
     12056    <method name="getProperty">
     12057      <desc>
     12058        Returns the value of the network attachment property with the given name.
     12059
     12060        If the requested data @a key does not exist, this function will
     12061        succeed and return an empty string in the @a value argument.
     12062
     12063        <result name="E_INVALIDARG">@a name is @c null or empty.</result>
     12064      </desc>
     12065      <param name="key" type="wstring" dir="in">
     12066        <desc>Name of the property to get.</desc>
     12067      </param>
     12068      <param name="value" type="wstring" dir="return">
     12069        <desc>Current property value.</desc>
     12070      </param>
     12071    </method>
     12072
     12073    <method name="setProperty">
     12074      <desc>
     12075        Sets the value of the network attachment property with the given name.
     12076
     12077        Setting the property value to @c null or an empty string is equivalent
     12078        to deleting the existing value.
     12079
     12080        <result name="E_INVALIDARG">@a name is @c null or empty.</result>
     12081      </desc>
     12082      <param name="key" type="wstring" dir="in">
     12083        <desc>Name of the property to set.</desc>
     12084      </param>
     12085      <param name="value" type="wstring" dir="in">
     12086        <desc>Property value to set.</desc>
     12087      </param>
     12088    </method>
     12089
     12090    <method name="getProperties">
     12091      <desc>
     12092        Returns values for a group of properties in one call.
     12093
     12094        The names of the properties to get are specified using the @a names
     12095        argument which is a list of comma-separated property names or
     12096        an empty string if all properties are to be returned.
     12097        <note>Currently the value of this argument is ignored and the method
     12098        always returns all existing properties.</note>
     12099
     12100        The method returns two arrays, the array of property names corresponding
     12101        to the @a names argument and the current values of these properties.
     12102        Both arrays have the same number of elements with each element at the
     12103        given index in the first array corresponds to an element at the same
     12104        index in the second array.
     12105      </desc>
     12106      <param name="names" type="wstring" dir="in">
     12107        <desc>
     12108          Names of properties to get.
     12109        </desc>
     12110      </param>
     12111      <param name="returnNames" type="wstring" safearray="yes" dir="out">
     12112        <desc>Names of returned properties.</desc>
     12113      </param>
     12114      <param name="returnValues" type="wstring" safearray="yes" dir="return">
     12115        <desc>Values of returned properties.</desc>
     12116      </param>
     12117    </method>
     12118
    1208212119  </interface>
    1208312120
     
    1224612283      <desc>
    1224712284        Host parallel device name. If this parallel port is enabled, setting a
    12248         @c null or an empty string as this attribute's value will result into
     12285        @c null or an empty string as this attribute's value will result in
    1224912286        an error.
    1225012287      </desc>
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r36275 r37200  
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4747                 mPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
    4848                 mTraceEnabled(FALSE),
    49                  mHostInterface("") /* cannot be null */,
    50 #ifdef VBOX_WITH_VDE
    51                  mVDENetwork("") /* can be null */,
    52 #endif
     49                 mBridgedInterface("") /* cannot be null */,
     50                 mHostOnlyInterface("") /* cannot be null */,
    5351                 mNATNetwork("") /* cannot be null */,
    5452                 mBootPriority(0)
     
    6563        BOOL mTraceEnabled;
    6664        Bstr mTraceFile;
    67         Bstr mHostInterface;
     65        Bstr mBridgedInterface;
     66        Bstr mHostOnlyInterface;
    6867        Bstr mInternalNetwork;
    69 #ifdef VBOX_WITH_VDE
    70         Bstr mVDENetwork;
    71 #endif
    7268        Bstr mNATNetwork;
     69        Bstr mGenericDriver;
     70        settings::StringsMap mGenericProperties;
    7371        ULONG mBootPriority;
    7472        ComObjPtr<BandwidthGroup> mBandwidthGroup;
     
    8280
    8381    BEGIN_COM_MAP(NetworkAdapter)
    84         VBOX_DEFAULT_INTERFACE_ENTRIES (INetworkAdapter)
     82        VBOX_DEFAULT_INTERFACE_ENTRIES(INetworkAdapter)
    8583    END_COM_MAP()
    8684
    87     DECLARE_EMPTY_CTOR_DTOR (NetworkAdapter)
     85    DECLARE_EMPTY_CTOR_DTOR(NetworkAdapter)
    8886
    8987    HRESULT FinalConstruct();
     
    9189
    9290    // public initializer/uninitializer for internal purposes only
    93     HRESULT init (Machine *aParent, ULONG aSlot);
    94     HRESULT init (Machine *aParent, NetworkAdapter *aThat);
    95     HRESULT initCopy (Machine *aParent, NetworkAdapter *aThat);
     91    HRESULT init(Machine *aParent, ULONG aSlot);
     92    HRESULT init(Machine *aParent, NetworkAdapter *aThat);
     93    HRESULT initCopy(Machine *aParent, NetworkAdapter *aThat);
    9694    void uninit();
    9795
     
    9997    STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType);
    10098    STDMETHOD(COMSETTER(AdapterType))(NetworkAdapterType_T aAdapterType);
    101     STDMETHOD(COMGETTER(Slot)) (ULONG *aSlot);
    102     STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
    103     STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
    104     STDMETHOD(COMGETTER(MACAddress)) (BSTR *aMACAddress);
    105     STDMETHOD(COMSETTER(MACAddress)) (IN_BSTR aMACAddress);
    106     STDMETHOD(COMGETTER(AttachmentType)) (NetworkAttachmentType_T *aAttachmentType);
    107     STDMETHOD(COMGETTER(HostInterface)) (BSTR *aHostInterface);
    108     STDMETHOD(COMSETTER(HostInterface)) (IN_BSTR aHostInterface);
    109     STDMETHOD(COMGETTER(InternalNetwork)) (BSTR *aInternalNetwork);
    110     STDMETHOD(COMSETTER(InternalNetwork)) (IN_BSTR aInternalNetwork);
    111     STDMETHOD(COMGETTER(NATNetwork)) (BSTR *aNATNetwork);
    112     STDMETHOD(COMSETTER(NATNetwork)) (IN_BSTR aNATNetwork);
    113     STDMETHOD(COMGETTER(VDENetwork)) (BSTR *aVDENetwork);
    114     STDMETHOD(COMSETTER(VDENetwork)) (IN_BSTR aVDENetwork);
    115     STDMETHOD(COMGETTER(CableConnected)) (BOOL *aConnected);
    116     STDMETHOD(COMSETTER(CableConnected)) (BOOL aConnected);
    117     STDMETHOD(COMGETTER(TraceEnabled)) (BOOL *aEnabled);
    118     STDMETHOD(COMSETTER(TraceEnabled)) (BOOL aEnabled);
    119     STDMETHOD(COMGETTER(LineSpeed)) (ULONG *aSpeed);
    120     STDMETHOD(COMSETTER(LineSpeed)) (ULONG aSpeed);
     99    STDMETHOD(COMGETTER(Slot))(ULONG *aSlot);
     100    STDMETHOD(COMGETTER(Enabled))(BOOL *aEnabled);
     101    STDMETHOD(COMSETTER(Enabled))(BOOL aEnabled);
     102    STDMETHOD(COMGETTER(MACAddress))(BSTR *aMACAddress);
     103    STDMETHOD(COMSETTER(MACAddress))(IN_BSTR aMACAddress);
     104    STDMETHOD(COMGETTER(AttachmentType))(NetworkAttachmentType_T *aAttachmentType);
     105    STDMETHOD(COMSETTER(AttachmentType))(NetworkAttachmentType_T aAttachmentType);
     106    STDMETHOD(COMGETTER(BridgedInterface))(BSTR *aBridgedInterface);
     107    STDMETHOD(COMSETTER(BridgedInterface))(IN_BSTR aBridgedInterface);
     108    STDMETHOD(COMGETTER(HostOnlyInterface))(BSTR *aHostOnlyInterface);
     109    STDMETHOD(COMSETTER(HostOnlyInterface))(IN_BSTR aHostOnlyInterface);
     110    STDMETHOD(COMGETTER(InternalNetwork))(BSTR *aInternalNetwork);
     111    STDMETHOD(COMSETTER(InternalNetwork))(IN_BSTR aInternalNetwork);
     112    STDMETHOD(COMGETTER(NATNetwork))(BSTR *aNATNetwork);
     113    STDMETHOD(COMSETTER(NATNetwork))(IN_BSTR aNATNetwork);
     114    STDMETHOD(COMGETTER(GenericDriver))(BSTR *aGenericDriver);
     115    STDMETHOD(COMSETTER(GenericDriver))(IN_BSTR aGenericDriver);
     116    STDMETHOD(COMGETTER(CableConnected))(BOOL *aConnected);
     117    STDMETHOD(COMSETTER(CableConnected))(BOOL aConnected);
     118    STDMETHOD(COMGETTER(TraceEnabled))(BOOL *aEnabled);
     119    STDMETHOD(COMSETTER(TraceEnabled))(BOOL aEnabled);
     120    STDMETHOD(COMGETTER(LineSpeed))(ULONG *aSpeed);
     121    STDMETHOD(COMSETTER(LineSpeed))(ULONG aSpeed);
    121122    STDMETHOD(COMGETTER(PromiscModePolicy))(NetworkAdapterPromiscModePolicy_T *aPromiscModePolicy);
    122123    STDMETHOD(COMSETTER(PromiscModePolicy))(NetworkAdapterPromiscModePolicy_T aPromiscModePolicy);
    123     STDMETHOD(COMGETTER(TraceFile)) (BSTR *aTraceFile);
    124     STDMETHOD(COMSETTER(TraceFile)) (IN_BSTR aTraceFile);
    125     STDMETHOD(COMGETTER(NatDriver)) (INATEngine **aNatDriver);
    126     STDMETHOD(COMGETTER(BootPriority)) (ULONG *aBootPriority);
    127     STDMETHOD(COMSETTER(BootPriority)) (ULONG aBootPriority);
    128     STDMETHOD(COMGETTER(BandwidthGroup)) (IBandwidthGroup **aBwGroup);
    129     STDMETHOD(COMSETTER(BandwidthGroup)) (IBandwidthGroup *aBwGroup);
     124    STDMETHOD(COMGETTER(TraceFile))(BSTR *aTraceFile);
     125    STDMETHOD(COMSETTER(TraceFile))(IN_BSTR aTraceFile);
     126    STDMETHOD(COMGETTER(NatDriver))(INATEngine **aNatDriver);
     127    STDMETHOD(COMGETTER(BootPriority))(ULONG *aBootPriority);
     128    STDMETHOD(COMSETTER(BootPriority))(ULONG aBootPriority);
     129    STDMETHOD(COMGETTER(BandwidthGroup))(IBandwidthGroup **aBwGroup);
     130    STDMETHOD(COMSETTER(BandwidthGroup))(IBandwidthGroup *aBwGroup);
    130131
    131132    // INetworkAdapter methods
    132     STDMETHOD(AttachToNAT)();
    133     STDMETHOD(AttachToBridgedInterface)();
    134     STDMETHOD(AttachToInternalNetwork)();
    135     STDMETHOD(AttachToHostOnlyInterface)();
    136     STDMETHOD(AttachToVDE)();
    137     STDMETHOD(Detach)();
     133    STDMETHOD(GetProperty)(IN_BSTR aName, BSTR *aValue);
     134    STDMETHOD(SetProperty)(IN_BSTR aName, IN_BSTR aValue);
     135    STDMETHOD(GetProperties)(IN_BSTR aNames,
     136                             ComSafeArrayOut(BSTR, aReturnNames),
     137                             ComSafeArrayOut(BSTR, aReturnValues));
    138138
    139139    // public methods only for internal purposes
     
    145145    void rollback();
    146146    void commit();
    147     void copyFrom (NetworkAdapter *aThat);
    148     void applyDefaults (GuestOSType *aOsType);
     147    void copyFrom(NetworkAdapter *aThat);
     148    void applyDefaults(GuestOSType *aOsType);
    149149
    150150private:
    151151
    152     void detach();
    153152    void generateMACAddress();
    154153    HRESULT updateMacAddress(Utf8Str aMacAddress);
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r37016 r37200  
    33353335                SafeArray<BSTR> names;
    33363336                SafeArray<BSTR> values;
    3337                 hrc = pMedium->GetProperties(NULL,
    3338                                             ComSafeArrayAsOutParam(names),
    3339                                             ComSafeArrayAsOutParam(values));               H();
     3337                hrc = pMedium->GetProperties((CBSTR)L"",
     3338                                             ComSafeArrayAsOutParam(names),
     3339                                             ComSafeArrayAsOutParam(values));               H();
    33403340
    33413341                if (names.size() != 0)
     
    35043504        }
    35053505
     3506        Utf8Str strNetDriver;
    35063507        if (fAttachDetach && fSniffer)
    35073508        {
     
    35133514                pszNetDriver = "HostInterface";
    35143515#endif
     3516            if (meAttachmentType[uInstance] == NetworkAttachmentType_Generic)
     3517            {
     3518                hrc = aNetworkAdapter->COMGETTER(GenericDriver)(bstr.asOutParam()); H();
     3519                strNetDriver = bstr;
     3520                pszNetDriver = strNetDriver.c_str();
     3521            }
    35153522
    35163523            rc = PDMR3DriverDetach(pVM, pszDevice, uInstance, uLun, pszNetDriver, 0, 0 /*fFlags*/);
     
    37633770                }
    37643771
    3765                 Bstr HifName;
    3766                 hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
     3772                Bstr BridgedIfName;
     3773                hrc = aNetworkAdapter->COMGETTER(BridgedInterface)(BridgedIfName.asOutParam());
    37673774                if (FAILED(hrc))
    37683775                {
    3769                     LogRel(("NetworkAttachmentType_Bridged: COMGETTER(HostInterface) failed, hrc (0x%x)", hrc));
     3776                    LogRel(("NetworkAttachmentType_Bridged: COMGETTER(BridgedInterface) failed, hrc (0x%x)", hrc));
    37703777                    H();
    37713778                }
    37723779
    3773                 Utf8Str HifNameUtf8(HifName);
    3774                 const char *pszHifName = HifNameUtf8.c_str();
     3780                Utf8Str BridgedIfNameUtf8(BridgedIfName);
     3781                const char *pszBridgedIfName = BridgedIfNameUtf8.c_str();
    37753782
    37763783# if defined(RT_OS_DARWIN)
    37773784                /* The name is on the form 'ifX: long name', chop it off at the colon. */
    37783785                char szTrunk[8];
    3779                 RTStrCopy(szTrunk, sizeof(szTrunk), pszHifName);
     3786                RTStrCopy(szTrunk, sizeof(szTrunk), pszBridgedIfName);
    37803787                char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
    37813788// Quick fix for #5633
     
    37913798//                     return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
    37923799//                                       N_("Malformed host interface networking name '%ls'"),
    3793 //                                       HifName.raw());
     3800//                                       BridgedIfName.raw());
    37943801//                 }
    37953802                if (pszColon)
     
    38003807                /* The name is on the form format 'ifX[:1] - long name, chop it off at space. */
    38013808                char szTrunk[256];
    3802                 strlcpy(szTrunk, pszHifName, sizeof(szTrunk));
     3809                strlcpy(szTrunk, pszBridgedIfName, sizeof(szTrunk));
    38033810                char *pszSpace = (char *)memchr(szTrunk, ' ', sizeof(szTrunk));
    38043811
     
    38203827# elif defined(RT_OS_WINDOWS)
    38213828                ComPtr<IHostNetworkInterface> hostInterface;
    3822                 hrc = host->FindHostNetworkInterfaceByName(HifName.raw(),
     3829                hrc = host->FindHostNetworkInterfaceByName(BridgedIfName.raw(),
    38233830                                                           hostInterface.asOutParam());
    38243831                if (!SUCCEEDED(hrc))
     
    38273834                    return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
    38283835                                      N_("Nonexistent host networking interface, name '%ls'"),
    3829                                       HifName.raw());
     3836                                      BridgedIfName.raw());
    38303837                }
    38313838
     
    38423849                    return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
    38433850                                      N_("Interface ('%ls') is not a Bridged Adapter interface"),
    3844                                       HifName.raw());
     3851                                      BridgedIfName.raw());
    38453852                }
    38463853
     
    39303937                 * interface via the current FreeBSD vboxnetflt implementation.
    39313938                 */
    3932                 if (!strncmp(pszHifName, "tap", sizeof "tap" - 1)) {
     3939                if (!strncmp(pszBridgedIfName, "tap", sizeof "tap" - 1)) {
    39333940                    hrc = attachToTapInterface(aNetworkAdapter);
    39343941                    if (FAILED(hrc))
     
    39423949                                                "sysctl is set.  Either run 'chmod 0666 /dev/%s' or "
    39433950                                                "change the group of that node to vboxusers and make yourself "
    3944                                                 "a member of that group.  Make sure that these changes are permanent."), pszHifName, pszHifName);
     3951                                                "a member of that group.  Make sure that these changes are permanent."), pszBridgedIfName, pszBridgedIfName);
    39453952                            default:
    39463953                                AssertMsgFailed(("Could not attach to tap interface! Bad!\n"));
     
    39613968#  endif
    39623969                /** @todo Check for malformed names. */
    3963                 const char *pszTrunk = pszHifName;
     3970                const char *pszTrunk = pszBridgedIfName;
    39643971
    39653972                /* Issue a warning if the interface is down */
     
    39703977                        struct ifreq Req;
    39713978                        RT_ZERO(Req);
    3972                         strncpy(Req.ifr_name, pszHifName, sizeof(Req.ifr_name) - 1);
     3979                        strncpy(Req.ifr_name, pszBridgedIfName, sizeof(Req.ifr_name) - 1);
    39733980                        if (ioctl(iSock, SIOCGIFFLAGS, &Req) >= 0)
    39743981                            if ((Req.ifr_flags & IFF_UP) == 0)
    39753982                                setVMRuntimeErrorCallbackF(pVM, this, 0, "BridgedInterfaceDown",
    39763983                                                           "Bridged interface %s is down. Guest will not be able to use this interface",
    3977                                                            pszHifName);
     3984                                                           pszBridgedIfName);
    39783985
    39793986                        close(iSock);
     
    39923999                InsertConfigString(pCfg, "IfPolicyPromisc", pszPromiscuousGuestPolicy);
    39934000                char szNetwork[INTNET_MAX_NETWORK_NAME];
    3994                 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
     4001                RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszBridgedIfName);
    39954002                InsertConfigString(pCfg, "Network", szNetwork);
    39964003                networkName = Bstr(szNetwork);
     
    40004007# if defined(RT_OS_DARWIN)
    40014008                /** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
    4002                 if (    strstr(pszHifName, "Wireless")
    4003                     ||  strstr(pszHifName, "AirPort" ))
     4009                if (    strstr(pszBridgedIfName, "Wireless")
     4010                    ||  strstr(pszBridgedIfName, "AirPort" ))
    40044011                    InsertConfigInteger(pCfg, "SharedMacOnWire", true);
    40054012# elif defined(RT_OS_LINUX)
     
    40104017
    40114018                    memset(&WRq, 0, sizeof(WRq));
    4012                     strncpy(WRq.ifr_name, pszHifName, IFNAMSIZ);
     4019                    strncpy(WRq.ifr_name, pszBridgedIfName, IFNAMSIZ);
    40134020                    bool fSharedMacOnWire = ioctl(iSock, SIOCGIWNAME, &WRq) >= 0;
    40144021                    close(iSock);
     
    40314038
    40324039                    memset(&WReq, 0, sizeof(WReq));
    4033                     strncpy(WReq.i_name, pszHifName, sizeof(WReq.i_name));
     4040                    strncpy(WReq.i_name, pszBridgedIfName, sizeof(WReq.i_name));
    40344041                    WReq.i_type = IEEE80211_IOC_SSID;
    40354042                    WReq.i_val = -1;
     
    41794186                InsertConfigNode(pLunL0, "Config", &pCfg);
    41804187
    4181                 Bstr HifName;
    4182                 hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
     4188                Bstr HostOnlyName;
     4189                hrc = aNetworkAdapter->COMGETTER(HostOnlyInterface)(HostOnlyName.asOutParam());
    41834190                if (FAILED(hrc))
    41844191                {
    4185                     LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostInterface) failed, hrc (0x%x)\n", hrc));
     4192                    LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostOnlyInterface) failed, hrc (0x%x)\n", hrc));
    41864193                    H();
    41874194                }
    41884195
    4189                 Utf8Str HifNameUtf8(HifName);
    4190                 const char *pszHifName = HifNameUtf8.c_str();
     4196                Utf8Str HostOnlyNameUtf8(HostOnlyName);
     4197                const char *pszHostOnlyName = HostOnlyNameUtf8.c_str();
    41914198                ComPtr<IHostNetworkInterface> hostInterface;
    4192                 rc = host->FindHostNetworkInterfaceByName(HifName.raw(),
     4199                rc = host->FindHostNetworkInterfaceByName(HostOnlyName.raw(),
    41934200                                                          hostInterface.asOutParam());
    41944201                if (!SUCCEEDED(rc))
     
    41974204                    return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
    41984205                                      N_("Nonexistent host networking interface, name '%ls'"),
    4199                                       HifName.raw());
     4206                                      HostOnlyName.raw());
    42004207                }
    42014208
    42024209                char szNetwork[INTNET_MAX_NETWORK_NAME];
    4203                 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
     4210                RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHostOnlyName);
    42044211
    42054212#if defined(RT_OS_WINDOWS)
     
    42224229                    return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
    42234230                                      N_("Interface ('%ls') is not a Host-Only Adapter interface"),
    4224                                       HifName.raw());
     4231                                      HostOnlyName.raw());
    42254232
    42264233                hrc = hostInterface->COMGETTER(Id)(bstr.asOutParam());
     
    43134320# endif /* defined VBOX_WITH_NETFLT*/
    43144321#elif defined(RT_OS_DARWIN)
    4315                 InsertConfigString(pCfg, "Trunk", pszHifName);
     4322                InsertConfigString(pCfg, "Trunk", pszHostOnlyName);
    43164323                InsertConfigString(pCfg, "Network", szNetwork);
    43174324                InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp);
    43184325                networkName = Bstr(szNetwork);
    4319                 trunkName   = Bstr(pszHifName);
     4326                trunkName   = Bstr(pszHostOnlyName);
    43204327                trunkType   = TRUNKTYPE_NETADP;
    43214328#else
    4322                 InsertConfigString(pCfg, "Trunk", pszHifName);
     4329                InsertConfigString(pCfg, "Trunk", pszHostOnlyName);
    43234330                InsertConfigString(pCfg, "Network", szNetwork);
    43244331                InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt);
    43254332                networkName = Bstr(szNetwork);
    4326                 trunkName   = Bstr(pszHifName);
     4333                trunkName   = Bstr(pszHostOnlyName);
    43274334                trunkType   = TRUNKTYPE_NETFLT;
    43284335#endif
     
    43344341
    43354342                hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPAddress",
    4336                                                        pszHifName).raw(),
     4343                                                       pszHostOnlyName).raw(),
    43374344                                               tmpAddr.asOutParam());
    43384345                if (SUCCEEDED(hrc) && !tmpAddr.isEmpty())
    43394346                {
    43404347                    hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPNetMask",
    4341                                                            pszHifName).raw(),
     4348                                                           pszHostOnlyName).raw(),
    43424349                                                   tmpMask.asOutParam());
    43434350                    if (SUCCEEDED(hrc) && !tmpMask.isEmpty())
     
    43514358                {
    43524359                    /* Grab the IP number from the 'vboxnetX' instance number (see netif.h) */
    4353                     hrc = hostInterface->EnableStaticIpConfig(getDefaultIPv4Address(Bstr(pszHifName)).raw(),
     4360                    hrc = hostInterface->EnableStaticIpConfig(getDefaultIPv4Address(Bstr(pszHostOnlyName)).raw(),
    43544361                                                              Bstr(VBOXNET_IPV4MASK_DEFAULT).raw());
    43554362                }
     
    43584365
    43594366                hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address",
    4360                                                        pszHifName).raw(),
     4367                                                       pszHostOnlyName).raw(),
    43614368                                               tmpAddr.asOutParam());
    43624369                if (SUCCEEDED(hrc))
    4363                     hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHifName).raw(),
     4370                    hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHostOnlyName).raw(),
    43644371                                                   tmpMask.asOutParam());
    43654372                if (SUCCEEDED(hrc) && !tmpAddr.isEmpty() && !tmpMask.isEmpty())
     
    43734380            }
    43744381
    4375 #if defined(VBOX_WITH_VDE)
    4376             case NetworkAttachmentType_VDE:
    4377             {
    4378                 hrc = aNetworkAdapter->COMGETTER(VDENetwork)(bstr.asOutParam());            H();
    4379                 InsertConfigNode(pInst, "LUN#0", &pLunL0);
    4380                 InsertConfigString(pLunL0, "Driver", "VDE");
     4382            case NetworkAttachmentType_Generic:
     4383            {
     4384                hrc = aNetworkAdapter->COMGETTER(GenericDriver)(bstr.asOutParam());         H();
     4385                SafeArray<BSTR> names;
     4386                SafeArray<BSTR> values;
     4387                hrc = aNetworkAdapter->GetProperties((CBSTR)L"",
     4388                                                     ComSafeArrayAsOutParam(names),
     4389                                                     ComSafeArrayAsOutParam(values));       H();
     4390
     4391                if (fSniffer)
     4392                    InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
     4393                else
     4394                    InsertConfigNode(pInst, "LUN#0", &pLunL0);
     4395                InsertConfigString(pLunL0, "Driver", bstr);
    43814396                InsertConfigNode(pLunL0, "Config", &pCfg);
    4382                 if (!bstr.isEmpty())
    4383                 {
    4384                     InsertConfigString(pCfg, "Network", bstr);
    4385                     networkName = bstr;
     4397                for (size_t ii = 0; ii < names.size(); ++ii)
     4398                {
     4399                    if (values[ii] && *values[ii])
     4400                    {
     4401                        Utf8Str name = names[ii];
     4402                        Utf8Str value = values[ii];
     4403                        InsertConfigString(pCfg, name.c_str(), value);
     4404                    }
    43864405                }
    43874406                break;
    43884407            }
    4389 #endif
    43904408
    43914409            default:
     
    44064424            case NetworkAttachmentType_HostOnly:
    44074425            case NetworkAttachmentType_NAT:
    4408 #if defined(VBOX_WITH_VDE)
    4409             case NetworkAttachmentType_VDE:
    4410 #endif
     4426            case NetworkAttachmentType_Generic:
    44114427            {
    44124428                if (SUCCEEDED(hrc) && SUCCEEDED(rc))
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r35368 r37200  
    66
    77/*
    8  * Copyright (C) 2008-2010 Oracle Corporation
     8 * Copyright (C) 2008-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    267267        case NetworkAttachmentType_Internal: strType = "Internal"; break;
    268268        case NetworkAttachmentType_HostOnly: strType = "HostOnly"; break;
    269         case NetworkAttachmentType_VDE: strType = "VDE"; break;
     269        case NetworkAttachmentType_Generic: strType = "Generic"; break;
    270270        case NetworkAttachmentType_Null: strType = "Null"; break;
    271271    }
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r37096 r37200  
    405405                         && (strNetwork.compare("Internal", Utf8Str::CaseInsensitive))
    406406                         && (strNetwork.compare("HostOnly", Utf8Str::CaseInsensitive))
    407                          && (strNetwork.compare("VDE", Utf8Str::CaseInsensitive))
     407                         && (strNetwork.compare("Generic", Utf8Str::CaseInsensitive))
    408408                       )
    409409                        strNetwork = "Bridged";     // VMware assumes this is the default apparently
     
    20452045            {
    20462046                /* Attach to the right interface */
    2047                 rc = pNetworkAdapter->AttachToBridgedInterface();
     2047                rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_Bridged);
    20482048                if (FAILED(rc)) throw rc;
    20492049                ComPtr<IHost> host;
     
    20682068                        if (FAILED(rc)) throw rc;
    20692069                        /* Set the interface name to attach to */
    2070                         pNetworkAdapter->COMSETTER(HostInterface)(name.raw());
     2070                        pNetworkAdapter->COMSETTER(BridgedInterface)(name.raw());
    20712071                        if (FAILED(rc)) throw rc;
    20722072                        break;
     
    20782078            {
    20792079                /* Attach to the right interface */
    2080                 rc = pNetworkAdapter->AttachToHostOnlyInterface();
     2080                rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_HostOnly);
    20812081                if (FAILED(rc)) throw rc;
    20822082                ComPtr<IHost> host;
     
    21012101                        if (FAILED(rc)) throw rc;
    21022102                        /* Set the interface name to attach to */
    2103                         pNetworkAdapter->COMSETTER(HostInterface)(name.raw());
     2103                        pNetworkAdapter->COMSETTER(HostOnlyInterface)(name.raw());
    21042104                        if (FAILED(rc)) throw rc;
    21052105                        break;
     
    21112111            {
    21122112                /* Attach to the right interface */
    2113                 rc = pNetworkAdapter->AttachToInternalNetwork();
     2113                rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_Internal);
    21142114                if (FAILED(rc)) throw rc;
    21152115            }
    2116             /* Next test for VDE interfaces */
    2117             else if (pvsys->strExtraConfigCurrent.endsWith("type=VDE", Utf8Str::CaseInsensitive))
     2116            /* Next test for Generic interfaces */
     2117            else if (pvsys->strExtraConfigCurrent.endsWith("type=Generic", Utf8Str::CaseInsensitive))
    21182118            {
    21192119                /* Attach to the right interface */
    2120                 rc = pNetworkAdapter->AttachToVDE();
     2120                rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_Generic);
    21212121                if (FAILED(rc)) throw rc;
    21222122            }
  • trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp

    r36615 r37200  
    436436}
    437437
    438 STDMETHODIMP NetworkAdapter::COMGETTER(HostInterface)(BSTR *aHostInterface)
    439 {
    440     CheckComArgOutPointerValid(aHostInterface);
    441 
    442     AutoCaller autoCaller(this);
    443     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    444 
    445     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    446 
    447     mData->mHostInterface.cloneTo(aHostInterface);
    448 
    449     return S_OK;
    450 }
    451 
    452 STDMETHODIMP NetworkAdapter::COMSETTER(HostInterface)(IN_BSTR aHostInterface)
     438STDMETHODIMP NetworkAdapter::COMSETTER(AttachmentType)(
     439    NetworkAttachmentType_T aAttachmentType)
     440{
     441    AutoCaller autoCaller(this);
     442    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     443
     444    /* the machine needs to be mutable */
     445    AutoMutableStateDependency adep(mParent);
     446    if (FAILED(adep.rc())) return adep.rc();
     447
     448    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     449
     450    if (mData->mAttachmentType != aAttachmentType)
     451    {
     452        mData.backup();
     453
     454        /* there must an internal network name */
     455        if (mData->mInternalNetwork.isEmpty())
     456        {
     457            LogRel(("Internal network name not defined, setting to default \"intnet\"\n"));
     458            mData->mInternalNetwork = "intnet";
     459        }
     460
     461        mData->mAttachmentType = aAttachmentType;
     462
     463        m_fModified = true;
     464        // leave the lock before informing callbacks
     465        alock.release();
     466
     467        AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
     468        mParent->setModified(Machine::IsModified_NetworkAdapters);
     469        mlock.release();
     470
     471        /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
     472        mParent->onNetworkAdapterChange(this, TRUE);
     473    }
     474
     475    return S_OK;
     476}
     477
     478STDMETHODIMP NetworkAdapter::COMGETTER(BridgedInterface)(BSTR *aBridgedInterface)
     479{
     480    CheckComArgOutPointerValid(aBridgedInterface);
     481
     482    AutoCaller autoCaller(this);
     483    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     484
     485    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     486
     487    mData->mBridgedInterface.cloneTo(aBridgedInterface);
     488
     489    return S_OK;
     490}
     491
     492STDMETHODIMP NetworkAdapter::COMSETTER(BridgedInterface)(IN_BSTR aBridgedInterface)
    453493{
    454494    Bstr bstrEmpty("");
    455     if (!aHostInterface)
    456         aHostInterface = bstrEmpty.raw();
     495    if (!aBridgedInterface)
     496        aBridgedInterface = bstrEmpty.raw();
    457497
    458498    AutoCaller autoCaller(this);
     
    465505    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    466506
    467     if (mData->mHostInterface != aHostInterface)
     507    if (mData->mBridgedInterface != aBridgedInterface)
    468508    {
    469509        mData.backup();
    470         mData->mHostInterface = aHostInterface;
     510        mData->mBridgedInterface = aBridgedInterface;
     511
     512        m_fModified = true;
     513        // leave the lock before informing callbacks
     514        alock.release();
     515
     516        AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
     517        mParent->setModified(Machine::IsModified_NetworkAdapters);
     518        mlock.release();
     519
     520        /* When changing the host adapter, adapt the CFGM logic to make this
     521         * change immediately effect and to notify the guest that the network
     522         * might have changed, therefore changeAdapter=TRUE. */
     523        mParent->onNetworkAdapterChange(this, TRUE);
     524    }
     525
     526    return S_OK;
     527}
     528
     529STDMETHODIMP NetworkAdapter::COMGETTER(HostOnlyInterface)(BSTR *aHostOnlyInterface)
     530{
     531    CheckComArgOutPointerValid(aHostOnlyInterface);
     532
     533    AutoCaller autoCaller(this);
     534    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     535
     536    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     537
     538    mData->mHostOnlyInterface.cloneTo(aHostOnlyInterface);
     539
     540    return S_OK;
     541}
     542
     543STDMETHODIMP NetworkAdapter::COMSETTER(HostOnlyInterface)(IN_BSTR aHostOnlyInterface)
     544{
     545    Bstr bstrEmpty("");
     546    if (!aHostOnlyInterface)
     547        aHostOnlyInterface = bstrEmpty.raw();
     548
     549    AutoCaller autoCaller(this);
     550    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     551
     552    /* the machine needs to be mutable */
     553    AutoMutableStateDependency adep(mParent);
     554    if (FAILED(adep.rc())) return adep.rc();
     555
     556    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     557
     558    if (mData->mHostOnlyInterface != aHostOnlyInterface)
     559    {
     560        mData.backup();
     561        mData->mHostOnlyInterface = aHostOnlyInterface;
    471562
    472563        m_fModified = true;
     
    593684}
    594685
    595 STDMETHODIMP NetworkAdapter::COMGETTER(VDENetwork) (BSTR *aVDENetwork)
    596 {
    597 #if defined(VBOX_WITH_VDE)
    598     CheckComArgOutPointerValid(aVDENetwork);
    599 
    600     AutoCaller autoCaller(this);
    601     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    602 
    603     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    604 
    605     mData->mVDENetwork.cloneTo(aVDENetwork);
    606 
    607     return S_OK;
    608 #else
    609     NOREF(aVDENetwork);
    610     return E_NOTIMPL;
    611 #endif
    612 }
    613 
    614 STDMETHODIMP NetworkAdapter::COMSETTER(VDENetwork) (IN_BSTR aVDENetwork)
    615 {
    616 #if defined(VBOX_WITH_VDE)
     686STDMETHODIMP NetworkAdapter::COMGETTER(GenericDriver)(BSTR *aGenericDriver)
     687{
     688    CheckComArgOutPointerValid(aGenericDriver);
     689
     690    AutoCaller autoCaller(this);
     691    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     692
     693    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     694
     695    mData->mGenericDriver.cloneTo(aGenericDriver);
     696
     697    return S_OK;
     698}
     699
     700STDMETHODIMP NetworkAdapter::COMSETTER(GenericDriver)(IN_BSTR aGenericDriver)
     701{
    617702    Bstr bstrEmpty("");
    618     if (!aVDENetwork)
    619         aVDENetwork = bstrEmpty.raw();
     703    if (!aGenericDriver)
     704        aGenericDriver = bstrEmpty.raw();
    620705
    621706    AutoCaller autoCaller(this);
     
    623708
    624709    /* the machine needs to be mutable */
    625     AutoMutableStateDependency adep (mParent);
    626     if (FAILED(adep.rc())) return adep.rc();
    627 
    628     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    629 
    630     if (mData->mVDENetwork != aVDENetwork)
     710    AutoMutableStateDependency adep(mParent);
     711    if (FAILED(adep.rc())) return adep.rc();
     712
     713    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     714
     715    if (mData->mGenericDriver != aGenericDriver)
    631716    {
    632717        mData.backup();
    633         mData->mVDENetwork = aVDENetwork;
     718        mData->mGenericDriver = aGenericDriver;
    634719
    635720        /* leave the lock before informing callbacks */
    636721        alock.release();
    637722
    638         mParent->onNetworkAdapterChange (this, FALSE);
    639     }
    640 
    641     return S_OK;
    642 #else
    643     NOREF(aVDENetwork);
    644     return E_NOTIMPL;
    645 #endif
     723        mParent->onNetworkAdapterChange(this, FALSE);
     724    }
     725
     726    return S_OK;
    646727}
    647728
     
    9351016////////////////////////////////////////////////////////////////////////////////
    9361017
    937 STDMETHODIMP NetworkAdapter::AttachToNAT()
    938 {
    939     AutoCaller autoCaller(this);
    940     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    941 
    942     /* the machine needs to be mutable */
    943     AutoMutableStateDependency adep(mParent);
    944     if (FAILED(adep.rc())) return adep.rc();
    945 
    946     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    947 
    948     if (mData->mAttachmentType != NetworkAttachmentType_NAT)
    949     {
    950         mData.backup();
    951 
    952         // Commented this for now as it resets the parameter mData->mNATNetwork
    953         // which is essential while changing the Attachment dynamically.
    954         //detach();
    955 
    956         mData->mAttachmentType = NetworkAttachmentType_NAT;
    957 
    958         m_fModified = true;
    959         // leave the lock before informing callbacks
    960         alock.release();
    961 
    962         AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
     1018STDMETHODIMP NetworkAdapter::GetProperty(IN_BSTR aKey, BSTR *aValue)
     1019{
     1020    CheckComArgOutPointerValid(aValue);
     1021
     1022    AutoCaller autoCaller(this);
     1023    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1024
     1025    Bstr key = aKey;
     1026    Bstr value;
     1027
     1028    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     1029
     1030    Utf8Str strKey(key);
     1031    settings::StringsMap::const_iterator it = mData->mGenericProperties.find(strKey);
     1032    if (it != mData->mGenericProperties.end())
     1033    {
     1034        value = it->second; // source is a Utf8Str
     1035        value.cloneTo(aValue);
     1036    }
     1037
     1038    return S_OK;
     1039}
     1040
     1041STDMETHODIMP NetworkAdapter::SetProperty(IN_BSTR aKey, IN_BSTR aValue)
     1042{
     1043    LogFlowThisFunc(("\n"));
     1044
     1045    AutoCaller autoCaller(this);
     1046    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1047
     1048    /* The machine needs to be mutable. */
     1049    AutoMutableStateDependency adep(mParent);
     1050    if (FAILED(adep.rc())) return adep.rc();
     1051
     1052    Bstr key = aKey;
     1053
     1054    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     1055
     1056    bool fGenericChange = (mData->mAttachmentType == NetworkAttachmentType_Generic);
     1057
     1058    /* Generic properties processing.
     1059     * Look up the old value first; if nothing's changed then do nothing.
     1060     */
     1061    Utf8Str strValue(aValue);
     1062    Utf8Str strKey(aKey);
     1063    Utf8Str strOldValue;
     1064
     1065    settings::StringsMap::const_iterator it = mData->mGenericProperties.find(strKey);
     1066    if (it != mData->mGenericProperties.end())
     1067        strOldValue = it->second;
     1068
     1069    if (strOldValue != strValue)
     1070    {
     1071        if (strValue.isEmpty())
     1072            mData->mGenericProperties.erase(strKey);
     1073        else
     1074            mData->mGenericProperties[strKey] = strValue;
     1075
     1076        /* leave the lock before informing callbacks */
     1077        alock.release();
     1078
     1079        AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);
    9631080        mParent->setModified(Machine::IsModified_NetworkAdapters);
    9641081        mlock.release();
    9651082
    966         /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
    967         HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);
    968         if (FAILED(rc))
    969         {
    970             /* If changing the attachment failed then we can't assume
    971              * that the previous attachment will attach correctly
    972              * and thus return error along with detaching all
    973              * attachments.
    974              */
    975             Detach();
    976             return rc;
    977         }
    978     }
    979 
    980     return S_OK;
    981 }
    982 
    983 STDMETHODIMP NetworkAdapter::AttachToBridgedInterface()
    984 {
    985     AutoCaller autoCaller(this);
    986     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    987 
    988     /* the machine needs to be mutable */
    989     AutoMutableStateDependency adep(mParent);
    990     if (FAILED(adep.rc())) return adep.rc();
    991 
    992     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    993 
    994     /* don't do anything if we're already host interface attached */
    995     if (mData->mAttachmentType != NetworkAttachmentType_Bridged)
    996     {
    997         mData.backup();
    998 
    999         /* first detach the current attachment */
    1000         // Commented this for now as it reset the parameter mData->mHostInterface
    1001         // which is essential while changing the Attachment dynamically.
    1002         //detach();
    1003 
    1004         mData->mAttachmentType = NetworkAttachmentType_Bridged;
    1005 
    1006         m_fModified = true;
    1007         // leave the lock before informing callbacks
    1008         alock.release();
    1009 
    1010         AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
    1011         mParent->setModified(Machine::IsModified_NetworkAdapters);
    1012         mlock.release();
    1013 
    1014         /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
    1015         HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);
    1016         if (FAILED(rc))
    1017         {
    1018             /* If changing the attachment failed then we can't assume that the
    1019              * previous attachment will attach correctly and thus return error
    1020              * along with detaching all attachments.
    1021              */
    1022             Detach();
    1023             return rc;
    1024         }
    1025     }
    1026 
    1027     return S_OK;
    1028 }
    1029 
    1030 STDMETHODIMP NetworkAdapter::AttachToInternalNetwork()
    1031 {
    1032     AutoCaller autoCaller(this);
    1033     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    1034 
    1035     /* the machine needs to be mutable */
    1036     AutoMutableStateDependency adep(mParent);
    1037     if (FAILED(adep.rc())) return adep.rc();
    1038 
    1039     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1040 
    1041     /* don't do anything if we're already internal network attached */
    1042     if (mData->mAttachmentType != NetworkAttachmentType_Internal)
    1043     {
    1044         mData.backup();
    1045 
    1046         /* first detach the current attachment */
    1047         // Commented this for now as it reset the parameter mData->mInternalNetwork
    1048         // which is essential while changing the Attachment dynamically.
    1049         //detach();
    1050 
    1051         /* there must an internal network name */
    1052         if (mData->mInternalNetwork.isEmpty())
    1053         {
    1054             LogRel (("Internal network name not defined, "
    1055                      "setting to default \"intnet\"\n"));
    1056             mData->mInternalNetwork = "intnet";
    1057         }
    1058 
    1059         mData->mAttachmentType = NetworkAttachmentType_Internal;
    1060 
    1061         m_fModified = true;
    1062         // leave the lock before informing callbacks
    1063         alock.release();
    1064 
    1065         AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
    1066         mParent->setModified(Machine::IsModified_NetworkAdapters);
    1067         mlock.release();
    1068 
    1069         /* Adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
    1070         HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);
    1071         if (FAILED(rc))
    1072         {
    1073             /* If changing the attachment failed then we can't assume
    1074              * that the previous attachment will attach correctly
    1075              * and thus return error along with detaching all
    1076              * attachments.
    1077              */
    1078             Detach();
    1079             return rc;
    1080         }
    1081     }
    1082 
    1083     return S_OK;
    1084 }
    1085 
    1086 STDMETHODIMP NetworkAdapter::AttachToHostOnlyInterface()
    1087 {
    1088     AutoCaller autoCaller(this);
    1089     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    1090 
    1091     /* the machine needs to be mutable */
    1092     AutoMutableStateDependency adep(mParent);
    1093     if (FAILED(adep.rc())) return adep.rc();
    1094 
    1095     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1096 
    1097     /* don't do anything if we're already host interface attached */
    1098     if (mData->mAttachmentType != NetworkAttachmentType_HostOnly)
    1099     {
    1100         mData.backup();
    1101 
    1102         /* first detach the current attachment */
    1103         // Commented this for now as it reset the parameter mData->mHostInterface
    1104         // which is essential while changing the Attachment dynamically.
    1105         //detach();
    1106 
    1107         mData->mAttachmentType = NetworkAttachmentType_HostOnly;
    1108 
    1109         m_fModified = true;
    1110         // leave the lock before informing callbacks
    1111         alock.release();
    1112 
    1113         AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
    1114         mParent->setModified(Machine::IsModified_NetworkAdapters);
    1115         mlock.release();
    1116 
    1117         /* Adapt the CFGM logic and notify the guest => changeAdpater=TRUE. */
    1118         HRESULT rc = mParent->onNetworkAdapterChange(this, TRUE);
    1119         if (FAILED(rc))
    1120         {
    1121             /* If changing the attachment failed then we can't assume
    1122              * that the previous attachment will attach correctly
    1123              * and thus return error along with detaching all
    1124              * attachments.
    1125              */
    1126             Detach();
    1127             return rc;
    1128         }
    1129     }
    1130 
    1131     return S_OK;
    1132 }
    1133 
    1134 STDMETHODIMP NetworkAdapter::AttachToVDE()
    1135 {
    1136 #if defined(VBOX_WITH_VDE)
    1137     AutoCaller autoCaller(this);
    1138     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    1139 
    1140     /* the machine needs to be mutable */
    1141     AutoMutableStateDependency adep (mParent);
    1142     if (FAILED(adep.rc())) return adep.rc();
    1143 
    1144     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1145 
    1146     /* don't do anything if we're already host interface attached */
    1147     if (mData->mAttachmentType != NetworkAttachmentType_VDE)
    1148     {
    1149         mData.backup();
    1150 
    1151         /* first detach the current attachment */
    1152         // Commented this for now as it reset the parameter mData->mHostInterface
    1153         // which is essential while changing the Attachment dynamically.
    1154         //detach();
    1155 
    1156         mData->mAttachmentType = NetworkAttachmentType_VDE;
    1157 
    1158         /* leave the lock before informing callbacks */
    1159         alock.release();
    1160 
    1161         HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE);
    1162         if (FAILED (rc))
    1163         {
    1164             /* If changing the attachment failed then we can't assume
    1165              * that the previous attachment will attach correctly
    1166              * and thus return error along with detaching all
    1167              * attachments.
    1168              */
    1169             Detach();
    1170             return rc;
    1171         }
    1172     }
    1173 
    1174     return S_OK;
    1175 #else /* !VBOX_WITH_VDE */
    1176     return E_NOTIMPL;
    1177 #endif
    1178 }
    1179 
    1180 STDMETHODIMP NetworkAdapter::Detach()
    1181 {
    1182     AutoCaller autoCaller(this);
    1183     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    1184 
    1185     /* the machine needs to be mutable */
    1186     AutoMutableStateDependency adep(mParent);
    1187     if (FAILED(adep.rc())) return adep.rc();
    1188 
    1189     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1190 
    1191     if (mData->mAttachmentType != NetworkAttachmentType_Null)
    1192     {
    1193         mData.backup();
    1194 
    1195         detach();
    1196 
    1197         m_fModified = true;
    1198         // leave the lock before informing callbacks
    1199         alock.release();
    1200 
    1201         AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
    1202         mParent->setModified(Machine::IsModified_NetworkAdapters);
    1203         mlock.release();
    1204 
    1205         /* adapt the CFGM logic and notify the guest => changeAdapter=TRUE. */
    1206         mParent->onNetworkAdapterChange(this, TRUE);
    1207     }
    1208 
    1209     return S_OK;
    1210 }
     1083        /* Avoid deadlock when the event triggers a call to a method of this
     1084         * interface. */
     1085        adep.release();
     1086
     1087        mParent->onNetworkAdapterChange(this, fGenericChange);
     1088    }
     1089
     1090    return S_OK;
     1091}
     1092
     1093STDMETHODIMP NetworkAdapter::GetProperties(IN_BSTR aNames,
     1094                                           ComSafeArrayOut(BSTR, aReturnNames),
     1095                                           ComSafeArrayOut(BSTR, aReturnValues))
     1096{
     1097    CheckComArgOutSafeArrayPointerValid(aReturnNames);
     1098    CheckComArgOutSafeArrayPointerValid(aReturnValues);
     1099
     1100    AutoCaller autoCaller(this);
     1101    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1102
     1103    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     1104
     1105    /// @todo make use of aNames according to the documentation
     1106    NOREF(aNames);
     1107
     1108    com::SafeArray<BSTR> names(mData->mGenericProperties.size());
     1109    com::SafeArray<BSTR> values(mData->mGenericProperties.size());
     1110    size_t i = 0;
     1111
     1112    for (settings::StringsMap::const_iterator it = mData->mGenericProperties.begin();
     1113         it != mData->mGenericProperties.end();
     1114         ++it)
     1115    {
     1116        it->first.cloneTo(&names[i]);
     1117        it->second.cloneTo(&values[i]);
     1118        ++i;
     1119    }
     1120
     1121    names.detachTo(ComSafeArrayOutArg(aReturnNames));
     1122    values.detachTo(ComSafeArrayOutArg(aReturnValues));
     1123
     1124    return S_OK;
     1125}
     1126
     1127
    12111128
    12121129// public methods only for internal purposes
     
    12671184    }
    12681185
    1269     // leave the lock before attaching
     1186    mNATEngine->loadSettings(data.nat);
     1187    mData->mBridgedInterface = data.strBridgedName;
     1188    mData->mInternalNetwork = data.strInternalNetworkName;
     1189    mData->mHostOnlyInterface = data.strHostOnlyName;
     1190    mData->mGenericDriver = data.strGenericDriver;
     1191    mData->mGenericProperties = data.genericProperties;
     1192
     1193    // leave the lock before setting attachment type
    12701194    alock.release();
    12711195
    1272     switch (data.mode)
    1273     {
    1274         case NetworkAttachmentType_NAT:
    1275             mNATEngine->loadSettings(data.nat);
    1276             rc = AttachToNAT();
    1277             if (FAILED(rc)) return rc;
    1278         break;
    1279 
    1280         case NetworkAttachmentType_Bridged:
    1281             rc = COMSETTER(HostInterface)(Bstr(data.strName).raw());
    1282             if (FAILED(rc)) return rc;
    1283             rc = AttachToBridgedInterface();
    1284             if (FAILED(rc)) return rc;
    1285         break;
    1286 
    1287         case NetworkAttachmentType_Internal:
    1288             mData->mInternalNetwork = data.strName;
    1289             Assert(!mData->mInternalNetwork.isEmpty());
    1290 
    1291             rc = AttachToInternalNetwork();
    1292             if (FAILED(rc)) return rc;
    1293         break;
    1294 
    1295         case NetworkAttachmentType_HostOnly:
    1296 #if defined(VBOX_WITH_NETFLT)
    1297             rc = COMSETTER(HostInterface)(Bstr(data.strName).raw());
    1298             if (FAILED(rc)) return rc;
    1299 #endif
    1300             rc = AttachToHostOnlyInterface();
    1301             if (FAILED(rc)) return rc;
    1302         break;
    1303 
    1304 #if defined(VBOX_WITH_VDE)
    1305         case NetworkAttachmentType_VDE:
    1306             mData->mVDENetwork = data.strName;
    1307             rc = AttachToVDE();
    1308             if (FAILED(rc)) return rc;
    1309         break;
    1310 #endif
    1311 
    1312         case NetworkAttachmentType_Null:
    1313             rc = Detach();
    1314             if (FAILED(rc)) return rc;
    1315         break;
    1316     }
    1317     if (data.fHasDisabledNAT)
    1318         mNATEngine->loadSettings(data.nat);
     1196    rc = COMSETTER(AttachmentType)(data.mode);
     1197    if (FAILED(rc)) return rc;
    13191198
    13201199    // after loading settings, we are no longer different from the XML on disk
     
    13601239    data.type = mData->mAdapterType;
    13611240
    1362     switch (data.mode = mData->mAttachmentType)
    1363     {
    1364         case NetworkAttachmentType_Null:
    1365             data.strName.setNull();
    1366         break;
    1367 
    1368         case NetworkAttachmentType_NAT:
    1369             data.fHasDisabledNAT = 0;
    1370             mNATEngine->commit();
    1371             mNATEngine->saveSettings(data.nat);
    1372         break;
    1373 
    1374         case NetworkAttachmentType_Bridged:
    1375             data.strName = mData->mHostInterface;
    1376         break;
    1377 
    1378         case NetworkAttachmentType_Internal:
    1379             data.strName = mData->mInternalNetwork;
    1380         break;
    1381 
    1382         case NetworkAttachmentType_HostOnly:
    1383             data.strName = mData->mHostInterface;
    1384         break;
    1385 
    1386 #if defined(VBOX_WITH_VDE)
    1387         case NetworkAttachmentType_VDE:
    1388             data.strName = mData->mVDENetwork;
    1389         break;
    1390 #endif
    1391     }
    1392 
    1393     if (data.mode != NetworkAttachmentType_NAT)
    1394     {
    1395         data.fHasDisabledNAT = 1; /* ??? */
    1396         mNATEngine->commit();
    1397         mNATEngine->saveSettings(data.nat);
    1398     }
     1241    data.mode = mData->mAttachmentType;
     1242
     1243    mNATEngine->commit();
     1244    mNATEngine->saveSettings(data.nat);
     1245
     1246    data.strBridgedName = mData->mBridgedInterface;
     1247
     1248    data.strHostOnlyName = mData->mHostOnlyInterface;
     1249
     1250    data.strInternalNetworkName = mData->mInternalNetwork;
     1251
     1252    data.strGenericDriver = mData->mGenericDriver;
     1253    data.genericProperties = mData->mGenericProperties;
    13991254
    14001255    // after saving settings, we are no longer different from the XML on disk
     
    15201375// private methods
    15211376////////////////////////////////////////////////////////////////////////////////
    1522 
    1523 /**
    1524  *  Worker routine for detach handling. No locking, no notifications.
    1525 
    1526  *  @note Must be called from under the object's write lock.
    1527  */
    1528 void NetworkAdapter::detach()
    1529 {
    1530     AssertReturnVoid (isWriteLockOnCurrentThread());
    1531 
    1532     switch (mData->mAttachmentType)
    1533     {
    1534         case NetworkAttachmentType_Null:
    1535         {
    1536             /* nothing to do here */
    1537             break;
    1538         }
    1539         case NetworkAttachmentType_NAT:
    1540         {
    1541             break;
    1542         }
    1543         case NetworkAttachmentType_Bridged:
    1544         {
    1545             /* reset handle and device name */
    1546             mData->mHostInterface = "";
    1547             break;
    1548         }
    1549         case NetworkAttachmentType_Internal:
    1550         {
    1551             mData->mInternalNetwork.setNull();
    1552             break;
    1553         }
    1554         case NetworkAttachmentType_HostOnly:
    1555         {
    1556 #if defined(VBOX_WITH_NETFLT)
    1557             /* reset handle and device name */
    1558             mData->mHostInterface = "";
    1559 #endif
    1560             break;
    1561         }
    1562     }
    1563 
    1564     mData->mAttachmentType = NetworkAttachmentType_Null;
    1565 }
    15661377
    15671378/**
  • trunk/src/VBox/Main/xml/Settings.cpp

    r36527 r37200  
    14801480                  && (mode                  == n.mode)
    14811481                  && (nat                   == n.nat)
    1482                   && (strName               == n.strName)
     1482                  && (strBridgedName        == n.strBridgedName)
     1483                  && (strHostOnlyName       == n.strHostOnlyName)
     1484                  && (strInternalNetworkName == n.strInternalNetworkName)
     1485                  && (strGenericDriver      == n.strGenericDriver)
     1486                  && (genericProperties     == n.genericProperties)
    14831487                  && (ulBootPriority        == n.ulBootPriority)
    1484                   && (fHasDisabledNAT       == n.fHasDisabledNAT)
    14851488                )
    14861489           );
     
    19972000void MachineConfigFile::readAttachedNetworkMode(const xml::ElementNode &elmMode, bool fEnabled, NetworkAdapter &nic)
    19982001{
     2002    NetworkAttachmentType_T enmAttachmentType = NetworkAttachmentType_Null;
     2003
    19992004    if (elmMode.nameEquals("NAT"))
    20002005    {
    2001         if (fEnabled)
    2002             nic.mode = NetworkAttachmentType_NAT;
    2003 
    2004         nic.fHasDisabledNAT = (nic.mode != NetworkAttachmentType_NAT && !fEnabled);
    2005         elmMode.getAttributeValue("network", nic.nat.strNetwork);    // optional network name
     2006        enmAttachmentType = NetworkAttachmentType_NAT;
     2007
    20062008        elmMode.getAttributeValue("hostip", nic.nat.strBindIP);
    20072009        elmMode.getAttributeValue("mtu", nic.nat.u32Mtu);
     
    20482050        }
    20492051    }
    2050     else if (   fEnabled
    2051              && (   (elmMode.nameEquals("HostInterface"))
    2052                  || (elmMode.nameEquals("BridgedInterface")))
    2053             )
    2054     {
    2055         nic.mode = NetworkAttachmentType_Bridged;
    2056         elmMode.getAttributeValue("name", nic.strName);    // optional host interface name
    2057     }
    2058     else if (   fEnabled
    2059              && elmMode.nameEquals("InternalNetwork"))
    2060     {
    2061         nic.mode = NetworkAttachmentType_Internal;
    2062         if (!elmMode.getAttributeValue("name", nic.strName))    // required network name
     2052    else if (   (elmMode.nameEquals("HostInterface"))
     2053             || (elmMode.nameEquals("BridgedInterface")))
     2054    {
     2055        enmAttachmentType = NetworkAttachmentType_Bridged;
     2056
     2057        elmMode.getAttributeValue("name", nic.strBridgedName);  // optional bridged interface name
     2058    }
     2059    else if (elmMode.nameEquals("InternalNetwork"))
     2060    {
     2061        enmAttachmentType = NetworkAttachmentType_Internal;
     2062
     2063        if (!elmMode.getAttributeValue("name", nic.strInternalNetworkName))    // required network name
    20632064            throw ConfigFileError(this, &elmMode, N_("Required InternalNetwork/@name element is missing"));
    20642065    }
    2065     else if (   fEnabled
    2066              && elmMode.nameEquals("HostOnlyInterface"))
    2067     {
    2068         nic.mode = NetworkAttachmentType_HostOnly;
    2069         if (!elmMode.getAttributeValue("name", nic.strName))    // required network name
     2066    else if (elmMode.nameEquals("HostOnlyInterface"))
     2067    {
     2068        enmAttachmentType = NetworkAttachmentType_HostOnly;
     2069
     2070        if (!elmMode.getAttributeValue("name", nic.strHostOnlyName))    // required network name
    20702071            throw ConfigFileError(this, &elmMode, N_("Required HostOnlyInterface/@name element is missing"));
    20712072    }
    2072 #if defined(VBOX_WITH_VDE)
    2073     else if (   fEnabled
    2074              && elmMode.nameEquals("VDE"))
    2075     {
    2076         nic.mode = NetworkAttachmentType_VDE;
    2077         elmMode.getAttributeValue("network", nic.strName);    // optional network name
    2078     }
    2079 #endif
     2073    else if (elmMode.nameEquals("GenericInterface"))
     2074    {
     2075        enmAttachmentType = NetworkAttachmentType_Generic;
     2076
     2077        elmMode.getAttributeValue("driver", nic.strGenericDriver);  // optional network attachment driver
     2078
     2079        // get all properties
     2080        xml::NodesLoop nl(elmMode);
     2081        const xml::ElementNode *pelmModeChild;
     2082        while ((pelmModeChild = nl.forAllNodes()))
     2083        {
     2084            if (pelmModeChild->nameEquals("Property"))
     2085            {
     2086                Utf8Str strPropName, strPropValue;
     2087                if (    (pelmModeChild->getAttributeValue("name", strPropName))
     2088                     && (pelmModeChild->getAttributeValue("value", strPropValue))
     2089                   )
     2090                    nic.genericProperties[strPropName] = strPropValue;
     2091                else
     2092                    throw ConfigFileError(this, pelmModeChild, N_("Required GenericInterface/Property/@name or @value attribute is missing"));
     2093            }
     2094        }
     2095    }
     2096    else if (elmMode.nameEquals("VDE"))
     2097    {
     2098        enmAttachmentType = NetworkAttachmentType_Generic;
     2099
     2100        com::Utf8Str strVDEName;
     2101        elmMode.getAttributeValue("network", strVDEName);   // optional network name
     2102        nic.strGenericDriver = "VDE";
     2103        nic.genericProperties["network"] = strVDEName;
     2104    }
     2105
     2106    if (fEnabled && enmAttachmentType != NetworkAttachmentType_Null)
     2107        nic.mode = enmAttachmentType;
    20802108}
    20812109
     
    37473775
    37483776                case NetworkAttachmentType_Bridged:
    3749                     pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.strName);
     3777                    pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.strBridgedName);
    37503778                break;
    37513779
    37523780                case NetworkAttachmentType_Internal:
    3753                     pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.strName);
     3781                    pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.strInternalNetworkName);
    37543782                break;
    37553783
    37563784                case NetworkAttachmentType_HostOnly:
    3757                     pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.strName);
     3785                    pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.strHostOnlyName);
    37583786                break;
    3759 
    3760 #if defined(VBOX_WITH_VDE)
    3761                 case NetworkAttachmentType_VDE:
    3762                     pelmAdapter->createChild("VDE")->setAttribute("network", nic.strName);
    3763                 break;
    3764 #endif
    37653787
    37663788                default: /*case NetworkAttachmentType_Null:*/
     
    37713793        {
    37723794            /* m->sv >= SettingsVersion_v1_10 */
    3773             xml::ElementNode *pelmDisabledNode= NULL;
    3774             if (nic.fHasDisabledNAT)
    3775                 pelmDisabledNode = pelmAdapter->createChild("DisabledModes");
    3776             if (nic.fHasDisabledNAT)
    3777                 buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, nic);
    3778             buildNetworkXML(nic.mode, *pelmAdapter, nic);
     3795            xml::ElementNode *pelmDisabledNode = NULL;
     3796            pelmDisabledNode = pelmAdapter->createChild("DisabledModes");
     3797            if (nic.mode != NetworkAttachmentType_NAT)
     3798                buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, false, nic);
     3799            if (nic.mode != NetworkAttachmentType_Bridged)
     3800                buildNetworkXML(NetworkAttachmentType_Bridged, *pelmDisabledNode, false, nic);
     3801            if (nic.mode != NetworkAttachmentType_Internal)
     3802                buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, false, nic);
     3803            if (nic.mode != NetworkAttachmentType_HostOnly)
     3804                buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, false, nic);
     3805            if (nic.mode != NetworkAttachmentType_Generic)
     3806                buildNetworkXML(NetworkAttachmentType_Generic, *pelmDisabledNode, false, nic);
     3807            buildNetworkXML(nic.mode, *pelmAdapter, true, nic);
    37793808        }
    37803809    }
     
    39724001 * @param mode
    39734002 * @param elmParent
    3974  * @param nice
     4003 * @param fEnabled
     4004 * @param nic
    39754005 */
    39764006void MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode,
    39774007                                        xml::ElementNode &elmParent,
     4008                                        bool fEnabled,
    39784009                                        const NetworkAdapter &nic)
    39794010{
     
    40434074
    40444075        case NetworkAttachmentType_Bridged:
    4045             elmParent.createChild("BridgedInterface")->setAttribute("name", nic.strName);
     4076            if (fEnabled || !nic.strBridgedName.isEmpty())
     4077                elmParent.createChild("BridgedInterface")->setAttribute("name", nic.strBridgedName);
    40464078        break;
    40474079
    40484080        case NetworkAttachmentType_Internal:
    4049             elmParent.createChild("InternalNetwork")->setAttribute("name", nic.strName);
     4081            if (fEnabled || !nic.strInternalNetworkName.isEmpty())
     4082                elmParent.createChild("InternalNetwork")->setAttribute("name", nic.strInternalNetworkName);
    40504083        break;
    40514084
    40524085        case NetworkAttachmentType_HostOnly:
    4053             elmParent.createChild("HostOnlyInterface")->setAttribute("name", nic.strName);
     4086            if (fEnabled || !nic.strHostOnlyName.isEmpty())
     4087                elmParent.createChild("HostOnlyInterface")->setAttribute("name", nic.strHostOnlyName);
    40544088        break;
    40554089
    4056 #ifdef VBOX_WITH_VDE
    4057         case NetworkAttachmentType_VDE:
    4058             elmParent.createChild("VDE")->setAttribute("network", nic.strName);
     4090        case NetworkAttachmentType_Generic:
     4091            if (fEnabled || !nic.strGenericDriver.isEmpty() || nic.genericProperties.size())
     4092            {
     4093                xml::ElementNode *pelmMode = elmParent.createChild("GenericInterface");
     4094                pelmMode->setAttribute("driver", nic.strGenericDriver);
     4095                for (StringsMap::const_iterator it = nic.genericProperties.begin();
     4096                     it != nic.genericProperties.end();
     4097                     ++it)
     4098                {
     4099                    xml::ElementNode *pelmProp = pelmMode->createChild("Property");
     4100                    pelmProp->setAttribute("name", it->first);
     4101                    pelmProp->setAttribute("value", it->second);
     4102                }
     4103            }
    40594104        break;
    4060 #endif
    40614105
    40624106        default: /*case NetworkAttachmentType_Null:*/
     
    45124556    if (m->sv < SettingsVersion_v1_12)
    45134557    {
    4514         // VirtualBox 4.1 adds a promiscuous mode policy to the network adapters.
     4558        // VirtualBox 4.1 adds a promiscuous mode policy to the network
     4559        // adapters and a generic network driver transport.
    45154560        NetworkAdaptersList::const_iterator netit;
    45164561        for (netit = hardwareMachine.llNetworkAdapters.begin();
     
    45184563             ++netit)
    45194564        {
    4520             if (netit->enmPromiscModePolicy != NetworkAdapterPromiscModePolicy_Deny)
     4565            if (   netit->enmPromiscModePolicy != NetworkAdapterPromiscModePolicy_Deny
     4566                || netit->mode == NetworkAttachmentType_Generic
     4567                || !netit->strGenericDriver.isEmpty()
     4568                || netit->genericProperties.size()
     4569               )
    45214570            {
    45224571                m->sv = SettingsVersion_v1_12;
  • trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd

    r36945 r37200  
    77 *  Common definitions
    88
    9      Copyright (C) 2004-2010 Oracle Corporation
     9     Copyright (C) 2004-2011 Oracle Corporation
    1010
    1111     This file is part of VirtualBox Open Source Edition (OSE), as
     
    767767      </xsd:complexType>
    768768    </xsd:element>
     769    <xsd:element name="Generic">
     770      <xsd:complexType>
     771        <xsd:attribute name="driver" type="xsd:string" use="required"/>
     772      </xsd:complexType>
     773      <xsd:element name="Property" minOccurs="0" maxOccurs="unbounded">
     774        <xsd:complexType>
     775          <xsd:attribute name="name" type="xsd:token" use="required"/>
     776          <xsd:attribute name="value" type="xsd:string" use="required"/>
     777        </xsd:complexType>
     778      </xsd:element>
     779    </xsd:element>
     780    <!-- The DisabledModes tag is not part of this XSD file right now. -->
    769781  </xsd:choice>
    770782  <xsd:attribute name="type" type="TNetworkAdapterType" default="Am79C970A"/>
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