Changeset 23706 in vbox
- Timestamp:
- Oct 12, 2009 4:31:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r23667 r23706 41 41 #include <iprt/stream.h> 42 42 #include <iprt/string.h> 43 #include <iprt/getopt.h> 43 44 #include <VBox/log.h> 44 45 … … 54 55 #endif 55 56 57 enum enOptionCodes 58 { 59 MODIFYVMNAME = 1000, 60 MODIFYVMOSTYPE, 61 MODIFYVMMEMORY, 62 MODIFYVMVRAM, 63 MODIFYVMFIRMWARE, 64 MODIFYVMACPI, 65 MODIFYVMIOAPIC, 66 MODIFYVMPAE, 67 MODIFYVMHWVIRTEX, 68 MODIFYVMNESTEDPAGING, 69 MODIFYVMVTXVPID, 70 MODIFYVMCPUS, 71 MODIFYVMMONITORCOUNT, 72 MODIFYVMACCELERATE3D, 73 MODIFYVMACCELERATE2DVIDEO, 74 MODIFYVMBIOSLOGOFADEIN, 75 MODIFYVMBIOSLOGOFADEOUT, 76 MODIFYVMBIOSLOGODISPLAYTIME, 77 MODIFYVMBIOSLOGOIMAGEPATH, 78 MODIFYVMBIOSBOOTMENU, 79 MODIFYVMBIOSSYSTEMTIMEOFFSET, 80 MODIFYVMBIOSPXEDEBUG, 81 MODIFYVMBOOT, 82 MODIFYVMHDA, 83 MODIFYVMHDB, 84 MODIFYVMHDD, 85 MODIFYVMIDECONTROLLER, 86 MODIFYVMSATAIDEEMULATION, 87 MODIFYVMSATAPORTCOUNT, 88 MODIFYVMSATAPORT, 89 MODIFYVMSATA, 90 MODIFYVMSCSIPORT, 91 MODIFYVMSCSITYPE, 92 MODIFYVMSCSI, 93 MODIFYVMDVDPASSTHROUGH, 94 MODIFYVMDVD, 95 MODIFYVMFLOPPY, 96 MODIFYVMNICTRACEFILE, 97 MODIFYVMNICTRACE, 98 MODIFYVMNICTYPE, 99 MODIFYVMNICSPEED, 100 MODIFYVMNIC, 101 MODIFYVMCABLECONNECTED, 102 MODIFYVMBRIDGEADAPTER, 103 MODIFYVMHOSTONLYADAPTER, 104 MODIFYVMINTNET, 105 MODIFYVMNATNET, 106 MODIFYVMMACADDRESS, 107 MODIFYVMUARTMODE, 108 MODIFYVMUART, 109 MODIFYVMGUESTSTATISTICSINTERVAL, 110 MODIFYVMGUESTMEMORYBALLOON, 111 MODIFYVMAUDIOCONTROLLER, 112 MODIFYVMAUDIO, 113 MODIFYVMCLIPBOARD, 114 MODIFYVMVRDPPORT, 115 MODIFYVMVRDPADDRESS, 116 MODIFYVMVRDPAUTHTYPE, 117 MODIFYVMVRDPMULTICON, 118 MODIFYVMVRDPREUSECON, 119 MODIFYVMVRDP, 120 MODIFYVMUSBEHCI, 121 MODIFYVMUSB, 122 MODIFYVMSNAPSHOTFOLDER, 123 MODIFYVMLIVEMIGRATIONTARGET, 124 MODIFYVMLIVEMIGRATIONPORT, 125 MODIFYVMLIVEMIGRATIONPASSWORD, 126 }; 127 128 static const RTGETOPTDEF g_aModifyVMOptions[] = 129 { 130 { "--name", MODIFYVMNAME, RTGETOPT_REQ_STRING }, 131 { "--ostype", MODIFYVMOSTYPE, RTGETOPT_REQ_STRING }, 132 { "--memory", MODIFYVMMEMORY, RTGETOPT_REQ_UINT32 }, 133 { "--vram", MODIFYVMVRAM, RTGETOPT_REQ_UINT32 }, 134 { "--firmware", MODIFYVMFIRMWARE, RTGETOPT_REQ_STRING }, 135 { "--acpi", MODIFYVMACPI, RTGETOPT_REQ_STRING }, 136 { "--ioapic", MODIFYVMIOAPIC, RTGETOPT_REQ_STRING }, 137 { "--pae", MODIFYVMPAE, RTGETOPT_REQ_STRING }, 138 { "--hwvirtex", MODIFYVMHWVIRTEX, RTGETOPT_REQ_STRING }, 139 { "--nestedpaging", MODIFYVMNESTEDPAGING, RTGETOPT_REQ_STRING }, 140 { "--vtxvpid", MODIFYVMVTXVPID, RTGETOPT_REQ_STRING }, 141 { "--cpus", MODIFYVMCPUS, RTGETOPT_REQ_UINT32 }, 142 { "--monitorcount", MODIFYVMMONITORCOUNT, RTGETOPT_REQ_UINT32 }, 143 { "--accelerate3d", MODIFYVMACCELERATE3D, RTGETOPT_REQ_STRING }, 144 { "--accelerate2dvideo", MODIFYVMACCELERATE2DVIDEO, RTGETOPT_REQ_STRING }, 145 { "--bioslogofadein", MODIFYVMBIOSLOGOFADEIN, RTGETOPT_REQ_STRING }, 146 { "--bioslogofadeout", MODIFYVMBIOSLOGOFADEOUT, RTGETOPT_REQ_STRING }, 147 { "--bioslogodisplaytime", MODIFYVMBIOSLOGODISPLAYTIME, RTGETOPT_REQ_UINT64 }, 148 { "--bioslogoimagepath", MODIFYVMBIOSLOGOIMAGEPATH, RTGETOPT_REQ_STRING }, 149 { "--biosbootmenu", MODIFYVMBIOSBOOTMENU, RTGETOPT_REQ_STRING }, 150 { "--biossystemtimeoffset", MODIFYVMBIOSSYSTEMTIMEOFFSET, RTGETOPT_REQ_UINT64 }, 151 { "--biospxedebug", MODIFYVMBIOSPXEDEBUG, RTGETOPT_REQ_STRING }, 152 { "--boot", MODIFYVMBOOT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 153 { "--hda", MODIFYVMHDA, RTGETOPT_REQ_STRING }, 154 { "--hdb", MODIFYVMHDB, RTGETOPT_REQ_STRING }, 155 { "--hdd", MODIFYVMHDD, RTGETOPT_REQ_STRING }, 156 { "--idecontroller", MODIFYVMIDECONTROLLER, RTGETOPT_REQ_STRING }, 157 { "--sataideemulation", MODIFYVMSATAIDEEMULATION, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX }, 158 { "--sataportcount", MODIFYVMSATAPORTCOUNT, RTGETOPT_REQ_UINT32 }, 159 { "--sataport", MODIFYVMSATAPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 160 { "--sata", MODIFYVMSATA, RTGETOPT_REQ_STRING }, 161 { "--scsiport", MODIFYVMSCSIPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 162 { "--scsitype", MODIFYVMSCSITYPE, RTGETOPT_REQ_STRING }, 163 { "--scsi", MODIFYVMSCSI, RTGETOPT_REQ_STRING }, 164 { "--dvdpassthrough", MODIFYVMDVDPASSTHROUGH, RTGETOPT_REQ_STRING }, 165 { "--dvd", MODIFYVMDVD, RTGETOPT_REQ_STRING }, 166 { "--floppy", MODIFYVMFLOPPY, RTGETOPT_REQ_STRING }, 167 { "--nictracefile", MODIFYVMNICTRACEFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 168 { "--nictrace", MODIFYVMNICTRACE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 169 { "--nictype", MODIFYVMNICTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 170 { "--nicspeed", MODIFYVMNICSPEED, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX }, 171 { "--nic", MODIFYVMNIC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 172 { "--cableconnected", MODIFYVMCABLECONNECTED, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 173 { "--bridgeadapter", MODIFYVMBRIDGEADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 174 { "--hostonlyadapter", MODIFYVMHOSTONLYADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 175 { "--intnet", MODIFYVMINTNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 176 { "--natnet", MODIFYVMNATNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 177 { "--macaddress", MODIFYVMMACADDRESS, RTGETOPT_REQ_MACADDR | RTGETOPT_FLAG_INDEX }, 178 { "--uartmode", MODIFYVMUARTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 179 { "--uart", MODIFYVMUART, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 180 { "--gueststatisticsinterval", MODIFYVMGUESTSTATISTICSINTERVAL, RTGETOPT_REQ_UINT32 }, 181 { "--guestmemoryballoon", MODIFYVMGUESTMEMORYBALLOON, RTGETOPT_REQ_UINT32 }, 182 { "--audiocontroller", MODIFYVMAUDIOCONTROLLER, RTGETOPT_REQ_STRING }, 183 { "--audio", MODIFYVMAUDIO, RTGETOPT_REQ_STRING }, 184 { "--clipboard", MODIFYVMCLIPBOARD, RTGETOPT_REQ_STRING }, 185 { "--vrdpport", MODIFYVMVRDPPORT, RTGETOPT_REQ_STRING }, 186 { "--vrdpaddress", MODIFYVMVRDPADDRESS, RTGETOPT_REQ_STRING }, 187 { "--vrdpauthtype", MODIFYVMVRDPAUTHTYPE, RTGETOPT_REQ_STRING }, 188 { "--vrdpmulticon", MODIFYVMVRDPMULTICON, RTGETOPT_REQ_STRING }, 189 { "--vrdpreusecon", MODIFYVMVRDPREUSECON, RTGETOPT_REQ_STRING }, 190 { "--vrdp", MODIFYVMVRDP, RTGETOPT_REQ_STRING }, 191 { "--usbehci", MODIFYVMUSBEHCI, RTGETOPT_REQ_STRING }, 192 { "--usb", MODIFYVMUSB, RTGETOPT_REQ_STRING }, 193 { "--snapshotfolder", MODIFYVMSNAPSHOTFOLDER, RTGETOPT_REQ_STRING }, 194 { "--livemigrationtarget", MODIFYVMLIVEMIGRATIONTARGET, RTGETOPT_REQ_STRING }, 195 { "--livemigrationport", MODIFYVMLIVEMIGRATIONPORT, RTGETOPT_REQ_UINT32 }, 196 { "--livemigrationpassword", MODIFYVMLIVEMIGRATIONPASSWORD, RTGETOPT_REQ_STRING }, 197 }; 198 56 199 int handleModifyVM(HandlerArg *a) 57 200 { 201 int c; 58 202 HRESULT rc; 59 203 Bstr name; 60 Bstr ostype; 61 uint32_t memorySize = 0; 62 uint32_t vramSize = 0; 63 char *acpi = NULL; 64 char *hwvirtex = NULL; 65 char *nestedpaging = NULL; 66 char *vtxvpid = NULL; 67 char *pae = NULL; 68 uint32_t numCpus = UINT32_MAX; 69 char *ioapic = NULL; 70 uint32_t monitorcount = ~0; 71 char *accelerate3d = NULL; 72 #ifdef VBOX_WITH_VIDEOHWACCEL 73 char *accelerate2dvideo = NULL; 74 #endif 75 char *bioslogofadein = NULL; 76 char *bioslogofadeout = NULL; 77 uint32_t bioslogodisplaytime = ~0; 78 char *bioslogoimagepath = NULL; 79 char *biosbootmenumode = NULL; 80 char *biossystemtimeoffset = NULL; 81 char *biospxedebug = NULL; 82 DeviceType_T bootDevice[4]; 83 int bootDeviceChanged[4] = { false }; 84 char *hdds[50] = {0}; 85 char *dvd = NULL; 86 char *dvdpassthrough = NULL; 87 char *idecontroller = NULL; 88 char *floppy = NULL; 89 char *audio = NULL; 90 char *audiocontroller = NULL; 91 char *clipboard = NULL; 92 char *firmware = NULL; 93 #ifdef VBOX_WITH_VRDP 94 char *vrdp = NULL; 95 char *vrdpport = NULL; 96 char *vrdpaddress = NULL; 97 char *vrdpauthtype = NULL; 98 char *vrdpmulticon = NULL; 99 char *vrdpreusecon = NULL; 100 #endif 101 int fUsbEnabled = -1; 102 int fUsbEhciEnabled = -1; 103 char *snapshotFolder = NULL; 104 ULONG guestMemBalloonSize = (ULONG)-1; 105 ULONG guestStatInterval = (ULONG)-1; 106 int fSataEnabled = -1; 107 int fScsiEnabled = -1; 108 int fScsiLsiLogic = -1; 109 int sataPortCount = -1; 110 int sataBootDevices[4] = {-1,-1,-1,-1}; 111 int fLiveMigrationTarget = -1; 112 uint32_t uLiveMigrationPort = UINT32_MAX; 113 const char *pszLiveMigrationPassword = NULL; 204 Bstr machineuuid (a->argv[0]); 205 RTGETOPTUNION pValueUnion; 206 RTGETOPTSTATE pGetState; 207 ComPtr <IMachine> machine; 208 ComPtr <IBIOSSettings> biosSettings; 114 209 115 210 /* VM ID + at least one parameter. Parameter arguments are checked … … 132 227 } 133 228 134 std::vector <char *> nics (NetworkAdapterCount, 0); 135 std::vector <char *> nictype (NetworkAdapterCount, 0); 136 std::vector <char *> cableconnected (NetworkAdapterCount, 0); 137 std::vector <char *> nictrace (NetworkAdapterCount, 0); 138 std::vector <char *> nictracefile (NetworkAdapterCount, 0); 139 std::vector <char *> nicspeed (NetworkAdapterCount, 0); 140 std::vector <char *> hostifdev (NetworkAdapterCount, 0); 141 std::vector <const char *> intnet (NetworkAdapterCount, 0); 142 std::vector <const char *> natnet (NetworkAdapterCount, 0); 143 std::vector <char *> macs (NetworkAdapterCount, 0); 144 std::vector <char *> uarts_mode (SerialPortCount, 0); 145 std::vector <ULONG> uarts_base (SerialPortCount, 0); 146 std::vector <ULONG> uarts_irq (SerialPortCount, 0); 147 std::vector <char *> uarts_path (SerialPortCount, 0); 148 149 for (int i = 1; i < a->argc; i++) 229 /* try to find the given machine */ 230 if (!Guid(machineuuid).isEmpty()) 150 231 { 151 if ( !strcmp(a->argv[i], "--name") 152 || !strcmp(a->argv[i], "-name")) 153 { 154 if (a->argc <= i + 1) 155 return errorArgument("Missing argument to '%s'", a->argv[i]); 156 i++; 157 name = a->argv[i]; 158 } 159 else if ( !strcmp(a->argv[i], "--ostype") 160 || !strcmp(a->argv[i], "-ostype")) 161 { 162 if (a->argc <= i + 1) 163 return errorArgument("Missing argument to '%s'", a->argv[i]); 164 i++; 165 ostype = a->argv[i]; 166 } 167 else if ( !strcmp(a->argv[i], "--memory") 168 || !strcmp(a->argv[i], "-memory")) 169 { 170 if (a->argc <= i + 1) 171 return errorArgument("Missing argument to '%s'", a->argv[i]); 172 i++; 173 memorySize = RTStrToUInt32(a->argv[i]); 174 } 175 else if ( !strcmp(a->argv[i], "--vram") 176 || !strcmp(a->argv[i], "-vram")) 177 { 178 if (a->argc <= i + 1) 179 return errorArgument("Missing argument to '%s'", a->argv[i]); 180 i++; 181 vramSize = RTStrToUInt32(a->argv[i]); 182 } 183 else if ( !strcmp(a->argv[i], "--acpi") 184 || !strcmp(a->argv[i], "-acpi")) 185 { 186 if (a->argc <= i + 1) 187 return errorArgument("Missing argument to '%s'", a->argv[i]); 188 i++; 189 acpi = a->argv[i]; 190 } 191 else if ( !strcmp(a->argv[i], "--ioapic") 192 || !strcmp(a->argv[i], "-ioapic")) 193 { 194 if (a->argc <= i + 1) 195 return errorArgument("Missing argument to '%s'", a->argv[i]); 196 i++; 197 ioapic = a->argv[i]; 198 } 199 else if ( !strcmp(a->argv[i], "--hwvirtex") 200 || !strcmp(a->argv[i], "-hwvirtex")) 201 { 202 if (a->argc <= i + 1) 203 return errorArgument("Missing argument to '%s'", a->argv[i]); 204 i++; 205 hwvirtex = a->argv[i]; 206 } 207 else if ( !strcmp(a->argv[i], "--nestedpaging") 208 || !strcmp(a->argv[i], "-nestedpaging")) 209 { 210 if (a->argc <= i + 1) 211 return errorArgument("Missing argument to '%s'", a->argv[i]); 212 i++; 213 nestedpaging = a->argv[i]; 214 } 215 else if ( !strcmp(a->argv[i], "--vtxvpid") 216 || !strcmp(a->argv[i], "-vtxvpid")) 217 { 218 if (a->argc <= i + 1) 219 return errorArgument("Missing argument to '%s'", a->argv[i]); 220 i++; 221 vtxvpid = a->argv[i]; 222 } 223 else if ( !strcmp(a->argv[i], "--pae") 224 || !strcmp(a->argv[i], "-pae")) 225 { 226 if (a->argc <= i + 1) 227 return errorArgument("Missing argument to '%s'", a->argv[i]); 228 i++; 229 pae = a->argv[i]; 230 } 231 else if (!strcmp(a->argv[i], "--cpus")) 232 { 233 if (a->argc <= i + 1) 234 return errorArgument("Missing argument to '%s'", a->argv[i]); 235 i++; 236 numCpus = RTStrToUInt32(a->argv[i]); 237 if (numCpus == UINT32_MAX) 238 return errorArgument("The number of cpus cannot be 0.", a->argv[i]); 239 } 240 else if ( !strcmp(a->argv[i], "--monitorcount") 241 || !strcmp(a->argv[i], "-monitorcount")) 242 { 243 if (a->argc <= i + 1) 244 return errorArgument("Missing argument to '%s'", a->argv[i]); 245 i++; 246 monitorcount = RTStrToUInt32(a->argv[i]); 247 } 248 else if ( !strcmp(a->argv[i], "--accelerate3d") 249 || !strcmp(a->argv[i], "-accelerate3d")) 250 { 251 if (a->argc <= i + 1) 252 return errorArgument("Missing argument to '%s'", a->argv[i]); 253 i++; 254 accelerate3d = a->argv[i]; 255 } 256 #ifdef VBOX_WITH_VIDEOHWACCEL 257 else if ( !strcmp(a->argv[i], "--accelerate2dvideo") 258 || !strcmp(a->argv[i], "-accelerate2dvideo")) 259 { 260 if (a->argc <= i + 1) 261 return errorArgument("Missing argument to '%s'", a->argv[i]); 262 i++; 263 accelerate2dvideo = a->argv[i]; 264 } 265 #endif 266 else if ( !strcmp(a->argv[i], "--firmware") 267 || !strcmp(a->argv[i], "-firmware")) 268 { 269 if (a->argc <= i + 1) 270 return errorArgument("Missing argument to '%s'", a->argv[i]); 271 i++; 272 firmware = a->argv[i]; 273 } 274 else if ( !strcmp(a->argv[i], "--bioslogofadein") 275 || !strcmp(a->argv[i], "-bioslogofadein")) 276 { 277 if (a->argc <= i + 1) 278 return errorArgument("Missing argument to '%s'", a->argv[i]); 279 i++; 280 bioslogofadein = a->argv[i]; 281 } 282 else if ( !strcmp(a->argv[i], "--bioslogofadeout") 283 || !strcmp(a->argv[i], "-bioslogofadeout")) 284 { 285 if (a->argc <= i + 1) 286 return errorArgument("Missing argument to '%s'", a->argv[i]); 287 i++; 288 bioslogofadeout = a->argv[i]; 289 } 290 else if ( !strcmp(a->argv[i], "--bioslogodisplaytime") 291 || !strcmp(a->argv[i], "-bioslogodisplaytime")) 292 { 293 if (a->argc <= i + 1) 294 return errorArgument("Missing argument to '%s'", a->argv[i]); 295 i++; 296 bioslogodisplaytime = RTStrToUInt32(a->argv[i]); 297 } 298 else if ( !strcmp(a->argv[i], "--bioslogoimagepath") 299 || !strcmp(a->argv[i], "-bioslogoimagepath")) 300 { 301 if (a->argc <= i + 1) 302 return errorArgument("Missing argument to '%s'", a->argv[i]); 303 i++; 304 bioslogoimagepath = a->argv[i]; 305 } 306 else if ( !strcmp(a->argv[i], "--biosbootmenu") 307 || !strcmp(a->argv[i], "-biosbootmenu")) 308 { 309 if (a->argc <= i + 1) 310 return errorArgument("Missing argument to '%s'", a->argv[i]); 311 i++; 312 biosbootmenumode = a->argv[i]; 313 } 314 else if ( !strcmp(a->argv[i], "--biossystemtimeoffset") 315 || !strcmp(a->argv[i], "-biossystemtimeoffset")) 316 { 317 if (a->argc <= i + 1) 318 return errorArgument("Missing argument to '%s'", a->argv[i]); 319 i++; 320 biossystemtimeoffset = a->argv[i]; 321 } 322 else if ( !strcmp(a->argv[i], "--biospxedebug") 323 || !strcmp(a->argv[i], "-biospxedebug")) 324 { 325 if (a->argc <= i + 1) 326 return errorArgument("Missing argument to '%s'", a->argv[i]); 327 i++; 328 biospxedebug = a->argv[i]; 329 } 330 else if ( !strncmp(a->argv[i], "--boot", 6) 331 || !strncmp(a->argv[i], "-boot", 5)) 332 { 333 uint32_t n = 0; 334 if (!a->argv[i][5 + (a->argv[i][1] == '-')]) 335 return errorSyntax(USAGE_MODIFYVM, "Missing boot slot number in '%s'", a->argv[i]); 336 if (VINF_SUCCESS != RTStrToUInt32Full(&a->argv[i][5 + (a->argv[i][1] == '-')], 10, &n)) 337 return errorSyntax(USAGE_MODIFYVM, "Invalid boot slot number in '%s'", a->argv[i]); 338 if (a->argc <= i + 1) 339 return errorArgument("Missing argument to '%s'", a->argv[i]); 340 i++; 341 if (!strcmp(a->argv[i], "none")) 342 { 343 bootDevice[n - 1] = DeviceType_Null; 344 } 345 else if (!strcmp(a->argv[i], "floppy")) 346 { 347 bootDevice[n - 1] = DeviceType_Floppy; 348 } 349 else if (!strcmp(a->argv[i], "dvd")) 350 { 351 bootDevice[n - 1] = DeviceType_DVD; 352 } 353 else if (!strcmp(a->argv[i], "disk")) 354 { 355 bootDevice[n - 1] = DeviceType_HardDisk; 356 } 357 else if (!strcmp(a->argv[i], "net")) 358 { 359 bootDevice[n - 1] = DeviceType_Network; 360 } 361 else 362 return errorArgument("Invalid boot device '%s'", a->argv[i]); 363 364 bootDeviceChanged[n - 1] = true; 365 } 366 else if ( !strcmp(a->argv[i], "--hda") 367 || !strcmp(a->argv[i], "-hda")) 368 { 369 if (a->argc <= i + 1) 370 return errorArgument("Missing argument to '%s'", a->argv[i]); 371 i++; 372 hdds[0] = a->argv[i]; 373 } 374 else if ( !strcmp(a->argv[i], "--hdb") 375 || !strcmp(a->argv[i], "-hdb")) 376 { 377 if (a->argc <= i + 1) 378 return errorArgument("Missing argument to '%s'", a->argv[i]); 379 i++; 380 hdds[1] = a->argv[i]; 381 } 382 else if ( !strcmp(a->argv[i], "--hdd") 383 || !strcmp(a->argv[i], "-hdd")) 384 { 385 if (a->argc <= i + 1) 386 return errorArgument("Missing argument to '%s'", a->argv[i]); 387 i++; 388 hdds[2] = a->argv[i]; 389 } 390 else if ( !strcmp(a->argv[i], "--dvd") 391 || !strcmp(a->argv[i], "-dvd")) 392 { 393 if (a->argc <= i + 1) 394 return errorArgument("Missing argument to '%s'", a->argv[i]); 395 i++; 396 dvd = a->argv[i]; 397 } 398 else if ( !strcmp(a->argv[i], "--dvdpassthrough") 399 || !strcmp(a->argv[i], "-dvdpassthrough")) 400 { 401 if (a->argc <= i + 1) 402 return errorArgument("Missing argument to '%s'", a->argv[i]); 403 i++; 404 dvdpassthrough = a->argv[i]; 405 } 406 else if ( !strcmp(a->argv[i], "--idecontroller") 407 || !strcmp(a->argv[i], "-idecontroller")) 408 { 409 if (a->argc <= i + 1) 410 return errorArgument("Missing argument to '%s'", a->argv[i]); 411 i++; 412 idecontroller = a->argv[i]; 413 } 414 else if ( !strcmp(a->argv[i], "--floppy") 415 || !strcmp(a->argv[i], "-floppy")) 416 { 417 if (a->argc <= i + 1) 418 return errorArgument("Missing argument to '%s'", a->argv[i]); 419 i++; 420 floppy = a->argv[i]; 421 } 422 else if ( !strcmp(a->argv[i], "--audio") 423 || !strcmp(a->argv[i], "-audio")) 424 { 425 if (a->argc <= i + 1) 426 return errorArgument("Missing argument to '%s'", a->argv[i]); 427 i++; 428 audio = a->argv[i]; 429 } 430 else if ( !strcmp(a->argv[i], "--audiocontroller") 431 || !strcmp(a->argv[i], "-audiocontroller")) 432 { 433 if (a->argc <= i + 1) 434 return errorArgument("Missing argument to '%s'", a->argv[i]); 435 i++; 436 audiocontroller = a->argv[i]; 437 } 438 else if ( !strcmp(a->argv[i], "--clipboard") 439 || !strcmp(a->argv[i], "-clipboard")) 440 { 441 if (a->argc <= i + 1) 442 return errorArgument("Missing argument to '%s'", a->argv[i]); 443 i++; 444 clipboard = a->argv[i]; 445 } 446 else if ( !strncmp(a->argv[i], "--cableconnected", 16) 447 || !strncmp(a->argv[i], "-cableconnected", 15)) 448 { 449 unsigned n = parseNum(&a->argv[i][15 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 450 if (!n) 451 return 1; 452 453 if (a->argc <= i + 1) 454 return errorArgument("Missing argument to '%s'", a->argv[i]); 455 456 cableconnected[n - 1] = a->argv[i + 1]; 457 i++; 458 } 459 /* watch for the right order of these --nic* comparisons! */ 460 else if ( !strncmp(a->argv[i], "--nictracefile", 14) 461 || !strncmp(a->argv[i], "-nictracefile", 13)) 462 { 463 unsigned n = parseNum(&a->argv[i][13 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 464 if (!n) 465 return 1; 466 if (a->argc <= i + 1) 467 { 468 return errorArgument("Missing argument to '%s'", a->argv[i]); 469 } 470 nictracefile[n - 1] = a->argv[i + 1]; 471 i++; 472 } 473 else if ( !strncmp(a->argv[i], "--nictrace", 10) 474 || !strncmp(a->argv[i], "-nictrace", 9)) 475 { 476 unsigned n = parseNum(&a->argv[i][9 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 477 if (!n) 478 return 1; 479 if (a->argc <= i + 1) 480 return errorArgument("Missing argument to '%s'", a->argv[i]); 481 nictrace[n - 1] = a->argv[i + 1]; 482 i++; 483 } 484 else if ( !strncmp(a->argv[i], "--nictype", 9) 485 || !strncmp(a->argv[i], "-nictype", 8)) 486 { 487 unsigned n = parseNum(&a->argv[i][8 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 488 if (!n) 489 return 1; 490 if (a->argc <= i + 1) 491 return errorArgument("Missing argument to '%s'", a->argv[i]); 492 nictype[n - 1] = a->argv[i + 1]; 493 i++; 494 } 495 else if ( !strncmp(a->argv[i], "--nicspeed", 10) 496 || !strncmp(a->argv[i], "-nicspeed", 9)) 497 { 498 unsigned n = parseNum(&a->argv[i][9 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 499 if (!n) 500 return 1; 501 if (a->argc <= i + 1) 502 return errorArgument("Missing argument to '%s'", a->argv[i]); 503 nicspeed[n - 1] = a->argv[i + 1]; 504 i++; 505 } 506 else if ( !strncmp(a->argv[i], "--nic", 5) 507 || !strncmp(a->argv[i], "-nic", 4)) 508 { 509 unsigned n = parseNum(&a->argv[i][4 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 510 if (!n) 511 return 1; 512 if (a->argc <= i + 1) 513 return errorArgument("Missing argument to '%s'", a->argv[i]); 514 nics[n - 1] = a->argv[i + 1]; 515 i++; 516 } 517 else if ( !strncmp(a->argv[i], "--hostifdev", 11) 518 || !strncmp(a->argv[i], "-hostifdev", 10)) /* backward compatibility */ 519 { 520 unsigned n = parseNum(&a->argv[i][10 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 521 if (!n) 522 return 1; 523 if (a->argc <= i + 1) 524 return errorArgument("Missing argument to '%s'", a->argv[i]); 525 hostifdev[n - 1] = a->argv[i + 1]; 526 i++; 527 } 528 else if ( !strncmp(a->argv[i], "--bridgeadapter", 15) 529 || !strncmp(a->argv[i], "-bridgeadapter", 14)) 530 { 531 unsigned n = parseNum(&a->argv[i][14 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 532 if (!n) 533 return 1; 534 if (a->argc <= i + 1) 535 return errorArgument("Missing argument to '%s'", a->argv[i]); 536 hostifdev[n - 1] = a->argv[i + 1]; 537 i++; 538 } 539 #if defined(VBOX_WITH_NETFLT) 540 else if ( !strncmp(a->argv[i], "--hostonlyadapter", 17) 541 || !strncmp(a->argv[i], "-hostonlyadapter", 16)) 542 { 543 unsigned n = parseNum(&a->argv[i][16 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 544 if (!n) 545 return 1; 546 if (a->argc <= i + 1) 547 return errorArgument("Missing argument to '%s'", a->argv[i]); 548 hostifdev[n - 1] = a->argv[i + 1]; 549 i++; 550 } 551 #endif 552 else if ( !strncmp(a->argv[i], "--intnet", 8) 553 || !strncmp(a->argv[i], "-intnet", 7)) 554 { 555 unsigned n = parseNum(&a->argv[i][7 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 556 if (!n) 557 return 1; 558 if (a->argc <= i + 1) 559 return errorArgument("Missing argument to '%s'", a->argv[i]); 560 intnet[n - 1] = a->argv[i + 1]; 561 i++; 562 } 563 else if ( !strncmp(a->argv[i], "--natnet", 8) 564 || !strncmp(a->argv[i], "-natnet", 7)) 565 { 566 unsigned n = parseNum(&a->argv[i][7 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 567 if (!n) 568 return 1; 569 if (a->argc <= i + 1) 570 return errorArgument("Missing argument to '%s'", a->argv[i]); 571 572 if (!strcmp(a->argv[i + 1], "default")) 573 natnet[n - 1] = ""; 574 else 575 { 576 RTIPV4ADDR Network; 577 RTIPV4ADDR Netmask; 578 int rc = RTCidrStrToIPv4(a->argv[i + 1], &Network, &Netmask); 579 if (RT_FAILURE(rc)) 580 return errorArgument("Invalid IPv4 network '%s' specified -- CIDR notation expected.\n", a->argv[i + 1]); 581 if (Netmask & 0x1f) 582 return errorArgument("Prefix length of the NAT network must be less than 28.\n"); 583 natnet[n - 1] = a->argv[i + 1]; 584 } 585 i++; 586 } 587 else if ( !strncmp(a->argv[i], "--macaddress", 12) 588 || !strncmp(a->argv[i], "-macaddress", 11)) 589 { 590 unsigned n = parseNum(&a->argv[i][11 + (a->argv[i][1] == '-')], NetworkAdapterCount, "NIC"); 591 if (!n) 592 return 1; 593 if (a->argc <= i + 1) 594 return errorArgument("Missing argument to '%s'", a->argv[i]); 595 macs[n - 1] = a->argv[i + 1]; 596 i++; 597 } 598 #ifdef VBOX_WITH_VRDP 599 else if ( !strcmp(a->argv[i], "--vrdp") 600 || !strcmp(a->argv[i], "-vrdp")) 601 { 602 if (a->argc <= i + 1) 603 return errorArgument("Missing argument to '%s'", a->argv[i]); 604 i++; 605 vrdp = a->argv[i]; 606 } 607 else if ( !strcmp(a->argv[i], "--vrdpport") 608 || !strcmp(a->argv[i], "-vrdpport")) 609 { 610 if (a->argc <= i + 1) 611 return errorArgument("Missing argument to '%s'", a->argv[i]); 612 i++; 613 if (!strcmp(a->argv[i], "default")) 614 vrdpport = "0"; 615 else 616 vrdpport = a->argv[i]; 617 } 618 else if ( !strcmp(a->argv[i], "--vrdpaddress") 619 || !strcmp(a->argv[i], "-vrdpaddress")) 620 { 621 if (a->argc <= i + 1) 622 return errorArgument("Missing argument to '%s'", a->argv[i]); 623 i++; 624 vrdpaddress = a->argv[i]; 625 } 626 else if ( !strcmp(a->argv[i], "--vrdpauthtype") 627 || !strcmp(a->argv[i], "-vrdpauthtype")) 628 { 629 if (a->argc <= i + 1) 630 return errorArgument("Missing argument to '%s'", a->argv[i]); 631 i++; 632 vrdpauthtype = a->argv[i]; 633 } 634 else if ( !strcmp(a->argv[i], "--vrdpmulticon") 635 || !strcmp(a->argv[i], "-vrdpmulticon")) 636 { 637 if (a->argc <= i + 1) 638 return errorArgument("Missing argument to '%s'", a->argv[i]); 639 i++; 640 vrdpmulticon = a->argv[i]; 641 } 642 else if ( !strcmp(a->argv[i], "--vrdpreusecon") 643 || !strcmp(a->argv[i], "-vrdpreusecon")) 644 { 645 if (a->argc <= i + 1) 646 return errorArgument("Missing argument to '%s'", a->argv[i]); 647 i++; 648 vrdpreusecon = a->argv[i]; 649 } 650 #endif /* VBOX_WITH_VRDP */ 651 else if ( !strcmp(a->argv[i], "--usb") 652 || !strcmp(a->argv[i], "-usb")) 653 { 654 if (a->argc <= i + 1) 655 return errorArgument("Missing argument to '%s'", a->argv[i]); 656 i++; 657 if (!strcmp(a->argv[i], "on") || !strcmp(a->argv[i], "enable")) 658 fUsbEnabled = 1; 659 else if (!strcmp(a->argv[i], "off") || !strcmp(a->argv[i], "disable")) 660 fUsbEnabled = 0; 661 else 662 return errorArgument("Invalid --usb argument '%s'", a->argv[i]); 663 } 664 else if ( !strcmp(a->argv[i], "--usbehci") 665 || !strcmp(a->argv[i], "-usbehci")) 666 { 667 if (a->argc <= i + 1) 668 return errorArgument("Missing argument to '%s'", a->argv[i]); 669 i++; 670 if (!strcmp(a->argv[i], "on") || !strcmp(a->argv[i], "enable")) 671 fUsbEhciEnabled = 1; 672 else if (!strcmp(a->argv[i], "off") || !strcmp(a->argv[i], "disable")) 673 fUsbEhciEnabled = 0; 674 else 675 return errorArgument("Invalid --usbehci argument '%s'", a->argv[i]); 676 } 677 else if ( !strcmp(a->argv[i], "--snapshotfolder") 678 || !strcmp(a->argv[i], "-snapshotfolder")) 679 { 680 if (a->argc <= i + 1) 681 return errorArgument("Missing argument to '%s'", a->argv[i]); 682 i++; 683 snapshotFolder = a->argv[i]; 684 } 685 else if ( !strncmp(a->argv[i], "--uartmode", 10) 686 || !strncmp(a->argv[i], "-uartmode", 9)) 687 { 688 unsigned n = parseNum(&a->argv[i][9 + (a->argv[i][1] == '-')], SerialPortCount, "UART"); 689 if (!n) 690 return 1; 691 i++; 692 if (!strcmp(a->argv[i], "disconnected")) 693 { 694 uarts_mode[n - 1] = a->argv[i]; 695 } 696 else 697 { 698 if (!strcmp(a->argv[i], "server") || !strcmp(a->argv[i], "client")) 699 { 700 uarts_mode[n - 1] = a->argv[i]; 701 i++; 702 #ifdef RT_OS_WINDOWS 703 if (!strncmp(a->argv[i], "\\\\.\\pipe\\", 9)) 704 return errorArgument("Uart pipe must start with \\\\.\\pipe\\"); 705 #endif 706 } 707 else if (!strcmp(a->argv[i], "file")) 708 { 709 uarts_mode[n - 1] = a->argv[i]; 710 i++; 711 } 712 else 713 { 714 uarts_mode[n - 1] = (char*)"device"; 715 } 716 if (a->argc <= i) 717 return errorArgument("Missing argument to --uartmode"); 718 uarts_path[n - 1] = a->argv[i]; 719 } 720 } 721 else if ( !strncmp(a->argv[i], "--uart", 6) 722 || !strncmp(a->argv[i], "-uart", 5)) 723 { 724 unsigned n = parseNum(&a->argv[i][5 + (a->argv[i][1] == '-')], SerialPortCount, "UART"); 725 if (!n) 726 return 1; 727 if (a->argc <= i + 1) 728 return errorArgument("Missing argument to '%s'", a->argv[i]); 729 i++; 730 if (!strcmp(a->argv[i], "off") || !strcmp(a->argv[i], "disable")) 731 { 732 uarts_base[n - 1] = (ULONG)-1; 733 } 734 else 735 { 736 if (a->argc <= i + 1) 737 return errorArgument("Missing argument to '%s'", a->argv[i-1]); 738 uint32_t uVal; 739 int vrc; 740 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal); 741 if (vrc != VINF_SUCCESS || uVal == 0) 742 return errorArgument("Error parsing UART I/O base '%s'", a->argv[i]); 743 uarts_base[n - 1] = uVal; 744 i++; 745 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal); 746 if (vrc != VINF_SUCCESS) 747 return errorArgument("Error parsing UART IRQ '%s'", a->argv[i]); 748 uarts_irq[n - 1] = uVal; 749 } 750 } 751 #ifdef VBOX_WITH_MEM_BALLOONING 752 else if ( !strcmp(a->argv[i], "--guestmemoryballoon") 753 || !strcmp(a->argv[i], "-guestmemoryballoon")) 754 { 755 if (a->argc <= i + 1) 756 return errorArgument("Missing argument to '%s'", a->argv[i]); 757 i++; 758 uint32_t uVal; 759 int vrc; 760 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal); 761 if (vrc != VINF_SUCCESS) 762 return errorArgument("Error parsing guest memory balloon size '%s'", a->argv[i]); 763 guestMemBalloonSize = uVal; 764 } 765 #endif 766 else if ( !strcmp(a->argv[i], "--gueststatisticsinterval") 767 || !strcmp(a->argv[i], "-gueststatisticsinterval")) 768 { 769 if (a->argc <= i + 1) 770 return errorArgument("Missing argument to '%s'", a->argv[i]); 771 i++; 772 uint32_t uVal; 773 int vrc; 774 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal); 775 if (vrc != VINF_SUCCESS) 776 return errorArgument("Error parsing guest statistics interval '%s'", a->argv[i]); 777 guestStatInterval = uVal; 778 } 779 else if ( !strcmp(a->argv[i], "--sata") 780 || !strcmp(a->argv[i], "-sata")) 781 { 782 if (a->argc <= i + 1) 783 return errorArgument("Missing argument to '%s'", a->argv[i]); 784 i++; 785 if (!strcmp(a->argv[i], "on") || !strcmp(a->argv[i], "enable")) 786 fSataEnabled = 1; 787 else if (!strcmp(a->argv[i], "off") || !strcmp(a->argv[i], "disable")) 788 fSataEnabled = 0; 789 else 790 return errorArgument("Invalid --usb argument '%s'", a->argv[i]); 791 } 792 else if ( !strcmp(a->argv[i], "--sataportcount") 793 || !strcmp(a->argv[i], "-sataportcount")) 794 { 795 unsigned n; 796 797 if (a->argc <= i + 1) 798 return errorArgument("Missing arguments to '%s'", a->argv[i]); 799 i++; 800 801 n = parseNum(a->argv[i], 30, "SATA"); 802 if (!n) 803 return 1; 804 sataPortCount = n; 805 } 806 else if ( !strncmp(a->argv[i], "--sataport", 10) 807 || !strncmp(a->argv[i], "-sataport", 9)) 808 { 809 unsigned n = parseNum(&a->argv[i][9 + (a->argv[i][1] == '-')], 30, "SATA"); 810 if (!n) 811 return 1; 812 if (a->argc <= i + 1) 813 return errorArgument("Missing argument to '%s'", a->argv[i]); 814 i++; 815 hdds[n-1+4] = a->argv[i]; 816 } 817 else if ( !strncmp(a->argv[i], "--sataideemulation", 18) 818 || !strncmp(a->argv[i], "-sataideemulation", 17)) 819 { 820 unsigned bootDevicePos = 0; 821 unsigned n; 822 823 bootDevicePos = parseNum(&a->argv[i][17 + (a->argv[i][1] == '-')], 4, "SATA"); 824 if (!bootDevicePos) 825 return 1; 826 bootDevicePos--; 827 828 if (a->argc <= i + 1) 829 return errorArgument("Missing arguments to '%s'", a->argv[i]); 830 i++; 831 832 n = parseNum(a->argv[i], 30, "SATA"); 833 if (!n) 834 return 1; 835 836 sataBootDevices[bootDevicePos] = n-1; 837 } 838 else if ( !strcmp(a->argv[i], "--scsi") 839 || !strcmp(a->argv[i], "-scsi")) 840 { 841 if (a->argc <= i + 1) 842 return errorArgument("Missing argument to '%s'", a->argv[i]); 843 i++; 844 if (!strcmp(a->argv[i], "on") || !strcmp(a->argv[i], "enable")) 845 fScsiEnabled = 1; 846 else if (!strcmp(a->argv[i], "off") || !strcmp(a->argv[i], "disable")) 847 fScsiEnabled = 0; 848 else 849 return errorArgument("Invalid --scsi argument '%s'", a->argv[i]); 850 } 851 else if ( !strncmp(a->argv[i], "--scsiport", 10) 852 || !strncmp(a->argv[i], "-scsiport", 9)) 853 { 854 unsigned n = parseNum(&a->argv[i][9 + (a->argv[i][1] == '-')], 16, "SCSI"); 855 if (!n) 856 return 1; 857 if (a->argc <= i + 1) 858 return errorArgument("Missing argument to '%s'", a->argv[i]); 859 i++; 860 hdds[n-1+34] = a->argv[i]; 861 } 862 else if ( !strcmp(a->argv[i], "--scsitype") 863 || !strcmp(a->argv[i], "-scsitype")) 864 { 865 if (a->argc <= i + 1) 866 return errorArgument("Missing argument to '%s'", a->argv[i]); 867 i++; 868 if (!RTStrICmp(a->argv[i], "LsiLogic")) 869 fScsiLsiLogic = 1; 870 else if (!RTStrICmp(a->argv[i], "BusLogic")) 871 fScsiLsiLogic = 0; 872 else 873 return errorArgument("Invalid --scsitype argument '%s'", a->argv[i]); 874 } 875 else if (!strcmp(a->argv[i], "--livemigrationtarget")) 876 { 877 if (a->argc <= i + 1) 878 return errorArgument("Missing argument to '%s'", a->argv[i]); 879 i++; 880 if (!strcmp(a->argv[i], "on")) 881 fLiveMigrationTarget = 1; 882 else if (!strcmp(a->argv[i], "off")) 883 fLiveMigrationTarget = 0; 884 else 885 return errorArgument("Invalid --livemigrationtarget value '%s'", a->argv[i]); 886 } 887 else if (!strcmp(a->argv[i], "--livemigrationport")) 888 { 889 if (a->argc <= i + 1) 890 return errorArgument("Missing argument to '%s'", a->argv[i]); 891 i++; 892 int vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uLiveMigrationPort); 893 if (vrc != VINF_SUCCESS) 894 return errorArgument("Invalid --livemigrationport value '%s'", a->argv[i]); 895 } 896 else if (!strcmp(a->argv[i], "--livemigrationpassword")) 897 { 898 if (a->argc <= i + 1) 899 return errorArgument("Missing argument to '%s'", a->argv[i]); 900 i++; 901 pszLiveMigrationPassword = a->argv[i]; 902 } 903 else 904 return errorSyntax(USAGE_MODIFYVM, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw()); 905 } 906 907 /* try to find the given machine */ 908 ComPtr <IMachine> machine; 909 Bstr uuid (a->argv[0]); 910 if (!Guid(uuid).isEmpty()) 911 { 912 CHECK_ERROR (a->virtualBox, GetMachine (uuid, machine.asOutParam())); 232 CHECK_ERROR_RET (a->virtualBox, GetMachine (machineuuid, machine.asOutParam()), 1); 913 233 } 914 234 else 915 235 { 916 CHECK_ERROR (a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam())); 917 if (SUCCEEDED (rc)) 918 machine->COMGETTER(Id)(uuid.asOutParam()); 236 CHECK_ERROR_RET (a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()), 1); 237 machine->COMGETTER(Id)(machineuuid.asOutParam()); 919 238 } 920 239 if (FAILED (rc)) … … 922 241 923 242 /* open a session for the VM */ 924 CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1); 925 926 do 243 CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, machineuuid), 1); 244 245 /* get the mutable session machine */ 246 a->session->COMGETTER(Machine)(machine.asOutParam()); 247 machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); 248 249 RTGetOptInit (&pGetState, a->argc, a->argv, g_aModifyVMOptions, 250 RT_ELEMENTS(g_aModifyVMOptions), 1, 0 /* fFlags */); 251 252 while ( SUCCEEDED (rc) 253 && (c = RTGetOpt(&pGetState, &pValueUnion))) 927 254 { 928 /* get the mutable session machine */ 929 a->session->COMGETTER(Machine)(machine.asOutParam()); 930 931 ComPtr <IBIOSSettings> biosSettings; 932 machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); 933 934 if (name) 935 CHECK_ERROR(machine, COMSETTER(Name)(name)); 936 /** @todo r=bird: What's the story on not reporting error some places 937 * (CHECK_ERROR) and immediately returning in other cases 938 * (CHECK_ERROR_RET)? If there is a logic, a comment why would be 939 * nice... */ 940 if (ostype) 255 #if 0 256 RTPrintf("Arguments(%d) '%s' : '%lu' :'%s - %u'\n", c, 257 pGetState.pDef ? pGetState.pDef->pszLong : "NULL", 258 pGetState.uIndex, pValueUnion.psz, pValueUnion.u32); 259 #endif 260 261 switch (c) 941 262 { 942 ComPtr<IGuestOSType> guestOSType; 943 CHECK_ERROR(a->virtualBox, GetGuestOSType(ostype, guestOSType.asOutParam())); 944 if (SUCCEEDED(rc) && guestOSType) 945 { 946 CHECK_ERROR(machine, COMSETTER(OSTypeId)(ostype)); 947 } 948 else 949 { 950 errorArgument("Invalid guest OS type '%s'", Utf8Str(ostype).raw()); 951 rc = E_FAIL; 952 break; 953 } 954 } 955 if (memorySize > 0) 956 CHECK_ERROR(machine, COMSETTER(MemorySize)(memorySize)); 957 if (vramSize > 0) 958 CHECK_ERROR(machine, COMSETTER(VRAMSize)(vramSize)); 959 if (acpi) 960 { 961 if (!strcmp(acpi, "on")) 962 { 963 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(true)); 964 } 965 else if (!strcmp(acpi, "off")) 966 { 967 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(false)); 968 } 969 else 970 { 971 errorArgument("Invalid --acpi argument '%s'", acpi); 972 rc = E_FAIL; 973 break; 974 } 975 } 976 if (ioapic) 977 { 978 if (!strcmp(ioapic, "on")) 979 { 980 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(true)); 981 } 982 else if (!strcmp(ioapic, "off")) 983 { 984 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(false)); 985 } 986 else 987 { 988 errorArgument("Invalid --ioapic argument '%s'", ioapic); 989 rc = E_FAIL; 990 break; 991 } 992 } 993 if (hwvirtex) 994 { 995 if (!strcmp(hwvirtex, "on")) 996 { 997 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TRUE)); 998 } 999 else if (!strcmp(hwvirtex, "off")) 1000 { 1001 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(FALSE)); 1002 } 1003 else 1004 { 1005 errorArgument("Invalid --hwvirtex argument '%s'", hwvirtex); 1006 rc = E_FAIL; 1007 break; 1008 } 1009 } 1010 if (nestedpaging) 1011 { 1012 if (!strcmp(nestedpaging, "on")) 1013 { 1014 CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(true)); 1015 } 1016 else if (!strcmp(nestedpaging, "off")) 1017 { 1018 CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(false)); 1019 } 1020 else 1021 { 1022 errorArgument("Invalid --nestedpaging argument '%s'", ioapic); 1023 rc = E_FAIL; 1024 break; 1025 } 1026 } 1027 if (vtxvpid) 1028 { 1029 if (!strcmp(vtxvpid, "on")) 1030 { 1031 CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(true)); 1032 } 1033 else if (!strcmp(vtxvpid, "off")) 1034 { 1035 CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(false)); 1036 } 1037 else 1038 { 1039 errorArgument("Invalid --vtxvpid argument '%s'", ioapic); 1040 rc = E_FAIL; 1041 break; 1042 } 1043 } 1044 if (pae) 1045 { 1046 if (!strcmp(pae, "on")) 1047 { 1048 CHECK_ERROR(machine, COMSETTER(PAEEnabled)(true)); 1049 } 1050 else if (!strcmp(pae, "off")) 1051 { 1052 CHECK_ERROR(machine, COMSETTER(PAEEnabled)(false)); 1053 } 1054 else 1055 { 1056 errorArgument("Invalid --pae argument '%s'", ioapic); 1057 rc = E_FAIL; 1058 break; 1059 } 1060 } 1061 if (numCpus != UINT32_MAX) 1062 { 1063 CHECK_ERROR(machine, COMSETTER(CPUCount)(numCpus)); 1064 } 1065 if (monitorcount != ~0U) 1066 { 1067 CHECK_ERROR(machine, COMSETTER(MonitorCount)(monitorcount)); 1068 } 1069 if (accelerate3d) 1070 { 1071 if (!strcmp(accelerate3d, "on")) 1072 { 1073 CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(true)); 1074 } 1075 else if (!strcmp(accelerate3d, "off")) 1076 { 1077 CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(false)); 1078 } 1079 else 1080 { 1081 errorArgument("Invalid --accelerate3d argument '%s'", accelerate3d); 1082 rc = E_FAIL; 1083 break; 1084 } 1085 } 263 case MODIFYVMNAME: 264 { 265 if (pValueUnion.psz) 266 CHECK_ERROR (machine, COMSETTER(Name)(Bstr(pValueUnion.psz))); 267 break; 268 } 269 case MODIFYVMOSTYPE: 270 { 271 if (pValueUnion.psz) 272 { 273 ComPtr<IGuestOSType> guestOSType; 274 CHECK_ERROR (a->virtualBox, GetGuestOSType(Bstr(pValueUnion.psz), guestOSType.asOutParam())); 275 if (SUCCEEDED(rc) && guestOSType) 276 { 277 CHECK_ERROR (machine, COMSETTER(OSTypeId)(Bstr(pValueUnion.psz))); 278 } 279 else 280 { 281 errorArgument("Invalid guest OS type '%s'", Utf8Str(pValueUnion.psz).raw()); 282 rc = E_FAIL; 283 } 284 } 285 break; 286 } 287 288 case MODIFYVMMEMORY: 289 { 290 if (pValueUnion.u32 > 0) 291 CHECK_ERROR (machine, COMSETTER(MemorySize)(pValueUnion.u32)); 292 break; 293 } 294 295 case MODIFYVMVRAM: 296 { 297 if (pValueUnion.u32 > 0) 298 CHECK_ERROR (machine, COMSETTER(VRAMSize)(pValueUnion.u32)); 299 break; 300 } 301 302 case MODIFYVMFIRMWARE: 303 { 304 if (pValueUnion.psz) 305 { 306 if (!strcmp(pValueUnion.psz, "efi")) 307 { 308 CHECK_ERROR (machine, COMSETTER(FirmwareType)(FirmwareType_EFI)); 309 } 310 else if (!strcmp(pValueUnion.psz, "bios")) 311 { 312 CHECK_ERROR (machine, COMSETTER(FirmwareType)(FirmwareType_BIOS)); 313 } 314 else 315 { 316 errorArgument("Invalid --firmware argument '%s'", pValueUnion.psz); 317 rc = E_FAIL; 318 } 319 } 320 break; 321 } 322 323 case MODIFYVMACPI: 324 { 325 if (pValueUnion.psz) 326 { 327 if (!strcmp(pValueUnion.psz, "on")) 328 { 329 CHECK_ERROR (biosSettings, COMSETTER(ACPIEnabled)(true)); 330 } 331 else if (!strcmp(pValueUnion.psz, "off")) 332 { 333 CHECK_ERROR (biosSettings, COMSETTER(ACPIEnabled)(false)); 334 } 335 else 336 { 337 errorArgument("Invalid --acpi argument '%s'", pValueUnion.psz); 338 rc = E_FAIL; 339 } 340 } 341 break; 342 } 343 344 case MODIFYVMIOAPIC: 345 { 346 if (pValueUnion.psz) 347 { 348 if (!strcmp(pValueUnion.psz, "on")) 349 { 350 CHECK_ERROR (biosSettings, COMSETTER(IOAPICEnabled)(true)); 351 } 352 else if (!strcmp(pValueUnion.psz, "off")) 353 { 354 CHECK_ERROR (biosSettings, COMSETTER(IOAPICEnabled)(false)); 355 } 356 else 357 { 358 errorArgument("Invalid --ioapic argument '%s'", pValueUnion.psz); 359 rc = E_FAIL; 360 } 361 } 362 break; 363 } 364 365 case MODIFYVMPAE: 366 { 367 if (pValueUnion.psz) 368 { 369 if (!strcmp(pValueUnion.psz, "on")) 370 { 371 CHECK_ERROR (machine, COMSETTER(PAEEnabled)(true)); 372 } 373 else if (!strcmp(pValueUnion.psz, "off")) 374 { 375 CHECK_ERROR (machine, COMSETTER(PAEEnabled)(false)); 376 } 377 else 378 { 379 errorArgument("Invalid --pae argument '%s'", pValueUnion.psz); 380 rc = E_FAIL; 381 } 382 } 383 break; 384 } 385 386 case MODIFYVMHWVIRTEX: 387 { 388 if (pValueUnion.psz) 389 { 390 if (!strcmp(pValueUnion.psz, "on")) 391 { 392 CHECK_ERROR (machine, COMSETTER(HWVirtExEnabled)(TRUE)); 393 } 394 else if (!strcmp(pValueUnion.psz, "off")) 395 { 396 CHECK_ERROR (machine, COMSETTER(HWVirtExEnabled)(FALSE)); 397 } 398 else 399 { 400 errorArgument("Invalid --hwvirtex argument '%s'", pValueUnion.psz); 401 rc = E_FAIL; 402 } 403 } 404 break; 405 } 406 407 case MODIFYVMNESTEDPAGING: 408 { 409 if (pValueUnion.psz) 410 { 411 if (!strcmp(pValueUnion.psz, "on")) 412 { 413 CHECK_ERROR (machine, COMSETTER(HWVirtExNestedPagingEnabled)(true)); 414 } 415 else if (!strcmp(pValueUnion.psz, "off")) 416 { 417 CHECK_ERROR (machine, COMSETTER(HWVirtExNestedPagingEnabled)(false)); 418 } 419 else 420 { 421 errorArgument("Invalid --nestedpaging argument '%s'", pValueUnion.psz); 422 rc = E_FAIL; 423 } 424 } 425 break; 426 } 427 428 case MODIFYVMVTXVPID: 429 { 430 if (pValueUnion.psz) 431 { 432 if (!strcmp(pValueUnion.psz, "on")) 433 { 434 CHECK_ERROR (machine, COMSETTER(HWVirtExVPIDEnabled)(true)); 435 } 436 else if (!strcmp(pValueUnion.psz, "off")) 437 { 438 CHECK_ERROR (machine, COMSETTER(HWVirtExVPIDEnabled)(false)); 439 } 440 else 441 { 442 errorArgument("Invalid --vtxvpid argument '%s'", pValueUnion.psz); 443 rc = E_FAIL; 444 } 445 } 446 break; 447 } 448 449 case MODIFYVMCPUS: 450 { 451 if (pValueUnion.u32 > 0) 452 CHECK_ERROR (machine, COMSETTER(CPUCount)(pValueUnion.u32)); 453 break; 454 } 455 456 case MODIFYVMMONITORCOUNT: 457 { 458 if (pValueUnion.u32 > 0) 459 CHECK_ERROR (machine, COMSETTER(MonitorCount)(pValueUnion.u32)); 460 break; 461 } 462 463 case MODIFYVMACCELERATE3D: 464 { 465 if (pValueUnion.psz) 466 { 467 if (!strcmp(pValueUnion.psz, "on")) 468 { 469 CHECK_ERROR (machine, COMSETTER(Accelerate3DEnabled)(true)); 470 } 471 else if (!strcmp(pValueUnion.psz, "off")) 472 { 473 CHECK_ERROR (machine, COMSETTER(Accelerate3DEnabled)(false)); 474 } 475 else 476 { 477 errorArgument("Invalid --accelerate3d argument '%s'", pValueUnion.psz); 478 rc = E_FAIL; 479 } 480 } 481 break; 482 } 483 484 case MODIFYVMACCELERATE2DVIDEO: 485 { 1086 486 #ifdef VBOX_WITH_VIDEOHWACCEL 1087 if (accelerate2dvideo) 1088 { 1089 if (!strcmp(accelerate2dvideo, "on")) 1090 { 1091 CHECK_ERROR(machine, COMSETTER(Accelerate2DVideoEnabled)(true)); 1092 } 1093 else if (!strcmp(accelerate2dvideo, "off")) 1094 { 1095 CHECK_ERROR(machine, COMSETTER(Accelerate2DVideoEnabled)(false)); 1096 } 1097 else 1098 { 1099 errorArgument("Invalid --accelerate2dvideo argument '%s'", accelerate2dvideo); 1100 rc = E_FAIL; 1101 break; 1102 } 1103 } 487 if (pValueUnion.psz) 488 { 489 if (!strcmp(pValueUnion.psz, "on")) 490 { 491 CHECK_ERROR (machine, COMSETTER(Accelerate2DVideoEnabled)(true)); 492 } 493 else if (!strcmp(pValueUnion.psz, "off")) 494 { 495 CHECK_ERROR (machine, COMSETTER(Accelerate2DVideoEnabled)(false)); 496 } 497 else 498 { 499 errorArgument("Invalid --accelerate2dvideo argument '%s'", pValueUnion.psz); 500 rc = E_FAIL; 501 } 502 } 1104 503 #endif 1105 if (firmware) 1106 { 1107 if (!strcmp(firmware, "efi")) 1108 { 1109 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI)); 1110 } 1111 else if (!strcmp(firmware, "bios")) 1112 { 1113 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_BIOS)); 1114 } 1115 else 1116 { 1117 errorArgument("Invalid --firmware argument '%s'", firmware); 1118 rc = E_FAIL; 1119 break; 1120 } 1121 } 1122 if (bioslogofadein) 1123 { 1124 if (!strcmp(bioslogofadein, "on")) 1125 { 1126 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(true)); 1127 } 1128 else if (!strcmp(bioslogofadein, "off")) 1129 { 1130 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(false)); 1131 } 1132 else 1133 { 1134 errorArgument("Invalid --bioslogofadein argument '%s'", bioslogofadein); 1135 rc = E_FAIL; 1136 break; 1137 } 1138 } 1139 if (bioslogofadeout) 1140 { 1141 if (!strcmp(bioslogofadeout, "on")) 1142 { 1143 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(true)); 1144 } 1145 else if (!strcmp(bioslogofadeout, "off")) 1146 { 1147 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(false)); 1148 } 1149 else 1150 { 1151 errorArgument("Invalid --bioslogofadeout argument '%s'", bioslogofadeout); 1152 rc = E_FAIL; 1153 break; 1154 } 1155 } 1156 if (bioslogodisplaytime != ~0U) 1157 { 1158 CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(bioslogodisplaytime)); 1159 } 1160 if (bioslogoimagepath) 1161 { 1162 CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(bioslogoimagepath))); 1163 } 1164 if (biosbootmenumode) 1165 { 1166 if (!strcmp(biosbootmenumode, "disabled")) 1167 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled)); 1168 else if (!strcmp(biosbootmenumode, "menuonly")) 1169 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly)); 1170 else if (!strcmp(biosbootmenumode, "messageandmenu")) 1171 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu)); 1172 else 1173 { 1174 errorArgument("Invalid --biosbootmenu argument '%s'", biosbootmenumode); 1175 rc = E_FAIL; 1176 break; 1177 } 1178 1179 } 1180 if (biossystemtimeoffset) 1181 { 1182 LONG64 timeOffset = RTStrToInt64(biossystemtimeoffset); 1183 CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(timeOffset)); 1184 } 1185 if (biospxedebug) 1186 { 1187 if (!strcmp(biospxedebug, "on")) 1188 { 1189 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(true)); 1190 } 1191 else if (!strcmp(biospxedebug, "off")) 1192 { 1193 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(false)); 1194 } 1195 else 1196 { 1197 errorArgument("Invalid --biospxedebug argument '%s'", biospxedebug); 1198 rc = E_FAIL; 1199 break; 1200 } 1201 } 1202 for (int curBootDev = 0; curBootDev < 4; curBootDev++) 1203 { 1204 if (bootDeviceChanged[curBootDev]) 1205 CHECK_ERROR(machine, SetBootOrder (curBootDev + 1, bootDevice[curBootDev])); 1206 } 1207 if (hdds[0]) 1208 { 1209 if (!strcmp(hdds[0], "none")) 1210 { 1211 machine->DetachDevice(Bstr("IDE Controller"), 0, 0); 1212 } 1213 else 1214 { 1215 /* first guess is that it's a UUID */ 1216 Bstr uuid(hdds[0]); 1217 ComPtr<IMedium> hardDisk; 1218 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1219 /* not successful? Then it must be a filename */ 1220 if (!hardDisk) 1221 { 1222 rc = a->virtualBox->FindHardDisk(Bstr(hdds[0]), hardDisk.asOutParam()); 1223 if (FAILED(rc)) 1224 { 1225 /* open the new hard disk object */ 1226 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1227 } 1228 } 1229 if (hardDisk) 1230 { 1231 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1232 CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 0, 0, DeviceType_HardDisk, uuid)); 1233 } 1234 else 1235 rc = E_FAIL; 1236 if (FAILED(rc)) 1237 break; 1238 } 1239 } 1240 if (hdds[1]) 1241 { 1242 if (!strcmp(hdds[1], "none")) 1243 { 1244 machine->DetachDevice(Bstr("IDE Controller"), 0, 1); 1245 } 1246 else 1247 { 1248 /* first guess is that it's a UUID */ 1249 Bstr uuid(hdds[1]); 1250 ComPtr<IMedium> hardDisk; 1251 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1252 /* not successful? Then it must be a filename */ 1253 if (!hardDisk) 1254 { 1255 rc = a->virtualBox->FindHardDisk(Bstr(hdds[1]), hardDisk.asOutParam()); 1256 if (FAILED(rc)) 1257 { 1258 /* open the new hard disk object */ 1259 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1260 } 1261 } 1262 if (hardDisk) 1263 { 1264 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1265 CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 0, 1, DeviceType_HardDisk, uuid)); 1266 } 1267 else 1268 rc = E_FAIL; 1269 if (FAILED(rc)) 1270 break; 1271 } 1272 } 1273 if (hdds[2]) 1274 { 1275 if (!strcmp(hdds[2], "none")) 1276 { 1277 machine->DetachDevice(Bstr("IDE Controller"), 1, 1); 1278 } 1279 else 1280 { 1281 /* first guess is that it's a UUID */ 1282 Bstr uuid(hdds[2]); 1283 ComPtr<IMedium> hardDisk; 1284 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 1285 /* not successful? Then it must be a filename */ 1286 if (!hardDisk) 1287 { 1288 rc = a->virtualBox->FindHardDisk(Bstr(hdds[2]), hardDisk.asOutParam()); 1289 if (FAILED(rc)) 1290 { 1291 /* open the new hard disk object */ 1292 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1293 } 1294 } 1295 if (hardDisk) 1296 { 1297 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 1298 CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 1, 1, DeviceType_HardDisk, uuid)); 1299 } 1300 else 1301 rc = E_FAIL; 1302 if (FAILED(rc)) 1303 break; 1304 } 1305 } 1306 if (dvd) 1307 { 1308 ComPtr<IMedium> dvdMedium; 1309 1310 /* unmount? */ 1311 if (!strcmp(dvd, "none")) 1312 { 1313 /* nothing to do, NULL object will cause unmount */ 1314 } 1315 /* host drive? */ 1316 else if (!strncmp(dvd, "host:", 5)) 1317 { 1318 ComPtr<IHost> host; 1319 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 1320 rc = host->FindHostDVDDrive(Bstr(dvd + 5), dvdMedium.asOutParam()); 1321 if (!dvdMedium) 1322 { 1323 /* 2nd try: try with the real name, important on Linux+libhal */ 1324 char szPathReal[RTPATH_MAX]; 1325 if (RT_FAILURE(RTPathReal(dvd + 5, szPathReal, sizeof(szPathReal)))) 1326 { 1327 errorArgument("Invalid host DVD drive name \"%s\"", dvd + 5); 504 break; 505 } 506 507 case MODIFYVMBIOSLOGOFADEIN: 508 { 509 if (pValueUnion.psz) 510 { 511 if (!strcmp(pValueUnion.psz, "on")) 512 { 513 CHECK_ERROR (biosSettings, COMSETTER(LogoFadeIn)(true)); 514 } 515 else if (!strcmp(pValueUnion.psz, "off")) 516 { 517 CHECK_ERROR (biosSettings, COMSETTER(LogoFadeIn)(false)); 518 } 519 else 520 { 521 errorArgument("Invalid --bioslogofadein argument '%s'", pValueUnion.psz); 522 rc = E_FAIL; 523 } 524 } 525 break; 526 } 527 528 case MODIFYVMBIOSLOGOFADEOUT: 529 { 530 if (pValueUnion.psz) 531 { 532 if (!strcmp(pValueUnion.psz, "on")) 533 { 534 CHECK_ERROR (biosSettings, COMSETTER(LogoFadeOut)(true)); 535 } 536 else if (!strcmp(pValueUnion.psz, "off")) 537 { 538 CHECK_ERROR (biosSettings, COMSETTER(LogoFadeOut)(false)); 539 } 540 else 541 { 542 errorArgument("Invalid --bioslogofadeout argument '%s'", pValueUnion.psz); 1328 543 rc = E_FAIL; 1329 544 break; 1330 545 } 1331 rc = host->FindHostDVDDrive(Bstr(szPathReal), dvdMedium.asOutParam()); 1332 if (!dvdMedium) 1333 { 1334 errorArgument("Invalid host DVD drive name \"%s\"", dvd + 5); 1335 rc = E_FAIL; 1336 break; 1337 } 1338 } 1339 } 1340 else 1341 { 1342 /* first assume it's a UUID */ 1343 Bstr uuid(dvd); 1344 rc = a->virtualBox->GetDVDImage(uuid, dvdMedium.asOutParam()); 1345 if (FAILED(rc) || !dvdMedium) 1346 { 1347 /* must be a filename, check if it's in the collection */ 1348 rc = a->virtualBox->FindDVDImage(Bstr(dvd), dvdMedium.asOutParam()); 1349 /* not registered, do that on the fly */ 1350 if (!dvdMedium) 1351 { 1352 Bstr emptyUUID; 1353 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(dvd), emptyUUID, dvdMedium.asOutParam())); 1354 } 1355 } 1356 if (!dvdMedium) 1357 { 1358 rc = E_FAIL; 1359 break; 1360 } 1361 } 1362 1363 /** @todo generalize this, allow arbitrary number of DVD drives 1364 * and as a consequence multiple attachments and different 1365 * storage controllers. */ 1366 dvdMedium->COMGETTER(Id)(uuid.asOutParam()); 1367 CHECK_ERROR(machine, MountMedium(Bstr("IDE Controller"), 1, 0, uuid)); 1368 } 1369 if (dvdpassthrough) 1370 { 1371 ComPtr<IMediumAttachment> dvdAttachment; 1372 machine->GetMediumAttachment(Bstr("IDE Controller"), 1, 0, dvdAttachment.asOutParam()); 1373 ASSERT(dvdAttachment); 1374 1375 CHECK_ERROR(dvdAttachment, COMSETTER(Passthrough)(!strcmp(dvdpassthrough, "on"))); 1376 } 1377 if (idecontroller) 1378 { 1379 ComPtr<IStorageController> storageController; 1380 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("IDE Controller"), storageController.asOutParam())); 1381 1382 if (!RTStrICmp(idecontroller, "PIIX3")) 1383 { 1384 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3)); 1385 } 1386 else if (!RTStrICmp(idecontroller, "PIIX4")) 1387 { 1388 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4)); 1389 } 1390 else if (!RTStrICmp(idecontroller, "ICH6")) 1391 { 1392 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6)); 1393 } 1394 else 1395 { 1396 errorArgument("Invalid --idecontroller argument '%s'", idecontroller); 1397 rc = E_FAIL; 1398 break; 1399 } 1400 } 1401 if (floppy) 1402 { 1403 ComPtr<IMedium> floppyMedium; 1404 ComPtr<IMediumAttachment> floppyAttachment; 1405 machine->GetMediumAttachment(Bstr("Floppy Controller"), 0, 0, floppyAttachment.asOutParam()); 1406 1407 /* disable? */ 1408 if (!strcmp(floppy, "disabled")) 1409 { 1410 /* disable the controller */ 1411 if (floppyAttachment) 1412 CHECK_ERROR(machine, DetachDevice(Bstr("Floppy Controller"), 0, 0)); 1413 } 1414 else 1415 { 1416 /* enable the controller */ 1417 if (!floppyAttachment) 1418 CHECK_ERROR(machine, AttachDevice(Bstr("Floppy Controller"), 0, 0, DeviceType_Floppy, NULL)); 1419 1420 /* unmount? */ 1421 if ( !strcmp(floppy, "none") 1422 || !strcmp(floppy, "empty")) // deprecated 1423 { 1424 /* nothing to do, NULL object will cause unmount */ 1425 } 1426 /* host drive? */ 1427 else if (!strncmp(floppy, "host:", 5)) 1428 { 1429 ComPtr<IHost> host; 1430 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 1431 rc = host->FindHostFloppyDrive(Bstr(floppy + 5), floppyMedium.asOutParam()); 1432 if (!floppyMedium) 1433 { 1434 errorArgument("Invalid host floppy drive name \"%s\"", floppy + 5); 1435 rc = E_FAIL; 1436 break; 1437 } 1438 } 1439 else 1440 { 1441 /* first assume it's a UUID */ 1442 Bstr uuid(floppy); 1443 rc = a->virtualBox->GetFloppyImage(uuid, floppyMedium.asOutParam()); 1444 if (FAILED(rc) || !floppyMedium) 1445 { 1446 /* must be a filename, check if it's in the collection */ 1447 rc = a->virtualBox->FindFloppyImage(Bstr(floppy), floppyMedium.asOutParam()); 1448 /* not registered, do that on the fly */ 1449 if (!floppyMedium) 1450 { 1451 Bstr emptyUUID; 1452 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(floppy), emptyUUID, floppyMedium.asOutParam())); 1453 } 1454 } 1455 if (!floppyMedium) 1456 { 1457 rc = E_FAIL; 1458 break; 1459 } 1460 } 1461 floppyMedium->COMGETTER(Id)(uuid.asOutParam()); 1462 CHECK_ERROR(machine, MountMedium(Bstr("Floppy Controller"), 0, 0, uuid)); 1463 } 1464 } 1465 if (audio || audiocontroller) 1466 { 1467 ComPtr<IAudioAdapter> audioAdapter; 1468 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); 1469 ASSERT(audioAdapter); 1470 1471 if (audio) 1472 { 1473 /* disable? */ 1474 if (!strcmp(audio, "none")) 1475 { 1476 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false)); 1477 } 1478 else if (!strcmp(audio, "null")) 1479 { 1480 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null)); 1481 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1482 } 1483 #ifdef RT_OS_WINDOWS 1484 #ifdef VBOX_WITH_WINMM 1485 else if (!strcmp(audio, "winmm")) 1486 { 1487 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM)); 1488 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1489 } 1490 #endif 1491 else if (!strcmp(audio, "dsound")) 1492 { 1493 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound)); 1494 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1495 } 1496 #endif /* RT_OS_WINDOWS */ 1497 #ifdef RT_OS_LINUX 1498 else if (!strcmp(audio, "oss")) 1499 { 1500 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS)); 1501 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1502 } 1503 # ifdef VBOX_WITH_ALSA 1504 else if (!strcmp(audio, "alsa")) 1505 { 1506 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA)); 1507 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1508 } 1509 # endif 1510 # ifdef VBOX_WITH_PULSE 1511 else if (!strcmp(audio, "pulse")) 1512 { 1513 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse)); 1514 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1515 } 1516 # endif 1517 #endif /* !RT_OS_LINUX */ 1518 #ifdef RT_OS_SOLARIS 1519 else if (!strcmp(audio, "solaudio")) 1520 { 1521 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio)); 1522 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1523 } 1524 1525 # ifdef VBOX_WITH_SOLARIS_OSS 1526 else if (!strcmp(audio, "oss")) 1527 { 1528 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS)); 1529 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1530 } 1531 # endif 1532 1533 #endif /* !RT_OS_SOLARIS */ 1534 #ifdef RT_OS_DARWIN 1535 else if (!strcmp(audio, "coreaudio")) 1536 { 1537 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio)); 1538 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true)); 1539 } 1540 1541 #endif /* !RT_OS_DARWIN */ 1542 else 1543 { 1544 errorArgument("Invalid --audio argument '%s'", audio); 1545 rc = E_FAIL; 1546 break; 1547 } 1548 } 1549 if (audiocontroller) 1550 { 1551 if (!strcmp(audiocontroller, "sb16")) 1552 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16)); 1553 else if (!strcmp(audiocontroller, "ac97")) 1554 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97)); 1555 else 1556 { 1557 errorArgument("Invalid --audiocontroller argument '%s'", audiocontroller); 1558 rc = E_FAIL; 1559 break; 1560 } 1561 } 1562 } 1563 /* Shared clipboard state */ 1564 if (clipboard) 1565 { 1566 /* ComPtr<IClipboardMode> clipboardMode; 1567 machine->COMGETTER(ClipboardMode)(clipboardMode.asOutParam()); 1568 ASSERT(clipboardMode); 1569 */ 1570 if (!strcmp(clipboard, "disabled")) 1571 { 1572 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled)); 1573 } 1574 else if (!strcmp(clipboard, "hosttoguest")) 1575 { 1576 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest)); 1577 } 1578 else if (!strcmp(clipboard, "guesttohost")) 1579 { 1580 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost)); 1581 } 1582 else if (!strcmp(clipboard, "bidirectional")) 1583 { 1584 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional)); 1585 } 1586 else 1587 { 1588 errorArgument("Invalid --clipboard argument '%s'", clipboard); 1589 rc = E_FAIL; 1590 break; 1591 } 1592 } 1593 /* iterate through all possible NICs */ 1594 for (ULONG n = 0; n < NetworkAdapterCount; n ++) 1595 { 1596 ComPtr<INetworkAdapter> nic; 1597 CHECK_ERROR_RET (machine, GetNetworkAdapter (n, nic.asOutParam()), 1); 1598 1599 ASSERT(nic); 1600 1601 /* something about the NIC? */ 1602 if (nics[n]) 1603 { 1604 if (!strcmp(nics[n], "none")) 1605 { 1606 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (FALSE), 1); 1607 } 1608 else if (!strcmp(nics[n], "null")) 1609 { 1610 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1); 1611 CHECK_ERROR_RET(nic, Detach(), 1); 1612 } 1613 else if (!strcmp(nics[n], "nat")) 1614 { 1615 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1); 1616 CHECK_ERROR_RET(nic, AttachToNAT(), 1); 1617 } 1618 else if ( !strcmp(nics[n], "bridged") 1619 || !strcmp(nics[n], "hostif")) /* backward compatibility */ 1620 { 1621 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1); 1622 CHECK_ERROR_RET(nic, AttachToBridgedInterface(), 1); 1623 } 1624 else if (!strcmp(nics[n], "intnet")) 1625 { 1626 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1); 1627 CHECK_ERROR_RET(nic, AttachToInternalNetwork(), 1); 1628 } 1629 #if defined(VBOX_WITH_NETFLT) 1630 else if (!strcmp(nics[n], "hostonly")) 1631 { 1632 1633 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1); 1634 CHECK_ERROR_RET(nic, AttachToHostOnlyInterface(), 1); 1635 } 1636 #endif 1637 else 1638 { 1639 errorArgument("Invalid type '%s' specfied for NIC %lu", nics[n], n + 1); 1640 rc = E_FAIL; 1641 break; 1642 } 1643 } 1644 1645 /* something about the NIC type? */ 1646 if (nictype[n]) 1647 { 1648 if (!strcmp(nictype[n], "Am79C970A")) 1649 { 1650 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A), 1); 1651 } 1652 else if (!strcmp(nictype[n], "Am79C973")) 1653 { 1654 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973), 1); 1655 } 1656 #ifdef VBOX_WITH_E1000 1657 else if (!strcmp(nictype[n], "82540EM")) 1658 { 1659 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM), 1); 1660 } 1661 else if (!strcmp(nictype[n], "82543GC")) 1662 { 1663 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC), 1); 1664 } 1665 else if (!strcmp(nictype[n], "82545EM")) 1666 { 1667 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82545EM), 1); 1668 } 1669 #endif 1670 #ifdef VBOX_WITH_VIRTIO 1671 else if (!strcmp(nictype[n], "virtio")) 1672 { 1673 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Virtio), 1); 1674 } 1675 #endif /* VBOX_WITH_VIRTIO */ 1676 else 1677 { 1678 errorArgument("Invalid NIC type '%s' specified for NIC %lu", nictype[n], n + 1); 1679 rc = E_FAIL; 1680 break; 1681 } 1682 } 1683 1684 /* something about the MAC address? */ 1685 if (macs[n]) 1686 { 1687 /* generate one? */ 1688 if (!strcmp(macs[n], "auto")) 1689 { 1690 CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(NULL), 1); 1691 } 1692 else 1693 { 1694 CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(Bstr(macs[n])), 1); 1695 } 1696 } 1697 1698 /* something about the reported link speed? */ 1699 if (nicspeed[n]) 1700 { 1701 uint32_t u32LineSpeed; 1702 1703 u32LineSpeed = RTStrToUInt32(nicspeed[n]); 1704 1705 if (u32LineSpeed < 1000 || u32LineSpeed > 4000000) 1706 { 1707 errorArgument("Invalid --nicspeed%lu argument '%s'", n + 1, nicspeed[n]); 1708 rc = E_FAIL; 1709 break; 1710 } 1711 CHECK_ERROR_RET(nic, COMSETTER(LineSpeed)(u32LineSpeed), 1); 1712 } 1713 1714 /* the link status flag? */ 1715 if (cableconnected[n]) 1716 { 1717 if (!strcmp(cableconnected[n], "on")) 1718 { 1719 CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(TRUE), 1); 1720 } 1721 else if (!strcmp(cableconnected[n], "off")) 1722 { 1723 CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(FALSE), 1); 1724 } 1725 else 1726 { 1727 errorArgument("Invalid --cableconnected%lu argument '%s'", n + 1, cableconnected[n]); 1728 rc = E_FAIL; 1729 break; 1730 } 1731 } 1732 1733 /* the trace flag? */ 1734 if (nictrace[n]) 1735 { 1736 if (!strcmp(nictrace[n], "on")) 1737 { 1738 CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(TRUE), 1); 1739 } 1740 else if (!strcmp(nictrace[n], "off")) 1741 { 1742 CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(FALSE), 1); 1743 } 1744 else 1745 { 1746 errorArgument("Invalid --nictrace%lu argument '%s'", n + 1, nictrace[n]); 1747 rc = E_FAIL; 1748 break; 1749 } 1750 } 1751 1752 /* the tracefile flag? */ 1753 if (nictracefile[n]) 1754 { 1755 CHECK_ERROR_RET(nic, COMSETTER(TraceFile)(Bstr(nictracefile[n])), 1); 1756 } 1757 1758 /* the host interface device? */ 1759 if (hostifdev[n]) 1760 { 1761 /* remove it? */ 1762 if (!strcmp(hostifdev[n], "none")) 1763 { 1764 CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(NULL), 1); 1765 } 1766 else 1767 { 1768 CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(Bstr(hostifdev[n])), 1); 1769 } 1770 } 1771 1772 /* the internal network name? */ 1773 if (intnet[n]) 1774 { 1775 /* remove it? */ 1776 if (!strcmp(intnet[n], "none")) 1777 { 1778 CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(NULL), 1); 1779 } 1780 else 1781 { 1782 CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(Bstr(intnet[n])), 1); 1783 } 1784 } 1785 /* the network of the NAT */ 1786 if (natnet[n]) 1787 { 1788 CHECK_ERROR_RET(nic, COMSETTER(NATNetwork)(Bstr(natnet[n])), 1); 1789 } 1790 } 1791 if (FAILED(rc)) 1792 break; 1793 1794 /* iterate through all possible serial ports */ 1795 for (ULONG n = 0; n < SerialPortCount; n ++) 1796 { 1797 ComPtr<ISerialPort> uart; 1798 CHECK_ERROR_RET (machine, GetSerialPort (n, uart.asOutParam()), 1); 1799 1800 ASSERT(uart); 1801 1802 if (uarts_base[n]) 1803 { 1804 if (uarts_base[n] == (ULONG)-1) 1805 { 1806 CHECK_ERROR_RET(uart, COMSETTER(Enabled) (FALSE), 1); 1807 } 1808 else 1809 { 1810 CHECK_ERROR_RET(uart, COMSETTER(IOBase) (uarts_base[n]), 1); 1811 CHECK_ERROR_RET(uart, COMSETTER(IRQ) (uarts_irq[n]), 1); 1812 CHECK_ERROR_RET(uart, COMSETTER(Enabled) (TRUE), 1); 1813 } 1814 } 1815 if (uarts_mode[n]) 1816 { 1817 if (!strcmp(uarts_mode[n], "disconnected")) 1818 { 1819 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_Disconnected), 1); 1820 } 1821 else 1822 { 1823 CHECK_ERROR_RET(uart, COMSETTER(Path) (Bstr(uarts_path[n])), 1); 1824 if (!strcmp(uarts_mode[n], "server")) 1825 { 1826 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1); 1827 CHECK_ERROR_RET(uart, COMSETTER(Server) (TRUE), 1); 1828 } 1829 else if (!strcmp(uarts_mode[n], "client")) 1830 { 1831 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1); 1832 CHECK_ERROR_RET(uart, COMSETTER(Server) (FALSE), 1); 1833 } 1834 else if (!strcmp(uarts_mode[n], "file")) 1835 { 1836 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_RawFile), 1); 1837 } 1838 else 1839 { 1840 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostDevice), 1); 1841 } 1842 } 1843 } 1844 } 1845 if (FAILED(rc)) 1846 break; 1847 1848 #ifdef VBOX_WITH_VRDP 1849 if (vrdp || vrdpport || vrdpaddress || vrdpauthtype || vrdpmulticon || vrdpreusecon) 1850 { 1851 ComPtr<IVRDPServer> vrdpServer; 1852 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam()); 1853 ASSERT(vrdpServer); 1854 if (vrdpServer) 1855 { 1856 if (vrdp) 1857 { 1858 if (!strcmp(vrdp, "on")) 1859 { 1860 CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(true)); 1861 } 1862 else if (!strcmp(vrdp, "off")) 1863 { 1864 CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(false)); 1865 } 1866 else 1867 { 1868 errorArgument("Invalid --vrdp argument '%s'", vrdp); 1869 rc = E_FAIL; 1870 break; 1871 } 1872 } 1873 if (vrdpport) 1874 { 1875 CHECK_ERROR(vrdpServer, COMSETTER(Ports)(Bstr(vrdpport))); 1876 } 1877 if (vrdpaddress) 1878 { 1879 CHECK_ERROR(vrdpServer, COMSETTER(NetAddress)(Bstr(vrdpaddress))); 1880 } 1881 if (vrdpauthtype) 1882 { 1883 if (!strcmp(vrdpauthtype, "null")) 1884 { 1885 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Null)); 1886 } 1887 else if (!strcmp(vrdpauthtype, "external")) 1888 { 1889 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_External)); 1890 } 1891 else if (!strcmp(vrdpauthtype, "guest")) 1892 { 1893 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Guest)); 1894 } 1895 else 1896 { 1897 errorArgument("Invalid --vrdpauthtype argument '%s'", vrdpauthtype); 1898 rc = E_FAIL; 1899 break; 1900 } 1901 } 1902 if (vrdpmulticon) 1903 { 1904 if (!strcmp(vrdpmulticon, "on")) 1905 { 1906 CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(true)); 1907 } 1908 else if (!strcmp(vrdpmulticon, "off")) 1909 { 1910 CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(false)); 1911 } 1912 else 1913 { 1914 errorArgument("Invalid --vrdpmulticon argument '%s'", vrdpmulticon); 1915 rc = E_FAIL; 1916 break; 1917 } 1918 } 1919 if (vrdpreusecon) 1920 { 1921 if (!strcmp(vrdpreusecon, "on")) 1922 { 1923 CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(true)); 1924 } 1925 else if (!strcmp(vrdpreusecon, "off")) 1926 { 1927 CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(false)); 1928 } 1929 else 1930 { 1931 errorArgument("Invalid --vrdpreusecon argument '%s'", vrdpreusecon); 1932 rc = E_FAIL; 1933 break; 1934 } 1935 } 1936 } 1937 } 1938 #endif /* VBOX_WITH_VRDP */ 1939 1940 /* 1941 * USB enable/disable 1942 */ 1943 if (fUsbEnabled != -1) 1944 { 1945 ComPtr<IUSBController> UsbCtl; 1946 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam())); 1947 if (SUCCEEDED(rc)) 1948 { 1949 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(!!fUsbEnabled)); 1950 } 1951 } 1952 /* 1953 * USB EHCI enable/disable 1954 */ 1955 if (fUsbEhciEnabled != -1) 1956 { 1957 ComPtr<IUSBController> UsbCtl; 1958 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam())); 1959 if (SUCCEEDED(rc)) 1960 { 1961 CHECK_ERROR(UsbCtl, COMSETTER(EnabledEhci)(!!fUsbEhciEnabled)); 1962 } 1963 } 1964 1965 if (snapshotFolder) 1966 { 1967 if (!strcmp(snapshotFolder, "default")) 1968 { 1969 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(NULL)); 1970 } 1971 else 1972 { 1973 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(snapshotFolder))); 1974 } 1975 } 1976 1977 if (guestMemBalloonSize != (ULONG)-1) 1978 CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(guestMemBalloonSize)); 1979 1980 if (guestStatInterval != (ULONG)-1) 1981 CHECK_ERROR(machine, COMSETTER(StatisticsUpdateInterval)(guestStatInterval)); 1982 1983 /* 1984 * SATA controller enable/disable 1985 */ 1986 if (fSataEnabled != -1) 1987 { 1988 if (fSataEnabled) 1989 { 1990 ComPtr<IStorageController> ctl; 1991 CHECK_ERROR(machine, AddStorageController(Bstr("SATA"), StorageBus_SATA, ctl.asOutParam())); 1992 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci)); 1993 } 1994 else 1995 CHECK_ERROR(machine, RemoveStorageController(Bstr("SATA"))); 1996 } 1997 1998 for (uint32_t i = 4; i < 34; i++) 1999 { 2000 if (hdds[i]) 2001 { 2002 if (!strcmp(hdds[i], "none")) 2003 { 2004 machine->DetachDevice(Bstr("SATA"), i-4, 0); 546 } 547 break; 548 } 549 550 case MODIFYVMBIOSLOGODISPLAYTIME: 551 { 552 if (pValueUnion.u64 > 0) 553 CHECK_ERROR (biosSettings, COMSETTER(LogoDisplayTime)(pValueUnion.u64)); 554 break; 555 } 556 557 case MODIFYVMBIOSLOGOIMAGEPATH: 558 { 559 if (pValueUnion.psz) 560 CHECK_ERROR (biosSettings, COMSETTER(LogoImagePath)(Bstr(pValueUnion.psz))); 561 break; 562 } 563 564 case MODIFYVMBIOSBOOTMENU: 565 { 566 if (pValueUnion.psz) 567 { 568 if (!strcmp(pValueUnion.psz, "disabled")) 569 CHECK_ERROR (biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled)); 570 else if (!strcmp(pValueUnion.psz, "menuonly")) 571 CHECK_ERROR (biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly)); 572 else if (!strcmp(pValueUnion.psz, "messageandmenu")) 573 CHECK_ERROR (biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu)); 574 else 575 { 576 errorArgument("Invalid --biosbootmenu argument '%s'", pValueUnion.psz); 577 rc = E_FAIL; 578 } 579 } 580 break; 581 } 582 583 case MODIFYVMBIOSSYSTEMTIMEOFFSET: 584 { 585 if (pValueUnion.u64 > 0) 586 CHECK_ERROR (biosSettings, COMSETTER(TimeOffset)(pValueUnion.u64)); 587 break; 588 } 589 590 case MODIFYVMBIOSPXEDEBUG: 591 { 592 if (pValueUnion.psz) 593 { 594 if (!strcmp(pValueUnion.psz, "on")) 595 { 596 CHECK_ERROR (biosSettings, COMSETTER(PXEDebugEnabled)(true)); 597 } 598 else if (!strcmp(pValueUnion.psz, "off")) 599 { 600 CHECK_ERROR (biosSettings, COMSETTER(PXEDebugEnabled)(false)); 601 } 602 else 603 { 604 errorArgument("Invalid --biospxedebug argument '%s'", pValueUnion.psz); 605 rc = E_FAIL; 606 } 607 } 608 break; 609 } 610 611 case MODIFYVMBOOT: 612 { 613 if ((pGetState.uIndex < 1) && (pGetState.uIndex > 4)) 614 return errorSyntax(USAGE_MODIFYVM, 615 "Missing or Invalid boot slot number in '%s'", 616 pGetState.pDef->pszLong); 617 618 if (!strcmp(pValueUnion.psz, "none")) 619 { 620 CHECK_ERROR (machine, SetBootOrder (pGetState.uIndex, DeviceType_Null)); 621 } 622 else if (!strcmp(pValueUnion.psz, "floppy")) 623 { 624 CHECK_ERROR (machine, SetBootOrder (pGetState.uIndex, DeviceType_Floppy)); 625 } 626 else if (!strcmp(pValueUnion.psz, "dvd")) 627 { 628 CHECK_ERROR (machine, SetBootOrder (pGetState.uIndex, DeviceType_DVD)); 629 } 630 else if (!strcmp(pValueUnion.psz, "disk")) 631 { 632 CHECK_ERROR (machine, SetBootOrder (pGetState.uIndex, DeviceType_HardDisk)); 633 } 634 else if (!strcmp(pValueUnion.psz, "net")) 635 { 636 CHECK_ERROR (machine, SetBootOrder (pGetState.uIndex, DeviceType_Network)); 637 } 638 else 639 return errorArgument("Invalid boot device '%s'", pValueUnion.psz); 640 641 break; 642 } 643 644 case MODIFYVMHDA: 645 { 646 if (!strcmp(pValueUnion.psz, "none")) 647 { 648 machine->DetachDevice(Bstr("IDE Controller"), 0, 0); 2005 649 } 2006 650 else 2007 651 { 2008 652 /* first guess is that it's a UUID */ 2009 Bstr uuid( hdds[i]);653 Bstr uuid(pValueUnion.psz); 2010 654 ComPtr<IMedium> hardDisk; 2011 655 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); … … 2013 657 if (!hardDisk) 2014 658 { 2015 rc = a->virtualBox->FindHardDisk(Bstr(hdds[i]), hardDisk.asOutParam());659 rc = a->virtualBox->FindHardDisk(Bstr(pValueUnion.psz), hardDisk.asOutParam()); 2016 660 if (FAILED(rc)) 2017 661 { 2018 662 /* open the new hard disk object */ 2019 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 663 CHECK_ERROR (a->virtualBox, 664 OpenHardDisk(Bstr(pValueUnion.psz), 665 AccessMode_ReadWrite, false, Bstr(""), 666 false, Bstr(""), hardDisk.asOutParam())); 2020 667 } 2021 668 } … … 2023 670 { 2024 671 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 2025 CHECK_ERROR(machine, AttachDevice(Bstr("SATA"), i-4, 0, DeviceType_HardDisk, uuid)); 2026 } 2027 else 2028 rc = E_FAIL; 2029 if (FAILED(rc)) 2030 break; 2031 } 2032 } 2033 } 2034 2035 for (uint32_t i = 0; i < 4; i++) 2036 { 2037 if (sataBootDevices[i] != -1) 2038 { 2039 ComPtr<IStorageController> SataCtl; 2040 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam())); 2041 if (SUCCEEDED(rc)) 2042 { 2043 CHECK_ERROR(SataCtl, SetIDEEmulationPort(i, sataBootDevices[i])); 2044 } 2045 } 2046 } 2047 2048 if (sataPortCount != -1) 2049 { 2050 ComPtr<IStorageController> SataCtl; 2051 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam())); 2052 if (SUCCEEDED(rc)) 2053 { 2054 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(sataPortCount)); 2055 } 2056 } 2057 2058 /* 2059 * SCSI controller enable/disable 2060 */ 2061 if (fScsiEnabled != -1) 2062 { 2063 if (fScsiEnabled) 2064 { 2065 ComPtr<IStorageController> ctl; 2066 if (!fScsiLsiLogic) 2067 { 2068 CHECK_ERROR(machine, AddStorageController(Bstr("BusLogic"), StorageBus_SCSI, ctl.asOutParam())); 2069 if (SUCCEEDED(rc)) 2070 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic)); 2071 } 2072 else /* LsiLogic is default */ 2073 { 2074 CHECK_ERROR(machine, AddStorageController(Bstr("LsiLogic"), StorageBus_SCSI, ctl.asOutParam())); 2075 if (SUCCEEDED(rc)) 2076 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic)); 2077 } 2078 } 2079 else 2080 { 2081 rc = machine->RemoveStorageController(Bstr("LsiLogic")); 2082 if (!SUCCEEDED(rc)) 2083 CHECK_ERROR(machine, RemoveStorageController(Bstr("BusLogic"))); 2084 } 2085 } 2086 2087 for (uint32_t i = 34; i < 50; i++) 2088 { 2089 if (hdds[i]) 2090 { 2091 if (!strcmp(hdds[i], "none")) 2092 { 2093 rc = machine->DetachDevice(Bstr("LsiLogic"), i-34, 0); 2094 if (!SUCCEEDED(rc)) 2095 CHECK_ERROR(machine, DetachDevice(Bstr("BusLogic"), i-34, 0)); 672 CHECK_ERROR (machine, AttachDevice(Bstr("IDE Controller"), 0, 0, DeviceType_HardDisk, uuid)); 673 } 674 else 675 rc = E_FAIL; 676 } 677 break; 678 } 679 680 case MODIFYVMHDB: 681 { 682 if (!strcmp(pValueUnion.psz, "none")) 683 { 684 machine->DetachDevice(Bstr("IDE Controller"), 0, 1); 2096 685 } 2097 686 else 2098 687 { 2099 688 /* first guess is that it's a UUID */ 2100 Bstr uuid( hdds[i]);689 Bstr uuid(pValueUnion.psz); 2101 690 ComPtr<IMedium> hardDisk; 2102 691 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); … … 2104 693 if (!hardDisk) 2105 694 { 2106 rc = a->virtualBox->FindHardDisk(Bstr( hdds[i]), hardDisk.asOutParam());695 rc = a->virtualBox->FindHardDisk(Bstr(pValueUnion.psz), hardDisk.asOutParam()); 2107 696 if (FAILED(rc)) 2108 697 { 2109 698 /* open the new hard disk object */ 2110 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 699 CHECK_ERROR (a->virtualBox, 700 OpenHardDisk(Bstr(pValueUnion.psz), 701 AccessMode_ReadWrite, false, Bstr(""), 702 false, Bstr(""), hardDisk.asOutParam())); 2111 703 } 2112 704 } … … 2114 706 { 2115 707 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 2116 rc = machine->AttachDevice(Bstr("LsiLogic"), i-34, 0, DeviceType_HardDisk, uuid); 2117 if (!SUCCEEDED(rc)) 2118 CHECK_ERROR(machine, AttachDevice(Bstr("BusLogic"), i-34, 0, DeviceType_HardDisk, uuid)); 2119 } 2120 else 2121 rc = E_FAIL; 708 CHECK_ERROR (machine, AttachDevice(Bstr("IDE Controller"), 0, 1, DeviceType_HardDisk, uuid)); 709 } 710 else 711 rc = E_FAIL; 712 } 713 break; 714 } 715 716 case MODIFYVMHDD: 717 { 718 if (!strcmp(pValueUnion.psz, "none")) 719 { 720 machine->DetachDevice(Bstr("IDE Controller"), 1, 1); 721 } 722 else 723 { 724 /* first guess is that it's a UUID */ 725 Bstr uuid(pValueUnion.psz); 726 ComPtr<IMedium> hardDisk; 727 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 728 /* not successful? Then it must be a filename */ 729 if (!hardDisk) 730 { 731 rc = a->virtualBox->FindHardDisk(Bstr(pValueUnion.psz), hardDisk.asOutParam()); 732 if (FAILED(rc)) 733 { 734 /* open the new hard disk object */ 735 CHECK_ERROR (a->virtualBox, 736 OpenHardDisk(Bstr(pValueUnion.psz), 737 AccessMode_ReadWrite, false, Bstr(""), 738 false, Bstr(""), hardDisk.asOutParam())); 739 } 740 } 741 if (hardDisk) 742 { 743 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 744 CHECK_ERROR (machine, AttachDevice(Bstr("IDE Controller"), 1, 1, DeviceType_HardDisk, uuid)); 745 } 746 else 747 rc = E_FAIL; 748 } 749 break; 750 } 751 752 case MODIFYVMIDECONTROLLER: 753 { 754 ComPtr<IStorageController> storageController; 755 CHECK_ERROR (machine, GetStorageControllerByName(Bstr("IDE Controller"), 756 storageController.asOutParam())); 757 758 if (!RTStrICmp(pValueUnion.psz, "PIIX3")) 759 { 760 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3)); 761 } 762 else if (!RTStrICmp(pValueUnion.psz, "PIIX4")) 763 { 764 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4)); 765 } 766 else if (!RTStrICmp(pValueUnion.psz, "ICH6")) 767 { 768 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6)); 769 } 770 else 771 { 772 errorArgument("Invalid --idecontroller argument '%s'", pValueUnion.psz); 773 rc = E_FAIL; 774 } 775 break; 776 } 777 778 case MODIFYVMSATAIDEEMULATION: 779 { 780 ComPtr<IStorageController> SataCtl; 781 CHECK_ERROR (machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam())); 782 783 if ((pGetState.uIndex < 1) && (pGetState.uIndex > 4)) 784 return errorSyntax(USAGE_MODIFYVM, 785 "Missing or Invalid SATA boot slot number in '%s'", 786 pGetState.pDef->pszLong); 787 788 if ((pValueUnion.u32 < 1) && (pValueUnion.u32 > 30)) 789 return errorSyntax(USAGE_MODIFYVM, 790 "Missing or Invalid SATA port number in '%s'", 791 pGetState.pDef->pszLong); 792 793 if (SUCCEEDED(rc)) 794 CHECK_ERROR(SataCtl, SetIDEEmulationPort(pGetState.uIndex, pValueUnion.u32)); 795 796 break; 797 } 798 799 case MODIFYVMSATAPORTCOUNT: 800 { 801 ComPtr<IStorageController> SataCtl; 802 CHECK_ERROR (machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam())); 803 804 if (SUCCEEDED(rc) && pValueUnion.u32 > 0) 805 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(pValueUnion.u32)); 806 807 break; 808 } 809 810 case MODIFYVMSATAPORT: 811 { 812 if ((pGetState.uIndex < 1) && (pGetState.uIndex > 30)) 813 return errorSyntax(USAGE_MODIFYVM, 814 "Missing or Invalid SATA port number in '%s'", 815 pGetState.pDef->pszLong); 816 817 if (!strcmp(pValueUnion.psz, "none")) 818 { 819 machine->DetachDevice(Bstr("SATA"), pGetState.uIndex, 0); 820 } 821 else 822 { 823 /* first guess is that it's a UUID */ 824 Bstr uuid(pValueUnion.psz); 825 ComPtr<IMedium> hardDisk; 826 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 827 /* not successful? Then it must be a filename */ 828 if (!hardDisk) 829 { 830 rc = a->virtualBox->FindHardDisk(Bstr(pValueUnion.psz), hardDisk.asOutParam()); 831 if (FAILED(rc)) 832 { 833 /* open the new hard disk object */ 834 CHECK_ERROR (a->virtualBox, 835 OpenHardDisk(Bstr(pValueUnion.psz), AccessMode_ReadWrite, 836 false, Bstr(""), false, 837 Bstr(""), hardDisk.asOutParam())); 838 } 839 } 840 if (hardDisk) 841 { 842 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 843 CHECK_ERROR (machine, 844 AttachDevice(Bstr("SATA"), pGetState.uIndex, 845 0, DeviceType_HardDisk, uuid)); 846 } 847 else 848 rc = E_FAIL; 849 } 850 break; 851 } 852 853 case MODIFYVMSATA: 854 { 855 if (!strcmp(pValueUnion.psz, "on") || !strcmp(pValueUnion.psz, "enable")) 856 { 857 ComPtr<IStorageController> ctl; 858 CHECK_ERROR (machine, AddStorageController(Bstr("SATA"), StorageBus_SATA, ctl.asOutParam())); 859 CHECK_ERROR (ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci)); 860 } 861 else if (!strcmp(pValueUnion.psz, "off") || !strcmp(pValueUnion.psz, "disable")) 862 CHECK_ERROR (machine, RemoveStorageController(Bstr("SATA"))); 863 else 864 return errorArgument("Invalid --usb argument '%s'", pValueUnion.psz); 865 break; 866 } 867 868 case MODIFYVMSCSIPORT: 869 { 870 if ((pGetState.uIndex < 1) && (pGetState.uIndex > 16)) 871 return errorSyntax(USAGE_MODIFYVM, 872 "Missing or Invalid SCSI port number in '%s'", 873 pGetState.pDef->pszLong); 874 875 if (!strcmp(pValueUnion.psz, "none")) 876 { 877 rc = machine->DetachDevice(Bstr("LsiLogic"), pGetState.uIndex, 0); 2122 878 if (FAILED(rc)) 879 CHECK_ERROR(machine, DetachDevice(Bstr("BusLogic"), pGetState.uIndex, 0)); 880 } 881 else 882 { 883 /* first guess is that it's a UUID */ 884 Bstr uuid(pValueUnion.psz); 885 ComPtr<IMedium> hardDisk; 886 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam()); 887 /* not successful? Then it must be a filename */ 888 if (!hardDisk) 889 { 890 rc = a->virtualBox->FindHardDisk(Bstr(pValueUnion.psz), hardDisk.asOutParam()); 891 if (FAILED(rc)) 892 { 893 /* open the new hard disk object */ 894 CHECK_ERROR (a->virtualBox, 895 OpenHardDisk(Bstr(pValueUnion.psz), 896 AccessMode_ReadWrite, false, Bstr(""), 897 false, Bstr(""), hardDisk.asOutParam())); 898 } 899 } 900 if (hardDisk) 901 { 902 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 903 rc = machine->AttachDevice(Bstr("LsiLogic"), pGetState.uIndex, 0, DeviceType_HardDisk, uuid); 904 if (FAILED(rc)) 905 CHECK_ERROR (machine, 906 AttachDevice(Bstr("BusLogic"), 907 pGetState.uIndex, 0, 908 DeviceType_HardDisk, uuid)); 909 } 910 else 911 rc = E_FAIL; 912 } 913 break; 914 } 915 916 case MODIFYVMSCSITYPE: 917 { 918 ComPtr<IStorageController> ctl; 919 920 if (!RTStrICmp(pValueUnion.psz, "LsiLogic")) 921 { 922 rc = machine->RemoveStorageController(Bstr("BusLogic")); 923 if (FAILED(rc)) 924 CHECK_ERROR (machine, RemoveStorageController(Bstr("LsiLogic"))); 925 926 CHECK_ERROR (machine, 927 AddStorageController(Bstr("LsiLogic"), 928 StorageBus_SCSI, 929 ctl.asOutParam())); 930 931 if (SUCCEEDED(rc)) 932 CHECK_ERROR (ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic)); 933 } 934 else if (!RTStrICmp(pValueUnion.psz, "BusLogic")) 935 { 936 rc = machine->RemoveStorageController(Bstr("LsiLogic")); 937 if (FAILED(rc)) 938 CHECK_ERROR (machine, RemoveStorageController(Bstr("BusLogic"))); 939 940 CHECK_ERROR (machine, 941 AddStorageController(Bstr("BusLogic"), 942 StorageBus_SCSI, 943 ctl.asOutParam())); 944 945 if (SUCCEEDED(rc)) 946 CHECK_ERROR (ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic)); 947 } 948 else 949 return errorArgument("Invalid --scsitype argument '%s'", pValueUnion.psz); 950 break; 951 } 952 953 case MODIFYVMSCSI: 954 { 955 if (!strcmp(pValueUnion.psz, "on") || !strcmp(pValueUnion.psz, "enable")) 956 { 957 ComPtr<IStorageController> ctl; 958 959 CHECK_ERROR (machine, AddStorageController(Bstr("BusLogic"), StorageBus_SCSI, ctl.asOutParam())); 960 if (SUCCEEDED(rc)) 961 CHECK_ERROR (ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic)); 962 } 963 else if (!strcmp(pValueUnion.psz, "off") || !strcmp(pValueUnion.psz, "disable")) 964 { 965 rc = machine->RemoveStorageController(Bstr("BusLogic")); 966 if (FAILED(rc)) 967 CHECK_ERROR (machine, RemoveStorageController(Bstr("LsiLogic"))); 968 } 969 break; 970 } 971 972 case MODIFYVMDVDPASSTHROUGH: 973 { 974 ComPtr<IMediumAttachment> dvdAttachment; 975 machine->GetMediumAttachment(Bstr("IDE Controller"), 1, 0, dvdAttachment.asOutParam()); 976 ASSERT(dvdAttachment); 977 978 CHECK_ERROR (dvdAttachment, COMSETTER(Passthrough)(!strcmp(pValueUnion.psz, "on"))); 979 break; 980 } 981 982 case MODIFYVMDVD: 983 { 984 ComPtr<IMedium> dvdMedium; 985 Bstr uuid(pValueUnion.psz); 986 987 /* unmount? */ 988 if (!strcmp(pValueUnion.psz, "none")) 989 { 990 /* nothing to do, NULL object will cause unmount */ 991 } 992 /* host drive? */ 993 else if (!strncmp(pValueUnion.psz, "host:", 5)) 994 { 995 ComPtr<IHost> host; 996 CHECK_ERROR (a->virtualBox, COMGETTER(Host)(host.asOutParam())); 997 rc = host->FindHostDVDDrive(Bstr(pValueUnion.psz + 5), dvdMedium.asOutParam()); 998 if (!dvdMedium) 999 { 1000 /* 2nd try: try with the real name, important on Linux+libhal */ 1001 char szPathReal[RTPATH_MAX]; 1002 if (RT_FAILURE(RTPathReal(pValueUnion.psz + 5, szPathReal, sizeof(szPathReal)))) 1003 { 1004 errorArgument("Invalid host DVD drive name \"%s\"", pValueUnion.psz + 5); 1005 rc = E_FAIL; 1006 break; 1007 } 1008 rc = host->FindHostDVDDrive(Bstr(szPathReal), dvdMedium.asOutParam()); 1009 if (!dvdMedium) 1010 { 1011 errorArgument("Invalid host DVD drive name \"%s\"", pValueUnion.psz + 5); 1012 rc = E_FAIL; 1013 break; 1014 } 1015 } 1016 } 1017 else 1018 { 1019 /* first assume it's a UUID */ 1020 rc = a->virtualBox->GetDVDImage(uuid, dvdMedium.asOutParam()); 1021 if (FAILED(rc) || !dvdMedium) 1022 { 1023 /* must be a filename, check if it's in the collection */ 1024 rc = a->virtualBox->FindDVDImage(Bstr(pValueUnion.psz), dvdMedium.asOutParam()); 1025 /* not registered, do that on the fly */ 1026 if (!dvdMedium) 1027 { 1028 Bstr emptyUUID; 1029 CHECK_ERROR (a->virtualBox, OpenDVDImage(Bstr(pValueUnion.psz), 1030 emptyUUID, dvdMedium.asOutParam())); 1031 } 1032 } 1033 if (!dvdMedium) 1034 { 1035 rc = E_FAIL; 2123 1036 break; 2124 } 1037 } 1038 } 1039 1040 /** @todo generalize this, allow arbitrary number of DVD drives 1041 * and as a consequence multiple attachments and different 1042 * storage controllers. */ 1043 dvdMedium->COMGETTER(Id)(uuid.asOutParam()); 1044 CHECK_ERROR (machine, MountMedium(Bstr("IDE Controller"), 1, 0, uuid)); 1045 break; 1046 } 1047 1048 case MODIFYVMFLOPPY: 1049 { 1050 Bstr uuid(pValueUnion.psz); 1051 ComPtr<IMedium> floppyMedium; 1052 ComPtr<IMediumAttachment> floppyAttachment; 1053 machine->GetMediumAttachment(Bstr("Floppy Controller"), 0, 0, floppyAttachment.asOutParam()); 1054 1055 /* disable? */ 1056 if (!strcmp(pValueUnion.psz, "disabled")) 1057 { 1058 /* disable the controller */ 1059 if (floppyAttachment) 1060 CHECK_ERROR(machine, DetachDevice(Bstr("Floppy Controller"), 0, 0)); 1061 } 1062 else 1063 { 1064 /* enable the controller */ 1065 if (!floppyAttachment) 1066 CHECK_ERROR(machine, AttachDevice(Bstr("Floppy Controller"), 0, 0, DeviceType_Floppy, NULL)); 1067 1068 /* unmount? */ 1069 if ( !strcmp(pValueUnion.psz, "none") 1070 || !strcmp(pValueUnion.psz, "empty")) // deprecated 1071 { 1072 /* nothing to do, NULL object will cause unmount */ 1073 } 1074 /* host drive? */ 1075 else if (!strncmp(pValueUnion.psz, "host:", 5)) 1076 { 1077 ComPtr<IHost> host; 1078 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam())); 1079 rc = host->FindHostFloppyDrive(Bstr(pValueUnion.psz + 5), floppyMedium.asOutParam()); 1080 if (!floppyMedium) 1081 { 1082 errorArgument("Invalid host floppy drive name \"%s\"", pValueUnion.psz + 5); 1083 rc = E_FAIL; 1084 break; 1085 } 1086 } 1087 else 1088 { 1089 /* first assume it's a UUID */ 1090 rc = a->virtualBox->GetFloppyImage(uuid, floppyMedium.asOutParam()); 1091 if (FAILED(rc) || !floppyMedium) 1092 { 1093 /* must be a filename, check if it's in the collection */ 1094 rc = a->virtualBox->FindFloppyImage(Bstr(pValueUnion.psz), floppyMedium.asOutParam()); 1095 /* not registered, do that on the fly */ 1096 if (!floppyMedium) 1097 { 1098 Bstr emptyUUID; 1099 CHECK_ERROR (a->virtualBox, 1100 OpenFloppyImage(Bstr(pValueUnion.psz), 1101 emptyUUID, 1102 floppyMedium.asOutParam())); 1103 } 1104 } 1105 if (!floppyMedium) 1106 { 1107 rc = E_FAIL; 1108 break; 1109 } 1110 } 1111 floppyMedium->COMGETTER(Id)(uuid.asOutParam()); 1112 CHECK_ERROR (machine, MountMedium(Bstr("Floppy Controller"), 0, 0, uuid)); 1113 } 1114 break; 1115 } 1116 1117 case MODIFYVMNICTRACEFILE: 1118 { 1119 ComPtr<INetworkAdapter> nic; 1120 1121 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1122 return errorSyntax(USAGE_MODIFYVM, 1123 "Missing or Invalid NIC slot number in '%s'", 1124 pGetState.pDef->pszLong); 1125 1126 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1127 ASSERT(nic); 1128 1129 CHECK_ERROR (nic, COMSETTER(TraceFile)(Bstr(pValueUnion.psz))); 1130 break; 1131 } 1132 1133 case MODIFYVMNICTRACE: 1134 { 1135 ComPtr<INetworkAdapter> nic; 1136 1137 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1138 return errorSyntax(USAGE_MODIFYVM, 1139 "Missing or Invalid NIC slot number in '%s'", 1140 pGetState.pDef->pszLong); 1141 1142 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1143 ASSERT(nic); 1144 1145 if (!strcmp(pValueUnion.psz, "on")) 1146 { 1147 CHECK_ERROR (nic, COMSETTER(TraceEnabled)(TRUE)); 1148 } 1149 else if (!strcmp(pValueUnion.psz, "off")) 1150 { 1151 CHECK_ERROR (nic, COMSETTER(TraceEnabled)(FALSE)); 1152 } 1153 else 1154 { 1155 errorArgument("Invalid --nictrace%lu argument '%s'", pGetState.uIndex, pValueUnion.psz); 1156 rc = E_FAIL; 1157 } 1158 break; 1159 } 1160 1161 case MODIFYVMNICTYPE: 1162 { 1163 ComPtr<INetworkAdapter> nic; 1164 1165 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1166 return errorSyntax(USAGE_MODIFYVM, 1167 "Missing or Invalid NIC slot number in '%s'", 1168 pGetState.pDef->pszLong); 1169 1170 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1171 ASSERT(nic); 1172 1173 if (!strcmp(pValueUnion.psz, "Am79C970A")) 1174 { 1175 CHECK_ERROR (nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A)); 1176 } 1177 else if (!strcmp(pValueUnion.psz, "Am79C973")) 1178 { 1179 CHECK_ERROR (nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973)); 1180 } 1181 #ifdef VBOX_WITH_E1000 1182 else if (!strcmp(pValueUnion.psz, "82540EM")) 1183 { 1184 CHECK_ERROR (nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM)); 1185 } 1186 else if (!strcmp(pValueUnion.psz, "82543GC")) 1187 { 1188 CHECK_ERROR (nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC)); 1189 } 1190 else if (!strcmp(pValueUnion.psz, "82545EM")) 1191 { 1192 CHECK_ERROR (nic, COMSETTER(AdapterType)(NetworkAdapterType_I82545EM)); 1193 } 1194 #endif 1195 #ifdef VBOX_WITH_VIRTIO 1196 else if (!strcmp(pValueUnion.psz, "virtio")) 1197 { 1198 CHECK_ERROR (nic, COMSETTER(AdapterType)(NetworkAdapterType_Virtio)); 1199 } 1200 #endif /* VBOX_WITH_VIRTIO */ 1201 else 1202 { 1203 errorArgument("Invalid NIC type '%s' specified for NIC %lu", pValueUnion.psz, pGetState.uIndex); 1204 rc = E_FAIL; 1205 } 1206 break; 1207 } 1208 1209 case MODIFYVMNICSPEED: 1210 { 1211 ComPtr<INetworkAdapter> nic; 1212 1213 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1214 return errorSyntax(USAGE_MODIFYVM, 1215 "Missing or Invalid NIC slot number in '%s'", 1216 pGetState.pDef->pszLong); 1217 1218 if ((pValueUnion.u32 < 1000) && (pValueUnion.u32 > 4000000)) 1219 { 1220 errorArgument("Invalid --nicspeed%lu argument '%u'", pGetState.uIndex, pValueUnion.u32); 1221 rc = E_FAIL; 1222 break; 1223 } 1224 1225 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1226 ASSERT(nic); 1227 1228 CHECK_ERROR (nic, COMSETTER(LineSpeed)(pValueUnion.u32)); 1229 break; 1230 } 1231 1232 case MODIFYVMNIC: 1233 { 1234 ComPtr<INetworkAdapter> nic; 1235 1236 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1237 return errorSyntax(USAGE_MODIFYVM, 1238 "Missing or Invalid NIC slot number in '%s'", 1239 pGetState.pDef->pszLong); 1240 1241 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1242 ASSERT(nic); 1243 1244 if (!strcmp(pValueUnion.psz, "none")) 1245 { 1246 CHECK_ERROR (nic, COMSETTER(Enabled) (FALSE)); 1247 } 1248 else if (!strcmp(pValueUnion.psz, "null")) 1249 { 1250 CHECK_ERROR (nic, COMSETTER(Enabled) (TRUE)); 1251 CHECK_ERROR (nic, Detach()); 1252 } 1253 else if (!strcmp(pValueUnion.psz, "nat")) 1254 { 1255 CHECK_ERROR (nic, COMSETTER(Enabled) (TRUE)); 1256 CHECK_ERROR (nic, AttachToNAT()); 1257 } 1258 else if ( !strcmp(pValueUnion.psz, "bridged") 1259 || !strcmp(pValueUnion.psz, "hostif")) /* backward compatibility */ 1260 { 1261 CHECK_ERROR (nic, COMSETTER(Enabled) (TRUE)); 1262 CHECK_ERROR (nic, AttachToBridgedInterface()); 1263 } 1264 else if (!strcmp(pValueUnion.psz, "intnet")) 1265 { 1266 CHECK_ERROR (nic, COMSETTER(Enabled) (TRUE)); 1267 CHECK_ERROR (nic, AttachToInternalNetwork()); 1268 } 1269 #if defined(VBOX_WITH_NETFLT) 1270 else if (!strcmp(pValueUnion.psz, "hostonly")) 1271 { 1272 1273 CHECK_ERROR (nic, COMSETTER(Enabled) (TRUE)); 1274 CHECK_ERROR (nic, AttachToHostOnlyInterface()); 1275 } 1276 #endif 1277 else 1278 { 1279 errorArgument("Invalid type '%s' specfied for NIC %lu", pValueUnion.psz, pGetState.uIndex); 1280 rc = E_FAIL; 1281 } 1282 break; 1283 } 1284 1285 case MODIFYVMCABLECONNECTED: 1286 { 1287 ComPtr<INetworkAdapter> nic; 1288 1289 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1290 return errorSyntax(USAGE_MODIFYVM, 1291 "Missing or Invalid NIC slot number in '%s'", 1292 pGetState.pDef->pszLong); 1293 1294 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1295 ASSERT(nic); 1296 1297 if (!strcmp(pValueUnion.psz, "on")) 1298 { 1299 CHECK_ERROR (nic, COMSETTER(CableConnected)(TRUE)); 1300 } 1301 else if (!strcmp(pValueUnion.psz, "off")) 1302 { 1303 CHECK_ERROR (nic, COMSETTER(CableConnected)(FALSE)); 1304 } 1305 else 1306 { 1307 errorArgument("Invalid --cableconnected%lu argument '%s'", pGetState.uIndex, pValueUnion.psz); 1308 rc = E_FAIL; 1309 } 1310 break; 1311 } 1312 1313 case MODIFYVMBRIDGEADAPTER: 1314 case MODIFYVMHOSTONLYADAPTER: 1315 { 1316 ComPtr<INetworkAdapter> nic; 1317 1318 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1319 return errorSyntax(USAGE_MODIFYVM, 1320 "Missing or Invalid NIC slot number in '%s'", 1321 pGetState.pDef->pszLong); 1322 1323 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1324 ASSERT(nic); 1325 1326 /* remove it? */ 1327 if (!strcmp(pValueUnion.psz, "none")) 1328 { 1329 CHECK_ERROR (nic, COMSETTER(HostInterface)(NULL)); 1330 } 1331 else 1332 { 1333 CHECK_ERROR (nic, COMSETTER(HostInterface)(Bstr(pValueUnion.psz))); 1334 } 1335 break; 1336 } 1337 1338 case MODIFYVMINTNET: 1339 { 1340 ComPtr<INetworkAdapter> nic; 1341 1342 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1343 return errorSyntax(USAGE_MODIFYVM, 1344 "Missing or Invalid NIC slot number in '%s'", 1345 pGetState.pDef->pszLong); 1346 1347 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1348 ASSERT(nic); 1349 1350 /* remove it? */ 1351 if (!strcmp(pValueUnion.psz, "none")) 1352 { 1353 CHECK_ERROR (nic, COMSETTER(InternalNetwork)(NULL)); 1354 } 1355 else 1356 { 1357 CHECK_ERROR (nic, COMSETTER(InternalNetwork)(Bstr(pValueUnion.psz))); 1358 } 1359 break; 1360 } 1361 1362 case MODIFYVMNATNET: 1363 { 1364 ComPtr<INetworkAdapter> nic; 1365 1366 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1367 return errorSyntax(USAGE_MODIFYVM, 1368 "Missing or Invalid NIC slot number in '%s'", 1369 pGetState.pDef->pszLong); 1370 1371 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1372 ASSERT(nic); 1373 1374 CHECK_ERROR (nic, COMSETTER(NATNetwork)(Bstr(pValueUnion.psz))); 1375 1376 break; 1377 } 1378 1379 case MODIFYVMMACADDRESS: 1380 { 1381 ComPtr<INetworkAdapter> nic; 1382 1383 if ((pGetState.uIndex < 1) && (pGetState.uIndex > NetworkAdapterCount)) 1384 return errorSyntax(USAGE_MODIFYVM, 1385 "Missing or Invalid NIC slot number in '%s'", 1386 pGetState.pDef->pszLong); 1387 1388 CHECK_ERROR_BREAK (machine, GetNetworkAdapter (pGetState.uIndex - 1, nic.asOutParam())); 1389 ASSERT(nic); 1390 1391 /* generate one? */ 1392 if (!strcmp(pValueUnion.psz, "auto")) 1393 { 1394 CHECK_ERROR (nic, COMSETTER(MACAddress)(NULL)); 1395 } 1396 else 1397 { 1398 CHECK_ERROR (nic, COMSETTER(MACAddress)(Bstr(pValueUnion.psz))); 1399 } 1400 break; 1401 } 1402 1403 case MODIFYVMUARTMODE: 1404 { 1405 ComPtr<ISerialPort> uart; 1406 char *pszIRQ = NULL; 1407 1408 if ((pGetState.uIndex < 1) && (pGetState.uIndex > SerialPortCount)) 1409 return errorSyntax(USAGE_MODIFYVM, 1410 "Missing or Invalid Serial Port number in '%s'", 1411 pGetState.pDef->pszLong); 1412 1413 CHECK_ERROR_BREAK (machine, GetSerialPort (pGetState.uIndex - 1, uart.asOutParam())); 1414 ASSERT(uart); 1415 1416 if (!strcmp(pValueUnion.psz, "disconnected")) 1417 { 1418 CHECK_ERROR (uart, COMSETTER(HostMode) (PortMode_Disconnected)); 1419 } 1420 else if ( !strcmp(pValueUnion.psz, "server") 1421 || !strcmp(pValueUnion.psz, "client") 1422 || !strcmp(pValueUnion.psz, "file")) 1423 { 1424 char *pszIRQ = NULL; 1425 1426 /** 1427 * @todo: not the right way to get the second value for 1428 * the argument, change this when RTGetOpt can return 1429 * multiple values 1430 */ 1431 pszIRQ = pGetState.argv[pGetState.iNext]; 1432 pGetState.iNext++; 1433 1434 if (!pszIRQ) 1435 return errorSyntax(USAGE_MODIFYVM, 1436 "Missing or Invalid argument to '%s'", 1437 pGetState.pDef->pszLong); 1438 1439 CHECK_ERROR (uart, COMSETTER(Path) (Bstr(pszIRQ))); 1440 1441 if (!strcmp(pValueUnion.psz, "server")) 1442 { 1443 CHECK_ERROR (uart, COMSETTER(HostMode) (PortMode_HostPipe)); 1444 CHECK_ERROR (uart, COMSETTER(Server) (TRUE)); 1445 } 1446 else if (!strcmp(pValueUnion.psz, "client")) 1447 { 1448 CHECK_ERROR (uart, COMSETTER(HostMode) (PortMode_HostPipe)); 1449 CHECK_ERROR (uart, COMSETTER(Server) (FALSE)); 1450 } 1451 else if (!strcmp(pValueUnion.psz, "file")) 1452 { 1453 CHECK_ERROR (uart, COMSETTER(HostMode) (PortMode_RawFile)); 1454 } 1455 } 1456 else 1457 { 1458 CHECK_ERROR (uart, COMSETTER(Path) (Bstr(pValueUnion.psz))); 1459 CHECK_ERROR (uart, COMSETTER(HostMode) (PortMode_HostDevice)); 1460 } 1461 break; 1462 } 1463 1464 case MODIFYVMUART: 1465 { 1466 ComPtr<ISerialPort> uart; 1467 1468 if ((pGetState.uIndex < 1) && (pGetState.uIndex > SerialPortCount)) 1469 return errorSyntax(USAGE_MODIFYVM, 1470 "Missing or Invalid Serial Port number in '%s'", 1471 pGetState.pDef->pszLong); 1472 1473 CHECK_ERROR_BREAK (machine, GetSerialPort (pGetState.uIndex - 1, uart.asOutParam())); 1474 ASSERT(uart); 1475 1476 if (!strcmp(pValueUnion.psz, "off") || !strcmp(pValueUnion.psz, "disable")) 1477 CHECK_ERROR (uart, COMSETTER(Enabled) (FALSE)); 1478 else 1479 { 1480 char *pszIRQ = NULL; 1481 uint32_t uVal = 0; 1482 int vrc; 1483 1484 /** 1485 * @todo: not the right way to get the second value for 1486 * the argument, change this when RTGetOpt can return 1487 * multiple values 1488 */ 1489 pszIRQ = pGetState.argv[pGetState.iNext]; 1490 pGetState.iNext++; 1491 1492 if (!pszIRQ) 1493 return errorSyntax(USAGE_MODIFYVM, 1494 "Missing or Invalid argument to '%s'", 1495 pGetState.pDef->pszLong); 1496 1497 vrc = RTStrToUInt32Ex(pszIRQ, NULL, 0, &uVal); 1498 if (vrc != VINF_SUCCESS || uVal == 0) 1499 return errorArgument("Error parsing UART I/O base '%s'", pszIRQ); 1500 1501 CHECK_ERROR (uart, COMSETTER(IRQ) (uVal)); 1502 1503 vrc = RTStrToUInt32Ex(pValueUnion.psz, NULL, 0, &uVal); 1504 if (vrc != VINF_SUCCESS || uVal == 0) 1505 return errorArgument("Error parsing UART I/O base '%s'", pszIRQ); 1506 CHECK_ERROR (uart, COMSETTER(IOBase) (uVal)); 1507 1508 CHECK_ERROR (uart, COMSETTER(Enabled) (TRUE)); 1509 } 1510 break; 1511 } 1512 1513 case MODIFYVMGUESTSTATISTICSINTERVAL: 1514 { 1515 if (pValueUnion.u32 > 0) 1516 CHECK_ERROR (machine, COMSETTER(StatisticsUpdateInterval)(pValueUnion.u32)); 1517 break; 1518 } 1519 1520 #ifdef VBOX_WITH_MEM_BALLOONING 1521 case MODIFYVMGUESTMEMORYBALLOON: 1522 { 1523 if (pValueUnion.u32 > 0) 1524 CHECK_ERROR (machine, COMSETTER(MemoryBalloonSize)(pValueUnion.u32)); 1525 break; 1526 } 1527 #endif 1528 1529 case MODIFYVMAUDIOCONTROLLER: 1530 { 1531 if (pValueUnion.psz) 1532 { 1533 ComPtr<IAudioAdapter> audioAdapter; 1534 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); 1535 ASSERT(audioAdapter); 1536 1537 if (!strcmp(pValueUnion.psz, "sb16")) 1538 CHECK_ERROR (audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16)); 1539 else if (!strcmp(pValueUnion.psz, "ac97")) 1540 CHECK_ERROR (audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97)); 1541 else 1542 { 1543 errorArgument("Invalid --audiocontroller argument '%s'", pValueUnion.psz); 1544 rc = E_FAIL; 1545 } 1546 } 1547 break; 1548 } 1549 1550 case MODIFYVMAUDIO: 1551 { 1552 if (pValueUnion.psz) 1553 { 1554 ComPtr<IAudioAdapter> audioAdapter; 1555 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); 1556 ASSERT(audioAdapter); 1557 1558 /* disable? */ 1559 if (!strcmp(pValueUnion.psz, "none")) 1560 { 1561 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(false)); 1562 } 1563 else if (!strcmp(pValueUnion.psz, "null")) 1564 { 1565 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null)); 1566 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1567 } 1568 #ifdef RT_OS_WINDOWS 1569 #ifdef VBOX_WITH_WINMM 1570 else if (!strcmp(pValueUnion.psz, "winmm")) 1571 { 1572 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM)); 1573 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1574 } 1575 #endif 1576 else if (!strcmp(pValueUnion.psz, "dsound")) 1577 { 1578 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound)); 1579 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1580 } 1581 #endif /* RT_OS_WINDOWS */ 1582 #ifdef RT_OS_LINUX 1583 else if (!strcmp(pValueUnion.psz, "oss")) 1584 { 1585 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS)); 1586 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1587 } 1588 # ifdef VBOX_WITH_ALSA 1589 else if (!strcmp(pValueUnion.psz, "alsa")) 1590 { 1591 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA)); 1592 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1593 } 1594 # endif 1595 # ifdef VBOX_WITH_PULSE 1596 else if (!strcmp(pValueUnion.psz, "pulse")) 1597 { 1598 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse)); 1599 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1600 } 1601 # endif 1602 #endif /* !RT_OS_LINUX */ 1603 #ifdef RT_OS_SOLARIS 1604 else if (!strcmp(pValueUnion.psz, "solaudio")) 1605 { 1606 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio)); 1607 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1608 } 1609 1610 # ifdef VBOX_WITH_SOLARIS_OSS 1611 else if (!strcmp(pValueUnion.psz, "oss")) 1612 { 1613 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS)); 1614 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1615 } 1616 # endif 1617 1618 #endif /* !RT_OS_SOLARIS */ 1619 #ifdef RT_OS_DARWIN 1620 else if (!strcmp(pValueUnion.psz, "coreaudio")) 1621 { 1622 CHECK_ERROR (audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio)); 1623 CHECK_ERROR (audioAdapter, COMSETTER(Enabled)(true)); 1624 } 1625 1626 #endif /* !RT_OS_DARWIN */ 1627 else 1628 { 1629 errorArgument("Invalid --audio argument '%s'", pValueUnion.psz); 1630 rc = E_FAIL; 1631 } 1632 } 1633 break; 1634 } 1635 1636 case MODIFYVMCLIPBOARD: 1637 { 1638 if (pValueUnion.psz) 1639 { 1640 if (!strcmp(pValueUnion.psz, "disabled")) 1641 { 1642 CHECK_ERROR (machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled)); 1643 } 1644 else if (!strcmp(pValueUnion.psz, "hosttoguest")) 1645 { 1646 CHECK_ERROR (machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest)); 1647 } 1648 else if (!strcmp(pValueUnion.psz, "guesttohost")) 1649 { 1650 CHECK_ERROR (machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost)); 1651 } 1652 else if (!strcmp(pValueUnion.psz, "bidirectional")) 1653 { 1654 CHECK_ERROR (machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional)); 1655 } 1656 else 1657 { 1658 errorArgument("Invalid --clipboard argument '%s'", pValueUnion.psz); 1659 rc = E_FAIL; 1660 } 1661 } 1662 break; 1663 } 1664 1665 #ifdef VBOX_WITH_VRDP 1666 case MODIFYVMVRDPPORT: 1667 { 1668 if (pValueUnion.psz) 1669 { 1670 ComPtr<IVRDPServer> vrdpServer; 1671 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam()); 1672 ASSERT(vrdpServer); 1673 1674 if (!strcmp(pValueUnion.psz, "default")) 1675 CHECK_ERROR (vrdpServer, COMSETTER(Ports)(Bstr("0"))); 1676 else 1677 CHECK_ERROR (vrdpServer, COMSETTER(Ports)(Bstr(pValueUnion.psz))); 1678 } 1679 break; 1680 } 1681 1682 case MODIFYVMVRDPADDRESS: 1683 { 1684 if (pValueUnion.psz) 1685 { 1686 ComPtr<IVRDPServer> vrdpServer; 1687 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam()); 1688 ASSERT(vrdpServer); 1689 1690 CHECK_ERROR (vrdpServer, COMSETTER(NetAddress)(Bstr(pValueUnion.psz))); 1691 } 1692 break; 1693 } 1694 1695 case MODIFYVMVRDPAUTHTYPE: 1696 { 1697 if (pValueUnion.psz) 1698 { 1699 ComPtr<IVRDPServer> vrdpServer; 1700 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam()); 1701 ASSERT(vrdpServer); 1702 1703 if (!strcmp(pValueUnion.psz, "null")) 1704 { 1705 CHECK_ERROR (vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Null)); 1706 } 1707 else if (!strcmp(pValueUnion.psz, "external")) 1708 { 1709 CHECK_ERROR (vrdpServer, COMSETTER(AuthType)(VRDPAuthType_External)); 1710 } 1711 else if (!strcmp(pValueUnion.psz, "guest")) 1712 { 1713 CHECK_ERROR (vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Guest)); 1714 } 1715 else 1716 { 1717 errorArgument("Invalid --vrdpauthtype argument '%s'", pValueUnion.psz); 1718 rc = E_FAIL; 1719 } 1720 } 1721 break; 1722 } 1723 1724 case MODIFYVMVRDPMULTICON: 1725 { 1726 if (pValueUnion.psz) 1727 { 1728 ComPtr<IVRDPServer> vrdpServer; 1729 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam()); 1730 ASSERT(vrdpServer); 1731 1732 if (!strcmp(pValueUnion.psz, "on")) 1733 { 1734 CHECK_ERROR (vrdpServer, COMSETTER(AllowMultiConnection)(true)); 1735 } 1736 else if (!strcmp(pValueUnion.psz, "off")) 1737 { 1738 CHECK_ERROR (vrdpServer, COMSETTER(AllowMultiConnection)(false)); 1739 } 1740 else 1741 { 1742 errorArgument("Invalid --vrdpmulticon argument '%s'", pValueUnion.psz); 1743 rc = E_FAIL; 1744 } 1745 } 1746 break; 1747 } 1748 1749 case MODIFYVMVRDPREUSECON: 1750 { 1751 if (pValueUnion.psz) 1752 { 1753 ComPtr<IVRDPServer> vrdpServer; 1754 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam()); 1755 ASSERT(vrdpServer); 1756 1757 if (!strcmp(pValueUnion.psz, "on")) 1758 { 1759 CHECK_ERROR (vrdpServer, COMSETTER(ReuseSingleConnection)(true)); 1760 } 1761 else if (!strcmp(pValueUnion.psz, "off")) 1762 { 1763 CHECK_ERROR (vrdpServer, COMSETTER(ReuseSingleConnection)(false)); 1764 } 1765 else 1766 { 1767 errorArgument("Invalid --vrdpreusecon argument '%s'", pValueUnion.psz); 1768 rc = E_FAIL; 1769 } 1770 } 1771 break; 1772 } 1773 1774 case MODIFYVMVRDP: 1775 { 1776 if (pValueUnion.psz) 1777 { 1778 ComPtr<IVRDPServer> vrdpServer; 1779 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam()); 1780 ASSERT(vrdpServer); 1781 1782 if (!strcmp(pValueUnion.psz, "on")) 1783 { 1784 CHECK_ERROR (vrdpServer, COMSETTER(Enabled)(true)); 1785 } 1786 else if (!strcmp(pValueUnion.psz, "off")) 1787 { 1788 CHECK_ERROR (vrdpServer, COMSETTER(Enabled)(false)); 1789 } 1790 else 1791 { 1792 errorArgument("Invalid --vrdp argument '%s'", pValueUnion.psz); 1793 rc = E_FAIL; 1794 } 1795 } 1796 break; 1797 } 1798 #endif /* VBOX_WITH_VRDP */ 1799 1800 case MODIFYVMUSBEHCI: 1801 { 1802 if (pValueUnion.psz) 1803 { 1804 ComPtr<IUSBController> UsbCtl; 1805 CHECK_ERROR (machine, COMGETTER(USBController)(UsbCtl.asOutParam())); 1806 if (SUCCEEDED(rc)) 1807 { 1808 if (!strcmp(pValueUnion.psz, "on") || !strcmp(pValueUnion.psz, "enable")) 1809 CHECK_ERROR (UsbCtl, COMSETTER(EnabledEhci)(true)); 1810 else if (!strcmp(pValueUnion.psz, "off") || !strcmp(pValueUnion.psz, "disable")) 1811 CHECK_ERROR (UsbCtl, COMSETTER(EnabledEhci)(false)); 1812 else 1813 return errorArgument("Invalid --usbehci argument '%s'", pValueUnion.psz); 1814 } 1815 } 1816 break; 1817 } 1818 1819 case MODIFYVMUSB: 1820 { 1821 if (pValueUnion.psz) 1822 { 1823 ComPtr<IUSBController> UsbCtl; 1824 CHECK_ERROR (machine, COMGETTER(USBController)(UsbCtl.asOutParam())); 1825 if (SUCCEEDED(rc)) 1826 { 1827 if (!strcmp(pValueUnion.psz, "on") || !strcmp(pValueUnion.psz, "enable")) 1828 CHECK_ERROR (UsbCtl, COMSETTER(Enabled)(true)); 1829 else if (!strcmp(pValueUnion.psz, "off") || !strcmp(pValueUnion.psz, "disable")) 1830 CHECK_ERROR (UsbCtl, COMSETTER(Enabled)(false)); 1831 else 1832 return errorArgument("Invalid --usb argument '%s'", pValueUnion.psz); 1833 } 1834 } 1835 break; 1836 } 1837 1838 case MODIFYVMSNAPSHOTFOLDER: 1839 { 1840 if (pValueUnion.psz) 1841 { 1842 if (!strcmp(pValueUnion.psz, "default")) 1843 CHECK_ERROR (machine, COMSETTER(SnapshotFolder)(NULL)); 1844 else 1845 CHECK_ERROR (machine, COMSETTER(SnapshotFolder)(Bstr(pValueUnion.psz))); 1846 } 1847 break; 1848 } 1849 1850 case MODIFYVMLIVEMIGRATIONTARGET: 1851 { 1852 if (pValueUnion.psz) 1853 { 1854 if (!strcmp(pValueUnion.psz, "on")) 1855 CHECK_ERROR (machine, COMSETTER(LiveMigrationTarget)(1)); 1856 else if (!strcmp(pValueUnion.psz, "off")) 1857 CHECK_ERROR (machine, COMSETTER(LiveMigrationTarget)(0)); 1858 else 1859 return errorArgument("Invalid --livemigrationtarget value '%s'", pValueUnion.psz); 1860 } 1861 break; 1862 } 1863 1864 case MODIFYVMLIVEMIGRATIONPORT: 1865 { 1866 if (pValueUnion.u32 > 0) 1867 CHECK_ERROR (machine, COMSETTER(LiveMigrationPort)(pValueUnion.u32)); 1868 break; 1869 } 1870 1871 case MODIFYVMLIVEMIGRATIONPASSWORD: 1872 { 1873 if (pValueUnion.psz) 1874 CHECK_ERROR (machine, COMSETTER(LiveMigrationPassword)(Bstr(pValueUnion.psz))); 1875 break; 1876 } 1877 1878 default: 1879 { 1880 errorGetOpt(USAGE_MODIFYVM, c, &pValueUnion); 1881 rc = E_FAIL; 1882 break; 2125 1883 } 2126 1884 } 2127 2128 /*2129 * Live Migration.2130 */2131 if (pszLiveMigrationPassword)2132 CHECK_ERROR_RET(machine, COMSETTER(LiveMigrationPassword)(Bstr(pszLiveMigrationPassword)), 1);2133 if (uLiveMigrationPort != UINT32_MAX)2134 CHECK_ERROR_RET(machine, COMSETTER(LiveMigrationPort)(uLiveMigrationPort), 1);2135 if (fLiveMigrationTarget != -1)2136 CHECK_ERROR_RET(machine, COMSETTER(LiveMigrationTarget)(fLiveMigrationTarget), 1);2137 2138 /* commit changes */2139 CHECK_ERROR(machine, SaveSettings());2140 1885 } 2141 while (0); 1886 1887 /* commit changes */ 1888 if (SUCCEEDED(rc)) 1889 CHECK_ERROR (machine, SaveSettings()); 2142 1890 2143 1891 /* it's important to always close sessions */
Note:
See TracChangeset
for help on using the changeset viewer.