VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp@ 17755

Last change on this file since 17755 was 17755, checked in by vboxsync, 16 years ago

Main, OVF: add output IStorageController to IMachine::addStorageController(); add SCSI support to OVF import/export

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.8 KB
Line 
1/* $Id: VBoxManageModifyVM.cpp 17755 2009-03-12 15:03:46Z vboxsync $ */
2/** @file
3 * VBoxManage - Implementation of -modifyvm command.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#ifndef VBOX_ONLY_DOCS
26#include <VBox/com/com.h>
27#include <VBox/com/array.h>
28#include <VBox/com/ErrorInfo.h>
29#include <VBox/com/errorprint2.h>
30#include <VBox/com/EventQueue.h>
31
32#include <VBox/com/VirtualBox.h>
33
34#include <vector>
35#include <list>
36#endif /* !VBOX_ONLY_DOCS */
37
38#include <iprt/cidr.h>
39#include <iprt/param.h>
40#include <iprt/path.h>
41#include <iprt/stream.h>
42#include <iprt/string.h>
43#include <VBox/log.h>
44
45#include "VBoxManage.h"
46
47#ifndef VBOX_ONLY_DOCS
48using namespace com;
49
50
51/** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */
52#if defined(_MSC_VER)
53# pragma optimize("g", off)
54#endif
55
56int handleModifyVM(HandlerArg *a)
57{
58 HRESULT rc;
59 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 char *ioapic = NULL;
69 uint32_t monitorcount = ~0;
70 char *accelerate3d = NULL;
71 char *bioslogofadein = NULL;
72 char *bioslogofadeout = NULL;
73 uint32_t bioslogodisplaytime = ~0;
74 char *bioslogoimagepath = NULL;
75 char *biosbootmenumode = NULL;
76 char *biossystemtimeoffset = NULL;
77 char *biospxedebug = NULL;
78 DeviceType_T bootDevice[4];
79 int bootDeviceChanged[4] = { false };
80 char *hdds[50] = {0};
81 char *dvd = NULL;
82 char *dvdpassthrough = NULL;
83 char *idecontroller = NULL;
84 char *floppy = NULL;
85 char *audio = NULL;
86 char *audiocontroller = NULL;
87 char *clipboard = NULL;
88#ifdef VBOX_WITH_VRDP
89 char *vrdp = NULL;
90 uint16_t vrdpport = UINT16_MAX;
91 char *vrdpaddress = NULL;
92 char *vrdpauthtype = NULL;
93 char *vrdpmulticon = NULL;
94 char *vrdpreusecon = NULL;
95#endif
96 int fUsbEnabled = -1;
97 int fUsbEhciEnabled = -1;
98 char *snapshotFolder = NULL;
99 ULONG guestMemBalloonSize = (ULONG)-1;
100 ULONG guestStatInterval = (ULONG)-1;
101 int fSataEnabled = -1;
102 int fLsiLogicEnabled = -1;
103 int sataPortCount = -1;
104 int sataBootDevices[4] = {-1,-1,-1,-1};
105
106 /* VM ID + at least one parameter. Parameter arguments are checked
107 * individually. */
108 if (a->argc < 2)
109 return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
110
111 /* Get the number of network adapters */
112 ULONG NetworkAdapterCount = 0;
113 {
114 ComPtr <ISystemProperties> info;
115 CHECK_ERROR_RET (a->virtualBox, COMGETTER(SystemProperties) (info.asOutParam()), 1);
116 CHECK_ERROR_RET (info, COMGETTER(NetworkAdapterCount) (&NetworkAdapterCount), 1);
117 }
118 ULONG SerialPortCount = 0;
119 {
120 ComPtr <ISystemProperties> info;
121 CHECK_ERROR_RET (a->virtualBox, COMGETTER(SystemProperties) (info.asOutParam()), 1);
122 CHECK_ERROR_RET (info, COMGETTER(SerialPortCount) (&SerialPortCount), 1);
123 }
124
125 std::vector <char *> nics (NetworkAdapterCount, 0);
126 std::vector <char *> nictype (NetworkAdapterCount, 0);
127 std::vector <char *> cableconnected (NetworkAdapterCount, 0);
128 std::vector <char *> nictrace (NetworkAdapterCount, 0);
129 std::vector <char *> nictracefile (NetworkAdapterCount, 0);
130 std::vector <char *> nicspeed (NetworkAdapterCount, 0);
131 std::vector <char *> hostifdev (NetworkAdapterCount, 0);
132 std::vector <const char *> intnet (NetworkAdapterCount, 0);
133 std::vector <const char *> natnet (NetworkAdapterCount, 0);
134 std::vector <char *> macs (NetworkAdapterCount, 0);
135 std::vector <char *> uarts_mode (SerialPortCount, 0);
136 std::vector <ULONG> uarts_base (SerialPortCount, 0);
137 std::vector <ULONG> uarts_irq (SerialPortCount, 0);
138 std::vector <char *> uarts_path (SerialPortCount, 0);
139
140 for (int i = 1; i < a->argc; i++)
141 {
142 if (strcmp(a->argv[i], "-name") == 0)
143 {
144 if (a->argc <= i + 1)
145 return errorArgument("Missing argument to '%s'", a->argv[i]);
146 i++;
147 name = a->argv[i];
148 }
149 else if (strcmp(a->argv[i], "-ostype") == 0)
150 {
151 if (a->argc <= i + 1)
152 return errorArgument("Missing argument to '%s'", a->argv[i]);
153 i++;
154 ostype = a->argv[i];
155 }
156 else if (strcmp(a->argv[i], "-memory") == 0)
157 {
158 if (a->argc <= i + 1)
159 return errorArgument("Missing argument to '%s'", a->argv[i]);
160 i++;
161 memorySize = RTStrToUInt32(a->argv[i]);
162 }
163 else if (strcmp(a->argv[i], "-vram") == 0)
164 {
165 if (a->argc <= i + 1)
166 return errorArgument("Missing argument to '%s'", a->argv[i]);
167 i++;
168 vramSize = RTStrToUInt32(a->argv[i]);
169 }
170 else if (strcmp(a->argv[i], "-acpi") == 0)
171 {
172 if (a->argc <= i + 1)
173 return errorArgument("Missing argument to '%s'", a->argv[i]);
174 i++;
175 acpi = a->argv[i];
176 }
177 else if (strcmp(a->argv[i], "-ioapic") == 0)
178 {
179 if (a->argc <= i + 1)
180 return errorArgument("Missing argument to '%s'", a->argv[i]);
181 i++;
182 ioapic = a->argv[i];
183 }
184 else if (strcmp(a->argv[i], "-hwvirtex") == 0)
185 {
186 if (a->argc <= i + 1)
187 return errorArgument("Missing argument to '%s'", a->argv[i]);
188 i++;
189 hwvirtex = a->argv[i];
190 }
191 else if (strcmp(a->argv[i], "-nestedpaging") == 0)
192 {
193 if (a->argc <= i + 1)
194 return errorArgument("Missing argument to '%s'", a->argv[i]);
195 i++;
196 nestedpaging = a->argv[i];
197 }
198 else if (strcmp(a->argv[i], "-vtxvpid") == 0)
199 {
200 if (a->argc <= i + 1)
201 return errorArgument("Missing argument to '%s'", a->argv[i]);
202 i++;
203 vtxvpid = a->argv[i];
204 }
205 else if (strcmp(a->argv[i], "-pae") == 0)
206 {
207 if (a->argc <= i + 1)
208 return errorArgument("Missing argument to '%s'", a->argv[i]);
209 i++;
210 pae = a->argv[i];
211 }
212 else if (strcmp(a->argv[i], "-monitorcount") == 0)
213 {
214 if (a->argc <= i + 1)
215 return errorArgument("Missing argument to '%s'", a->argv[i]);
216 i++;
217 monitorcount = RTStrToUInt32(a->argv[i]);
218 }
219 else if (strcmp(a->argv[i], "-accelerate3d") == 0)
220 {
221 if (a->argc <= i + 1)
222 return errorArgument("Missing argument to '%s'", a->argv[i]);
223 i++;
224 accelerate3d = a->argv[i];
225 }
226 else if (strcmp(a->argv[i], "-bioslogofadein") == 0)
227 {
228 if (a->argc <= i + 1)
229 return errorArgument("Missing argument to '%s'", a->argv[i]);
230 i++;
231 bioslogofadein = a->argv[i];
232 }
233 else if (strcmp(a->argv[i], "-bioslogofadeout") == 0)
234 {
235 if (a->argc <= i + 1)
236 return errorArgument("Missing argument to '%s'", a->argv[i]);
237 i++;
238 bioslogofadeout = a->argv[i];
239 }
240 else if (strcmp(a->argv[i], "-bioslogodisplaytime") == 0)
241 {
242 if (a->argc <= i + 1)
243 return errorArgument("Missing argument to '%s'", a->argv[i]);
244 i++;
245 bioslogodisplaytime = RTStrToUInt32(a->argv[i]);
246 }
247 else if (strcmp(a->argv[i], "-bioslogoimagepath") == 0)
248 {
249 if (a->argc <= i + 1)
250 return errorArgument("Missing argument to '%s'", a->argv[i]);
251 i++;
252 bioslogoimagepath = a->argv[i];
253 }
254 else if (strcmp(a->argv[i], "-biosbootmenu") == 0)
255 {
256 if (a->argc <= i + 1)
257 return errorArgument("Missing argument to '%s'", a->argv[i]);
258 i++;
259 biosbootmenumode = a->argv[i];
260 }
261 else if (strcmp(a->argv[i], "-biossystemtimeoffset") == 0)
262 {
263 if (a->argc <= i + 1)
264 return errorArgument("Missing argument to '%s'", a->argv[i]);
265 i++;
266 biossystemtimeoffset = a->argv[i];
267 }
268 else if (strcmp(a->argv[i], "-biospxedebug") == 0)
269 {
270 if (a->argc <= i + 1)
271 return errorArgument("Missing argument to '%s'", a->argv[i]);
272 i++;
273 biospxedebug = a->argv[i];
274 }
275 else if (strncmp(a->argv[i], "-boot", 5) == 0)
276 {
277 uint32_t n = 0;
278 if (!a->argv[i][5])
279 return errorSyntax(USAGE_MODIFYVM, "Missing boot slot number in '%s'", a->argv[i]);
280 if (VINF_SUCCESS != RTStrToUInt32Full(&a->argv[i][5], 10, &n))
281 return errorSyntax(USAGE_MODIFYVM, "Invalid boot slot number in '%s'", a->argv[i]);
282 if (a->argc <= i + 1)
283 return errorArgument("Missing argument to '%s'", a->argv[i]);
284 i++;
285 if (strcmp(a->argv[i], "none") == 0)
286 {
287 bootDevice[n - 1] = DeviceType_Null;
288 }
289 else if (strcmp(a->argv[i], "floppy") == 0)
290 {
291 bootDevice[n - 1] = DeviceType_Floppy;
292 }
293 else if (strcmp(a->argv[i], "dvd") == 0)
294 {
295 bootDevice[n - 1] = DeviceType_DVD;
296 }
297 else if (strcmp(a->argv[i], "disk") == 0)
298 {
299 bootDevice[n - 1] = DeviceType_HardDisk;
300 }
301 else if (strcmp(a->argv[i], "net") == 0)
302 {
303 bootDevice[n - 1] = DeviceType_Network;
304 }
305 else
306 return errorArgument("Invalid boot device '%s'", a->argv[i]);
307
308 bootDeviceChanged[n - 1] = true;
309 }
310 else if (strcmp(a->argv[i], "-hda") == 0)
311 {
312 if (a->argc <= i + 1)
313 return errorArgument("Missing argument to '%s'", a->argv[i]);
314 i++;
315 hdds[0] = a->argv[i];
316 }
317 else if (strcmp(a->argv[i], "-hdb") == 0)
318 {
319 if (a->argc <= i + 1)
320 return errorArgument("Missing argument to '%s'", a->argv[i]);
321 i++;
322 hdds[1] = a->argv[i];
323 }
324 else if (strcmp(a->argv[i], "-hdd") == 0)
325 {
326 if (a->argc <= i + 1)
327 return errorArgument("Missing argument to '%s'", a->argv[i]);
328 i++;
329 hdds[2] = a->argv[i];
330 }
331 else if (strcmp(a->argv[i], "-dvd") == 0)
332 {
333 if (a->argc <= i + 1)
334 return errorArgument("Missing argument to '%s'", a->argv[i]);
335 i++;
336 dvd = a->argv[i];
337 }
338 else if (strcmp(a->argv[i], "-dvdpassthrough") == 0)
339 {
340 if (a->argc <= i + 1)
341 return errorArgument("Missing argument to '%s'", a->argv[i]);
342 i++;
343 dvdpassthrough = a->argv[i];
344 }
345 else if (strcmp(a->argv[i], "-idecontroller") == 0)
346 {
347 if (a->argc <= i + 1)
348 return errorArgument("Missing argument to '%s'", a->argv[i]);
349 i++;
350 idecontroller = a->argv[i];
351 }
352 else if (strcmp(a->argv[i], "-floppy") == 0)
353 {
354 if (a->argc <= i + 1)
355 return errorArgument("Missing argument to '%s'", a->argv[i]);
356 i++;
357 floppy = a->argv[i];
358 }
359 else if (strcmp(a->argv[i], "-audio") == 0)
360 {
361 if (a->argc <= i + 1)
362 return errorArgument("Missing argument to '%s'", a->argv[i]);
363 i++;
364 audio = a->argv[i];
365 }
366 else if (strcmp(a->argv[i], "-audiocontroller") == 0)
367 {
368 if (a->argc <= i + 1)
369 return errorArgument("Missing argument to '%s'", a->argv[i]);
370 i++;
371 audiocontroller = a->argv[i];
372 }
373 else if (strcmp(a->argv[i], "-clipboard") == 0)
374 {
375 if (a->argc <= i + 1)
376 return errorArgument("Missing argument to '%s'", a->argv[i]);
377 i++;
378 clipboard = a->argv[i];
379 }
380 else if (strncmp(a->argv[i], "-cableconnected", 15) == 0)
381 {
382 unsigned n = parseNum(&a->argv[i][15], NetworkAdapterCount, "NIC");
383 if (!n)
384 return 1;
385
386 if (a->argc <= i + 1)
387 return errorArgument("Missing argument to '%s'", a->argv[i]);
388
389 cableconnected[n - 1] = a->argv[i + 1];
390 i++;
391 }
392 /* watch for the right order of these -nic* comparisons! */
393 else if (strncmp(a->argv[i], "-nictracefile", 13) == 0)
394 {
395 unsigned n = parseNum(&a->argv[i][13], NetworkAdapterCount, "NIC");
396 if (!n)
397 return 1;
398 if (a->argc <= i + 1)
399 {
400 return errorArgument("Missing argument to '%s'", a->argv[i]);
401 }
402 nictracefile[n - 1] = a->argv[i + 1];
403 i++;
404 }
405 else if (strncmp(a->argv[i], "-nictrace", 9) == 0)
406 {
407 unsigned n = parseNum(&a->argv[i][9], NetworkAdapterCount, "NIC");
408 if (!n)
409 return 1;
410 if (a->argc <= i + 1)
411 return errorArgument("Missing argument to '%s'", a->argv[i]);
412 nictrace[n - 1] = a->argv[i + 1];
413 i++;
414 }
415 else if (strncmp(a->argv[i], "-nictype", 8) == 0)
416 {
417 unsigned n = parseNum(&a->argv[i][8], NetworkAdapterCount, "NIC");
418 if (!n)
419 return 1;
420 if (a->argc <= i + 1)
421 return errorArgument("Missing argument to '%s'", a->argv[i]);
422 nictype[n - 1] = a->argv[i + 1];
423 i++;
424 }
425 else if (strncmp(a->argv[i], "-nicspeed", 9) == 0)
426 {
427 unsigned n = parseNum(&a->argv[i][9], NetworkAdapterCount, "NIC");
428 if (!n)
429 return 1;
430 if (a->argc <= i + 1)
431 return errorArgument("Missing argument to '%s'", a->argv[i]);
432 nicspeed[n - 1] = a->argv[i + 1];
433 i++;
434 }
435 else if (strncmp(a->argv[i], "-nic", 4) == 0)
436 {
437 unsigned n = parseNum(&a->argv[i][4], NetworkAdapterCount, "NIC");
438 if (!n)
439 return 1;
440 if (a->argc <= i + 1)
441 return errorArgument("Missing argument to '%s'", a->argv[i]);
442 nics[n - 1] = a->argv[i + 1];
443 i++;
444 }
445 else if ( strncmp(a->argv[i], "-bridgeadapter", 11) == 0
446 || strncmp(a->argv[i], "-hostonlyadapter", 12) == 0
447 || strncmp(a->argv[i], "-hostifdev", 10) == 0) /* backward compatibility */
448 {
449 unsigned n = parseNum(&a->argv[i][10], NetworkAdapterCount, "NIC");
450 if (!n)
451 return 1;
452 if (a->argc <= i + 1)
453 return errorArgument("Missing argument to '%s'", a->argv[i]);
454 hostifdev[n - 1] = a->argv[i + 1];
455 i++;
456 }
457 else if (strncmp(a->argv[i], "-intnet", 7) == 0)
458 {
459 unsigned n = parseNum(&a->argv[i][7], NetworkAdapterCount, "NIC");
460 if (!n)
461 return 1;
462 if (a->argc <= i + 1)
463 return errorArgument("Missing argument to '%s'", a->argv[i]);
464 intnet[n - 1] = a->argv[i + 1];
465 i++;
466 }
467 else if (strncmp(a->argv[i], "-natnet", 7) == 0)
468 {
469 unsigned n = parseNum(&a->argv[i][7], NetworkAdapterCount, "NIC");
470 if (!n)
471 return 1;
472 if (a->argc <= i + 1)
473 return errorArgument("Missing argument to '%s'", a->argv[i]);
474
475 if (!strcmp(a->argv[i + 1], "default"))
476 natnet[n - 1] = "";
477 else
478 {
479 RTIPV4ADDR Network;
480 RTIPV4ADDR Netmask;
481 int rc = RTCidrStrToIPv4(a->argv[i + 1], &Network, &Netmask);
482 if (RT_FAILURE(rc))
483 return errorArgument("Invalid IPv4 network '%s' specified -- CIDR notation expected.\n", a->argv[i + 1]);
484 if (Netmask & 0x1f)
485 return errorArgument("Prefix length of the NAT network must be less than 28.\n");
486 natnet[n - 1] = a->argv[i + 1];
487 }
488 i++;
489 }
490 else if (strncmp(a->argv[i], "-macaddress", 11) == 0)
491 {
492 unsigned n = parseNum(&a->argv[i][11], NetworkAdapterCount, "NIC");
493 if (!n)
494 return 1;
495 if (a->argc <= i + 1)
496 return errorArgument("Missing argument to '%s'", a->argv[i]);
497 macs[n - 1] = a->argv[i + 1];
498 i++;
499 }
500#ifdef VBOX_WITH_VRDP
501 else if (strcmp(a->argv[i], "-vrdp") == 0)
502 {
503 if (a->argc <= i + 1)
504 return errorArgument("Missing argument to '%s'", a->argv[i]);
505 i++;
506 vrdp = a->argv[i];
507 }
508 else if (strcmp(a->argv[i], "-vrdpport") == 0)
509 {
510 if (a->argc <= i + 1)
511 return errorArgument("Missing argument to '%s'", a->argv[i]);
512 i++;
513 if (strcmp(a->argv[i], "default") == 0)
514 vrdpport = 0;
515 else
516 vrdpport = RTStrToUInt16(a->argv[i]);
517 }
518 else if (strcmp(a->argv[i], "-vrdpaddress") == 0)
519 {
520 if (a->argc <= i + 1)
521 return errorArgument("Missing argument to '%s'", a->argv[i]);
522 i++;
523 vrdpaddress = a->argv[i];
524 }
525 else if (strcmp(a->argv[i], "-vrdpauthtype") == 0)
526 {
527 if (a->argc <= i + 1)
528 return errorArgument("Missing argument to '%s'", a->argv[i]);
529 i++;
530 vrdpauthtype = a->argv[i];
531 }
532 else if (strcmp(a->argv[i], "-vrdpmulticon") == 0)
533 {
534 if (a->argc <= i + 1)
535 return errorArgument("Missing argument to '%s'", a->argv[i]);
536 i++;
537 vrdpmulticon = a->argv[i];
538 }
539 else if (strcmp(a->argv[i], "-vrdpreusecon") == 0)
540 {
541 if (a->argc <= i + 1)
542 return errorArgument("Missing argument to '%s'", a->argv[i]);
543 i++;
544 vrdpreusecon = a->argv[i];
545 }
546#endif /* VBOX_WITH_VRDP */
547 else if (strcmp(a->argv[i], "-usb") == 0)
548 {
549 if (a->argc <= i + 1)
550 return errorArgument("Missing argument to '%s'", a->argv[i]);
551 i++;
552 if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
553 fUsbEnabled = 1;
554 else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
555 fUsbEnabled = 0;
556 else
557 return errorArgument("Invalid -usb argument '%s'", a->argv[i]);
558 }
559 else if (strcmp(a->argv[i], "-usbehci") == 0)
560 {
561 if (a->argc <= i + 1)
562 return errorArgument("Missing argument to '%s'", a->argv[i]);
563 i++;
564 if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
565 fUsbEhciEnabled = 1;
566 else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
567 fUsbEhciEnabled = 0;
568 else
569 return errorArgument("Invalid -usbehci argument '%s'", a->argv[i]);
570 }
571 else if (strcmp(a->argv[i], "-snapshotfolder") == 0)
572 {
573 if (a->argc <= i + 1)
574 return errorArgument("Missing argument to '%s'", a->argv[i]);
575 i++;
576 snapshotFolder = a->argv[i];
577 }
578 else if (strncmp(a->argv[i], "-uartmode", 9) == 0)
579 {
580 unsigned n = parseNum(&a->argv[i][9], SerialPortCount, "UART");
581 if (!n)
582 return 1;
583 i++;
584 if (strcmp(a->argv[i], "disconnected") == 0)
585 {
586 uarts_mode[n - 1] = a->argv[i];
587 }
588 else
589 {
590 if (strcmp(a->argv[i], "server") == 0 || strcmp(a->argv[i], "client") == 0)
591 {
592 uarts_mode[n - 1] = a->argv[i];
593 i++;
594#ifdef RT_OS_WINDOWS
595 if (strncmp(a->argv[i], "\\\\.\\pipe\\", 9))
596 return errorArgument("Uart pipe must start with \\\\.\\pipe\\");
597#endif
598 }
599 else
600 {
601 uarts_mode[n - 1] = (char*)"device";
602 }
603 if (a->argc <= i)
604 return errorArgument("Missing argument to -uartmode");
605 uarts_path[n - 1] = a->argv[i];
606 }
607 }
608 else if (strncmp(a->argv[i], "-uart", 5) == 0)
609 {
610 unsigned n = parseNum(&a->argv[i][5], SerialPortCount, "UART");
611 if (!n)
612 return 1;
613 if (a->argc <= i + 1)
614 return errorArgument("Missing argument to '%s'", a->argv[i]);
615 i++;
616 if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
617 {
618 uarts_base[n - 1] = (ULONG)-1;
619 }
620 else
621 {
622 if (a->argc <= i + 1)
623 return errorArgument("Missing argument to '%s'", a->argv[i-1]);
624 uint32_t uVal;
625 int vrc;
626 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
627 if (vrc != VINF_SUCCESS || uVal == 0)
628 return errorArgument("Error parsing UART I/O base '%s'", a->argv[i]);
629 uarts_base[n - 1] = uVal;
630 i++;
631 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
632 if (vrc != VINF_SUCCESS)
633 return errorArgument("Error parsing UART IRQ '%s'", a->argv[i]);
634 uarts_irq[n - 1] = uVal;
635 }
636 }
637#ifdef VBOX_WITH_MEM_BALLOONING
638 else if (strncmp(a->argv[i], "-guestmemoryballoon", 19) == 0)
639 {
640 if (a->argc <= i + 1)
641 return errorArgument("Missing argument to '%s'", a->argv[i]);
642 i++;
643 uint32_t uVal;
644 int vrc;
645 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
646 if (vrc != VINF_SUCCESS)
647 return errorArgument("Error parsing guest memory balloon size '%s'", a->argv[i]);
648 guestMemBalloonSize = uVal;
649 }
650#endif
651 else if (strncmp(a->argv[i], "-gueststatisticsinterval", 24) == 0)
652 {
653 if (a->argc <= i + 1)
654 return errorArgument("Missing argument to '%s'", a->argv[i]);
655 i++;
656 uint32_t uVal;
657 int vrc;
658 vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
659 if (vrc != VINF_SUCCESS)
660 return errorArgument("Error parsing guest statistics interval '%s'", a->argv[i]);
661 guestStatInterval = uVal;
662 }
663 else if (strcmp(a->argv[i], "-sata") == 0)
664 {
665 if (a->argc <= i + 1)
666 return errorArgument("Missing argument to '%s'", a->argv[i]);
667 i++;
668 if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
669 fSataEnabled = 1;
670 else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
671 fSataEnabled = 0;
672 else
673 return errorArgument("Invalid -usb argument '%s'", a->argv[i]);
674 }
675 else if (strcmp(a->argv[i], "-sataportcount") == 0)
676 {
677 unsigned n;
678
679 if (a->argc <= i + 1)
680 return errorArgument("Missing arguments to '%s'", a->argv[i]);
681 i++;
682
683 n = parseNum(a->argv[i], 30, "SATA");
684 if (!n)
685 return 1;
686 sataPortCount = n;
687 }
688 else if (strncmp(a->argv[i], "-sataport", 9) == 0)
689 {
690 unsigned n = parseNum(&a->argv[i][9], 30, "SATA");
691 if (!n)
692 return 1;
693 if (a->argc <= i + 1)
694 return errorArgument("Missing argument to '%s'", a->argv[i]);
695 i++;
696 hdds[n-1+4] = a->argv[i];
697 }
698 else if (strncmp(a->argv[i], "-sataideemulation", 17) == 0)
699 {
700 unsigned bootDevicePos = 0;
701 unsigned n;
702
703 bootDevicePos = parseNum(&a->argv[i][17], 4, "SATA");
704 if (!bootDevicePos)
705 return 1;
706 bootDevicePos--;
707
708 if (a->argc <= i + 1)
709 return errorArgument("Missing arguments to '%s'", a->argv[i]);
710 i++;
711
712 n = parseNum(a->argv[i], 30, "SATA");
713 if (!n)
714 return 1;
715
716 sataBootDevices[bootDevicePos] = n-1;
717 }
718 else if (strcmp(a->argv[i], "-lsilogic") == 0)
719 {
720 if (a->argc <= i + 1)
721 return errorArgument("Missing argument to '%s'", a->argv[i]);
722 i++;
723 if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
724 fLsiLogicEnabled = 1;
725 else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
726 fLsiLogicEnabled = 0;
727 else
728 return errorArgument("Invalid -lsilogic argument '%s'", a->argv[i]);
729 }
730 else if (strncmp(a->argv[i], "-lsilogicport", 13) == 0)
731 {
732 unsigned n = parseNum(&a->argv[i][13], 16, "LsiLogic");
733 if (!n)
734 return 1;
735 if (a->argc <= i + 1)
736 return errorArgument("Missing argument to '%s'", a->argv[i]);
737 i++;
738 hdds[n-1+34] = a->argv[i];
739 }
740 else
741 return errorSyntax(USAGE_MODIFYVM, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());
742 }
743
744 /* try to find the given machine */
745 ComPtr <IMachine> machine;
746 Guid uuid (a->argv[0]);
747 if (!uuid.isEmpty())
748 {
749 CHECK_ERROR (a->virtualBox, GetMachine (uuid, machine.asOutParam()));
750 }
751 else
752 {
753 CHECK_ERROR (a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
754 if (SUCCEEDED (rc))
755 machine->COMGETTER(Id)(uuid.asOutParam());
756 }
757 if (FAILED (rc))
758 return 1;
759
760 /* open a session for the VM */
761 CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1);
762
763 do
764 {
765 /* get the mutable session machine */
766 a->session->COMGETTER(Machine)(machine.asOutParam());
767
768 ComPtr <IBIOSSettings> biosSettings;
769 machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
770
771 if (name)
772 CHECK_ERROR(machine, COMSETTER(Name)(name));
773 if (ostype)
774 {
775 ComPtr<IGuestOSType> guestOSType;
776 CHECK_ERROR(a->virtualBox, GetGuestOSType(ostype, guestOSType.asOutParam()));
777 if (SUCCEEDED(rc) && guestOSType)
778 {
779 CHECK_ERROR(machine, COMSETTER(OSTypeId)(ostype));
780 }
781 else
782 {
783 errorArgument("Invalid guest OS type '%s'", Utf8Str(ostype).raw());
784 rc = E_FAIL;
785 break;
786 }
787 }
788 if (memorySize > 0)
789 CHECK_ERROR(machine, COMSETTER(MemorySize)(memorySize));
790 if (vramSize > 0)
791 CHECK_ERROR(machine, COMSETTER(VRAMSize)(vramSize));
792 if (acpi)
793 {
794 if (strcmp(acpi, "on") == 0)
795 {
796 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(true));
797 }
798 else if (strcmp(acpi, "off") == 0)
799 {
800 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(false));
801 }
802 else
803 {
804 errorArgument("Invalid -acpi argument '%s'", acpi);
805 rc = E_FAIL;
806 break;
807 }
808 }
809 if (ioapic)
810 {
811 if (strcmp(ioapic, "on") == 0)
812 {
813 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(true));
814 }
815 else if (strcmp(ioapic, "off") == 0)
816 {
817 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(false));
818 }
819 else
820 {
821 errorArgument("Invalid -ioapic argument '%s'", ioapic);
822 rc = E_FAIL;
823 break;
824 }
825 }
826 if (hwvirtex)
827 {
828 if (strcmp(hwvirtex, "on") == 0)
829 {
830 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_True));
831 }
832 else if (strcmp(hwvirtex, "off") == 0)
833 {
834 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_False));
835 }
836 else if (strcmp(hwvirtex, "default") == 0)
837 {
838 CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_Default));
839 }
840 else
841 {
842 errorArgument("Invalid -hwvirtex argument '%s'", hwvirtex);
843 rc = E_FAIL;
844 break;
845 }
846 }
847 if (nestedpaging)
848 {
849 if (strcmp(nestedpaging, "on") == 0)
850 {
851 CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(true));
852 }
853 else if (strcmp(nestedpaging, "off") == 0)
854 {
855 CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(false));
856 }
857 else
858 {
859 errorArgument("Invalid -nestedpaging argument '%s'", ioapic);
860 rc = E_FAIL;
861 break;
862 }
863 }
864 if (vtxvpid)
865 {
866 if (strcmp(vtxvpid, "on") == 0)
867 {
868 CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(true));
869 }
870 else if (strcmp(vtxvpid, "off") == 0)
871 {
872 CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(false));
873 }
874 else
875 {
876 errorArgument("Invalid -vtxvpid argument '%s'", ioapic);
877 rc = E_FAIL;
878 break;
879 }
880 }
881 if (pae)
882 {
883 if (strcmp(pae, "on") == 0)
884 {
885 CHECK_ERROR(machine, COMSETTER(PAEEnabled)(true));
886 }
887 else if (strcmp(pae, "off") == 0)
888 {
889 CHECK_ERROR(machine, COMSETTER(PAEEnabled)(false));
890 }
891 else
892 {
893 errorArgument("Invalid -pae argument '%s'", ioapic);
894 rc = E_FAIL;
895 break;
896 }
897 }
898 if (monitorcount != ~0U)
899 {
900 CHECK_ERROR(machine, COMSETTER(MonitorCount)(monitorcount));
901 }
902 if (accelerate3d)
903 {
904 if (strcmp(accelerate3d, "on") == 0)
905 {
906 CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(true));
907 }
908 else if (strcmp(accelerate3d, "off") == 0)
909 {
910 CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(false));
911 }
912 else
913 {
914 errorArgument("Invalid -accelerate3d argument '%s'", ioapic);
915 rc = E_FAIL;
916 break;
917 }
918 }
919 if (bioslogofadein)
920 {
921 if (strcmp(bioslogofadein, "on") == 0)
922 {
923 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(true));
924 }
925 else if (strcmp(bioslogofadein, "off") == 0)
926 {
927 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(false));
928 }
929 else
930 {
931 errorArgument("Invalid -bioslogofadein argument '%s'", bioslogofadein);
932 rc = E_FAIL;
933 break;
934 }
935 }
936 if (bioslogofadeout)
937 {
938 if (strcmp(bioslogofadeout, "on") == 0)
939 {
940 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(true));
941 }
942 else if (strcmp(bioslogofadeout, "off") == 0)
943 {
944 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(false));
945 }
946 else
947 {
948 errorArgument("Invalid -bioslogofadeout argument '%s'", bioslogofadeout);
949 rc = E_FAIL;
950 break;
951 }
952 }
953 if (bioslogodisplaytime != ~0U)
954 {
955 CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(bioslogodisplaytime));
956 }
957 if (bioslogoimagepath)
958 {
959 CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(bioslogoimagepath)));
960 }
961 if (biosbootmenumode)
962 {
963 if (strcmp(biosbootmenumode, "disabled") == 0)
964 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled));
965 else if (strcmp(biosbootmenumode, "menuonly") == 0)
966 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly));
967 else if (strcmp(biosbootmenumode, "messageandmenu") == 0)
968 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu));
969 else
970 {
971 errorArgument("Invalid -biosbootmenu argument '%s'", biosbootmenumode);
972 rc = E_FAIL;
973 break;
974 }
975
976 }
977 if (biossystemtimeoffset)
978 {
979 LONG64 timeOffset = RTStrToInt64(biossystemtimeoffset);
980 CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(timeOffset));
981 }
982 if (biospxedebug)
983 {
984 if (strcmp(biospxedebug, "on") == 0)
985 {
986 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(true));
987 }
988 else if (strcmp(biospxedebug, "off") == 0)
989 {
990 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(false));
991 }
992 else
993 {
994 errorArgument("Invalid -biospxedebug argument '%s'", biospxedebug);
995 rc = E_FAIL;
996 break;
997 }
998 }
999 for (int curBootDev = 0; curBootDev < 4; curBootDev++)
1000 {
1001 if (bootDeviceChanged[curBootDev])
1002 CHECK_ERROR(machine, SetBootOrder (curBootDev + 1, bootDevice[curBootDev]));
1003 }
1004 if (hdds[0])
1005 {
1006 if (strcmp(hdds[0], "none") == 0)
1007 {
1008 machine->DetachHardDisk(Bstr("IDE"), 0, 0);
1009 }
1010 else
1011 {
1012 /* first guess is that it's a UUID */
1013 Guid uuid(hdds[0]);
1014 ComPtr<IHardDisk> hardDisk;
1015 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
1016 /* not successful? Then it must be a filename */
1017 if (!hardDisk)
1018 {
1019 CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[0]), hardDisk.asOutParam()));
1020 if (FAILED(rc))
1021 {
1022 /* open the new hard disk object */
1023 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), hardDisk.asOutParam()));
1024 }
1025 }
1026 if (hardDisk)
1027 {
1028 hardDisk->COMGETTER(Id)(uuid.asOutParam());
1029 CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("IDE"), 0, 0));
1030 }
1031 else
1032 rc = E_FAIL;
1033 if (FAILED(rc))
1034 break;
1035 }
1036 }
1037 if (hdds[1])
1038 {
1039 if (strcmp(hdds[1], "none") == 0)
1040 {
1041 machine->DetachHardDisk(Bstr("IDE"), 0, 1);
1042 }
1043 else
1044 {
1045 /* first guess is that it's a UUID */
1046 Guid uuid(hdds[1]);
1047 ComPtr<IHardDisk> hardDisk;
1048 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
1049 /* not successful? Then it must be a filename */
1050 if (!hardDisk)
1051 {
1052 CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[1]), hardDisk.asOutParam()));
1053 if (FAILED(rc))
1054 {
1055 /* open the new hard disk object */
1056 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), hardDisk.asOutParam()));
1057 }
1058 }
1059 if (hardDisk)
1060 {
1061 hardDisk->COMGETTER(Id)(uuid.asOutParam());
1062 CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("IDE"), 0, 1));
1063 }
1064 else
1065 rc = E_FAIL;
1066 if (FAILED(rc))
1067 break;
1068 }
1069 }
1070 if (hdds[2])
1071 {
1072 if (strcmp(hdds[2], "none") == 0)
1073 {
1074 machine->DetachHardDisk(Bstr("IDE"), 1, 1);
1075 }
1076 else
1077 {
1078 /* first guess is that it's a UUID */
1079 Guid uuid(hdds[2]);
1080 ComPtr<IHardDisk> hardDisk;
1081 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
1082 /* not successful? Then it must be a filename */
1083 if (!hardDisk)
1084 {
1085 CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[2]), hardDisk.asOutParam()));
1086 if (FAILED(rc))
1087 {
1088 /* open the new hard disk object */
1089 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), hardDisk.asOutParam()));
1090 }
1091 }
1092 if (hardDisk)
1093 {
1094 hardDisk->COMGETTER(Id)(uuid.asOutParam());
1095 CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("IDE"), 1, 1));
1096 }
1097 else
1098 rc = E_FAIL;
1099 if (FAILED(rc))
1100 break;
1101 }
1102 }
1103 if (dvd)
1104 {
1105 ComPtr<IDVDDrive> dvdDrive;
1106 machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
1107 ASSERT(dvdDrive);
1108
1109 /* unmount? */
1110 if (strcmp(dvd, "none") == 0)
1111 {
1112 CHECK_ERROR(dvdDrive, Unmount());
1113 }
1114 /* host drive? */
1115 else if (strncmp(dvd, "host:", 5) == 0)
1116 {
1117 ComPtr<IHost> host;
1118 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
1119 com::SafeIfaceArray <IHostDVDDrive> hostDVDs;
1120 rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs));
1121
1122 ComPtr<IHostDVDDrive> hostDVDDrive;
1123 rc = host->FindHostDVDDrive(Bstr(dvd + 5), hostDVDDrive.asOutParam());
1124 if (!hostDVDDrive)
1125 {
1126 /* 2nd try: try with the real name, important on Linux+libhal */
1127 char szPathReal[RTPATH_MAX];
1128 if (RT_FAILURE(RTPathReal(dvd + 5, szPathReal, sizeof(szPathReal))))
1129 {
1130 errorArgument("Invalid host DVD drive name");
1131 rc = E_FAIL;
1132 break;
1133 }
1134 rc = host->FindHostDVDDrive(Bstr(szPathReal), hostDVDDrive.asOutParam());
1135 if (!hostDVDDrive)
1136 {
1137 errorArgument("Invalid host DVD drive name");
1138 rc = E_FAIL;
1139 break;
1140 }
1141 }
1142 CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));
1143 }
1144 else
1145 {
1146 /* first assume it's a UUID */
1147 Guid uuid(dvd);
1148 ComPtr<IDVDImage> dvdImage;
1149 rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam());
1150 if (FAILED(rc) || !dvdImage)
1151 {
1152 /* must be a filename, check if it's in the collection */
1153 rc = a->virtualBox->FindDVDImage(Bstr(dvd), dvdImage.asOutParam());
1154 /* not registered, do that on the fly */
1155 if (!dvdImage)
1156 {
1157 Guid emptyUUID;
1158 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(dvd), emptyUUID, dvdImage.asOutParam()));
1159 }
1160 }
1161 if (!dvdImage)
1162 {
1163 rc = E_FAIL;
1164 break;
1165 }
1166
1167 dvdImage->COMGETTER(Id)(uuid.asOutParam());
1168 CHECK_ERROR(dvdDrive, MountImage(uuid));
1169 }
1170 }
1171 if (dvdpassthrough)
1172 {
1173 ComPtr<IDVDDrive> dvdDrive;
1174 machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
1175 ASSERT(dvdDrive);
1176
1177 CHECK_ERROR(dvdDrive, COMSETTER(Passthrough)(strcmp(dvdpassthrough, "on") == 0));
1178 }
1179 if (idecontroller)
1180 {
1181 ComPtr<IStorageController> storageController;
1182 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("IDE"), storageController.asOutParam()));
1183
1184 if (RTStrICmp(idecontroller, "PIIX3") == 0)
1185 {
1186 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3));
1187 }
1188 else if (RTStrICmp(idecontroller, "PIIX4") == 0)
1189 {
1190 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4));
1191 }
1192 else if (RTStrICmp(idecontroller, "ICH6") == 0)
1193 {
1194 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6));
1195 }
1196 else
1197 {
1198 errorArgument("Invalid -idecontroller argument '%s'", idecontroller);
1199 rc = E_FAIL;
1200 break;
1201 }
1202 }
1203 if (floppy)
1204 {
1205 ComPtr<IFloppyDrive> floppyDrive;
1206 machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
1207 ASSERT(floppyDrive);
1208
1209 /* disable? */
1210 if (strcmp(floppy, "disabled") == 0)
1211 {
1212 /* disable the controller */
1213 CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(false));
1214 }
1215 else
1216 {
1217 /* enable the controller */
1218 CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(true));
1219
1220 /* unmount? */
1221 if (strcmp(floppy, "empty") == 0)
1222 {
1223 CHECK_ERROR(floppyDrive, Unmount());
1224 }
1225 /* host drive? */
1226 else if (strncmp(floppy, "host:", 5) == 0)
1227 {
1228 ComPtr<IHost> host;
1229 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
1230 com::SafeIfaceArray <IHostFloppyDrive> hostFloppies;
1231 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(hostFloppies)));
1232 ComPtr<IHostFloppyDrive> hostFloppyDrive;
1233 rc = host->FindHostFloppyDrive(Bstr(floppy + 5), hostFloppyDrive.asOutParam());
1234 if (!hostFloppyDrive)
1235 {
1236 errorArgument("Invalid host floppy drive name");
1237 rc = E_FAIL;
1238 break;
1239 }
1240 CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));
1241 }
1242 else
1243 {
1244 /* first assume it's a UUID */
1245 Guid uuid(floppy);
1246 ComPtr<IFloppyImage> floppyImage;
1247 rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam());
1248 if (FAILED(rc) || !floppyImage)
1249 {
1250 /* must be a filename, check if it's in the collection */
1251 rc = a->virtualBox->FindFloppyImage(Bstr(floppy), floppyImage.asOutParam());
1252 /* not registered, do that on the fly */
1253 if (!floppyImage)
1254 {
1255 Guid emptyUUID;
1256 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(floppy), emptyUUID, floppyImage.asOutParam()));
1257 }
1258 }
1259 if (!floppyImage)
1260 {
1261 rc = E_FAIL;
1262 break;
1263 }
1264
1265 floppyImage->COMGETTER(Id)(uuid.asOutParam());
1266 CHECK_ERROR(floppyDrive, MountImage(uuid));
1267 }
1268 }
1269 }
1270 if (audio || audiocontroller)
1271 {
1272 ComPtr<IAudioAdapter> audioAdapter;
1273 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
1274 ASSERT(audioAdapter);
1275
1276 if (audio)
1277 {
1278 /* disable? */
1279 if (strcmp(audio, "none") == 0)
1280 {
1281 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
1282 }
1283 else if (strcmp(audio, "null") == 0)
1284 {
1285 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));
1286 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1287 }
1288#ifdef RT_OS_WINDOWS
1289#ifdef VBOX_WITH_WINMM
1290 else if (strcmp(audio, "winmm") == 0)
1291 {
1292 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));
1293 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1294 }
1295#endif
1296 else if (strcmp(audio, "dsound") == 0)
1297 {
1298 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
1299 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1300 }
1301#endif /* RT_OS_WINDOWS */
1302#ifdef RT_OS_LINUX
1303 else if (strcmp(audio, "oss") == 0)
1304 {
1305 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
1306 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1307 }
1308# ifdef VBOX_WITH_ALSA
1309 else if (strcmp(audio, "alsa") == 0)
1310 {
1311 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));
1312 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1313 }
1314# endif
1315# ifdef VBOX_WITH_PULSE
1316 else if (strcmp(audio, "pulse") == 0)
1317 {
1318 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
1319 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1320 }
1321# endif
1322#endif /* !RT_OS_LINUX */
1323#ifdef RT_OS_SOLARIS
1324 else if (strcmp(audio, "solaudio") == 0)
1325 {
1326 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio));
1327 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1328 }
1329
1330#endif /* !RT_OS_SOLARIS */
1331#ifdef RT_OS_DARWIN
1332 else if (strcmp(audio, "coreaudio") == 0)
1333 {
1334 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));
1335 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1336 }
1337
1338#endif /* !RT_OS_DARWIN */
1339 else
1340 {
1341 errorArgument("Invalid -audio argument '%s'", audio);
1342 rc = E_FAIL;
1343 break;
1344 }
1345 }
1346 if (audiocontroller)
1347 {
1348 if (strcmp(audiocontroller, "sb16") == 0)
1349 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));
1350 else if (strcmp(audiocontroller, "ac97") == 0)
1351 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));
1352 else
1353 {
1354 errorArgument("Invalid -audiocontroller argument '%s'", audiocontroller);
1355 rc = E_FAIL;
1356 break;
1357 }
1358 }
1359 }
1360 /* Shared clipboard state */
1361 if (clipboard)
1362 {
1363/* ComPtr<IClipboardMode> clipboardMode;
1364 machine->COMGETTER(ClipboardMode)(clipboardMode.asOutParam());
1365 ASSERT(clipboardMode);
1366*/
1367 if (strcmp(clipboard, "disabled") == 0)
1368 {
1369 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled));
1370 }
1371 else if (strcmp(clipboard, "hosttoguest") == 0)
1372 {
1373 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest));
1374 }
1375 else if (strcmp(clipboard, "guesttohost") == 0)
1376 {
1377 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost));
1378 }
1379 else if (strcmp(clipboard, "bidirectional") == 0)
1380 {
1381 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional));
1382 }
1383 else
1384 {
1385 errorArgument("Invalid -clipboard argument '%s'", clipboard);
1386 rc = E_FAIL;
1387 break;
1388 }
1389 }
1390 /* iterate through all possible NICs */
1391 for (ULONG n = 0; n < NetworkAdapterCount; n ++)
1392 {
1393 ComPtr<INetworkAdapter> nic;
1394 CHECK_ERROR_RET (machine, GetNetworkAdapter (n, nic.asOutParam()), 1);
1395
1396 ASSERT(nic);
1397
1398 /* something about the NIC? */
1399 if (nics[n])
1400 {
1401 if (strcmp(nics[n], "none") == 0)
1402 {
1403 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (FALSE), 1);
1404 }
1405 else if (strcmp(nics[n], "null") == 0)
1406 {
1407 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
1408 CHECK_ERROR_RET(nic, Detach(), 1);
1409 }
1410 else if (strcmp(nics[n], "nat") == 0)
1411 {
1412 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
1413 CHECK_ERROR_RET(nic, AttachToNAT(), 1);
1414 }
1415 else if ( strcmp(nics[n], "bridged") == 0
1416 || strcmp(nics[n], "hostif") == 0) /* backward compatibility */
1417 {
1418 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
1419 CHECK_ERROR_RET(nic, AttachToBridgedInterface(), 1);
1420 }
1421 else if (strcmp(nics[n], "intnet") == 0)
1422 {
1423 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
1424 CHECK_ERROR_RET(nic, AttachToInternalNetwork(), 1);
1425 }
1426#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
1427 else if (strcmp(nics[n], "hostonly") == 0)
1428 {
1429
1430 CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
1431 CHECK_ERROR_RET(nic, AttachToHostOnlyInterface(), 1);
1432 }
1433#endif /* defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) */
1434 else
1435 {
1436 errorArgument("Invalid type '%s' specfied for NIC %lu", nics[n], n + 1);
1437 rc = E_FAIL;
1438 break;
1439 }
1440 }
1441
1442 /* something about the NIC type? */
1443 if (nictype[n])
1444 {
1445 if (strcmp(nictype[n], "Am79C970A") == 0)
1446 {
1447 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A), 1);
1448 }
1449 else if (strcmp(nictype[n], "Am79C973") == 0)
1450 {
1451 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973), 1);
1452 }
1453#ifdef VBOX_WITH_E1000
1454 else if (strcmp(nictype[n], "82540EM") == 0)
1455 {
1456 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM), 1);
1457 }
1458 else if (strcmp(nictype[n], "82543GC") == 0)
1459 {
1460 CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC), 1);
1461 }
1462#endif
1463 else
1464 {
1465 errorArgument("Invalid NIC type '%s' specified for NIC %lu", nictype[n], n + 1);
1466 rc = E_FAIL;
1467 break;
1468 }
1469 }
1470
1471 /* something about the MAC address? */
1472 if (macs[n])
1473 {
1474 /* generate one? */
1475 if (strcmp(macs[n], "auto") == 0)
1476 {
1477 CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(NULL), 1);
1478 }
1479 else
1480 {
1481 CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(Bstr(macs[n])), 1);
1482 }
1483 }
1484
1485 /* something about the reported link speed? */
1486 if (nicspeed[n])
1487 {
1488 uint32_t u32LineSpeed;
1489
1490 u32LineSpeed = RTStrToUInt32(nicspeed[n]);
1491
1492 if (u32LineSpeed < 1000 || u32LineSpeed > 4000000)
1493 {
1494 errorArgument("Invalid -nicspeed%lu argument '%s'", n + 1, nicspeed[n]);
1495 rc = E_FAIL;
1496 break;
1497 }
1498 CHECK_ERROR_RET(nic, COMSETTER(LineSpeed)(u32LineSpeed), 1);
1499 }
1500
1501 /* the link status flag? */
1502 if (cableconnected[n])
1503 {
1504 if (strcmp(cableconnected[n], "on") == 0)
1505 {
1506 CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(TRUE), 1);
1507 }
1508 else if (strcmp(cableconnected[n], "off") == 0)
1509 {
1510 CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(FALSE), 1);
1511 }
1512 else
1513 {
1514 errorArgument("Invalid -cableconnected%lu argument '%s'", n + 1, cableconnected[n]);
1515 rc = E_FAIL;
1516 break;
1517 }
1518 }
1519
1520 /* the trace flag? */
1521 if (nictrace[n])
1522 {
1523 if (strcmp(nictrace[n], "on") == 0)
1524 {
1525 CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(TRUE), 1);
1526 }
1527 else if (strcmp(nictrace[n], "off") == 0)
1528 {
1529 CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(FALSE), 1);
1530 }
1531 else
1532 {
1533 errorArgument("Invalid -nictrace%lu argument '%s'", n + 1, nictrace[n]);
1534 rc = E_FAIL;
1535 break;
1536 }
1537 }
1538
1539 /* the tracefile flag? */
1540 if (nictracefile[n])
1541 {
1542 CHECK_ERROR_RET(nic, COMSETTER(TraceFile)(Bstr(nictracefile[n])), 1);
1543 }
1544
1545 /* the host interface device? */
1546 if (hostifdev[n])
1547 {
1548 /* remove it? */
1549 if (strcmp(hostifdev[n], "none") == 0)
1550 {
1551 CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(NULL), 1);
1552 }
1553 else
1554 {
1555 CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(Bstr(hostifdev[n])), 1);
1556 }
1557 }
1558
1559 /* the internal network name? */
1560 if (intnet[n])
1561 {
1562 /* remove it? */
1563 if (strcmp(intnet[n], "none") == 0)
1564 {
1565 CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(NULL), 1);
1566 }
1567 else
1568 {
1569 CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(Bstr(intnet[n])), 1);
1570 }
1571 }
1572 /* the network of the NAT */
1573 if (natnet[n])
1574 {
1575 CHECK_ERROR_RET(nic, COMSETTER(NATNetwork)(Bstr(natnet[n])), 1);
1576 }
1577 }
1578 if (FAILED(rc))
1579 break;
1580
1581 /* iterate through all possible serial ports */
1582 for (ULONG n = 0; n < SerialPortCount; n ++)
1583 {
1584 ComPtr<ISerialPort> uart;
1585 CHECK_ERROR_RET (machine, GetSerialPort (n, uart.asOutParam()), 1);
1586
1587 ASSERT(uart);
1588
1589 if (uarts_base[n])
1590 {
1591 if (uarts_base[n] == (ULONG)-1)
1592 {
1593 CHECK_ERROR_RET(uart, COMSETTER(Enabled) (FALSE), 1);
1594 }
1595 else
1596 {
1597 CHECK_ERROR_RET(uart, COMSETTER(IOBase) (uarts_base[n]), 1);
1598 CHECK_ERROR_RET(uart, COMSETTER(IRQ) (uarts_irq[n]), 1);
1599 CHECK_ERROR_RET(uart, COMSETTER(Enabled) (TRUE), 1);
1600 }
1601 }
1602 if (uarts_mode[n])
1603 {
1604 if (strcmp(uarts_mode[n], "disconnected") == 0)
1605 {
1606 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_Disconnected), 1);
1607 }
1608 else
1609 {
1610 CHECK_ERROR_RET(uart, COMSETTER(Path) (Bstr(uarts_path[n])), 1);
1611 if (strcmp(uarts_mode[n], "server") == 0)
1612 {
1613 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1);
1614 CHECK_ERROR_RET(uart, COMSETTER(Server) (TRUE), 1);
1615 }
1616 else if (strcmp(uarts_mode[n], "client") == 0)
1617 {
1618 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1);
1619 CHECK_ERROR_RET(uart, COMSETTER(Server) (FALSE), 1);
1620 }
1621 else
1622 {
1623 CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostDevice), 1);
1624 }
1625 }
1626 }
1627 }
1628 if (FAILED(rc))
1629 break;
1630
1631#ifdef VBOX_WITH_VRDP
1632 if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon || vrdpreusecon)
1633 {
1634 ComPtr<IVRDPServer> vrdpServer;
1635 machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
1636 ASSERT(vrdpServer);
1637 if (vrdpServer)
1638 {
1639 if (vrdp)
1640 {
1641 if (strcmp(vrdp, "on") == 0)
1642 {
1643 CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(true));
1644 }
1645 else if (strcmp(vrdp, "off") == 0)
1646 {
1647 CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(false));
1648 }
1649 else
1650 {
1651 errorArgument("Invalid -vrdp argument '%s'", vrdp);
1652 rc = E_FAIL;
1653 break;
1654 }
1655 }
1656 if (vrdpport != UINT16_MAX)
1657 {
1658 CHECK_ERROR(vrdpServer, COMSETTER(Port)(vrdpport));
1659 }
1660 if (vrdpaddress)
1661 {
1662 CHECK_ERROR(vrdpServer, COMSETTER(NetAddress)(Bstr(vrdpaddress)));
1663 }
1664 if (vrdpauthtype)
1665 {
1666 if (strcmp(vrdpauthtype, "null") == 0)
1667 {
1668 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Null));
1669 }
1670 else if (strcmp(vrdpauthtype, "external") == 0)
1671 {
1672 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_External));
1673 }
1674 else if (strcmp(vrdpauthtype, "guest") == 0)
1675 {
1676 CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Guest));
1677 }
1678 else
1679 {
1680 errorArgument("Invalid -vrdpauthtype argument '%s'", vrdpauthtype);
1681 rc = E_FAIL;
1682 break;
1683 }
1684 }
1685 if (vrdpmulticon)
1686 {
1687 if (strcmp(vrdpmulticon, "on") == 0)
1688 {
1689 CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(true));
1690 }
1691 else if (strcmp(vrdpmulticon, "off") == 0)
1692 {
1693 CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(false));
1694 }
1695 else
1696 {
1697 errorArgument("Invalid -vrdpmulticon argument '%s'", vrdpmulticon);
1698 rc = E_FAIL;
1699 break;
1700 }
1701 }
1702 if (vrdpreusecon)
1703 {
1704 if (strcmp(vrdpreusecon, "on") == 0)
1705 {
1706 CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(true));
1707 }
1708 else if (strcmp(vrdpreusecon, "off") == 0)
1709 {
1710 CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(false));
1711 }
1712 else
1713 {
1714 errorArgument("Invalid -vrdpreusecon argument '%s'", vrdpreusecon);
1715 rc = E_FAIL;
1716 break;
1717 }
1718 }
1719 }
1720 }
1721#endif /* VBOX_WITH_VRDP */
1722
1723 /*
1724 * USB enable/disable
1725 */
1726 if (fUsbEnabled != -1)
1727 {
1728 ComPtr<IUSBController> UsbCtl;
1729 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
1730 if (SUCCEEDED(rc))
1731 {
1732 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(!!fUsbEnabled));
1733 }
1734 }
1735 /*
1736 * USB EHCI enable/disable
1737 */
1738 if (fUsbEhciEnabled != -1)
1739 {
1740 ComPtr<IUSBController> UsbCtl;
1741 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
1742 if (SUCCEEDED(rc))
1743 {
1744 CHECK_ERROR(UsbCtl, COMSETTER(EnabledEhci)(!!fUsbEhciEnabled));
1745 }
1746 }
1747
1748 if (snapshotFolder)
1749 {
1750 if (strcmp(snapshotFolder, "default") == 0)
1751 {
1752 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(NULL));
1753 }
1754 else
1755 {
1756 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(snapshotFolder)));
1757 }
1758 }
1759
1760 if (guestMemBalloonSize != (ULONG)-1)
1761 CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(guestMemBalloonSize));
1762
1763 if (guestStatInterval != (ULONG)-1)
1764 CHECK_ERROR(machine, COMSETTER(StatisticsUpdateInterval)(guestStatInterval));
1765
1766 /*
1767 * SATA controller enable/disable
1768 */
1769 if (fSataEnabled != -1)
1770 {
1771 if (fSataEnabled)
1772 {
1773 ComPtr<IStorageController> ctl;
1774 CHECK_ERROR(machine, AddStorageController(Bstr("SATA"), StorageBus_SATA, ctl.asOutParam()));
1775 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci));
1776 }
1777 else
1778 CHECK_ERROR(machine, RemoveStorageController(Bstr("SATA")));
1779 }
1780
1781 for (uint32_t i = 4; i < 34; i++)
1782 {
1783 if (hdds[i])
1784 {
1785 if (strcmp(hdds[i], "none") == 0)
1786 {
1787 machine->DetachHardDisk(Bstr("SATA"), i-4, 0);
1788 }
1789 else
1790 {
1791 /* first guess is that it's a UUID */
1792 Guid uuid(hdds[i]);
1793 ComPtr<IHardDisk> hardDisk;
1794 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
1795 /* not successful? Then it must be a filename */
1796 if (!hardDisk)
1797 {
1798 CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
1799 if (FAILED(rc))
1800 {
1801 /* open the new hard disk object */
1802 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
1803 }
1804 }
1805 if (hardDisk)
1806 {
1807 hardDisk->COMGETTER(Id)(uuid.asOutParam());
1808 CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("SATA"), i-4, 0));
1809 }
1810 else
1811 rc = E_FAIL;
1812 if (FAILED(rc))
1813 break;
1814 }
1815 }
1816 }
1817
1818 for (uint32_t i = 0; i < 4; i++)
1819 {
1820 if (sataBootDevices[i] != -1)
1821 {
1822 ComPtr<IStorageController> SataCtl;
1823 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam()));
1824 if (SUCCEEDED(rc))
1825 {
1826 CHECK_ERROR(SataCtl, SetIDEEmulationPort(i, sataBootDevices[i]));
1827 }
1828 }
1829 }
1830
1831 if (sataPortCount != -1)
1832 {
1833 ComPtr<IStorageController> SataCtl;
1834 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam()));
1835 if (SUCCEEDED(rc))
1836 {
1837 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(sataPortCount));
1838 }
1839 }
1840
1841 /*
1842 * LsiLogic controller enable/disable
1843 */
1844 if (fLsiLogicEnabled != -1)
1845 {
1846 if (fLsiLogicEnabled)
1847 {
1848 ComPtr<IStorageController> ctl;
1849 CHECK_ERROR(machine, AddStorageController(Bstr("LsiLogic"), StorageBus_SCSI, ctl.asOutParam()));
1850 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic));
1851 }
1852 else
1853 CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic")));
1854 }
1855
1856 for (uint32_t i = 34; i < 50; i++)
1857 {
1858 if (hdds[i])
1859 {
1860 if (strcmp(hdds[i], "none") == 0)
1861 {
1862 machine->DetachHardDisk(Bstr("LsiLogic"), i-34, 0);
1863 }
1864 else
1865 {
1866 /* first guess is that it's a UUID */
1867 Guid uuid(hdds[i]);
1868 ComPtr<IHardDisk> hardDisk;
1869 rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
1870 /* not successful? Then it must be a filename */
1871 if (!hardDisk)
1872 {
1873 CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
1874 if (FAILED(rc))
1875 {
1876 /* open the new hard disk object */
1877 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
1878 }
1879 }
1880 if (hardDisk)
1881 {
1882 hardDisk->COMGETTER(Id)(uuid.asOutParam());
1883 CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("LsiLogic"), i-34, 0));
1884 }
1885 else
1886 rc = E_FAIL;
1887 if (FAILED(rc))
1888 break;
1889 }
1890 }
1891 }
1892
1893 /* commit changes */
1894 CHECK_ERROR(machine, SaveSettings());
1895 }
1896 while (0);
1897
1898 /* it's important to always close sessions */
1899 a->session->Close();
1900
1901 return SUCCEEDED(rc) ? 0 : 1;
1902}
1903
1904#endif /* !VBOX_ONLY_DOCS */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette