Changeset 22166 in vbox for trunk/src/VBox
- Timestamp:
- Aug 11, 2009 1:56:40 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl2.cpp
r22165 r22166 170 170 int rc; 171 171 HRESULT hrc; 172 char *psz = NULL;173 172 BSTR str = NULL; 174 173 175 Bstr bstr; /* use this bstr when calling COM methods instead 176 of str as it manages memory! */ 177 178 #define STR_CONV() do { rc = RTUtf16ToUtf8(str, &psz); RC_CHECK(); } while (0) 179 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0) 180 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 181 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 174 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 175 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 176 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 182 177 183 178 /* … … 196 191 hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H(); 197 192 198 Bstr id;199 hrc = pMachine->COMGETTER(Id)(id.asOutParam()); H();200 Guid uuid(id);201 PCRTUUID pUuid = uuid.raw();193 hrc = pMachine->COMGETTER(Id)(&str); H(); 194 Guid MachineUuid(str); 195 PCRTUUID pUuid = MachineUuid.raw(); 196 STR_FREE(); 202 197 203 198 ULONG cRamMBs; … … 633 628 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 634 629 hrc = floppyImage->COMGETTER(Location)(&str); H(); 635 STR_CONV(); 636 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK(); 630 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 637 631 STR_FREE(); 638 632 } … … 647 641 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 648 642 hrc = hostFloppyDrive->COMGETTER(Name)(&str); H(); 649 STR_CONV(); 650 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK(); 643 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 651 644 STR_FREE(); 652 645 } … … 812 805 { 813 806 char szExtraDataKey[sizeof("CustomVideoModeXX")]; 814 RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode% d", iMode);807 RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%u", iMode); 815 808 hrc = pMachine->GetExtraData(Bstr(szExtraDataKey), &str); H(); 816 809 if (!str || !*str) 817 810 break; 818 rc = CFGMR3InsertStringW(pCfg, szExtraDataKey, str); 811 rc = CFGMR3InsertStringW(pCfg, szExtraDataKey, str); RC_CHECK(); 812 STR_FREE(); 819 813 cModes++; 820 814 } … … 846 840 */ 847 841 com::SafeIfaceArray<IStorageController> ctrls; 848 hrc = pMachine-> 849 COMGETTER(StorageControllers) (ComSafeArrayAsOutParam (ctrls)); H(); 842 hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); H(); 850 843 851 844 for (size_t i = 0; i < ctrls.size(); ++ i) … … 994 987 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 995 988 hrc = hostDvdDrive->COMGETTER(Name)(&str); H(); 996 STR_CONV(); 997 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK(); 989 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 998 990 STR_FREE(); 999 991 BOOL fPassthrough; … … 1018 1010 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 1019 1011 hrc = dvdImage->COMGETTER(Location)(&str); H(); 1020 STR_CONV(); 1021 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK(); 1012 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1022 1013 STR_FREE(); 1023 1014 } … … 1033 1024 1034 1025 /* At the moment we only support one controller per type. So the instance id is always 0. */ 1035 rc = ctrls[i]->COMSETTER(Instance)(0); 1026 rc = ctrls[i]->COMSETTER(Instance)(0); H(); 1036 1027 1037 1028 /* Attach the hard disks. */ 1038 1029 com::SafeIfaceArray<IHardDiskAttachment> atts; 1039 hrc = pMachine-> 1040 GetHardDiskAttachmentsOfController (controllerName, 1041 ComSafeArrayAsOutParam (atts)); H(); 1030 hrc = pMachine->GetHardDiskAttachmentsOfController(controllerName, 1031 ComSafeArrayAsOutParam(atts)); H(); 1042 1032 1043 1033 for (size_t j = 0; j < atts.size(); ++ j) 1044 1034 { 1045 1035 ComPtr<IHardDisk> hardDisk; 1046 hrc = atts [j]->COMGETTER(HardDisk) (hardDisk.asOutParam());H();1036 hrc = atts[j]->COMGETTER(HardDisk)(hardDisk.asOutParam()); H(); 1047 1037 LONG lDev; 1048 hrc = atts [j]->COMGETTER(Device) (&lDev);H();1038 hrc = atts[j]->COMGETTER(Device)(&lDev); H(); 1049 1039 LONG lPort; 1050 hrc = atts [j]->COMGETTER(Port) (&lPort);H();1040 hrc = atts[j]->COMGETTER(Port)(&lPort); H(); 1051 1041 1052 1042 int iLUN = 0; … … 1087 1077 } 1088 1078 1089 char szLUN[16]; 1090 RTStrPrintf (szLUN, sizeof(szLUN), "LUN#%u", iLUN); 1091 1092 rc = CFGMR3InsertNode (pCtlInst, szLUN, &pLunL0); RC_CHECK(); 1079 rc = CFGMR3InsertNodeF(pCtlInst, &pLunL0, "LUN#%u", iLUN); RC_CHECK(); 1093 1080 /* SCSI has a another driver between device and block. */ 1094 1081 if (fSCSI) 1095 1082 { 1096 rc = CFGMR3InsertString (pLunL0, "Driver", "SCSI"); RC_CHECK(); 1097 rc = CFGMR3InsertNode (pLunL0, "Config", &pCfg); RC_CHECK(); 1098 1099 rc = CFGMR3InsertNode (pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 1100 } 1101 rc = CFGMR3InsertString (pLunL0, "Driver", "Block"); RC_CHECK(); 1102 rc = CFGMR3InsertNode (pLunL0, "Config", &pCfg); RC_CHECK(); 1103 rc = CFGMR3InsertString (pCfg, "Type", "HardDisk"); RC_CHECK(); 1104 rc = CFGMR3InsertInteger (pCfg, "Mountable", 0); RC_CHECK(); 1105 1106 rc = CFGMR3InsertNode (pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 1107 rc = CFGMR3InsertString (pLunL1, "Driver", "VD"); RC_CHECK(); 1108 rc = CFGMR3InsertNode (pLunL1, "Config", &pCfg); RC_CHECK(); 1109 1110 hrc = hardDisk->COMGETTER(Location) (bstr.asOutParam()); H(); 1111 rc = CFGMR3InsertString (pCfg, "Path", Utf8Str (bstr)); RC_CHECK(); 1112 1113 hrc = hardDisk->COMGETTER(Format) (bstr.asOutParam()); H(); 1114 rc = CFGMR3InsertString (pCfg, "Format", Utf8Str (bstr)); RC_CHECK(); 1083 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); 1084 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1085 1086 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 1087 } 1088 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 1089 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1090 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK(); 1091 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK(); 1092 1093 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 1094 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 1095 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 1096 1097 hrc = hardDisk->COMGETTER(Location)(&str); H(); 1098 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1099 STR_FREE(); 1100 1101 hrc = hardDisk->COMGETTER(Format)(&str); H(); 1102 rc = CFGMR3InsertStringW(pCfg, "Format", str); RC_CHECK(); 1103 STR_FREE(); 1115 1104 1116 1105 /* Pass all custom parameters. */ … … 1118 1107 SafeArray<BSTR> names; 1119 1108 SafeArray<BSTR> values; 1120 hrc = hardDisk->GetProperties 1121 ComSafeArrayAsOutParam(names),1122 ComSafeArrayAsOutParam (values));H();1109 hrc = hardDisk->GetProperties(NULL, 1110 ComSafeArrayAsOutParam(names), 1111 ComSafeArrayAsOutParam(values)); H(); 1123 1112 1124 1113 if (names.size() != 0) 1125 1114 { 1126 1115 PCFGMNODE pVDC; 1127 rc = CFGMR3InsertNode (pCfg, "VDConfig", &pVDC);RC_CHECK();1116 rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK(); 1128 1117 for (size_t ii = 0; ii < names.size(); ++ ii) 1129 1118 { 1130 1119 if (values[ii] && *values[ii]) 1131 1120 { 1132 Utf8Str name = names 1133 Utf8Str value = values 1134 rc = CFGMR3InsertString 1121 Utf8Str name = names[ii]; 1122 Utf8Str value = values[ii]; 1123 rc = CFGMR3InsertString(pVDC, name, value); 1135 1124 if ( !(name.compare("HostIPStack")) 1136 1125 && !(value.compare("0"))) … … 1144 1133 for (PCFGMNODE pParent = pCfg;;) 1145 1134 { 1146 hrc = parentHardDisk-> 1147 COMGETTER(Parent) (hardDisk.asOutParam()); H(); 1135 hrc = parentHardDisk->COMGETTER(Parent)(hardDisk.asOutParam()); H(); 1148 1136 if (hardDisk.isNull()) 1149 1137 break; 1150 1138 1151 1139 PCFGMNODE pCur; 1152 rc = CFGMR3InsertNode (pParent, "Parent", &pCur); RC_CHECK(); 1153 hrc = hardDisk->COMGETTER(Location) (bstr.asOutParam()); H(); 1154 rc = CFGMR3InsertString (pCur, "Path", Utf8Str (bstr)); RC_CHECK(); 1155 1156 hrc = hardDisk->COMGETTER(Format) (bstr.asOutParam()); H(); 1157 rc = CFGMR3InsertString (pCur, "Format", Utf8Str (bstr)); RC_CHECK(); 1140 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK(); 1141 hrc = hardDisk->COMGETTER(Location)(&str); H(); 1142 rc = CFGMR3InsertStringW(pCur, "Path", str); RC_CHECK(); 1143 STR_FREE(); 1144 1145 hrc = hardDisk->COMGETTER(Format)(&str); H(); 1146 rc = CFGMR3InsertStringW(pCur, "Format", str); RC_CHECK(); 1147 STR_FREE(); 1158 1148 1159 1149 /* Pass all custom parameters. */ 1160 1150 SafeArray<BSTR> names; 1161 1151 SafeArray<BSTR> values; 1162 hrc = hardDisk->GetProperties 1163 ComSafeArrayAsOutParam(names),1164 ComSafeArrayAsOutParam (values));H();1152 hrc = hardDisk->GetProperties(NULL, 1153 ComSafeArrayAsOutParam(names), 1154 ComSafeArrayAsOutParam(values)); H(); 1165 1155 1166 1156 if (names.size() != 0) 1167 1157 { 1168 1158 PCFGMNODE pVDC; 1169 rc = CFGMR3InsertNode (pCur, "VDConfig", &pVDC);RC_CHECK();1170 for (size_t ii = 0; ii < names.size(); ++ 1159 rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK(); 1160 for (size_t ii = 0; ii < names.size(); ++ii) 1171 1161 { 1172 if (values 1162 if (values[ii]) 1173 1163 { 1174 Utf8Str name = names 1175 Utf8Str value = values 1164 Utf8Str name = names[ii]; 1165 Utf8Str value = values[ii]; 1176 1166 rc = CFGMR3InsertString (pVDC, name, value); 1177 if ( !(name.compare("HostIPStack"))1178 && !(value.compare("0")))1167 if ( name.compare("HostIPStack") == 0 1168 && value.compare("0") == 0) 1179 1169 fHostIP = false; 1180 1170 } … … 1186 1176 if (!fHostIP) 1187 1177 { 1188 rc = CFGMR3InsertInteger (pCfg, "HostIPStack", 0);RC_CHECK();1178 rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK(); 1189 1179 } 1190 1180 … … 1247 1237 } 1248 1238 1249 char szInstance[4]; Assert(ulInstance <= 999); 1250 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance); 1251 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK(); 1239 rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK(); 1252 1240 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK(); 1253 1241 /* the first network card gets the PCI ID 3, the next 3 gets 8..10, … … 1358 1346 */ 1359 1347 1360 rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter, pCfg, pLunL0, pInst, false); 1348 rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter, 1349 pCfg, pLunL0, pInst, false /*fAttachDetach*/); 1361 1350 RC_CHECK(); 1362 1351 } … … 1376 1365 continue; 1377 1366 1378 char szInstance[4]; Assert(ulInstance <= 999); 1379 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance); 1380 1381 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK(); 1367 rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK(); 1382 1368 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK(); 1383 1369 … … 1436 1422 continue; 1437 1423 1438 char szInstance[4]; Assert(ulInstance <= 999); 1439 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance); 1440 1441 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK(); 1424 rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK(); 1442 1425 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK(); 1443 1426 … … 1615 1598 } 1616 1599 hrc = pMachine->COMGETTER(Name)(&str); H(); 1617 STR_CONV(); 1618 rc = CFGMR3InsertString(pCfg, "StreamName", psz); RC_CHECK(); 1600 rc = CFGMR3InsertStringW(pCfg, "StreamName", str); RC_CHECK(); 1619 1601 STR_FREE(); 1620 1602 } … … 1706 1688 { 1707 1689 ClipboardMode_T mode = ClipboardMode_Disabled; 1708 hrc = pMachine->COMGETTER(ClipboardMode) (&mode);H();1690 hrc = pMachine->COMGETTER(ClipboardMode)(&mode); H(); 1709 1691 1710 1692 if (mode != ClipboardMode_Disabled) … … 1770 1752 { 1771 1753 BOOL fEnabled = false; 1772 hrc = pMachine->COMGETTER(Accelerate3DEnabled) (&fEnabled);H();1754 hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled); H(); 1773 1755 1774 1756 if (fEnabled) … … 1810 1792 1811 1793 #ifdef VBOX_WITH_GUEST_PROPS 1794 /** @todo r=bird: functions! methods! */ 1812 1795 /* 1813 1796 * Guest property service … … 2051 2034 } 2052 2035 2036 #undef STR_FREE 2053 2037 #undef H 2054 2038 #undef RC_CHECK 2055 #undef STR_FREE2056 #undef STR_CONV2057 2039 2058 2040 /* Register VM state change handler */ … … 2094 2076 * @note Locks the Console object for writing. 2095 2077 */ 2096 DECLCALLBACK(int)Console::configNetwork(Console *pThis, const char *pszDevice,2097 2098 2099 2100 2078 /*static*/ int Console::configNetwork(Console *pThis, const char *pszDevice, 2079 unsigned uInstance, unsigned uLun, 2080 INetworkAdapter *aNetworkAdapter, 2081 PCFGMNODE pCfg, PCFGMNODE pLunL0, 2082 PCFGMNODE pInst, bool fAttachDetach) 2101 2083 { 2102 2084 int rc = VINF_SUCCESS; … … 2114 2096 PVM pVM = pThis->mpVM; 2115 2097 BSTR str = NULL; 2116 char *psz = NULL; 2117 2118 #define STR_CONV() do { rc = RTUtf16ToUtf8(str, &psz); RC_CHECK(); } while (0) 2119 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0) 2120 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2121 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2098 2099 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2100 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2101 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2122 2102 2123 2103 HRESULT hrc; … … 2161 2141 if (str) /* check convention for indicating default file. */ 2162 2142 { 2163 STR_CONV(); 2164 rc = CFGMR3InsertString(pCfg, "File", psz); RC_CHECK(); 2165 STR_FREE(); 2166 } 2143 rc = CFGMR3InsertStringW(pCfg, "File", str); RC_CHECK(); 2144 } 2145 STR_FREE(); 2167 2146 } 2168 2147 2169 2148 Bstr networkName, trunkName, trunkType; 2170 2149 NetworkAttachmentType_T eAttachmentType; 2171 hrc = aNetworkAdapter->COMGETTER(AttachmentType)(&eAttachmentType); 2172 H(); 2150 hrc = aNetworkAdapter->COMGETTER(AttachmentType)(&eAttachmentType); H(); 2173 2151 switch (eAttachmentType) 2174 2152 { … … 2190 2168 2191 2169 /* Configure TFTP prefix and boot filename. */ 2192 hrc = virtualBox->COMGETTER(HomeFolder)(&str); 2193 H(); 2194 STR_CONV(); 2195 if (psz && *psz) 2196 { 2197 rc = CFGMR3InsertStringF(pCfg, "TFTPPrefix", "%s%c%s", psz, RTPATH_DELIMITER, "TFTP"); RC_CHECK(); 2170 hrc = virtualBox->COMGETTER(HomeFolder)(&str); H(); 2171 if (str && *str) 2172 { 2173 rc = CFGMR3InsertStringF(pCfg, "TFTPPrefix", "%ls%c%s", str, RTPATH_DELIMITER, "TFTP"); RC_CHECK(); 2198 2174 } 2199 2175 STR_FREE(); 2200 hrc = pMachine->COMGETTER(Name)(&str); 2201 H(); 2202 STR_CONV(); 2203 rc = CFGMR3InsertStringF(pCfg, "BootFile", "%s.pxe", psz); RC_CHECK(); 2176 hrc = pMachine->COMGETTER(Name)(&str); H(); 2177 rc = CFGMR3InsertStringF(pCfg, "BootFile", "%ls.pxe", str); RC_CHECK(); 2204 2178 STR_FREE(); 2205 2179 2206 hrc = aNetworkAdapter->COMGETTER(NATNetwork)(&str); 2207 H(); 2208 if (str) 2209 { 2210 STR_CONV(); 2211 if (psz && *psz) 2212 { 2213 rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK(); 2214 /* NAT uses its own DHCP implementation */ 2215 //networkName = Bstr(psz); 2216 } 2217 2218 STR_FREE(); 2219 } 2180 hrc = aNetworkAdapter->COMGETTER(NATNetwork)(&str); H(); 2181 if (str && *str) 2182 { 2183 rc = CFGMR3InsertStringW(pCfg, "Network", str); RC_CHECK(); 2184 /* NAT uses its own DHCP implementation */ 2185 //networkName = Bstr(psz); 2186 } 2187 STR_FREE(); 2220 2188 break; 2221 2189 } … … 2310 2278 } 2311 2279 2312 HostNetworkInterfaceType_T ifType;2313 hrc = hostInterface->COMGETTER(InterfaceType)(& ifType);2280 HostNetworkInterfaceType_T eIfType; 2281 hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType); 2314 2282 if (FAILED(hrc)) 2315 2283 { … … 2318 2286 } 2319 2287 2320 if ( ifType != HostNetworkInterfaceType_Bridged)2288 if (eIfType != HostNetworkInterfaceType_Bridged) 2321 2289 { 2322 2290 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, … … 2325 2293 } 2326 2294 2327 Bstr hostIFGuid_; 2328 hrc = hostInterface->COMGETTER(Id)(hostIFGuid_.asOutParam()); 2295 hrc = hostInterface->COMGETTER(Id)(&str); 2329 2296 if (FAILED(hrc)) 2330 2297 { … … 2332 2299 H(); 2333 2300 } 2334 Guid hostIFGuid(hostIFGuid_); 2301 Guid hostIFGuid(str); 2302 STR_FREE(str); 2335 2303 2336 2304 INetCfg *pNc; … … 2405 2373 2406 2374 # elif defined(RT_OS_LINUX) 2407 /* @todo Check for malformed names. */2375 /** @todo Check for malformed names. */ 2408 2376 const char *pszTrunk = pszHifName; 2409 2377 … … 2554 2522 case NetworkAttachmentType_Internal: 2555 2523 { 2556 hrc = aNetworkAdapter->COMGETTER(InternalNetwork)(&str); H(); 2557 if (str) 2558 { 2559 STR_CONV(); 2560 if (psz && *psz) 2561 { 2562 if (fSniffer) 2563 { 2564 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); 2565 RC_CHECK(); 2566 } 2567 else 2568 { 2569 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); 2570 RC_CHECK(); 2571 } 2572 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK(); 2573 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2574 rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK(); 2575 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_WhateverNone); RC_CHECK(); 2576 networkName = Bstr(psz); 2577 trunkType = Bstr(TRUNKTYPE_WHATEVER); 2578 } 2579 STR_FREE(); 2580 } 2524 hrc = aNetworkAdapter->COMGETTER(InternalNetwork)(&str); H(); 2525 if (str && *str) 2526 { 2527 if (fSniffer) 2528 { 2529 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); 2530 RC_CHECK(); 2531 } 2532 else 2533 { 2534 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); 2535 RC_CHECK(); 2536 } 2537 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK(); 2538 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2539 rc = CFGMR3InsertStringW(pCfg, "Network", str); RC_CHECK(); 2540 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_WhateverNone); RC_CHECK(); 2541 networkName = str; 2542 trunkType = Bstr(TRUNKTYPE_WHATEVER); 2543 } 2544 STR_FREE(); 2581 2545 break; 2582 2546 } … … 2630 2594 /** @todo r=bird: Put this in a function. */ 2631 2595 2632 HostNetworkInterfaceType_T ifType;2633 hrc = hostInterface->COMGETTER(InterfaceType)(& ifType);2596 HostNetworkInterfaceType_T eIfType; 2597 hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType); 2634 2598 if (FAILED(hrc)) 2635 2599 { … … 2638 2602 } 2639 2603 2640 if ( ifType != HostNetworkInterfaceType_HostOnly)2604 if (eIfType != HostNetworkInterfaceType_HostOnly) 2641 2605 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS, 2642 2606 N_("Interface ('%ls') is not a Host-Only Adapter interface"), 2643 2607 HifName.raw()); 2644 2608 2645 Bstr hostIFGuid_; 2646 hrc = hostInterface->COMGETTER(Id)(hostIFGuid_.asOutParam()); 2609 hrc = hostInterface->COMGETTER(Id)(&str); 2647 2610 if (FAILED(hrc)) 2648 2611 { … … 2650 2613 H(); 2651 2614 } 2652 Guid hostIFGuid(hostIFGuid_); 2615 Guid hostIFGuid(str); 2616 STR_FREE(str); 2653 2617 2654 2618 INetCfg *pNc; … … 2855 2819 2856 2820 #undef STR_FREE 2857 #undef STR_CONV2858 2821 #undef H 2859 2822 #undef RC_CHECK -
trunk/src/VBox/Main/include/ConsoleImpl.h
r22162 r22166 429 429 430 430 static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole); 431 static DECLCALLBACK(int)configNetwork(Console *pThis, const char *pszDevice,432 433 434 435 431 static int configNetwork(Console *pThis, const char *pszDevice, 432 unsigned uInstance, unsigned uLun, 433 INetworkAdapter *aNetworkAdapter, 434 PCFGMNODE pCfg, PCFGMNODE pLunL0, 435 PCFGMNODE pInst, bool fAttachDetach); 436 436 static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState, 437 437 VMSTATE aOldState, void *aUser);
Note:
See TracChangeset
for help on using the changeset viewer.