Changeset 37200 in vbox for trunk/src/VBox/Main
- Timestamp:
- May 24, 2011 3:34:06 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r36941 r37200 5 5 6 6 # 7 # Copyright (C) 2006-201 0Oracle Corporation7 # Copyright (C) 2006-2011 Oracle Corporation 8 8 # 9 9 # This file is part of VirtualBox Open Source Edition (OSE), as … … 62 62 $(if $(VBOX_WITH_GUEST_PROPS_RDONLY_GUEST),VBOX_WITH_GUEST_PROPS_RDONLY_GUEST,) \ 63 63 $(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,) 66 65 67 66 # Unconditionally enable the new semaphore key generation code -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r37069 r37200 272 272 <td> 273 273 Returned if a memory pointer for the output argument is invalid (for 274 example, @c null). Note that when pointers representing input275 a rguments (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. 276 276 </td> 277 277 </tr> … … 559 559 executed), only a few machine settings can be modified. Methods working 560 560 with such settings contain an explicit note about that. An attempt to 561 change any ot er setting or perform a modifying operation during this time561 change any other setting or perform a modifying operation during this time 562 562 will result in the @c VBOX_E_INVALID_VM_STATE error. 563 563 … … 1207 1207 through a single IVirtualBoxErrorInfo object set after method invocation. 1208 1208 1209 Note thaterrors are stored to a chain in the reverse order, i.e. the1209 <note>errors are stored to a chain in the reverse order, i.e. the 1210 1210 initial error object you query right after method invocation is the last 1211 1211 error set by the callee, the object it points to in the @a next attribute 1212 1212 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> 1214 1214 </desc> 1215 1215 … … 1768 1768 format and location for medium data. 1769 1769 1770 Note that the actual storage unit is not created by this method. In1771 order to do it, and before you are able to attach the created medium1772 tovirtual machines, you must call one of the following methods to1770 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 1773 1773 allocate a format-specific storage unit at the specified location: 1774 1774 <ul> … … 10226 10226 </method> 10227 10227 10228 <!-- storagemethods -->10228 <!-- property methods --> 10229 10229 10230 10230 <method name="getProperty"> … … 10235 10235 be obtained with <link to="IMediumFormat::describeProperties"/>. 10236 10236 10237 Note that if this method returns an empty string in @a value, the10238 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> 10239 10239 10240 10240 <result name="VBOX_E_OBJECT_NOT_FOUND"> … … 10258 10258 be obtained with <link to="IMediumFormat::describeProperties"/>. 10259 10259 10260 Note that setting the property value to @c null or an empty string is10260 <note>Setting the property value to @c null or an empty string is 10261 10261 equivalent to deleting the existing value. A default value (if it is 10262 10262 defined for this property) will be used by the format backend in this 10263 case. 10263 case.</note> 10264 10264 10265 10265 <result name="VBOX_E_OBJECT_NOT_FOUND"> … … 10282 10282 The names of the properties to get are specified using the @a names 10283 10283 argument which is a list of comma-separated property names or 10284 an empty string if all properties are to be returned. Note that currently10285 the value of this argument is ignored and the method always returns all10286 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> 10287 10287 10288 10288 The list of all properties supported by the given medium format can … … 10291 10291 The method returns two arrays, the array of property names corresponding 10292 10292 to the @a names argument and the current values of these properties. 10293 Both arrays have the same number of elements with each elemen dat the10293 Both arrays have the same number of elements with each element at the 10294 10294 given index in the first array corresponds to an element at the same 10295 10295 index in the second array. 10296 10296 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. 10300 10299 10301 10300 </desc> … … 10319 10318 The names of the properties to set are passed in the @a names 10320 10319 array along with the new values for them in the @a values array. Both 10321 arrays have the same number of elements with each elemen dat the given10320 arrays have the same number of elements with each element at the given 10322 10321 index in the first array corresponding to an element at the same index 10323 10322 in the second array. … … 10328 10327 10329 10328 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. 10332 10330 10333 10331 The list of all properties supported by the given medium format can 10334 10332 be obtained with <link to="IMediumFormat::describeProperties"/>. 10335 10333 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. 10340 10337 </desc> 10341 10338 <param name="names" type="wstring" safearray="yes" dir="in"> … … 11845 11842 <enum 11846 11843 name="NetworkAttachmentType" 11847 uuid=" 44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"11844 uuid="2ac4bc71-6b82-417a-acd1-f7426d2570d6" 11848 11845 > 11849 11846 <desc> … … 11858 11855 <const name="Internal" value="3"/> 11859 11856 <const name="HostOnly" value="4"/> 11860 <const name=" VDE"value="5"/>11857 <const name="Generic" value="5"/> 11861 11858 </enum> 11862 11859 … … 11919 11916 <interface 11920 11917 name="INetworkAdapter" extends="$unknown" 11921 uuid=" 6aa240a1-dd58-478e-92e8-aac001ce5547"11918 uuid="b22f71f6-082e-4a1d-aaf2-3ce40e275dd9" 11922 11919 wsmap="managed" 11923 11920 > … … 11966 11963 </attribute> 11967 11964 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. 11973 11980 </desc> 11974 11981 </attribute> … … 11986 11993 </attribute> 11987 11994 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. 11991 11998 </desc> 11992 11999 </attribute> … … 12030 12037 Points to the NAT engine which handles the network address translation 12031 12038 for this interface. This is active only when the interface actually uses 12032 NAT (see <link to="#attachToNAT" />).12039 NAT. 12033 12040 </desc> 12034 12041 </attribute> … … 12045 12052 </attribute> 12046 12053 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 12082 12119 </interface> 12083 12120 … … 12246 12283 <desc> 12247 12284 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 in to12285 @c null or an empty string as this attribute's value will result in 12249 12286 an error. 12250 12287 </desc> -
trunk/src/VBox/Main/include/NetworkAdapterImpl.h
r36275 r37200 7 7 8 8 /* 9 * Copyright (C) 2006-201 0Oracle Corporation9 * Copyright (C) 2006-2011 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 mPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny), 48 48 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 */, 53 51 mNATNetwork("") /* cannot be null */, 54 52 mBootPriority(0) … … 65 63 BOOL mTraceEnabled; 66 64 Bstr mTraceFile; 67 Bstr mHostInterface; 65 Bstr mBridgedInterface; 66 Bstr mHostOnlyInterface; 68 67 Bstr mInternalNetwork; 69 #ifdef VBOX_WITH_VDE70 Bstr mVDENetwork;71 #endif72 68 Bstr mNATNetwork; 69 Bstr mGenericDriver; 70 settings::StringsMap mGenericProperties; 73 71 ULONG mBootPriority; 74 72 ComObjPtr<BandwidthGroup> mBandwidthGroup; … … 82 80 83 81 BEGIN_COM_MAP(NetworkAdapter) 84 VBOX_DEFAULT_INTERFACE_ENTRIES 82 VBOX_DEFAULT_INTERFACE_ENTRIES(INetworkAdapter) 85 83 END_COM_MAP() 86 84 87 DECLARE_EMPTY_CTOR_DTOR 85 DECLARE_EMPTY_CTOR_DTOR(NetworkAdapter) 88 86 89 87 HRESULT FinalConstruct(); … … 91 89 92 90 // public initializer/uninitializer for internal purposes only 93 HRESULT init 94 HRESULT init 95 HRESULT initCopy 91 HRESULT init(Machine *aParent, ULONG aSlot); 92 HRESULT init(Machine *aParent, NetworkAdapter *aThat); 93 HRESULT initCopy(Machine *aParent, NetworkAdapter *aThat); 96 94 void uninit(); 97 95 … … 99 97 STDMETHOD(COMGETTER(AdapterType))(NetworkAdapterType_T *aAdapterType); 100 98 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); 121 122 STDMETHOD(COMGETTER(PromiscModePolicy))(NetworkAdapterPromiscModePolicy_T *aPromiscModePolicy); 122 123 STDMETHOD(COMSETTER(PromiscModePolicy))(NetworkAdapterPromiscModePolicy_T aPromiscModePolicy); 123 STDMETHOD(COMGETTER(TraceFile)) 124 STDMETHOD(COMSETTER(TraceFile)) 125 STDMETHOD(COMGETTER(NatDriver)) 126 STDMETHOD(COMGETTER(BootPriority)) 127 STDMETHOD(COMSETTER(BootPriority)) 128 STDMETHOD(COMGETTER(BandwidthGroup)) 129 STDMETHOD(COMSETTER(BandwidthGroup)) 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); 130 131 131 132 // 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)); 138 138 139 139 // public methods only for internal purposes … … 145 145 void rollback(); 146 146 void commit(); 147 void copyFrom 148 void applyDefaults 147 void copyFrom(NetworkAdapter *aThat); 148 void applyDefaults(GuestOSType *aOsType); 149 149 150 150 private: 151 151 152 void detach();153 152 void generateMACAddress(); 154 153 HRESULT updateMacAddress(Utf8Str aMacAddress); -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r37016 r37200 3335 3335 SafeArray<BSTR> names; 3336 3336 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(); 3340 3340 3341 3341 if (names.size() != 0) … … 3504 3504 } 3505 3505 3506 Utf8Str strNetDriver; 3506 3507 if (fAttachDetach && fSniffer) 3507 3508 { … … 3513 3514 pszNetDriver = "HostInterface"; 3514 3515 #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 } 3515 3522 3516 3523 rc = PDMR3DriverDetach(pVM, pszDevice, uInstance, uLun, pszNetDriver, 0, 0 /*fFlags*/); … … 3763 3770 } 3764 3771 3765 Bstr HifName;3766 hrc = aNetworkAdapter->COMGETTER( HostInterface)(HifName.asOutParam());3772 Bstr BridgedIfName; 3773 hrc = aNetworkAdapter->COMGETTER(BridgedInterface)(BridgedIfName.asOutParam()); 3767 3774 if (FAILED(hrc)) 3768 3775 { 3769 LogRel(("NetworkAttachmentType_Bridged: COMGETTER( HostInterface) failed, hrc (0x%x)", hrc));3776 LogRel(("NetworkAttachmentType_Bridged: COMGETTER(BridgedInterface) failed, hrc (0x%x)", hrc)); 3770 3777 H(); 3771 3778 } 3772 3779 3773 Utf8Str HifNameUtf8(HifName);3774 const char *psz HifName = HifNameUtf8.c_str();3780 Utf8Str BridgedIfNameUtf8(BridgedIfName); 3781 const char *pszBridgedIfName = BridgedIfNameUtf8.c_str(); 3775 3782 3776 3783 # if defined(RT_OS_DARWIN) 3777 3784 /* The name is on the form 'ifX: long name', chop it off at the colon. */ 3778 3785 char szTrunk[8]; 3779 RTStrCopy(szTrunk, sizeof(szTrunk), psz HifName);3786 RTStrCopy(szTrunk, sizeof(szTrunk), pszBridgedIfName); 3780 3787 char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk)); 3781 3788 // Quick fix for #5633 … … 3791 3798 // return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, 3792 3799 // N_("Malformed host interface networking name '%ls'"), 3793 // HifName.raw());3800 // BridgedIfName.raw()); 3794 3801 // } 3795 3802 if (pszColon) … … 3800 3807 /* The name is on the form format 'ifX[:1] - long name, chop it off at space. */ 3801 3808 char szTrunk[256]; 3802 strlcpy(szTrunk, psz HifName, sizeof(szTrunk));3809 strlcpy(szTrunk, pszBridgedIfName, sizeof(szTrunk)); 3803 3810 char *pszSpace = (char *)memchr(szTrunk, ' ', sizeof(szTrunk)); 3804 3811 … … 3820 3827 # elif defined(RT_OS_WINDOWS) 3821 3828 ComPtr<IHostNetworkInterface> hostInterface; 3822 hrc = host->FindHostNetworkInterfaceByName( HifName.raw(),3829 hrc = host->FindHostNetworkInterfaceByName(BridgedIfName.raw(), 3823 3830 hostInterface.asOutParam()); 3824 3831 if (!SUCCEEDED(hrc)) … … 3827 3834 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, 3828 3835 N_("Nonexistent host networking interface, name '%ls'"), 3829 HifName.raw());3836 BridgedIfName.raw()); 3830 3837 } 3831 3838 … … 3842 3849 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, 3843 3850 N_("Interface ('%ls') is not a Bridged Adapter interface"), 3844 HifName.raw());3851 BridgedIfName.raw()); 3845 3852 } 3846 3853 … … 3930 3937 * interface via the current FreeBSD vboxnetflt implementation. 3931 3938 */ 3932 if (!strncmp(psz HifName, "tap", sizeof "tap" - 1)) {3939 if (!strncmp(pszBridgedIfName, "tap", sizeof "tap" - 1)) { 3933 3940 hrc = attachToTapInterface(aNetworkAdapter); 3934 3941 if (FAILED(hrc)) … … 3942 3949 "sysctl is set. Either run 'chmod 0666 /dev/%s' or " 3943 3950 "change the group of that node to vboxusers and make yourself " 3944 "a member of that group. Make sure that these changes are permanent."), psz HifName, pszHifName);3951 "a member of that group. Make sure that these changes are permanent."), pszBridgedIfName, pszBridgedIfName); 3945 3952 default: 3946 3953 AssertMsgFailed(("Could not attach to tap interface! Bad!\n")); … … 3961 3968 # endif 3962 3969 /** @todo Check for malformed names. */ 3963 const char *pszTrunk = psz HifName;3970 const char *pszTrunk = pszBridgedIfName; 3964 3971 3965 3972 /* Issue a warning if the interface is down */ … … 3970 3977 struct ifreq Req; 3971 3978 RT_ZERO(Req); 3972 strncpy(Req.ifr_name, psz HifName, sizeof(Req.ifr_name) - 1);3979 strncpy(Req.ifr_name, pszBridgedIfName, sizeof(Req.ifr_name) - 1); 3973 3980 if (ioctl(iSock, SIOCGIFFLAGS, &Req) >= 0) 3974 3981 if ((Req.ifr_flags & IFF_UP) == 0) 3975 3982 setVMRuntimeErrorCallbackF(pVM, this, 0, "BridgedInterfaceDown", 3976 3983 "Bridged interface %s is down. Guest will not be able to use this interface", 3977 psz HifName);3984 pszBridgedIfName); 3978 3985 3979 3986 close(iSock); … … 3992 3999 InsertConfigString(pCfg, "IfPolicyPromisc", pszPromiscuousGuestPolicy); 3993 4000 char szNetwork[INTNET_MAX_NETWORK_NAME]; 3994 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", psz HifName);4001 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszBridgedIfName); 3995 4002 InsertConfigString(pCfg, "Network", szNetwork); 3996 4003 networkName = Bstr(szNetwork); … … 4000 4007 # if defined(RT_OS_DARWIN) 4001 4008 /** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */ 4002 if ( strstr(psz HifName, "Wireless")4003 || strstr(psz HifName, "AirPort" ))4009 if ( strstr(pszBridgedIfName, "Wireless") 4010 || strstr(pszBridgedIfName, "AirPort" )) 4004 4011 InsertConfigInteger(pCfg, "SharedMacOnWire", true); 4005 4012 # elif defined(RT_OS_LINUX) … … 4010 4017 4011 4018 memset(&WRq, 0, sizeof(WRq)); 4012 strncpy(WRq.ifr_name, psz HifName, IFNAMSIZ);4019 strncpy(WRq.ifr_name, pszBridgedIfName, IFNAMSIZ); 4013 4020 bool fSharedMacOnWire = ioctl(iSock, SIOCGIWNAME, &WRq) >= 0; 4014 4021 close(iSock); … … 4031 4038 4032 4039 memset(&WReq, 0, sizeof(WReq)); 4033 strncpy(WReq.i_name, psz HifName, sizeof(WReq.i_name));4040 strncpy(WReq.i_name, pszBridgedIfName, sizeof(WReq.i_name)); 4034 4041 WReq.i_type = IEEE80211_IOC_SSID; 4035 4042 WReq.i_val = -1; … … 4179 4186 InsertConfigNode(pLunL0, "Config", &pCfg); 4180 4187 4181 Bstr H ifName;4182 hrc = aNetworkAdapter->COMGETTER(Host Interface)(HifName.asOutParam());4188 Bstr HostOnlyName; 4189 hrc = aNetworkAdapter->COMGETTER(HostOnlyInterface)(HostOnlyName.asOutParam()); 4183 4190 if (FAILED(hrc)) 4184 4191 { 4185 LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(Host Interface) failed, hrc (0x%x)\n", hrc));4192 LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostOnlyInterface) failed, hrc (0x%x)\n", hrc)); 4186 4193 H(); 4187 4194 } 4188 4195 4189 Utf8Str H ifNameUtf8(HifName);4190 const char *pszH ifName = HifNameUtf8.c_str();4196 Utf8Str HostOnlyNameUtf8(HostOnlyName); 4197 const char *pszHostOnlyName = HostOnlyNameUtf8.c_str(); 4191 4198 ComPtr<IHostNetworkInterface> hostInterface; 4192 rc = host->FindHostNetworkInterfaceByName(H ifName.raw(),4199 rc = host->FindHostNetworkInterfaceByName(HostOnlyName.raw(), 4193 4200 hostInterface.asOutParam()); 4194 4201 if (!SUCCEEDED(rc)) … … 4197 4204 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, 4198 4205 N_("Nonexistent host networking interface, name '%ls'"), 4199 H ifName.raw());4206 HostOnlyName.raw()); 4200 4207 } 4201 4208 4202 4209 char szNetwork[INTNET_MAX_NETWORK_NAME]; 4203 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszH ifName);4210 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHostOnlyName); 4204 4211 4205 4212 #if defined(RT_OS_WINDOWS) … … 4222 4229 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, 4223 4230 N_("Interface ('%ls') is not a Host-Only Adapter interface"), 4224 H ifName.raw());4231 HostOnlyName.raw()); 4225 4232 4226 4233 hrc = hostInterface->COMGETTER(Id)(bstr.asOutParam()); … … 4313 4320 # endif /* defined VBOX_WITH_NETFLT*/ 4314 4321 #elif defined(RT_OS_DARWIN) 4315 InsertConfigString(pCfg, "Trunk", pszH ifName);4322 InsertConfigString(pCfg, "Trunk", pszHostOnlyName); 4316 4323 InsertConfigString(pCfg, "Network", szNetwork); 4317 4324 InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp); 4318 4325 networkName = Bstr(szNetwork); 4319 trunkName = Bstr(pszH ifName);4326 trunkName = Bstr(pszHostOnlyName); 4320 4327 trunkType = TRUNKTYPE_NETADP; 4321 4328 #else 4322 InsertConfigString(pCfg, "Trunk", pszH ifName);4329 InsertConfigString(pCfg, "Trunk", pszHostOnlyName); 4323 4330 InsertConfigString(pCfg, "Network", szNetwork); 4324 4331 InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); 4325 4332 networkName = Bstr(szNetwork); 4326 trunkName = Bstr(pszH ifName);4333 trunkName = Bstr(pszHostOnlyName); 4327 4334 trunkType = TRUNKTYPE_NETFLT; 4328 4335 #endif … … 4334 4341 4335 4342 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPAddress", 4336 pszH ifName).raw(),4343 pszHostOnlyName).raw(), 4337 4344 tmpAddr.asOutParam()); 4338 4345 if (SUCCEEDED(hrc) && !tmpAddr.isEmpty()) 4339 4346 { 4340 4347 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPNetMask", 4341 pszH ifName).raw(),4348 pszHostOnlyName).raw(), 4342 4349 tmpMask.asOutParam()); 4343 4350 if (SUCCEEDED(hrc) && !tmpMask.isEmpty()) … … 4351 4358 { 4352 4359 /* Grab the IP number from the 'vboxnetX' instance number (see netif.h) */ 4353 hrc = hostInterface->EnableStaticIpConfig(getDefaultIPv4Address(Bstr(pszH ifName)).raw(),4360 hrc = hostInterface->EnableStaticIpConfig(getDefaultIPv4Address(Bstr(pszHostOnlyName)).raw(), 4354 4361 Bstr(VBOXNET_IPV4MASK_DEFAULT).raw()); 4355 4362 } … … 4358 4365 4359 4366 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address", 4360 pszH ifName).raw(),4367 pszHostOnlyName).raw(), 4361 4368 tmpAddr.asOutParam()); 4362 4369 if (SUCCEEDED(hrc)) 4363 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszH ifName).raw(),4370 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHostOnlyName).raw(), 4364 4371 tmpMask.asOutParam()); 4365 4372 if (SUCCEEDED(hrc) && !tmpAddr.isEmpty() && !tmpMask.isEmpty()) … … 4373 4380 } 4374 4381 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); 4381 4396 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 } 4386 4405 } 4387 4406 break; 4388 4407 } 4389 #endif4390 4408 4391 4409 default: … … 4406 4424 case NetworkAttachmentType_HostOnly: 4407 4425 case NetworkAttachmentType_NAT: 4408 #if defined(VBOX_WITH_VDE) 4409 case NetworkAttachmentType_VDE: 4410 #endif 4426 case NetworkAttachmentType_Generic: 4411 4427 { 4412 4428 if (SUCCEEDED(hrc) && SUCCEEDED(rc)) -
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r35368 r37200 6 6 7 7 /* 8 * Copyright (C) 2008-201 0Oracle Corporation8 * Copyright (C) 2008-2011 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 267 267 case NetworkAttachmentType_Internal: strType = "Internal"; break; 268 268 case NetworkAttachmentType_HostOnly: strType = "HostOnly"; break; 269 case NetworkAttachmentType_ VDE: strType = "VDE"; break;269 case NetworkAttachmentType_Generic: strType = "Generic"; break; 270 270 case NetworkAttachmentType_Null: strType = "Null"; break; 271 271 } -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r37096 r37200 405 405 && (strNetwork.compare("Internal", Utf8Str::CaseInsensitive)) 406 406 && (strNetwork.compare("HostOnly", Utf8Str::CaseInsensitive)) 407 && (strNetwork.compare(" VDE", Utf8Str::CaseInsensitive))407 && (strNetwork.compare("Generic", Utf8Str::CaseInsensitive)) 408 408 ) 409 409 strNetwork = "Bridged"; // VMware assumes this is the default apparently … … 2045 2045 { 2046 2046 /* Attach to the right interface */ 2047 rc = pNetworkAdapter-> AttachToBridgedInterface();2047 rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_Bridged); 2048 2048 if (FAILED(rc)) throw rc; 2049 2049 ComPtr<IHost> host; … … 2068 2068 if (FAILED(rc)) throw rc; 2069 2069 /* Set the interface name to attach to */ 2070 pNetworkAdapter->COMSETTER( HostInterface)(name.raw());2070 pNetworkAdapter->COMSETTER(BridgedInterface)(name.raw()); 2071 2071 if (FAILED(rc)) throw rc; 2072 2072 break; … … 2078 2078 { 2079 2079 /* Attach to the right interface */ 2080 rc = pNetworkAdapter-> AttachToHostOnlyInterface();2080 rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_HostOnly); 2081 2081 if (FAILED(rc)) throw rc; 2082 2082 ComPtr<IHost> host; … … 2101 2101 if (FAILED(rc)) throw rc; 2102 2102 /* Set the interface name to attach to */ 2103 pNetworkAdapter->COMSETTER(Host Interface)(name.raw());2103 pNetworkAdapter->COMSETTER(HostOnlyInterface)(name.raw()); 2104 2104 if (FAILED(rc)) throw rc; 2105 2105 break; … … 2111 2111 { 2112 2112 /* Attach to the right interface */ 2113 rc = pNetworkAdapter-> AttachToInternalNetwork();2113 rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_Internal); 2114 2114 if (FAILED(rc)) throw rc; 2115 2115 } 2116 /* Next test for VDEinterfaces */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)) 2118 2118 { 2119 2119 /* Attach to the right interface */ 2120 rc = pNetworkAdapter-> AttachToVDE();2120 rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_Generic); 2121 2121 if (FAILED(rc)) throw rc; 2122 2122 } -
trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp
r36615 r37200 436 436 } 437 437 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) 438 STDMETHODIMP 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 478 STDMETHODIMP 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 492 STDMETHODIMP NetworkAdapter::COMSETTER(BridgedInterface)(IN_BSTR aBridgedInterface) 453 493 { 454 494 Bstr bstrEmpty(""); 455 if (!a HostInterface)456 a HostInterface = bstrEmpty.raw();495 if (!aBridgedInterface) 496 aBridgedInterface = bstrEmpty.raw(); 457 497 458 498 AutoCaller autoCaller(this); … … 465 505 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 466 506 467 if (mData->m HostInterface != aHostInterface)507 if (mData->mBridgedInterface != aBridgedInterface) 468 508 { 469 509 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 529 STDMETHODIMP 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 543 STDMETHODIMP 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; 471 562 472 563 m_fModified = true; … … 593 684 } 594 685 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) 686 STDMETHODIMP 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 700 STDMETHODIMP NetworkAdapter::COMSETTER(GenericDriver)(IN_BSTR aGenericDriver) 701 { 617 702 Bstr bstrEmpty(""); 618 if (!a VDENetwork)619 a VDENetwork= bstrEmpty.raw();703 if (!aGenericDriver) 704 aGenericDriver = bstrEmpty.raw(); 620 705 621 706 AutoCaller autoCaller(this); … … 623 708 624 709 /* the machine needs to be mutable */ 625 AutoMutableStateDependency adep 626 if (FAILED(adep.rc())) return adep.rc(); 627 628 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 629 630 if (mData->m VDENetwork != 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) 631 716 { 632 717 mData.backup(); 633 mData->m VDENetwork = aVDENetwork;718 mData->mGenericDriver = aGenericDriver; 634 719 635 720 /* leave the lock before informing callbacks */ 636 721 alock.release(); 637 722 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; 646 727 } 647 728 … … 935 1016 //////////////////////////////////////////////////////////////////////////////// 936 1017 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 1018 STDMETHODIMP 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 1041 STDMETHODIMP 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); 963 1080 mParent->setModified(Machine::IsModified_NetworkAdapters); 964 1081 mlock.release(); 965 1082 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 1093 STDMETHODIMP 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 1211 1128 1212 1129 // public methods only for internal purposes … … 1267 1184 } 1268 1185 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 1270 1194 alock.release(); 1271 1195 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; 1319 1198 1320 1199 // after loading settings, we are no longer different from the XML on disk … … 1360 1239 data.type = mData->mAdapterType; 1361 1240 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; 1399 1254 1400 1255 // after saving settings, we are no longer different from the XML on disk … … 1520 1375 // private methods 1521 1376 //////////////////////////////////////////////////////////////////////////////// 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 #endif1560 break;1561 }1562 }1563 1564 mData->mAttachmentType = NetworkAttachmentType_Null;1565 }1566 1377 1567 1378 /** -
trunk/src/VBox/Main/xml/Settings.cpp
r36527 r37200 1480 1480 && (mode == n.mode) 1481 1481 && (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) 1483 1487 && (ulBootPriority == n.ulBootPriority) 1484 && (fHasDisabledNAT == n.fHasDisabledNAT)1485 1488 ) 1486 1489 ); … … 1997 2000 void MachineConfigFile::readAttachedNetworkMode(const xml::ElementNode &elmMode, bool fEnabled, NetworkAdapter &nic) 1998 2001 { 2002 NetworkAttachmentType_T enmAttachmentType = NetworkAttachmentType_Null; 2003 1999 2004 if (elmMode.nameEquals("NAT")) 2000 2005 { 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 2006 2008 elmMode.getAttributeValue("hostip", nic.nat.strBindIP); 2007 2009 elmMode.getAttributeValue("mtu", nic.nat.u32Mtu); … … 2048 2050 } 2049 2051 } 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 2063 2064 throw ConfigFileError(this, &elmMode, N_("Required InternalNetwork/@name element is missing")); 2064 2065 } 2065 else if ( fEnabled2066 && elmMode.nameEquals("HostOnlyInterface"))2067 {2068 nic.mode = NetworkAttachmentType_HostOnly; 2069 if (!elmMode.getAttributeValue("name", nic.str Name)) // required network name2066 else if (elmMode.nameEquals("HostOnlyInterface")) 2067 { 2068 enmAttachmentType = NetworkAttachmentType_HostOnly; 2069 2070 if (!elmMode.getAttributeValue("name", nic.strHostOnlyName)) // required network name 2070 2071 throw ConfigFileError(this, &elmMode, N_("Required HostOnlyInterface/@name element is missing")); 2071 2072 } 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; 2080 2108 } 2081 2109 … … 3747 3775 3748 3776 case NetworkAttachmentType_Bridged: 3749 pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.str Name);3777 pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.strBridgedName); 3750 3778 break; 3751 3779 3752 3780 case NetworkAttachmentType_Internal: 3753 pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.str Name);3781 pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.strInternalNetworkName); 3754 3782 break; 3755 3783 3756 3784 case NetworkAttachmentType_HostOnly: 3757 pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.str Name);3785 pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.strHostOnlyName); 3758 3786 break; 3759 3760 #if defined(VBOX_WITH_VDE)3761 case NetworkAttachmentType_VDE:3762 pelmAdapter->createChild("VDE")->setAttribute("network", nic.strName);3763 break;3764 #endif3765 3787 3766 3788 default: /*case NetworkAttachmentType_Null:*/ … … 3771 3793 { 3772 3794 /* 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); 3779 3808 } 3780 3809 } … … 3972 4001 * @param mode 3973 4002 * @param elmParent 3974 * @param nice 4003 * @param fEnabled 4004 * @param nic 3975 4005 */ 3976 4006 void MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode, 3977 4007 xml::ElementNode &elmParent, 4008 bool fEnabled, 3978 4009 const NetworkAdapter &nic) 3979 4010 { … … 4043 4074 4044 4075 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); 4046 4078 break; 4047 4079 4048 4080 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); 4050 4083 break; 4051 4084 4052 4085 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); 4054 4088 break; 4055 4089 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 } 4059 4104 break; 4060 #endif4061 4105 4062 4106 default: /*case NetworkAttachmentType_Null:*/ … … 4512 4556 if (m->sv < SettingsVersion_v1_12) 4513 4557 { 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. 4515 4560 NetworkAdaptersList::const_iterator netit; 4516 4561 for (netit = hardwareMachine.llNetworkAdapters.begin(); … … 4518 4563 ++netit) 4519 4564 { 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 ) 4521 4570 { 4522 4571 m->sv = SettingsVersion_v1_12; -
trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd
r36945 r37200 7 7 * Common definitions 8 8 9 Copyright (C) 2004-201 0Oracle Corporation9 Copyright (C) 2004-2011 Oracle Corporation 10 10 11 11 This file is part of VirtualBox Open Source Edition (OSE), as … … 767 767 </xsd:complexType> 768 768 </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. --> 769 781 </xsd:choice> 770 782 <xsd:attribute name="type" type="TNetworkAdapterType" default="Am79C970A"/>
Note:
See TracChangeset
for help on using the changeset viewer.