儲存庫 vbox 的更動 16485
- 時間撮記:
- 2009-2-3 下午01:05:35 (16 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VBoxManage
- 檔案:
-
- 新增 1 筆資料
- 修改 3 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk
r15492 r16485 44 44 VBoxManage_SOURCES = \ 45 45 VBoxManage.cpp \ 46 VBoxManageModifyVM.cpp \ 46 47 VBoxManageInfo.cpp \ 48 VBoxManageImport.cpp \ 47 49 VBoxManageMetrics.cpp \ 48 50 VBoxManageList.cpp \ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r16052 r16485 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 317 317 " [-basefolder <path> | -settingsfile <path>]\n" 318 318 " [-uuid <uuid>]\n" 319 " \n" 319 "\n"); 320 } 321 322 if (u64Cmd & USAGE_IMPORTAPPLIANCE) 323 { 324 RTPrintf("VBoxManage import <ovf>\n" 320 325 "\n"); 321 326 } … … 901 906 * @param psz Pointer to the nic number. 902 907 */ 903 staticunsigned parseNum(const char *psz, unsigned cMaxNum, const char *name)908 unsigned parseNum(const char *psz, unsigned cMaxNum, const char *name) 904 909 { 905 910 uint32_t u32; … … 915 920 } 916 921 917 /** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */918 #if defined(_MSC_VER)919 # pragma optimize("g", off)920 #endif921 922 static int handleModifyVM(HandlerArg *a)923 {924 HRESULT rc;925 Bstr name;926 Bstr ostype;927 uint32_t memorySize = 0;928 uint32_t vramSize = 0;929 char *acpi = NULL;930 char *hwvirtex = NULL;931 char *nestedpaging = NULL;932 char *vtxvpid = NULL;933 char *pae = NULL;934 char *ioapic = NULL;935 uint32_t monitorcount = ~0;936 char *accelerate3d = NULL;937 char *bioslogofadein = NULL;938 char *bioslogofadeout = NULL;939 uint32_t bioslogodisplaytime = ~0;940 char *bioslogoimagepath = NULL;941 char *biosbootmenumode = NULL;942 char *biossystemtimeoffset = NULL;943 char *biospxedebug = NULL;944 DeviceType_T bootDevice[4];945 int bootDeviceChanged[4] = { false };946 char *hdds[34] = {0};947 char *dvd = NULL;948 char *dvdpassthrough = NULL;949 char *idecontroller = NULL;950 char *floppy = NULL;951 char *audio = NULL;952 char *audiocontroller = NULL;953 char *clipboard = NULL;954 #ifdef VBOX_WITH_VRDP955 char *vrdp = NULL;956 uint16_t vrdpport = UINT16_MAX;957 char *vrdpaddress = NULL;958 char *vrdpauthtype = NULL;959 char *vrdpmulticon = NULL;960 char *vrdpreusecon = NULL;961 #endif962 int fUsbEnabled = -1;963 int fUsbEhciEnabled = -1;964 char *snapshotFolder = NULL;965 ULONG guestMemBalloonSize = (ULONG)-1;966 ULONG guestStatInterval = (ULONG)-1;967 int fSataEnabled = -1;968 int sataPortCount = -1;969 int sataBootDevices[4] = {-1,-1,-1,-1};970 971 /* VM ID + at least one parameter. Parameter arguments are checked972 * individually. */973 if (a->argc < 2)974 return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");975 976 /* Get the number of network adapters */977 ULONG NetworkAdapterCount = 0;978 {979 ComPtr <ISystemProperties> info;980 CHECK_ERROR_RET (a->virtualBox, COMGETTER(SystemProperties) (info.asOutParam()), 1);981 CHECK_ERROR_RET (info, COMGETTER(NetworkAdapterCount) (&NetworkAdapterCount), 1);982 }983 ULONG SerialPortCount = 0;984 {985 ComPtr <ISystemProperties> info;986 CHECK_ERROR_RET (a->virtualBox, COMGETTER(SystemProperties) (info.asOutParam()), 1);987 CHECK_ERROR_RET (info, COMGETTER(SerialPortCount) (&SerialPortCount), 1);988 }989 990 std::vector <char *> nics (NetworkAdapterCount, 0);991 std::vector <char *> nictype (NetworkAdapterCount, 0);992 std::vector <char *> cableconnected (NetworkAdapterCount, 0);993 std::vector <char *> nictrace (NetworkAdapterCount, 0);994 std::vector <char *> nictracefile (NetworkAdapterCount, 0);995 std::vector <char *> nicspeed (NetworkAdapterCount, 0);996 std::vector <char *> hostifdev (NetworkAdapterCount, 0);997 std::vector <const char *> intnet (NetworkAdapterCount, 0);998 std::vector <const char *> natnet (NetworkAdapterCount, 0);999 std::vector <char *> macs (NetworkAdapterCount, 0);1000 std::vector <char *> uarts_mode (SerialPortCount, 0);1001 std::vector <ULONG> uarts_base (SerialPortCount, 0);1002 std::vector <ULONG> uarts_irq (SerialPortCount, 0);1003 std::vector <char *> uarts_path (SerialPortCount, 0);1004 1005 for (int i = 1; i < a->argc; i++)1006 {1007 if (strcmp(a->argv[i], "-name") == 0)1008 {1009 if (a->argc <= i + 1)1010 return errorArgument("Missing argument to '%s'", a->argv[i]);1011 i++;1012 name = a->argv[i];1013 }1014 else if (strcmp(a->argv[i], "-ostype") == 0)1015 {1016 if (a->argc <= i + 1)1017 return errorArgument("Missing argument to '%s'", a->argv[i]);1018 i++;1019 ostype = a->argv[i];1020 }1021 else if (strcmp(a->argv[i], "-memory") == 0)1022 {1023 if (a->argc <= i + 1)1024 return errorArgument("Missing argument to '%s'", a->argv[i]);1025 i++;1026 memorySize = RTStrToUInt32(a->argv[i]);1027 }1028 else if (strcmp(a->argv[i], "-vram") == 0)1029 {1030 if (a->argc <= i + 1)1031 return errorArgument("Missing argument to '%s'", a->argv[i]);1032 i++;1033 vramSize = RTStrToUInt32(a->argv[i]);1034 }1035 else if (strcmp(a->argv[i], "-acpi") == 0)1036 {1037 if (a->argc <= i + 1)1038 return errorArgument("Missing argument to '%s'", a->argv[i]);1039 i++;1040 acpi = a->argv[i];1041 }1042 else if (strcmp(a->argv[i], "-ioapic") == 0)1043 {1044 if (a->argc <= i + 1)1045 return errorArgument("Missing argument to '%s'", a->argv[i]);1046 i++;1047 ioapic = a->argv[i];1048 }1049 else if (strcmp(a->argv[i], "-hwvirtex") == 0)1050 {1051 if (a->argc <= i + 1)1052 return errorArgument("Missing argument to '%s'", a->argv[i]);1053 i++;1054 hwvirtex = a->argv[i];1055 }1056 else if (strcmp(a->argv[i], "-nestedpaging") == 0)1057 {1058 if (a->argc <= i + 1)1059 return errorArgument("Missing argument to '%s'", a->argv[i]);1060 i++;1061 nestedpaging = a->argv[i];1062 }1063 else if (strcmp(a->argv[i], "-vtxvpid") == 0)1064 {1065 if (a->argc <= i + 1)1066 return errorArgument("Missing argument to '%s'", a->argv[i]);1067 i++;1068 vtxvpid = a->argv[i];1069 }1070 else if (strcmp(a->argv[i], "-pae") == 0)1071 {1072 if (a->argc <= i + 1)1073 return errorArgument("Missing argument to '%s'", a->argv[i]);1074 i++;1075 pae = a->argv[i];1076 }1077 else if (strcmp(a->argv[i], "-monitorcount") == 0)1078 {1079 if (a->argc <= i + 1)1080 return errorArgument("Missing argument to '%s'", a->argv[i]);1081 i++;1082 monitorcount = RTStrToUInt32(a->argv[i]);1083 }1084 else if (strcmp(a->argv[i], "-accelerate3d") == 0)1085 {1086 if (a->argc <= i + 1)1087 return errorArgument("Missing argument to '%s'", a->argv[i]);1088 i++;1089 accelerate3d = a->argv[i];1090 }1091 else if (strcmp(a->argv[i], "-bioslogofadein") == 0)1092 {1093 if (a->argc <= i + 1)1094 return errorArgument("Missing argument to '%s'", a->argv[i]);1095 i++;1096 bioslogofadein = a->argv[i];1097 }1098 else if (strcmp(a->argv[i], "-bioslogofadeout") == 0)1099 {1100 if (a->argc <= i + 1)1101 return errorArgument("Missing argument to '%s'", a->argv[i]);1102 i++;1103 bioslogofadeout = a->argv[i];1104 }1105 else if (strcmp(a->argv[i], "-bioslogodisplaytime") == 0)1106 {1107 if (a->argc <= i + 1)1108 return errorArgument("Missing argument to '%s'", a->argv[i]);1109 i++;1110 bioslogodisplaytime = RTStrToUInt32(a->argv[i]);1111 }1112 else if (strcmp(a->argv[i], "-bioslogoimagepath") == 0)1113 {1114 if (a->argc <= i + 1)1115 return errorArgument("Missing argument to '%s'", a->argv[i]);1116 i++;1117 bioslogoimagepath = a->argv[i];1118 }1119 else if (strcmp(a->argv[i], "-biosbootmenu") == 0)1120 {1121 if (a->argc <= i + 1)1122 return errorArgument("Missing argument to '%s'", a->argv[i]);1123 i++;1124 biosbootmenumode = a->argv[i];1125 }1126 else if (strcmp(a->argv[i], "-biossystemtimeoffset") == 0)1127 {1128 if (a->argc <= i + 1)1129 return errorArgument("Missing argument to '%s'", a->argv[i]);1130 i++;1131 biossystemtimeoffset = a->argv[i];1132 }1133 else if (strcmp(a->argv[i], "-biospxedebug") == 0)1134 {1135 if (a->argc <= i + 1)1136 return errorArgument("Missing argument to '%s'", a->argv[i]);1137 i++;1138 biospxedebug = a->argv[i];1139 }1140 else if (strncmp(a->argv[i], "-boot", 5) == 0)1141 {1142 uint32_t n = 0;1143 if (!a->argv[i][5])1144 return errorSyntax(USAGE_MODIFYVM, "Missing boot slot number in '%s'", a->argv[i]);1145 if (VINF_SUCCESS != RTStrToUInt32Full(&a->argv[i][5], 10, &n))1146 return errorSyntax(USAGE_MODIFYVM, "Invalid boot slot number in '%s'", a->argv[i]);1147 if (a->argc <= i + 1)1148 return errorArgument("Missing argument to '%s'", a->argv[i]);1149 i++;1150 if (strcmp(a->argv[i], "none") == 0)1151 {1152 bootDevice[n - 1] = DeviceType_Null;1153 }1154 else if (strcmp(a->argv[i], "floppy") == 0)1155 {1156 bootDevice[n - 1] = DeviceType_Floppy;1157 }1158 else if (strcmp(a->argv[i], "dvd") == 0)1159 {1160 bootDevice[n - 1] = DeviceType_DVD;1161 }1162 else if (strcmp(a->argv[i], "disk") == 0)1163 {1164 bootDevice[n - 1] = DeviceType_HardDisk;1165 }1166 else if (strcmp(a->argv[i], "net") == 0)1167 {1168 bootDevice[n - 1] = DeviceType_Network;1169 }1170 else1171 return errorArgument("Invalid boot device '%s'", a->argv[i]);1172 1173 bootDeviceChanged[n - 1] = true;1174 }1175 else if (strcmp(a->argv[i], "-hda") == 0)1176 {1177 if (a->argc <= i + 1)1178 return errorArgument("Missing argument to '%s'", a->argv[i]);1179 i++;1180 hdds[0] = a->argv[i];1181 }1182 else if (strcmp(a->argv[i], "-hdb") == 0)1183 {1184 if (a->argc <= i + 1)1185 return errorArgument("Missing argument to '%s'", a->argv[i]);1186 i++;1187 hdds[1] = a->argv[i];1188 }1189 else if (strcmp(a->argv[i], "-hdd") == 0)1190 {1191 if (a->argc <= i + 1)1192 return errorArgument("Missing argument to '%s'", a->argv[i]);1193 i++;1194 hdds[2] = a->argv[i];1195 }1196 else if (strcmp(a->argv[i], "-dvd") == 0)1197 {1198 if (a->argc <= i + 1)1199 return errorArgument("Missing argument to '%s'", a->argv[i]);1200 i++;1201 dvd = a->argv[i];1202 }1203 else if (strcmp(a->argv[i], "-dvdpassthrough") == 0)1204 {1205 if (a->argc <= i + 1)1206 return errorArgument("Missing argument to '%s'", a->argv[i]);1207 i++;1208 dvdpassthrough = a->argv[i];1209 }1210 else if (strcmp(a->argv[i], "-idecontroller") == 0)1211 {1212 if (a->argc <= i + 1)1213 return errorArgument("Missing argument to '%s'", a->argv[i]);1214 i++;1215 idecontroller = a->argv[i];1216 }1217 else if (strcmp(a->argv[i], "-floppy") == 0)1218 {1219 if (a->argc <= i + 1)1220 return errorArgument("Missing argument to '%s'", a->argv[i]);1221 i++;1222 floppy = a->argv[i];1223 }1224 else if (strcmp(a->argv[i], "-audio") == 0)1225 {1226 if (a->argc <= i + 1)1227 return errorArgument("Missing argument to '%s'", a->argv[i]);1228 i++;1229 audio = a->argv[i];1230 }1231 else if (strcmp(a->argv[i], "-audiocontroller") == 0)1232 {1233 if (a->argc <= i + 1)1234 return errorArgument("Missing argument to '%s'", a->argv[i]);1235 i++;1236 audiocontroller = a->argv[i];1237 }1238 else if (strcmp(a->argv[i], "-clipboard") == 0)1239 {1240 if (a->argc <= i + 1)1241 return errorArgument("Missing argument to '%s'", a->argv[i]);1242 i++;1243 clipboard = a->argv[i];1244 }1245 else if (strncmp(a->argv[i], "-cableconnected", 15) == 0)1246 {1247 unsigned n = parseNum(&a->argv[i][15], NetworkAdapterCount, "NIC");1248 if (!n)1249 return 1;1250 1251 if (a->argc <= i + 1)1252 return errorArgument("Missing argument to '%s'", a->argv[i]);1253 1254 cableconnected[n - 1] = a->argv[i + 1];1255 i++;1256 }1257 /* watch for the right order of these -nic* comparisons! */1258 else if (strncmp(a->argv[i], "-nictracefile", 13) == 0)1259 {1260 unsigned n = parseNum(&a->argv[i][13], NetworkAdapterCount, "NIC");1261 if (!n)1262 return 1;1263 if (a->argc <= i + 1)1264 {1265 return errorArgument("Missing argument to '%s'", a->argv[i]);1266 }1267 nictracefile[n - 1] = a->argv[i + 1];1268 i++;1269 }1270 else if (strncmp(a->argv[i], "-nictrace", 9) == 0)1271 {1272 unsigned n = parseNum(&a->argv[i][9], NetworkAdapterCount, "NIC");1273 if (!n)1274 return 1;1275 if (a->argc <= i + 1)1276 return errorArgument("Missing argument to '%s'", a->argv[i]);1277 nictrace[n - 1] = a->argv[i + 1];1278 i++;1279 }1280 else if (strncmp(a->argv[i], "-nictype", 8) == 0)1281 {1282 unsigned n = parseNum(&a->argv[i][8], NetworkAdapterCount, "NIC");1283 if (!n)1284 return 1;1285 if (a->argc <= i + 1)1286 return errorArgument("Missing argument to '%s'", a->argv[i]);1287 nictype[n - 1] = a->argv[i + 1];1288 i++;1289 }1290 else if (strncmp(a->argv[i], "-nicspeed", 9) == 0)1291 {1292 unsigned n = parseNum(&a->argv[i][9], NetworkAdapterCount, "NIC");1293 if (!n)1294 return 1;1295 if (a->argc <= i + 1)1296 return errorArgument("Missing argument to '%s'", a->argv[i]);1297 nicspeed[n - 1] = a->argv[i + 1];1298 i++;1299 }1300 else if (strncmp(a->argv[i], "-nic", 4) == 0)1301 {1302 unsigned n = parseNum(&a->argv[i][4], NetworkAdapterCount, "NIC");1303 if (!n)1304 return 1;1305 if (a->argc <= i + 1)1306 return errorArgument("Missing argument to '%s'", a->argv[i]);1307 nics[n - 1] = a->argv[i + 1];1308 i++;1309 }1310 else if (strncmp(a->argv[i], "-hostifdev", 10) == 0)1311 {1312 unsigned n = parseNum(&a->argv[i][10], NetworkAdapterCount, "NIC");1313 if (!n)1314 return 1;1315 if (a->argc <= i + 1)1316 return errorArgument("Missing argument to '%s'", a->argv[i]);1317 hostifdev[n - 1] = a->argv[i + 1];1318 i++;1319 }1320 else if (strncmp(a->argv[i], "-intnet", 7) == 0)1321 {1322 unsigned n = parseNum(&a->argv[i][7], NetworkAdapterCount, "NIC");1323 if (!n)1324 return 1;1325 if (a->argc <= i + 1)1326 return errorArgument("Missing argument to '%s'", a->argv[i]);1327 intnet[n - 1] = a->argv[i + 1];1328 i++;1329 }1330 else if (strncmp(a->argv[i], "-natnet", 7) == 0)1331 {1332 unsigned n = parseNum(&a->argv[i][7], NetworkAdapterCount, "NIC");1333 if (!n)1334 return 1;1335 if (a->argc <= i + 1)1336 return errorArgument("Missing argument to '%s'", a->argv[i]);1337 1338 if (!strcmp(a->argv[i + 1], "default"))1339 natnet[n - 1] = "";1340 else1341 {1342 RTIPV4ADDR Network;1343 RTIPV4ADDR Netmask;1344 int rc = RTCidrStrToIPv4(a->argv[i + 1], &Network, &Netmask);1345 if (RT_FAILURE(rc))1346 return errorArgument("Invalid IPv4 network '%s' specified -- CIDR notation expected.\n", a->argv[i + 1]);1347 if (Netmask & 0x1f)1348 return errorArgument("Prefix length of the NAT network must be less than 28.\n");1349 natnet[n - 1] = a->argv[i + 1];1350 }1351 i++;1352 }1353 else if (strncmp(a->argv[i], "-macaddress", 11) == 0)1354 {1355 unsigned n = parseNum(&a->argv[i][11], NetworkAdapterCount, "NIC");1356 if (!n)1357 return 1;1358 if (a->argc <= i + 1)1359 return errorArgument("Missing argument to '%s'", a->argv[i]);1360 macs[n - 1] = a->argv[i + 1];1361 i++;1362 }1363 #ifdef VBOX_WITH_VRDP1364 else if (strcmp(a->argv[i], "-vrdp") == 0)1365 {1366 if (a->argc <= i + 1)1367 return errorArgument("Missing argument to '%s'", a->argv[i]);1368 i++;1369 vrdp = a->argv[i];1370 }1371 else if (strcmp(a->argv[i], "-vrdpport") == 0)1372 {1373 if (a->argc <= i + 1)1374 return errorArgument("Missing argument to '%s'", a->argv[i]);1375 i++;1376 if (strcmp(a->argv[i], "default") == 0)1377 vrdpport = 0;1378 else1379 vrdpport = RTStrToUInt16(a->argv[i]);1380 }1381 else if (strcmp(a->argv[i], "-vrdpaddress") == 0)1382 {1383 if (a->argc <= i + 1)1384 return errorArgument("Missing argument to '%s'", a->argv[i]);1385 i++;1386 vrdpaddress = a->argv[i];1387 }1388 else if (strcmp(a->argv[i], "-vrdpauthtype") == 0)1389 {1390 if (a->argc <= i + 1)1391 return errorArgument("Missing argument to '%s'", a->argv[i]);1392 i++;1393 vrdpauthtype = a->argv[i];1394 }1395 else if (strcmp(a->argv[i], "-vrdpmulticon") == 0)1396 {1397 if (a->argc <= i + 1)1398 return errorArgument("Missing argument to '%s'", a->argv[i]);1399 i++;1400 vrdpmulticon = a->argv[i];1401 }1402 else if (strcmp(a->argv[i], "-vrdpreusecon") == 0)1403 {1404 if (a->argc <= i + 1)1405 return errorArgument("Missing argument to '%s'", a->argv[i]);1406 i++;1407 vrdpreusecon = a->argv[i];1408 }1409 #endif /* VBOX_WITH_VRDP */1410 else if (strcmp(a->argv[i], "-usb") == 0)1411 {1412 if (a->argc <= i + 1)1413 return errorArgument("Missing argument to '%s'", a->argv[i]);1414 i++;1415 if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)1416 fUsbEnabled = 1;1417 else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)1418 fUsbEnabled = 0;1419 else1420 return errorArgument("Invalid -usb argument '%s'", a->argv[i]);1421 }1422 else if (strcmp(a->argv[i], "-usbehci") == 0)1423 {1424 if (a->argc <= i + 1)1425 return errorArgument("Missing argument to '%s'", a->argv[i]);1426 i++;1427 if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)1428 fUsbEhciEnabled = 1;1429 else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)1430 fUsbEhciEnabled = 0;1431 else1432 return errorArgument("Invalid -usbehci argument '%s'", a->argv[i]);1433 }1434 else if (strcmp(a->argv[i], "-snapshotfolder") == 0)1435 {1436 if (a->argc <= i + 1)1437 return errorArgument("Missing argument to '%s'", a->argv[i]);1438 i++;1439 snapshotFolder = a->argv[i];1440 }1441 else if (strncmp(a->argv[i], "-uartmode", 9) == 0)1442 {1443 unsigned n = parseNum(&a->argv[i][9], SerialPortCount, "UART");1444 if (!n)1445 return 1;1446 i++;1447 if (strcmp(a->argv[i], "disconnected") == 0)1448 {1449 uarts_mode[n - 1] = a->argv[i];1450 }1451 else1452 {1453 if (strcmp(a->argv[i], "server") == 0 || strcmp(a->argv[i], "client") == 0)1454 {1455 uarts_mode[n - 1] = a->argv[i];1456 i++;1457 #ifdef RT_OS_WINDOWS1458 if (strncmp(a->argv[i], "\\\\.\\pipe\\", 9))1459 return errorArgument("Uart pipe must start with \\\\.\\pipe\\");1460 #endif1461 }1462 else1463 {1464 uarts_mode[n - 1] = (char*)"device";1465 }1466 if (a->argc <= i)1467 return errorArgument("Missing argument to -uartmode");1468 uarts_path[n - 1] = a->argv[i];1469 }1470 }1471 else if (strncmp(a->argv[i], "-uart", 5) == 0)1472 {1473 unsigned n = parseNum(&a->argv[i][5], SerialPortCount, "UART");1474 if (!n)1475 return 1;1476 if (a->argc <= i + 1)1477 return errorArgument("Missing argument to '%s'", a->argv[i]);1478 i++;1479 if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)1480 {1481 uarts_base[n - 1] = (ULONG)-1;1482 }1483 else1484 {1485 if (a->argc <= i + 1)1486 return errorArgument("Missing argument to '%s'", a->argv[i-1]);1487 uint32_t uVal;1488 int vrc;1489 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);1490 if (vrc != VINF_SUCCESS || uVal == 0)1491 return errorArgument("Error parsing UART I/O base '%s'", a->argv[i]);1492 uarts_base[n - 1] = uVal;1493 i++;1494 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);1495 if (vrc != VINF_SUCCESS)1496 return errorArgument("Error parsing UART IRQ '%s'", a->argv[i]);1497 uarts_irq[n - 1] = uVal;1498 }1499 }1500 #ifdef VBOX_WITH_MEM_BALLOONING1501 else if (strncmp(a->argv[i], "-guestmemoryballoon", 19) == 0)1502 {1503 if (a->argc <= i + 1)1504 return errorArgument("Missing argument to '%s'", a->argv[i]);1505 i++;1506 uint32_t uVal;1507 int vrc;1508 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);1509 if (vrc != VINF_SUCCESS)1510 return errorArgument("Error parsing guest memory balloon size '%s'", a->argv[i]);1511 guestMemBalloonSize = uVal;1512 }1513 #endif1514 else if (strncmp(a->argv[i], "-gueststatisticsinterval", 24) == 0)1515 {1516 if (a->argc <= i + 1)1517 return errorArgument("Missing argument to '%s'", a->argv[i]);1518 i++;1519 uint32_t uVal;1520 int vrc;1521 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);1522 if (vrc != VINF_SUCCESS)1523 return errorArgument("Error parsing guest statistics interval '%s'", a->argv[i]);1524 guestStatInterval = uVal;1525 }1526 else if (strcmp(a->argv[i], "-sata") == 0)1527 {1528 if (a->argc <= i + 1)1529 return errorArgument("Missing argument to '%s'", a->argv[i]);1530 i++;1531 if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)1532 fSataEnabled = 1;1533 else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)1534 fSataEnabled = 0;1535 else1536 return errorArgument("Invalid -usb argument '%s'", a->argv[i]);1537 }1538 else if (strcmp(a->argv[i], "-sataportcount") == 0)1539 {1540 unsigned n;1541 1542 if (a->argc <= i + 1)1543 return errorArgument("Missing arguments to '%s'", a->argv[i]);1544 i++;1545 1546 n = parseNum(a->argv[i], 30, "SATA");1547 if (!n)1548 return 1;1549 sataPortCount = n;1550 }1551 else if (strncmp(a->argv[i], "-sataport", 9) == 0)1552 {1553 unsigned n = parseNum(&a->argv[i][9], 30, "SATA");1554 if (!n)1555 return 1;1556 if (a->argc <= i + 1)1557 return errorArgument("Missing argument to '%s'", a->argv[i]);1558 i++;1559 hdds[n-1+4] = a->argv[i];1560 }1561 else if (strncmp(a->argv[i], "-sataideemulation", 17) == 0)1562 {1563 unsigned bootDevicePos = 0;1564 unsigned n;1565 1566 bootDevicePos = parseNum(&a->argv[i][17], 4, "SATA");1567 if (!bootDevicePos)1568 return 1;1569 bootDevicePos--;1570 1571 if (a->argc <= i + 1)1572 return errorArgument("Missing arguments to '%s'", a->argv[i]);1573 i++;1574 1575 n = parseNum(a->argv[i], 30, "SATA");1576 if (!n)1577 return 1;1578 1579 sataBootDevices[bootDevicePos] = n-1;1580 }1581 else1582 return errorSyntax(USAGE_MODIFYVM, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());1583 }1584 1585 /* try to find the given machine */1586 ComPtr <IMachine> machine;1587 Guid uuid (a->argv[0]);1588 if (!uuid.isEmpty())1589 {1590 CHECK_ERROR (a->virtualBox, GetMachine (uuid, machine.asOutParam()));1591 }1592 else1593 {1594 CHECK_ERROR (a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));1595 if (SUCCEEDED (rc))1596 machine->COMGETTER(Id)(uuid.asOutParam());1597 }1598 if (FAILED (rc))1599 return 1;1600 1601 /* open a session for the VM */1602 CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1);1603 1604 do1605 {1606 /* get the mutable session machine */1607 a->session->COMGETTER(Machine)(machine.asOutParam());1608 1609 ComPtr <IBIOSSettings> biosSettings;1610 machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());1611 1612 if (name)1613 CHECK_ERROR(machine, COMSETTER(Name)(name));1614 if (ostype)1615 {1616 ComPtr<IGuestOSType> guestOSType;1617 CHECK_ERROR(a->virtualBox, GetGuestOSType(ostype, guestOSType.asOutParam()));1618 if (SUCCEEDED(rc) && guestOSType)1619 {1620 CHECK_ERROR(machine, COMSETTER(OSTypeId)(ostype));1621 }1622 else1623 {1624 errorArgument("Invalid guest OS type '%s'", Utf8Str(ostype).raw());1625 rc = E_FAIL;1626 break;1627 }1628 }1629 if (memorySize > 0)1630 CHECK_ERROR(machine, COMSETTER(MemorySize)(memorySize));1631 if (vramSize > 0)1632 CHECK_ERROR(machine, COMSETTER(VRAMSize)(vramSize));1633 if (acpi)1634 {1635 if (strcmp(acpi, "on") == 0)1636 {1637 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(true));1638 }1639 else if (strcmp(acpi, "off") == 0)1640 {1641 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(false));1642 }1643 else1644 {1645 errorArgument("Invalid -acpi argument '%s'", acpi);1646 rc = E_FAIL;1647 break;1648 }1649 }1650 if (ioapic)1651 {1652 if (strcmp(ioapic, "on") == 0)1653 {1654 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(true));1655 }1656 else if (strcmp(ioapic, "off") == 0)1657 {1658 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(false));1659 }1660 else1661 {1662 errorArgument("Invalid -ioapic argument '%s'", ioapic);1663 rc = E_FAIL;1664 break;1665 }1666 }1667 if (hwvirtex)1668 {1669 if (strcmp(hwvirtex, "on") == 0)1670 {1671 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_True));1672 }1673 else if (strcmp(hwvirtex, "off") == 0)1674 {1675 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_False));1676 }1677 else if (strcmp(hwvirtex, "default") == 0)1678 {1679 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_Default));1680 }1681 else1682 {1683 errorArgument("Invalid -hwvirtex argument '%s'", hwvirtex);1684 rc = E_FAIL;1685 break;1686 }1687 }1688 if (nestedpaging)1689 {1690 if (strcmp(nestedpaging, "on") == 0)1691 {1692 CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(true));1693 }1694 else if (strcmp(nestedpaging, "off") == 0)1695 {1696 CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(false));1697 }1698 else1699 {1700 errorArgument("Invalid -nestedpaging argument '%s'", ioapic);1701 rc = E_FAIL;1702 break;1703 }1704 }1705 if (vtxvpid)1706 {1707 if (strcmp(vtxvpid, "on") == 0)1708 {1709 CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(true));1710 }1711 else if (strcmp(vtxvpid, "off") == 0)1712 {1713 CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(false));1714 }1715 else1716 {1717 errorArgument("Invalid -vtxvpid argument '%s'", ioapic);1718 rc = E_FAIL;1719 break;1720 }1721 }1722 if (pae)1723 {1724 if (strcmp(pae, "on") == 0)1725 {1726 CHECK_ERROR(machine, COMSETTER(PAEEnabled)(true));1727 }1728 else if (strcmp(pae, "off") == 0)1729 {1730 CHECK_ERROR(machine, COMSETTER(PAEEnabled)(false));1731 }1732 else1733 {1734 errorArgument("Invalid -pae argument '%s'", ioapic);1735 rc = E_FAIL;1736 break;1737 }1738 }1739 if (monitorcount != ~0U)1740 {1741 CHECK_ERROR(machine, COMSETTER(MonitorCount)(monitorcount));1742 }1743 if (accelerate3d)1744 {1745 if (strcmp(accelerate3d, "on") == 0)1746 {1747 CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(true));1748 }1749 else if (strcmp(accelerate3d, "off") == 0)1750 {1751 CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(false));1752 }1753 else1754 {1755 errorArgument("Invalid -accelerate3d argument '%s'", ioapic);1756 rc = E_FAIL;1757 break;1758 }1759 }1760 if (bioslogofadein)1761 {1762 if (strcmp(bioslogofadein, "on") == 0)1763 {1764 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(true));1765 }1766 else if (strcmp(bioslogofadein, "off") == 0)1767 {1768 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(false));1769 }1770 else1771 {1772 errorArgument("Invalid -bioslogofadein argument '%s'", bioslogofadein);1773 rc = E_FAIL;1774 break;1775 }1776 }1777 if (bioslogofadeout)1778 {1779 if (strcmp(bioslogofadeout, "on") == 0)1780 {1781 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(true));1782 }1783 else if (strcmp(bioslogofadeout, "off") == 0)1784 {1785 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(false));1786 }1787 else1788 {1789 errorArgument("Invalid -bioslogofadeout argument '%s'", bioslogofadeout);1790 rc = E_FAIL;1791 break;1792 }1793 }1794 if (bioslogodisplaytime != ~0U)1795 {1796 CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(bioslogodisplaytime));1797 }1798 if (bioslogoimagepath)1799 {1800 CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(bioslogoimagepath)));1801 }1802 if (biosbootmenumode)1803 {1804 if (strcmp(biosbootmenumode, "disabled") == 0)1805 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled));1806 else if (strcmp(biosbootmenumode, "menuonly") == 0)1807 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly));1808 else if (strcmp(biosbootmenumode, "messageandmenu") == 0)1809 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu));1810 else1811 {1812 errorArgument("Invalid -biosbootmenu argument '%s'", biosbootmenumode);1813 rc = E_FAIL;1814 break;1815 }1816 1817 }1818 if (biossystemtimeoffset)1819 {1820 LONG64 timeOffset = RTStrToInt64(biossystemtimeoffset);1821 CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(timeOffset));1822 }1823 if (biospxedebug)1824 {1825 if (strcmp(biospxedebug, "on") == 0)1826 {1827 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(true));1828 }1829 else if (strcmp(biospxedebug, "off") == 0)1830 {1831 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(false));1832 }1833 else1834 {1835 errorArgument("Invalid -biospxedebug argument '%s'", biospxedebug);1836 rc = E_FAIL;1837 break;1838 }1839 }1840 for (int curBootDev = 0; curBootDev < 4; curBootDev++)1841 {1842 if (bootDeviceChanged[curBootDev])1843 CHECK_ERROR(machine, SetBootOrder (curBootDev + 1, bootDevice[curBootDev]));1844 }1845 if (hdds[0])1846 {1847 if (strcmp(hdds[0], "none") == 0)1848 {1849 machine->DetachHardDisk2(StorageBus_IDE, 0, 0);1850 }1851 else1852 {1853 /* first guess is that it's a UUID */1854 Guid uuid(hdds[0]);1855 ComPtr<IHardDisk2> hardDisk;1856 rc = a->virtualBox->GetHardDisk2(uuid, hardDisk.asOutParam());1857 /* not successful? Then it must be a filename */1858 if (!hardDisk)1859 {1860 CHECK_ERROR(a->virtualBox, FindHardDisk2(Bstr(hdds[0]), hardDisk.asOutParam()));1861 if (FAILED(rc))1862 {1863 /* open the new hard disk object */1864 CHECK_ERROR(a->virtualBox, OpenHardDisk2(Bstr(hdds[0]), hardDisk.asOutParam()));1865 }1866 }1867 if (hardDisk)1868 {1869 hardDisk->COMGETTER(Id)(uuid.asOutParam());1870 CHECK_ERROR(machine, AttachHardDisk2(uuid, StorageBus_IDE, 0, 0));1871 }1872 else1873 rc = E_FAIL;1874 if (FAILED(rc))1875 break;1876 }1877 }1878 if (hdds[1])1879 {1880 if (strcmp(hdds[1], "none") == 0)1881 {1882 machine->DetachHardDisk2(StorageBus_IDE, 0, 1);1883 }1884 else1885 {1886 /* first guess is that it's a UUID */1887 Guid uuid(hdds[1]);1888 ComPtr<IHardDisk2> hardDisk;1889 rc = a->virtualBox->GetHardDisk2(uuid, hardDisk.asOutParam());1890 /* not successful? Then it must be a filename */1891 if (!hardDisk)1892 {1893 CHECK_ERROR(a->virtualBox, FindHardDisk2(Bstr(hdds[1]), hardDisk.asOutParam()));1894 if (FAILED(rc))1895 {1896 /* open the new hard disk object */1897 CHECK_ERROR(a->virtualBox, OpenHardDisk2(Bstr(hdds[1]), hardDisk.asOutParam()));1898 }1899 }1900 if (hardDisk)1901 {1902 hardDisk->COMGETTER(Id)(uuid.asOutParam());1903 CHECK_ERROR(machine, AttachHardDisk2(uuid, StorageBus_IDE, 0, 1));1904 }1905 else1906 rc = E_FAIL;1907 if (FAILED(rc))1908 break;1909 }1910 }1911 if (hdds[2])1912 {1913 if (strcmp(hdds[2], "none") == 0)1914 {1915 machine->DetachHardDisk2(StorageBus_IDE, 1, 1);1916 }1917 else1918 {1919 /* first guess is that it's a UUID */1920 Guid uuid(hdds[2]);1921 ComPtr<IHardDisk2> hardDisk;1922 rc = a->virtualBox->GetHardDisk2(uuid, hardDisk.asOutParam());1923 /* not successful? Then it must be a filename */1924 if (!hardDisk)1925 {1926 CHECK_ERROR(a->virtualBox, FindHardDisk2(Bstr(hdds[2]), hardDisk.asOutParam()));1927 if (FAILED(rc))1928 {1929 /* open the new hard disk object */1930 CHECK_ERROR(a->virtualBox, OpenHardDisk2(Bstr(hdds[2]), hardDisk.asOutParam()));1931 }1932 }1933 if (hardDisk)1934 {1935 hardDisk->COMGETTER(Id)(uuid.asOutParam());1936 CHECK_ERROR(machine, AttachHardDisk2(uuid, StorageBus_IDE, 1, 1));1937 }1938 else1939 rc = E_FAIL;1940 if (FAILED(rc))1941 break;1942 }1943 }1944 if (dvd)1945 {1946 ComPtr<IDVDDrive> dvdDrive;1947 machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());1948 ASSERT(dvdDrive);1949 1950 /* unmount? */1951 if (strcmp(dvd, "none") == 0)1952 {1953 CHECK_ERROR(dvdDrive, Unmount());1954 }1955 /* host drive? */1956 else if (strncmp(dvd, "host:", 5) == 0)1957 {1958 ComPtr<IHost> host;1959 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));1960 ComPtr<IHostDVDDriveCollection> hostDVDs;1961 CHECK_ERROR(host, COMGETTER(DVDDrives)(hostDVDs.asOutParam()));1962 ComPtr<IHostDVDDrive> hostDVDDrive;1963 rc = hostDVDs->FindByName(Bstr(dvd + 5), hostDVDDrive.asOutParam());1964 if (!hostDVDDrive)1965 {1966 /* 2nd try: try with the real name, important on Linux+libhal */1967 char szPathReal[RTPATH_MAX];1968 if (RT_FAILURE(RTPathReal(dvd + 5, szPathReal, sizeof(szPathReal))))1969 {1970 errorArgument("Invalid host DVD drive name");1971 rc = E_FAIL;1972 break;1973 }1974 rc = hostDVDs->FindByName(Bstr(szPathReal), hostDVDDrive.asOutParam());1975 if (!hostDVDDrive)1976 {1977 errorArgument("Invalid host DVD drive name");1978 rc = E_FAIL;1979 break;1980 }1981 }1982 CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));1983 }1984 else1985 {1986 /* first assume it's a UUID */1987 Guid uuid(dvd);1988 ComPtr<IDVDImage2> dvdImage;1989 rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam());1990 if (FAILED(rc) || !dvdImage)1991 {1992 /* must be a filename, check if it's in the collection */1993 rc = a->virtualBox->FindDVDImage(Bstr(dvd), dvdImage.asOutParam());1994 /* not registered, do that on the fly */1995 if (!dvdImage)1996 {1997 Guid emptyUUID;1998 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(dvd), emptyUUID, dvdImage.asOutParam()));1999 }2000 }2001 if (!dvdImage)2002 {2003 rc = E_FAIL;2004 break;2005 }2006 2007 dvdImage->COMGETTER(Id)(uuid.asOutParam());2008 CHECK_ERROR(dvdDrive, MountImage(uuid));2009 }2010 }2011 if (dvdpassthrough)2012 {2013 ComPtr<IDVDDrive> dvdDrive;2014 machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());2015 ASSERT(dvdDrive);2016 2017 CHECK_ERROR(dvdDrive, COMSETTER(Passthrough)(strcmp(dvdpassthrough, "on") == 0));2018 }2019 if (idecontroller)2020 {2021 if (RTStrICmp(idecontroller, "PIIX3") == 0)2022 {2023 CHECK_ERROR(biosSettings, COMSETTER(IDEControllerType)(IDEControllerType_PIIX3));2024 }2025 else if (RTStrICmp(idecontroller, "PIIX4") == 0)2026 {2027 CHECK_ERROR(biosSettings, COMSETTER(IDEControllerType)(IDEControllerType_PIIX4));2028 }2029 else2030 {2031 errorArgument("Invalid -idecontroller argument '%s'", idecontroller);2032 rc = E_FAIL;2033 break;2034 }2035 }2036 if (floppy)2037 {2038 ComPtr<IFloppyDrive> floppyDrive;2039 machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());2040 ASSERT(floppyDrive);2041 2042 /* disable? */2043 if (strcmp(floppy, "disabled") == 0)2044 {2045 /* disable the controller */2046 CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(false));2047 }2048 else2049 {2050 /* enable the controller */2051 CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(true));2052 2053 /* unmount? */2054 if (strcmp(floppy, "empty") == 0)2055 {2056 CHECK_ERROR(floppyDrive, Unmount());2057 }2058 /* host drive? */2059 else if (strncmp(floppy, "host:", 5) == 0)2060 {2061 ComPtr<IHost> host;2062 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));2063 ComPtr<IHostFloppyDriveCollection> hostFloppies;2064 CHECK_ERROR(host, COMGETTER(FloppyDrives)(hostFloppies.asOutParam()));2065 ComPtr<IHostFloppyDrive> hostFloppyDrive;2066 rc = hostFloppies->FindByName(Bstr(floppy + 5), hostFloppyDrive.asOutParam());2067 if (!hostFloppyDrive)2068 {2069 errorArgument("Invalid host floppy drive name");2070 rc = E_FAIL;2071 break;2072 }2073 CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));2074 }2075 else2076 {2077 /* first assume it's a UUID */2078 Guid uuid(floppy);2079 ComPtr<IFloppyImage2> floppyImage;2080 rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam());2081 if (FAILED(rc) || !floppyImage)2082 {2083 /* must be a filename, check if it's in the collection */2084 rc = a->virtualBox->FindFloppyImage(Bstr(floppy), floppyImage.asOutParam());2085 /* not registered, do that on the fly */2086 if (!floppyImage)2087 {2088 Guid emptyUUID;2089 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(floppy), emptyUUID, floppyImage.asOutParam()));2090 }2091 }2092 if (!floppyImage)2093 {2094 rc = E_FAIL;2095 break;2096 }2097 2098 floppyImage->COMGETTER(Id)(uuid.asOutParam());2099 CHECK_ERROR(floppyDrive, MountImage(uuid));2100 }2101 }2102 }2103 if (audio || audiocontroller)2104 {2105 ComPtr<IAudioAdapter> audioAdapter;2106 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());2107 ASSERT(audioAdapter);2108 2109 if (audio)2110 {2111 /* disable? */2112 if (strcmp(audio, "none") == 0)2113 {2114 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));2115 }2116 else if (strcmp(audio, "null") == 0)2117 {2118 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));2119 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2120 }2121 #ifdef RT_OS_WINDOWS2122 #ifdef VBOX_WITH_WINMM2123 else if (strcmp(audio, "winmm") == 0)2124 {2125 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));2126 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2127 }2128 #endif2129 else if (strcmp(audio, "dsound") == 0)2130 {2131 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));2132 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2133 }2134 #endif /* RT_OS_WINDOWS */2135 #ifdef RT_OS_LINUX2136 else if (strcmp(audio, "oss") == 0)2137 {2138 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));2139 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2140 }2141 # ifdef VBOX_WITH_ALSA2142 else if (strcmp(audio, "alsa") == 0)2143 {2144 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));2145 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2146 }2147 # endif2148 # ifdef VBOX_WITH_PULSE2149 else if (strcmp(audio, "pulse") == 0)2150 {2151 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));2152 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2153 }2154 # endif2155 #endif /* !RT_OS_LINUX */2156 #ifdef RT_OS_SOLARIS2157 else if (strcmp(audio, "solaudio") == 0)2158 {2159 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio));2160 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2161 }2162 2163 #endif /* !RT_OS_SOLARIS */2164 #ifdef RT_OS_DARWIN2165 else if (strcmp(audio, "coreaudio") == 0)2166 {2167 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));2168 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));2169 }2170 2171 #endif /* !RT_OS_DARWIN */2172 else2173 {2174 errorArgument("Invalid -audio argument '%s'", audio);2175 rc = E_FAIL;2176 break;2177 }2178 }2179 if (audiocontroller)2180 {2181 if (strcmp(audiocontroller, "sb16") == 0)2182 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));2183 else if (strcmp(audiocontroller, "ac97") == 0)2184 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));2185 else2186 {2187 errorArgument("Invalid -audiocontroller argument '%s'", audiocontroller);2188 rc = E_FAIL;2189 break;2190 }2191 }2192 }2193 /* Shared clipboard state */2194 if (clipboard)2195 {2196 /* ComPtr<IClipboardMode> clipboardMode;2197 machine->COMGETTER(ClipboardMode)(clipboardMode.asOutParam());2198 ASSERT(clipboardMode);2199 */2200 if (strcmp(clipboard, "disabled") == 0)2201 {2202 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled));2203 }2204 else if (strcmp(clipboard, "hosttoguest") == 0)2205 {2206 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest));2207 }2208 else if (strcmp(clipboard, "guesttohost") == 0)2209 {2210 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost));2211 }2212 else if (strcmp(clipboard, "bidirectional") == 0)2213 {2214 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional));2215 }2216 else2217 {2218 errorArgument("Invalid -clipboard argument '%s'", clipboard);2219 rc = E_FAIL;2220 break;2221 }2222 }2223 /* iterate through all possible NICs */2224 for (ULONG n = 0; n < NetworkAdapterCount; n ++)2225 {2226 ComPtr<INetworkAdapter> nic;2227 CHECK_ERROR_RET (machine, GetNetworkAdapter (n, nic.asOutParam()), 1);2228 2229 ASSERT(nic);2230 2231 /* something about the NIC? */2232 if (nics[n])2233 {2234 if (strcmp(nics[n], "none") == 0)2235 {2236 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (FALSE), 1);2237 }2238 else if (strcmp(nics[n], "null") == 0)2239 {2240 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);2241 CHECK_ERROR_RET(nic, Detach(), 1);2242 }2243 else if (strcmp(nics[n], "nat") == 0)2244 {2245 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);2246 CHECK_ERROR_RET(nic, AttachToNAT(), 1);2247 }2248 else if (strcmp(nics[n], "hostif") == 0)2249 {2250 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);2251 CHECK_ERROR_RET(nic, AttachToHostInterface(), 1);2252 }2253 else if (strcmp(nics[n], "intnet") == 0)2254 {2255 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);2256 CHECK_ERROR_RET(nic, AttachToInternalNetwork(), 1);2257 }2258 else2259 {2260 errorArgument("Invalid type '%s' specfied for NIC %lu", nics[n], n + 1);2261 rc = E_FAIL;2262 break;2263 }2264 }2265 2266 /* something about the NIC type? */2267 if (nictype[n])2268 {2269 if (strcmp(nictype[n], "Am79C970A") == 0)2270 {2271 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A), 1);2272 }2273 else if (strcmp(nictype[n], "Am79C973") == 0)2274 {2275 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973), 1);2276 }2277 #ifdef VBOX_WITH_E10002278 else if (strcmp(nictype[n], "82540EM") == 0)2279 {2280 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM), 1);2281 }2282 else if (strcmp(nictype[n], "82543GC") == 0)2283 {2284 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC), 1);2285 }2286 #endif2287 else2288 {2289 errorArgument("Invalid NIC type '%s' specified for NIC %lu", nictype[n], n + 1);2290 rc = E_FAIL;2291 break;2292 }2293 }2294 2295 /* something about the MAC address? */2296 if (macs[n])2297 {2298 /* generate one? */2299 if (strcmp(macs[n], "auto") == 0)2300 {2301 CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(NULL), 1);2302 }2303 else2304 {2305 CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(Bstr(macs[n])), 1);2306 }2307 }2308 2309 /* something about the reported link speed? */2310 if (nicspeed[n])2311 {2312 uint32_t u32LineSpeed;2313 2314 u32LineSpeed = RTStrToUInt32(nicspeed[n]);2315 2316 if (u32LineSpeed < 1000 || u32LineSpeed > 4000000)2317 {2318 errorArgument("Invalid -nicspeed%lu argument '%s'", n + 1, nicspeed[n]);2319 rc = E_FAIL;2320 break;2321 }2322 CHECK_ERROR_RET(nic, COMSETTER(LineSpeed)(u32LineSpeed), 1);2323 }2324 2325 /* the link status flag? */2326 if (cableconnected[n])2327 {2328 if (strcmp(cableconnected[n], "on") == 0)2329 {2330 CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(TRUE), 1);2331 }2332 else if (strcmp(cableconnected[n], "off") == 0)2333 {2334 CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(FALSE), 1);2335 }2336 else2337 {2338 errorArgument("Invalid -cableconnected%lu argument '%s'", n + 1, cableconnected[n]);2339 rc = E_FAIL;2340 break;2341 }2342 }2343 2344 /* the trace flag? */2345 if (nictrace[n])2346 {2347 if (strcmp(nictrace[n], "on") == 0)2348 {2349 CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(TRUE), 1);2350 }2351 else if (strcmp(nictrace[n], "off") == 0)2352 {2353 CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(FALSE), 1);2354 }2355 else2356 {2357 errorArgument("Invalid -nictrace%lu argument '%s'", n + 1, nictrace[n]);2358 rc = E_FAIL;2359 break;2360 }2361 }2362 2363 /* the tracefile flag? */2364 if (nictracefile[n])2365 {2366 CHECK_ERROR_RET(nic, COMSETTER(TraceFile)(Bstr(nictracefile[n])), 1);2367 }2368 2369 /* the host interface device? */2370 if (hostifdev[n])2371 {2372 /* remove it? */2373 if (strcmp(hostifdev[n], "none") == 0)2374 {2375 CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(NULL), 1);2376 }2377 else2378 {2379 CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(Bstr(hostifdev[n])), 1);2380 }2381 }2382 2383 /* the internal network name? */2384 if (intnet[n])2385 {2386 /* remove it? */2387 if (strcmp(intnet[n], "none") == 0)2388 {2389 CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(NULL), 1);2390 }2391 else2392 {2393 CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(Bstr(intnet[n])), 1);2394 }2395 }2396 /* the network of the NAT */2397 if (natnet[n])2398 {2399 CHECK_ERROR_RET(nic, COMSETTER(NATNetwork)(Bstr(natnet[n])), 1);2400 }2401 }2402 if (FAILED(rc))2403 break;2404 2405 /* iterate through all possible serial ports */2406 for (ULONG n = 0; n < SerialPortCount; n ++)2407 {2408 ComPtr<ISerialPort> uart;2409 CHECK_ERROR_RET (machine, GetSerialPort (n, uart.asOutParam()), 1);2410 2411 ASSERT(uart);2412 2413 if (uarts_base[n])2414 {2415 if (uarts_base[n] == (ULONG)-1)2416 {2417 CHECK_ERROR_RET(uart, COMSETTER(Enabled) (FALSE), 1);2418 }2419 else2420 {2421 CHECK_ERROR_RET(uart, COMSETTER(IOBase) (uarts_base[n]), 1);2422 CHECK_ERROR_RET(uart, COMSETTER(IRQ) (uarts_irq[n]), 1);2423 CHECK_ERROR_RET(uart, COMSETTER(Enabled) (TRUE), 1);2424 }2425 }2426 if (uarts_mode[n])2427 {2428 if (strcmp(uarts_mode[n], "disconnected") == 0)2429 {2430 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_Disconnected), 1);2431 }2432 else2433 {2434 CHECK_ERROR_RET(uart, COMSETTER(Path) (Bstr(uarts_path[n])), 1);2435 if (strcmp(uarts_mode[n], "server") == 0)2436 {2437 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1);2438 CHECK_ERROR_RET(uart, COMSETTER(Server) (TRUE), 1);2439 }2440 else if (strcmp(uarts_mode[n], "client") == 0)2441 {2442 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1);2443 CHECK_ERROR_RET(uart, COMSETTER(Server) (FALSE), 1);2444 }2445 else2446 {2447 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostDevice), 1);2448 }2449 }2450 }2451 }2452 if (FAILED(rc))2453 break;2454 2455 #ifdef VBOX_WITH_VRDP2456 if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon || vrdpreusecon)2457 {2458 ComPtr<IVRDPServer> vrdpServer;2459 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());2460 ASSERT(vrdpServer);2461 if (vrdpServer)2462 {2463 if (vrdp)2464 {2465 if (strcmp(vrdp, "on") == 0)2466 {2467 CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(true));2468 }2469 else if (strcmp(vrdp, "off") == 0)2470 {2471 CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(false));2472 }2473 else2474 {2475 errorArgument("Invalid -vrdp argument '%s'", vrdp);2476 rc = E_FAIL;2477 break;2478 }2479 }2480 if (vrdpport != UINT16_MAX)2481 {2482 CHECK_ERROR(vrdpServer, COMSETTER(Port)(vrdpport));2483 }2484 if (vrdpaddress)2485 {2486 CHECK_ERROR(vrdpServer, COMSETTER(NetAddress)(Bstr(vrdpaddress)));2487 }2488 if (vrdpauthtype)2489 {2490 if (strcmp(vrdpauthtype, "null") == 0)2491 {2492 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Null));2493 }2494 else if (strcmp(vrdpauthtype, "external") == 0)2495 {2496 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_External));2497 }2498 else if (strcmp(vrdpauthtype, "guest") == 0)2499 {2500 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Guest));2501 }2502 else2503 {2504 errorArgument("Invalid -vrdpauthtype argument '%s'", vrdpauthtype);2505 rc = E_FAIL;2506 break;2507 }2508 }2509 if (vrdpmulticon)2510 {2511 if (strcmp(vrdpmulticon, "on") == 0)2512 {2513 CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(true));2514 }2515 else if (strcmp(vrdpmulticon, "off") == 0)2516 {2517 CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(false));2518 }2519 else2520 {2521 errorArgument("Invalid -vrdpmulticon argument '%s'", vrdpmulticon);2522 rc = E_FAIL;2523 break;2524 }2525 }2526 if (vrdpreusecon)2527 {2528 if (strcmp(vrdpreusecon, "on") == 0)2529 {2530 CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(true));2531 }2532 else if (strcmp(vrdpreusecon, "off") == 0)2533 {2534 CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(false));2535 }2536 else2537 {2538 errorArgument("Invalid -vrdpreusecon argument '%s'", vrdpreusecon);2539 rc = E_FAIL;2540 break;2541 }2542 }2543 }2544 }2545 #endif /* VBOX_WITH_VRDP */2546 2547 /*2548 * USB enable/disable2549 */2550 if (fUsbEnabled != -1)2551 {2552 ComPtr<IUSBController> UsbCtl;2553 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));2554 if (SUCCEEDED(rc))2555 {2556 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(!!fUsbEnabled));2557 }2558 }2559 /*2560 * USB EHCI enable/disable2561 */2562 if (fUsbEhciEnabled != -1)2563 {2564 ComPtr<IUSBController> UsbCtl;2565 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));2566 if (SUCCEEDED(rc))2567 {2568 CHECK_ERROR(UsbCtl, COMSETTER(EnabledEhci)(!!fUsbEhciEnabled));2569 }2570 }2571 2572 if (snapshotFolder)2573 {2574 if (strcmp(snapshotFolder, "default") == 0)2575 {2576 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(NULL));2577 }2578 else2579 {2580 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(snapshotFolder)));2581 }2582 }2583 2584 if (guestMemBalloonSize != (ULONG)-1)2585 CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(guestMemBalloonSize));2586 2587 if (guestStatInterval != (ULONG)-1)2588 CHECK_ERROR(machine, COMSETTER(StatisticsUpdateInterval)(guestStatInterval));2589 2590 /*2591 * SATA controller enable/disable2592 */2593 if (fSataEnabled != -1)2594 {2595 ComPtr<ISATAController> SataCtl;2596 CHECK_ERROR(machine, COMGETTER(SATAController)(SataCtl.asOutParam()));2597 if (SUCCEEDED(rc))2598 {2599 CHECK_ERROR(SataCtl, COMSETTER(Enabled)(!!fSataEnabled));2600 }2601 }2602 2603 for (uint32_t i = 4; i < 34; i++)2604 {2605 if (hdds[i])2606 {2607 if (strcmp(hdds[i], "none") == 0)2608 {2609 machine->DetachHardDisk2(StorageBus_SATA, i-4, 0);2610 }2611 else2612 {2613 /* first guess is that it's a UUID */2614 Guid uuid(hdds[i]);2615 ComPtr<IHardDisk2> hardDisk;2616 rc = a->virtualBox->GetHardDisk2(uuid, hardDisk.asOutParam());2617 /* not successful? Then it must be a filename */2618 if (!hardDisk)2619 {2620 CHECK_ERROR(a->virtualBox, FindHardDisk2(Bstr(hdds[i]), hardDisk.asOutParam()));2621 if (FAILED(rc))2622 {2623 /* open the new hard disk object */2624 CHECK_ERROR(a->virtualBox, OpenHardDisk2(Bstr(hdds[i]), hardDisk.asOutParam()));2625 }2626 }2627 if (hardDisk)2628 {2629 hardDisk->COMGETTER(Id)(uuid.asOutParam());2630 CHECK_ERROR(machine, AttachHardDisk2(uuid, StorageBus_SATA, i-4, 0));2631 }2632 else2633 rc = E_FAIL;2634 if (FAILED(rc))2635 break;2636 }2637 }2638 }2639 2640 for (uint32_t i = 0; i < 4; i++)2641 {2642 if (sataBootDevices[i] != -1)2643 {2644 ComPtr<ISATAController> SataCtl;2645 CHECK_ERROR(machine, COMGETTER(SATAController)(SataCtl.asOutParam()));2646 if (SUCCEEDED(rc))2647 {2648 CHECK_ERROR(SataCtl, SetIDEEmulationPort(i, sataBootDevices[i]));2649 }2650 }2651 }2652 2653 if (sataPortCount != -1)2654 {2655 ComPtr<ISATAController> SataCtl;2656 CHECK_ERROR(machine, COMGETTER(SATAController)(SataCtl.asOutParam()));2657 if (SUCCEEDED(rc))2658 {2659 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(sataPortCount));2660 }2661 }2662 2663 /* commit changes */2664 CHECK_ERROR(machine, SaveSettings());2665 }2666 while (0);2667 2668 /* it's important to always close sessions */2669 a->session->Close();2670 2671 return SUCCEEDED(rc) ? 0 : 1;2672 }2673 922 2674 923 /** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */ … … 4753 3002 #endif /* VBOX_WITH_GUEST_PROPS defined */ 4754 3003 { "metrics", handleMetrics }, 3004 { "import", handleImportAppliance }, 4755 3005 { NULL, NULL } 4756 3006 }; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r16057 r16485 86 86 #define USAGE_METRICS RT_BIT_64(42) 87 87 #define USAGE_CONVERTHD RT_BIT_64(43) 88 #define USAGE_IMPORTAPPLIANCE RT_BIT_64(44) 88 89 #define USAGE_ALL (~(uint64_t)0) 89 90 /** @} */ … … 132 133 133 134 int handleInternalCommands(HandlerArg *a); 135 136 unsigned parseNum(const char *psz, unsigned cMaxNum, const char *name); 134 137 #endif /* !VBOX_ONLY_DOCS */ 138 139 /* VBoxManageModifyVM.cpp */ 140 int handleModifyVM(HandlerArg *a); 135 141 136 142 /* VBoxManageGuestProp.cpp */ … … 162 168 int handleCloseMedium(HandlerArg *a); 163 169 170 // VBoxManageImport.cpp 171 int handleImportAppliance(HandlerArg *a); 172 164 173 /* VBoxManageUSB.cpp */ 165 174 /* VBoxManageTODO.cpp */
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器