Changeset 37200 in vbox for trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
- Timestamp:
- May 24, 2011 3:34:06 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r36630 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 … … 101 101 MODIFYVM_NICTRACEFILE, 102 102 MODIFYVM_NICTRACE, 103 MODIFYVM_NICPROPERTY, 103 104 MODIFYVM_NICTYPE, 104 105 MODIFYVM_NICSPEED, … … 112 113 MODIFYVM_INTNET, 113 114 MODIFYVM_NATNET, 114 #ifdef VBOX_WITH_VDE 115 MODIFYVM_VDENET, 116 #endif 115 MODIFYVM_GENERICDRV, 117 116 MODIFYVM_NATBINDIP, 118 117 MODIFYVM_NATSETTINGS, … … 233 232 { "--nictracefile", MODIFYVM_NICTRACEFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 234 233 { "--nictrace", MODIFYVM_NICTRACE, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX }, 234 { "--nicproperty", MODIFYVM_NICPROPERTY, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 235 235 { "--nictype", MODIFYVM_NICTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 236 236 { "--nicspeed", MODIFYVM_NICSPEED, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX }, … … 244 244 { "--intnet", MODIFYVM_INTNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 245 245 { "--natnet", MODIFYVM_NATNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 246 #ifdef VBOX_WITH_VDE 247 { "--vdenet", MODIFYVM_VDENET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 248 #endif 246 { "--nicgenericdrv", MODIFYVM_GENERICDRV, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 249 247 { "--natbindip", MODIFYVM_NATBINDIP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 250 248 { "--natsettings", MODIFYVM_NATSETTINGS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, … … 320 318 int rc; 321 319 uint8_t aVals[3] = {0, 0, 0}; 322 320 323 321 rc = RTStrToUInt8Ex(pszNext, &pszNext, 16, &aVals[0]); 324 322 if (RT_FAILURE(rc) || pszNext == NULL || *pszNext != ':') 325 323 return -1; 326 324 327 325 rc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[1]); 328 326 if (RT_FAILURE(rc) || pszNext == NULL || *pszNext != '.') … … 1038 1036 } 1039 1037 1038 case MODIFYVM_NICPROPERTY: 1039 { 1040 ComPtr<INetworkAdapter> nic; 1041 1042 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1043 ASSERT(nic); 1044 1045 if (nic) 1046 { 1047 /* Parse 'name=value' */ 1048 char *pszProperty = RTStrDup(ValueUnion.psz); 1049 if (pszProperty) 1050 { 1051 char *pDelimiter = strchr(pszProperty, '='); 1052 if (pDelimiter) 1053 { 1054 *pDelimiter = '\0'; 1055 1056 Bstr bstrName = pszProperty; 1057 Bstr bstrValue = &pDelimiter[1]; 1058 CHECK_ERROR(nic, SetProperty(bstrName.raw(), bstrValue.raw())); 1059 } 1060 else 1061 { 1062 errorArgument("Invalid --nicproperty%d argument '%s'", GetOptState.uIndex, ValueUnion.psz); 1063 rc = E_FAIL; 1064 } 1065 RTStrFree(pszProperty); 1066 } 1067 else 1068 { 1069 RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for --nicproperty%d '%s'\n", GetOptState.uIndex, ValueUnion.psz); 1070 rc = E_FAIL; 1071 } 1072 } 1073 break; 1074 } 1040 1075 case MODIFYVM_NICTYPE: 1041 1076 { … … 1184 1219 { 1185 1220 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE)); 1186 CHECK_ERROR(nic, Detach());1221 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Null)); 1187 1222 } 1188 1223 else if (!strcmp(ValueUnion.psz, "nat")) 1189 1224 { 1190 1225 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE)); 1191 CHECK_ERROR(nic, AttachToNAT());1226 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NAT)); 1192 1227 } 1193 1228 else if ( !strcmp(ValueUnion.psz, "bridged") … … 1195 1230 { 1196 1231 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE)); 1197 CHECK_ERROR(nic, AttachToBridgedInterface());1232 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Bridged)); 1198 1233 } 1199 1234 else if (!strcmp(ValueUnion.psz, "intnet")) 1200 1235 { 1201 1236 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE)); 1202 CHECK_ERROR(nic, AttachToInternalNetwork()); 1203 } 1204 #if defined(VBOX_WITH_NETFLT) 1237 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Internal)); 1238 } 1205 1239 else if (!strcmp(ValueUnion.psz, "hostonly")) 1206 1240 { 1207 1241 1208 1242 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE)); 1209 CHECK_ERROR(nic, AttachToHostOnlyInterface()); 1210 } 1211 #endif 1212 #ifdef VBOX_WITH_VDE 1213 else if (!strcmp(ValueUnion.psz, "vde")) 1243 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_HostOnly)); 1244 } 1245 else if (!strcmp(ValueUnion.psz, "generic")) 1214 1246 { 1215 1247 1216 1248 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE)); 1217 CHECK_ERROR(nic, AttachToVDE()); 1218 } 1219 #endif 1249 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Generic)); 1250 } 1220 1251 else 1221 1252 { … … 1238 1269 1239 1270 case MODIFYVM_BRIDGEADAPTER: 1240 case MODIFYVM_HOSTONLYADAPTER: 1241 { 1242 ComPtr<INetworkAdapter> nic; 1243 1244 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1245 ASSERT(nic); 1246 1247 /** @todo NULL string deprecated */ 1271 { 1272 ComPtr<INetworkAdapter> nic; 1273 1274 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1275 ASSERT(nic); 1276 1248 1277 /* remove it? */ 1249 1278 if (!strcmp(ValueUnion.psz, "none")) 1250 1279 { 1251 CHECK_ERROR(nic, COMSETTER(HostInterface)(NULL)); 1252 } 1253 else 1254 { 1255 CHECK_ERROR(nic, COMSETTER(HostInterface)(Bstr(ValueUnion.psz).raw())); 1256 } 1257 break; 1258 } 1259 1260 case MODIFYVM_INTNET: 1261 { 1262 ComPtr<INetworkAdapter> nic; 1263 1264 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1265 ASSERT(nic); 1266 1267 /** @todo NULL string deprecated */ 1280 CHECK_ERROR(nic, COMSETTER(BridgedInterface)((CBSTR)L"")); 1281 } 1282 else 1283 { 1284 CHECK_ERROR(nic, COMSETTER(BridgedInterface)(Bstr(ValueUnion.psz).raw())); 1285 } 1286 break; 1287 } 1288 1289 case MODIFYVM_HOSTONLYADAPTER: 1290 { 1291 ComPtr<INetworkAdapter> nic; 1292 1293 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1294 ASSERT(nic); 1295 1268 1296 /* remove it? */ 1269 1297 if (!strcmp(ValueUnion.psz, "none")) 1270 1298 { 1271 CHECK_ERROR(nic, COMSETTER(InternalNetwork)(NULL)); 1299 CHECK_ERROR(nic, COMSETTER(HostOnlyInterface)((CBSTR)L"")); 1300 } 1301 else 1302 { 1303 CHECK_ERROR(nic, COMSETTER(HostOnlyInterface)(Bstr(ValueUnion.psz).raw())); 1304 } 1305 break; 1306 } 1307 1308 case MODIFYVM_INTNET: 1309 { 1310 ComPtr<INetworkAdapter> nic; 1311 1312 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1313 ASSERT(nic); 1314 1315 /* remove it? */ 1316 if (!strcmp(ValueUnion.psz, "none")) 1317 { 1318 CHECK_ERROR(nic, COMSETTER(InternalNetwork)((CBSTR)L"")); 1272 1319 } 1273 1320 else … … 1278 1325 } 1279 1326 1280 #ifdef VBOX_WITH_VDE 1281 case MODIFYVM_VDENET: 1282 { 1283 ComPtr<INetworkAdapter> nic; 1284 1285 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1286 ASSERT(nic); 1287 1288 /** @todo NULL string deprecated */ 1289 /* remove it? */ 1290 if (!strcmp(ValueUnion.psz, "default")) 1291 { 1292 CHECK_ERROR(nic, COMSETTER(VDENetwork)(NULL)); 1293 } 1294 else 1295 { 1296 CHECK_ERROR(nic, COMSETTER(VDENetwork)(Bstr(ValueUnion.psz).raw())); 1297 } 1298 break; 1299 } 1300 #endif 1327 case MODIFYVM_GENERICDRV: 1328 { 1329 ComPtr<INetworkAdapter> nic; 1330 1331 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1332 ASSERT(nic); 1333 1334 CHECK_ERROR(nic, COMSETTER(GenericDriver)(Bstr(ValueUnion.psz).raw())); 1335 break; 1336 } 1337 1301 1338 case MODIFYVM_NATNET: 1302 1339 { … … 1558 1595 if (!strcmp(ValueUnion.psz, "auto")) 1559 1596 { 1560 CHECK_ERROR(nic, COMSETTER(MACAddress)( NULL));1597 CHECK_ERROR(nic, COMSETTER(MACAddress)((CBSTR)L"")); 1561 1598 } 1562 1599 else … … 1882 1919 } 1883 1920 else 1884 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)( NULL));1921 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)((CBSTR)L"")); 1885 1922 } 1886 1923 break; … … 1998 2035 } 1999 2036 else 2000 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)( NULL));2037 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)((CBSTR)L"")); 2001 2038 } 2002 2039 break; … … 2086 2123 { 2087 2124 if (!strcmp(ValueUnion.psz, "default")) 2088 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)( NULL));2125 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)((CBSTR)L"")); 2089 2126 else 2090 2127 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz).raw())); … … 2215 2252 iHostAddr = parsePci(ValueUnion.psz); 2216 2253 iGuestAddr = pAt != NULL ? parsePci(pAt + 1) : iHostAddr; 2217 2254 2218 2255 if (iHostAddr == -1 || iGuestAddr == -1) 2219 2256 {
Note:
See TracChangeset
for help on using the changeset viewer.