1 | /* $Id: VBoxManageModifyVM.cpp 17843 2009-03-13 15:51:55Z 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
|
---|
48 | using 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 |
|
---|
56 | int 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], "-hostifdev", 10) == 0) /* backward compatibility */
|
---|
446 | {
|
---|
447 | unsigned n = parseNum(&a->argv[i][10], NetworkAdapterCount, "NIC");
|
---|
448 | if (!n)
|
---|
449 | return 1;
|
---|
450 | if (a->argc <= i + 1)
|
---|
451 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
452 | hostifdev[n - 1] = a->argv[i + 1];
|
---|
453 | i++;
|
---|
454 | }
|
---|
455 | else if ( strncmp(a->argv[i], "-bridgeadapter", 14) == 0)
|
---|
456 | {
|
---|
457 | unsigned n = parseNum(&a->argv[i][14], NetworkAdapterCount, "NIC");
|
---|
458 | if (!n)
|
---|
459 | return 1;
|
---|
460 | if (a->argc <= i + 1)
|
---|
461 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
462 | hostifdev[n - 1] = a->argv[i + 1];
|
---|
463 | i++;
|
---|
464 | }
|
---|
465 | else if (strncmp(a->argv[i], "-hostonlyadapter", 16) == 0)
|
---|
466 | {
|
---|
467 | unsigned n = parseNum(&a->argv[i][16], NetworkAdapterCount, "NIC");
|
---|
468 | if (!n)
|
---|
469 | return 1;
|
---|
470 | if (a->argc <= i + 1)
|
---|
471 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
472 | hostifdev[n - 1] = a->argv[i + 1];
|
---|
473 | i++;
|
---|
474 | }
|
---|
475 | else if (strncmp(a->argv[i], "-intnet", 7) == 0)
|
---|
476 | {
|
---|
477 | unsigned n = parseNum(&a->argv[i][7], NetworkAdapterCount, "NIC");
|
---|
478 | if (!n)
|
---|
479 | return 1;
|
---|
480 | if (a->argc <= i + 1)
|
---|
481 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
482 | intnet[n - 1] = a->argv[i + 1];
|
---|
483 | i++;
|
---|
484 | }
|
---|
485 | else if (strncmp(a->argv[i], "-natnet", 7) == 0)
|
---|
486 | {
|
---|
487 | unsigned n = parseNum(&a->argv[i][7], 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 |
|
---|
493 | if (!strcmp(a->argv[i + 1], "default"))
|
---|
494 | natnet[n - 1] = "";
|
---|
495 | else
|
---|
496 | {
|
---|
497 | RTIPV4ADDR Network;
|
---|
498 | RTIPV4ADDR Netmask;
|
---|
499 | int rc = RTCidrStrToIPv4(a->argv[i + 1], &Network, &Netmask);
|
---|
500 | if (RT_FAILURE(rc))
|
---|
501 | return errorArgument("Invalid IPv4 network '%s' specified -- CIDR notation expected.\n", a->argv[i + 1]);
|
---|
502 | if (Netmask & 0x1f)
|
---|
503 | return errorArgument("Prefix length of the NAT network must be less than 28.\n");
|
---|
504 | natnet[n - 1] = a->argv[i + 1];
|
---|
505 | }
|
---|
506 | i++;
|
---|
507 | }
|
---|
508 | else if (strncmp(a->argv[i], "-macaddress", 11) == 0)
|
---|
509 | {
|
---|
510 | unsigned n = parseNum(&a->argv[i][11], NetworkAdapterCount, "NIC");
|
---|
511 | if (!n)
|
---|
512 | return 1;
|
---|
513 | if (a->argc <= i + 1)
|
---|
514 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
515 | macs[n - 1] = a->argv[i + 1];
|
---|
516 | i++;
|
---|
517 | }
|
---|
518 | #ifdef VBOX_WITH_VRDP
|
---|
519 | else if (strcmp(a->argv[i], "-vrdp") == 0)
|
---|
520 | {
|
---|
521 | if (a->argc <= i + 1)
|
---|
522 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
523 | i++;
|
---|
524 | vrdp = a->argv[i];
|
---|
525 | }
|
---|
526 | else if (strcmp(a->argv[i], "-vrdpport") == 0)
|
---|
527 | {
|
---|
528 | if (a->argc <= i + 1)
|
---|
529 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
530 | i++;
|
---|
531 | if (strcmp(a->argv[i], "default") == 0)
|
---|
532 | vrdpport = 0;
|
---|
533 | else
|
---|
534 | vrdpport = RTStrToUInt16(a->argv[i]);
|
---|
535 | }
|
---|
536 | else if (strcmp(a->argv[i], "-vrdpaddress") == 0)
|
---|
537 | {
|
---|
538 | if (a->argc <= i + 1)
|
---|
539 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
540 | i++;
|
---|
541 | vrdpaddress = a->argv[i];
|
---|
542 | }
|
---|
543 | else if (strcmp(a->argv[i], "-vrdpauthtype") == 0)
|
---|
544 | {
|
---|
545 | if (a->argc <= i + 1)
|
---|
546 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
547 | i++;
|
---|
548 | vrdpauthtype = a->argv[i];
|
---|
549 | }
|
---|
550 | else if (strcmp(a->argv[i], "-vrdpmulticon") == 0)
|
---|
551 | {
|
---|
552 | if (a->argc <= i + 1)
|
---|
553 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
554 | i++;
|
---|
555 | vrdpmulticon = a->argv[i];
|
---|
556 | }
|
---|
557 | else if (strcmp(a->argv[i], "-vrdpreusecon") == 0)
|
---|
558 | {
|
---|
559 | if (a->argc <= i + 1)
|
---|
560 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
561 | i++;
|
---|
562 | vrdpreusecon = a->argv[i];
|
---|
563 | }
|
---|
564 | #endif /* VBOX_WITH_VRDP */
|
---|
565 | else if (strcmp(a->argv[i], "-usb") == 0)
|
---|
566 | {
|
---|
567 | if (a->argc <= i + 1)
|
---|
568 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
569 | i++;
|
---|
570 | if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
|
---|
571 | fUsbEnabled = 1;
|
---|
572 | else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
|
---|
573 | fUsbEnabled = 0;
|
---|
574 | else
|
---|
575 | return errorArgument("Invalid -usb argument '%s'", a->argv[i]);
|
---|
576 | }
|
---|
577 | else if (strcmp(a->argv[i], "-usbehci") == 0)
|
---|
578 | {
|
---|
579 | if (a->argc <= i + 1)
|
---|
580 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
581 | i++;
|
---|
582 | if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
|
---|
583 | fUsbEhciEnabled = 1;
|
---|
584 | else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
|
---|
585 | fUsbEhciEnabled = 0;
|
---|
586 | else
|
---|
587 | return errorArgument("Invalid -usbehci argument '%s'", a->argv[i]);
|
---|
588 | }
|
---|
589 | else if (strcmp(a->argv[i], "-snapshotfolder") == 0)
|
---|
590 | {
|
---|
591 | if (a->argc <= i + 1)
|
---|
592 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
593 | i++;
|
---|
594 | snapshotFolder = a->argv[i];
|
---|
595 | }
|
---|
596 | else if (strncmp(a->argv[i], "-uartmode", 9) == 0)
|
---|
597 | {
|
---|
598 | unsigned n = parseNum(&a->argv[i][9], SerialPortCount, "UART");
|
---|
599 | if (!n)
|
---|
600 | return 1;
|
---|
601 | i++;
|
---|
602 | if (strcmp(a->argv[i], "disconnected") == 0)
|
---|
603 | {
|
---|
604 | uarts_mode[n - 1] = a->argv[i];
|
---|
605 | }
|
---|
606 | else
|
---|
607 | {
|
---|
608 | if (strcmp(a->argv[i], "server") == 0 || strcmp(a->argv[i], "client") == 0)
|
---|
609 | {
|
---|
610 | uarts_mode[n - 1] = a->argv[i];
|
---|
611 | i++;
|
---|
612 | #ifdef RT_OS_WINDOWS
|
---|
613 | if (strncmp(a->argv[i], "\\\\.\\pipe\\", 9))
|
---|
614 | return errorArgument("Uart pipe must start with \\\\.\\pipe\\");
|
---|
615 | #endif
|
---|
616 | }
|
---|
617 | else
|
---|
618 | {
|
---|
619 | uarts_mode[n - 1] = (char*)"device";
|
---|
620 | }
|
---|
621 | if (a->argc <= i)
|
---|
622 | return errorArgument("Missing argument to -uartmode");
|
---|
623 | uarts_path[n - 1] = a->argv[i];
|
---|
624 | }
|
---|
625 | }
|
---|
626 | else if (strncmp(a->argv[i], "-uart", 5) == 0)
|
---|
627 | {
|
---|
628 | unsigned n = parseNum(&a->argv[i][5], SerialPortCount, "UART");
|
---|
629 | if (!n)
|
---|
630 | return 1;
|
---|
631 | if (a->argc <= i + 1)
|
---|
632 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
633 | i++;
|
---|
634 | if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
|
---|
635 | {
|
---|
636 | uarts_base[n - 1] = (ULONG)-1;
|
---|
637 | }
|
---|
638 | else
|
---|
639 | {
|
---|
640 | if (a->argc <= i + 1)
|
---|
641 | return errorArgument("Missing argument to '%s'", a->argv[i-1]);
|
---|
642 | uint32_t uVal;
|
---|
643 | int vrc;
|
---|
644 | vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
|
---|
645 | if (vrc != VINF_SUCCESS || uVal == 0)
|
---|
646 | return errorArgument("Error parsing UART I/O base '%s'", a->argv[i]);
|
---|
647 | uarts_base[n - 1] = uVal;
|
---|
648 | i++;
|
---|
649 | vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
|
---|
650 | if (vrc != VINF_SUCCESS)
|
---|
651 | return errorArgument("Error parsing UART IRQ '%s'", a->argv[i]);
|
---|
652 | uarts_irq[n - 1] = uVal;
|
---|
653 | }
|
---|
654 | }
|
---|
655 | #ifdef VBOX_WITH_MEM_BALLOONING
|
---|
656 | else if (strncmp(a->argv[i], "-guestmemoryballoon", 19) == 0)
|
---|
657 | {
|
---|
658 | if (a->argc <= i + 1)
|
---|
659 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
660 | i++;
|
---|
661 | uint32_t uVal;
|
---|
662 | int vrc;
|
---|
663 | vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
|
---|
664 | if (vrc != VINF_SUCCESS)
|
---|
665 | return errorArgument("Error parsing guest memory balloon size '%s'", a->argv[i]);
|
---|
666 | guestMemBalloonSize = uVal;
|
---|
667 | }
|
---|
668 | #endif
|
---|
669 | else if (strncmp(a->argv[i], "-gueststatisticsinterval", 24) == 0)
|
---|
670 | {
|
---|
671 | if (a->argc <= i + 1)
|
---|
672 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
673 | i++;
|
---|
674 | uint32_t uVal;
|
---|
675 | int vrc;
|
---|
676 | vrc = RTStrToUInt32Ex(a->argv[i], NULL, 0, &uVal);
|
---|
677 | if (vrc != VINF_SUCCESS)
|
---|
678 | return errorArgument("Error parsing guest statistics interval '%s'", a->argv[i]);
|
---|
679 | guestStatInterval = uVal;
|
---|
680 | }
|
---|
681 | else if (strcmp(a->argv[i], "-sata") == 0)
|
---|
682 | {
|
---|
683 | if (a->argc <= i + 1)
|
---|
684 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
685 | i++;
|
---|
686 | if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
|
---|
687 | fSataEnabled = 1;
|
---|
688 | else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
|
---|
689 | fSataEnabled = 0;
|
---|
690 | else
|
---|
691 | return errorArgument("Invalid -usb argument '%s'", a->argv[i]);
|
---|
692 | }
|
---|
693 | else if (strcmp(a->argv[i], "-sataportcount") == 0)
|
---|
694 | {
|
---|
695 | unsigned n;
|
---|
696 |
|
---|
697 | if (a->argc <= i + 1)
|
---|
698 | return errorArgument("Missing arguments to '%s'", a->argv[i]);
|
---|
699 | i++;
|
---|
700 |
|
---|
701 | n = parseNum(a->argv[i], 30, "SATA");
|
---|
702 | if (!n)
|
---|
703 | return 1;
|
---|
704 | sataPortCount = n;
|
---|
705 | }
|
---|
706 | else if (strncmp(a->argv[i], "-sataport", 9) == 0)
|
---|
707 | {
|
---|
708 | unsigned n = parseNum(&a->argv[i][9], 30, "SATA");
|
---|
709 | if (!n)
|
---|
710 | return 1;
|
---|
711 | if (a->argc <= i + 1)
|
---|
712 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
713 | i++;
|
---|
714 | hdds[n-1+4] = a->argv[i];
|
---|
715 | }
|
---|
716 | else if (strncmp(a->argv[i], "-sataideemulation", 17) == 0)
|
---|
717 | {
|
---|
718 | unsigned bootDevicePos = 0;
|
---|
719 | unsigned n;
|
---|
720 |
|
---|
721 | bootDevicePos = parseNum(&a->argv[i][17], 4, "SATA");
|
---|
722 | if (!bootDevicePos)
|
---|
723 | return 1;
|
---|
724 | bootDevicePos--;
|
---|
725 |
|
---|
726 | if (a->argc <= i + 1)
|
---|
727 | return errorArgument("Missing arguments to '%s'", a->argv[i]);
|
---|
728 | i++;
|
---|
729 |
|
---|
730 | n = parseNum(a->argv[i], 30, "SATA");
|
---|
731 | if (!n)
|
---|
732 | return 1;
|
---|
733 |
|
---|
734 | sataBootDevices[bootDevicePos] = n-1;
|
---|
735 | }
|
---|
736 | else if (strcmp(a->argv[i], "-lsilogic") == 0)
|
---|
737 | {
|
---|
738 | if (a->argc <= i + 1)
|
---|
739 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
740 | i++;
|
---|
741 | if (strcmp(a->argv[i], "on") == 0 || strcmp(a->argv[i], "enable") == 0)
|
---|
742 | fLsiLogicEnabled = 1;
|
---|
743 | else if (strcmp(a->argv[i], "off") == 0 || strcmp(a->argv[i], "disable") == 0)
|
---|
744 | fLsiLogicEnabled = 0;
|
---|
745 | else
|
---|
746 | return errorArgument("Invalid -lsilogic argument '%s'", a->argv[i]);
|
---|
747 | }
|
---|
748 | else if (strncmp(a->argv[i], "-lsilogicport", 13) == 0)
|
---|
749 | {
|
---|
750 | unsigned n = parseNum(&a->argv[i][13], 16, "LsiLogic");
|
---|
751 | if (!n)
|
---|
752 | return 1;
|
---|
753 | if (a->argc <= i + 1)
|
---|
754 | return errorArgument("Missing argument to '%s'", a->argv[i]);
|
---|
755 | i++;
|
---|
756 | hdds[n-1+34] = a->argv[i];
|
---|
757 | }
|
---|
758 | else
|
---|
759 | return errorSyntax(USAGE_MODIFYVM, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());
|
---|
760 | }
|
---|
761 |
|
---|
762 | /* try to find the given machine */
|
---|
763 | ComPtr <IMachine> machine;
|
---|
764 | Guid uuid (a->argv[0]);
|
---|
765 | if (!uuid.isEmpty())
|
---|
766 | {
|
---|
767 | CHECK_ERROR (a->virtualBox, GetMachine (uuid, machine.asOutParam()));
|
---|
768 | }
|
---|
769 | else
|
---|
770 | {
|
---|
771 | CHECK_ERROR (a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
|
---|
772 | if (SUCCEEDED (rc))
|
---|
773 | machine->COMGETTER(Id)(uuid.asOutParam());
|
---|
774 | }
|
---|
775 | if (FAILED (rc))
|
---|
776 | return 1;
|
---|
777 |
|
---|
778 | /* open a session for the VM */
|
---|
779 | CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1);
|
---|
780 |
|
---|
781 | do
|
---|
782 | {
|
---|
783 | /* get the mutable session machine */
|
---|
784 | a->session->COMGETTER(Machine)(machine.asOutParam());
|
---|
785 |
|
---|
786 | ComPtr <IBIOSSettings> biosSettings;
|
---|
787 | machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
|
---|
788 |
|
---|
789 | if (name)
|
---|
790 | CHECK_ERROR(machine, COMSETTER(Name)(name));
|
---|
791 | if (ostype)
|
---|
792 | {
|
---|
793 | ComPtr<IGuestOSType> guestOSType;
|
---|
794 | CHECK_ERROR(a->virtualBox, GetGuestOSType(ostype, guestOSType.asOutParam()));
|
---|
795 | if (SUCCEEDED(rc) && guestOSType)
|
---|
796 | {
|
---|
797 | CHECK_ERROR(machine, COMSETTER(OSTypeId)(ostype));
|
---|
798 | }
|
---|
799 | else
|
---|
800 | {
|
---|
801 | errorArgument("Invalid guest OS type '%s'", Utf8Str(ostype).raw());
|
---|
802 | rc = E_FAIL;
|
---|
803 | break;
|
---|
804 | }
|
---|
805 | }
|
---|
806 | if (memorySize > 0)
|
---|
807 | CHECK_ERROR(machine, COMSETTER(MemorySize)(memorySize));
|
---|
808 | if (vramSize > 0)
|
---|
809 | CHECK_ERROR(machine, COMSETTER(VRAMSize)(vramSize));
|
---|
810 | if (acpi)
|
---|
811 | {
|
---|
812 | if (strcmp(acpi, "on") == 0)
|
---|
813 | {
|
---|
814 | CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(true));
|
---|
815 | }
|
---|
816 | else if (strcmp(acpi, "off") == 0)
|
---|
817 | {
|
---|
818 | CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(false));
|
---|
819 | }
|
---|
820 | else
|
---|
821 | {
|
---|
822 | errorArgument("Invalid -acpi argument '%s'", acpi);
|
---|
823 | rc = E_FAIL;
|
---|
824 | break;
|
---|
825 | }
|
---|
826 | }
|
---|
827 | if (ioapic)
|
---|
828 | {
|
---|
829 | if (strcmp(ioapic, "on") == 0)
|
---|
830 | {
|
---|
831 | CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(true));
|
---|
832 | }
|
---|
833 | else if (strcmp(ioapic, "off") == 0)
|
---|
834 | {
|
---|
835 | CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(false));
|
---|
836 | }
|
---|
837 | else
|
---|
838 | {
|
---|
839 | errorArgument("Invalid -ioapic argument '%s'", ioapic);
|
---|
840 | rc = E_FAIL;
|
---|
841 | break;
|
---|
842 | }
|
---|
843 | }
|
---|
844 | if (hwvirtex)
|
---|
845 | {
|
---|
846 | if (strcmp(hwvirtex, "on") == 0)
|
---|
847 | {
|
---|
848 | CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_True));
|
---|
849 | }
|
---|
850 | else if (strcmp(hwvirtex, "off") == 0)
|
---|
851 | {
|
---|
852 | CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_False));
|
---|
853 | }
|
---|
854 | else if (strcmp(hwvirtex, "default") == 0)
|
---|
855 | {
|
---|
856 | CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TSBool_Default));
|
---|
857 | }
|
---|
858 | else
|
---|
859 | {
|
---|
860 | errorArgument("Invalid -hwvirtex argument '%s'", hwvirtex);
|
---|
861 | rc = E_FAIL;
|
---|
862 | break;
|
---|
863 | }
|
---|
864 | }
|
---|
865 | if (nestedpaging)
|
---|
866 | {
|
---|
867 | if (strcmp(nestedpaging, "on") == 0)
|
---|
868 | {
|
---|
869 | CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(true));
|
---|
870 | }
|
---|
871 | else if (strcmp(nestedpaging, "off") == 0)
|
---|
872 | {
|
---|
873 | CHECK_ERROR(machine, COMSETTER(HWVirtExNestedPagingEnabled)(false));
|
---|
874 | }
|
---|
875 | else
|
---|
876 | {
|
---|
877 | errorArgument("Invalid -nestedpaging argument '%s'", ioapic);
|
---|
878 | rc = E_FAIL;
|
---|
879 | break;
|
---|
880 | }
|
---|
881 | }
|
---|
882 | if (vtxvpid)
|
---|
883 | {
|
---|
884 | if (strcmp(vtxvpid, "on") == 0)
|
---|
885 | {
|
---|
886 | CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(true));
|
---|
887 | }
|
---|
888 | else if (strcmp(vtxvpid, "off") == 0)
|
---|
889 | {
|
---|
890 | CHECK_ERROR(machine, COMSETTER(HWVirtExVPIDEnabled)(false));
|
---|
891 | }
|
---|
892 | else
|
---|
893 | {
|
---|
894 | errorArgument("Invalid -vtxvpid argument '%s'", ioapic);
|
---|
895 | rc = E_FAIL;
|
---|
896 | break;
|
---|
897 | }
|
---|
898 | }
|
---|
899 | if (pae)
|
---|
900 | {
|
---|
901 | if (strcmp(pae, "on") == 0)
|
---|
902 | {
|
---|
903 | CHECK_ERROR(machine, COMSETTER(PAEEnabled)(true));
|
---|
904 | }
|
---|
905 | else if (strcmp(pae, "off") == 0)
|
---|
906 | {
|
---|
907 | CHECK_ERROR(machine, COMSETTER(PAEEnabled)(false));
|
---|
908 | }
|
---|
909 | else
|
---|
910 | {
|
---|
911 | errorArgument("Invalid -pae argument '%s'", ioapic);
|
---|
912 | rc = E_FAIL;
|
---|
913 | break;
|
---|
914 | }
|
---|
915 | }
|
---|
916 | if (monitorcount != ~0U)
|
---|
917 | {
|
---|
918 | CHECK_ERROR(machine, COMSETTER(MonitorCount)(monitorcount));
|
---|
919 | }
|
---|
920 | if (accelerate3d)
|
---|
921 | {
|
---|
922 | if (strcmp(accelerate3d, "on") == 0)
|
---|
923 | {
|
---|
924 | CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(true));
|
---|
925 | }
|
---|
926 | else if (strcmp(accelerate3d, "off") == 0)
|
---|
927 | {
|
---|
928 | CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(false));
|
---|
929 | }
|
---|
930 | else
|
---|
931 | {
|
---|
932 | errorArgument("Invalid -accelerate3d argument '%s'", ioapic);
|
---|
933 | rc = E_FAIL;
|
---|
934 | break;
|
---|
935 | }
|
---|
936 | }
|
---|
937 | if (bioslogofadein)
|
---|
938 | {
|
---|
939 | if (strcmp(bioslogofadein, "on") == 0)
|
---|
940 | {
|
---|
941 | CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(true));
|
---|
942 | }
|
---|
943 | else if (strcmp(bioslogofadein, "off") == 0)
|
---|
944 | {
|
---|
945 | CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(false));
|
---|
946 | }
|
---|
947 | else
|
---|
948 | {
|
---|
949 | errorArgument("Invalid -bioslogofadein argument '%s'", bioslogofadein);
|
---|
950 | rc = E_FAIL;
|
---|
951 | break;
|
---|
952 | }
|
---|
953 | }
|
---|
954 | if (bioslogofadeout)
|
---|
955 | {
|
---|
956 | if (strcmp(bioslogofadeout, "on") == 0)
|
---|
957 | {
|
---|
958 | CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(true));
|
---|
959 | }
|
---|
960 | else if (strcmp(bioslogofadeout, "off") == 0)
|
---|
961 | {
|
---|
962 | CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(false));
|
---|
963 | }
|
---|
964 | else
|
---|
965 | {
|
---|
966 | errorArgument("Invalid -bioslogofadeout argument '%s'", bioslogofadeout);
|
---|
967 | rc = E_FAIL;
|
---|
968 | break;
|
---|
969 | }
|
---|
970 | }
|
---|
971 | if (bioslogodisplaytime != ~0U)
|
---|
972 | {
|
---|
973 | CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(bioslogodisplaytime));
|
---|
974 | }
|
---|
975 | if (bioslogoimagepath)
|
---|
976 | {
|
---|
977 | CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(bioslogoimagepath)));
|
---|
978 | }
|
---|
979 | if (biosbootmenumode)
|
---|
980 | {
|
---|
981 | if (strcmp(biosbootmenumode, "disabled") == 0)
|
---|
982 | CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled));
|
---|
983 | else if (strcmp(biosbootmenumode, "menuonly") == 0)
|
---|
984 | CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly));
|
---|
985 | else if (strcmp(biosbootmenumode, "messageandmenu") == 0)
|
---|
986 | CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu));
|
---|
987 | else
|
---|
988 | {
|
---|
989 | errorArgument("Invalid -biosbootmenu argument '%s'", biosbootmenumode);
|
---|
990 | rc = E_FAIL;
|
---|
991 | break;
|
---|
992 | }
|
---|
993 |
|
---|
994 | }
|
---|
995 | if (biossystemtimeoffset)
|
---|
996 | {
|
---|
997 | LONG64 timeOffset = RTStrToInt64(biossystemtimeoffset);
|
---|
998 | CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(timeOffset));
|
---|
999 | }
|
---|
1000 | if (biospxedebug)
|
---|
1001 | {
|
---|
1002 | if (strcmp(biospxedebug, "on") == 0)
|
---|
1003 | {
|
---|
1004 | CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(true));
|
---|
1005 | }
|
---|
1006 | else if (strcmp(biospxedebug, "off") == 0)
|
---|
1007 | {
|
---|
1008 | CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(false));
|
---|
1009 | }
|
---|
1010 | else
|
---|
1011 | {
|
---|
1012 | errorArgument("Invalid -biospxedebug argument '%s'", biospxedebug);
|
---|
1013 | rc = E_FAIL;
|
---|
1014 | break;
|
---|
1015 | }
|
---|
1016 | }
|
---|
1017 | for (int curBootDev = 0; curBootDev < 4; curBootDev++)
|
---|
1018 | {
|
---|
1019 | if (bootDeviceChanged[curBootDev])
|
---|
1020 | CHECK_ERROR(machine, SetBootOrder (curBootDev + 1, bootDevice[curBootDev]));
|
---|
1021 | }
|
---|
1022 | if (hdds[0])
|
---|
1023 | {
|
---|
1024 | if (strcmp(hdds[0], "none") == 0)
|
---|
1025 | {
|
---|
1026 | machine->DetachHardDisk(Bstr("IDE"), 0, 0);
|
---|
1027 | }
|
---|
1028 | else
|
---|
1029 | {
|
---|
1030 | /* first guess is that it's a UUID */
|
---|
1031 | Guid uuid(hdds[0]);
|
---|
1032 | ComPtr<IHardDisk> hardDisk;
|
---|
1033 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
1034 | /* not successful? Then it must be a filename */
|
---|
1035 | if (!hardDisk)
|
---|
1036 | {
|
---|
1037 | CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[0]), hardDisk.asOutParam()));
|
---|
1038 | if (FAILED(rc))
|
---|
1039 | {
|
---|
1040 | /* open the new hard disk object */
|
---|
1041 | CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), hardDisk.asOutParam()));
|
---|
1042 | }
|
---|
1043 | }
|
---|
1044 | if (hardDisk)
|
---|
1045 | {
|
---|
1046 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
1047 | CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("IDE"), 0, 0));
|
---|
1048 | }
|
---|
1049 | else
|
---|
1050 | rc = E_FAIL;
|
---|
1051 | if (FAILED(rc))
|
---|
1052 | break;
|
---|
1053 | }
|
---|
1054 | }
|
---|
1055 | if (hdds[1])
|
---|
1056 | {
|
---|
1057 | if (strcmp(hdds[1], "none") == 0)
|
---|
1058 | {
|
---|
1059 | machine->DetachHardDisk(Bstr("IDE"), 0, 1);
|
---|
1060 | }
|
---|
1061 | else
|
---|
1062 | {
|
---|
1063 | /* first guess is that it's a UUID */
|
---|
1064 | Guid uuid(hdds[1]);
|
---|
1065 | ComPtr<IHardDisk> hardDisk;
|
---|
1066 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
1067 | /* not successful? Then it must be a filename */
|
---|
1068 | if (!hardDisk)
|
---|
1069 | {
|
---|
1070 | CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[1]), hardDisk.asOutParam()));
|
---|
1071 | if (FAILED(rc))
|
---|
1072 | {
|
---|
1073 | /* open the new hard disk object */
|
---|
1074 | CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), hardDisk.asOutParam()));
|
---|
1075 | }
|
---|
1076 | }
|
---|
1077 | if (hardDisk)
|
---|
1078 | {
|
---|
1079 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
1080 | CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("IDE"), 0, 1));
|
---|
1081 | }
|
---|
1082 | else
|
---|
1083 | rc = E_FAIL;
|
---|
1084 | if (FAILED(rc))
|
---|
1085 | break;
|
---|
1086 | }
|
---|
1087 | }
|
---|
1088 | if (hdds[2])
|
---|
1089 | {
|
---|
1090 | if (strcmp(hdds[2], "none") == 0)
|
---|
1091 | {
|
---|
1092 | machine->DetachHardDisk(Bstr("IDE"), 1, 1);
|
---|
1093 | }
|
---|
1094 | else
|
---|
1095 | {
|
---|
1096 | /* first guess is that it's a UUID */
|
---|
1097 | Guid uuid(hdds[2]);
|
---|
1098 | ComPtr<IHardDisk> hardDisk;
|
---|
1099 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
1100 | /* not successful? Then it must be a filename */
|
---|
1101 | if (!hardDisk)
|
---|
1102 | {
|
---|
1103 | CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[2]), hardDisk.asOutParam()));
|
---|
1104 | if (FAILED(rc))
|
---|
1105 | {
|
---|
1106 | /* open the new hard disk object */
|
---|
1107 | CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), hardDisk.asOutParam()));
|
---|
1108 | }
|
---|
1109 | }
|
---|
1110 | if (hardDisk)
|
---|
1111 | {
|
---|
1112 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
1113 | CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("IDE"), 1, 1));
|
---|
1114 | }
|
---|
1115 | else
|
---|
1116 | rc = E_FAIL;
|
---|
1117 | if (FAILED(rc))
|
---|
1118 | break;
|
---|
1119 | }
|
---|
1120 | }
|
---|
1121 | if (dvd)
|
---|
1122 | {
|
---|
1123 | ComPtr<IDVDDrive> dvdDrive;
|
---|
1124 | machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
|
---|
1125 | ASSERT(dvdDrive);
|
---|
1126 |
|
---|
1127 | /* unmount? */
|
---|
1128 | if (strcmp(dvd, "none") == 0)
|
---|
1129 | {
|
---|
1130 | CHECK_ERROR(dvdDrive, Unmount());
|
---|
1131 | }
|
---|
1132 | /* host drive? */
|
---|
1133 | else if (strncmp(dvd, "host:", 5) == 0)
|
---|
1134 | {
|
---|
1135 | ComPtr<IHost> host;
|
---|
1136 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1137 | com::SafeIfaceArray <IHostDVDDrive> hostDVDs;
|
---|
1138 | rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs));
|
---|
1139 |
|
---|
1140 | ComPtr<IHostDVDDrive> hostDVDDrive;
|
---|
1141 | rc = host->FindHostDVDDrive(Bstr(dvd + 5), hostDVDDrive.asOutParam());
|
---|
1142 | if (!hostDVDDrive)
|
---|
1143 | {
|
---|
1144 | /* 2nd try: try with the real name, important on Linux+libhal */
|
---|
1145 | char szPathReal[RTPATH_MAX];
|
---|
1146 | if (RT_FAILURE(RTPathReal(dvd + 5, szPathReal, sizeof(szPathReal))))
|
---|
1147 | {
|
---|
1148 | errorArgument("Invalid host DVD drive name");
|
---|
1149 | rc = E_FAIL;
|
---|
1150 | break;
|
---|
1151 | }
|
---|
1152 | rc = host->FindHostDVDDrive(Bstr(szPathReal), hostDVDDrive.asOutParam());
|
---|
1153 | if (!hostDVDDrive)
|
---|
1154 | {
|
---|
1155 | errorArgument("Invalid host DVD drive name");
|
---|
1156 | rc = E_FAIL;
|
---|
1157 | break;
|
---|
1158 | }
|
---|
1159 | }
|
---|
1160 | CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));
|
---|
1161 | }
|
---|
1162 | else
|
---|
1163 | {
|
---|
1164 | /* first assume it's a UUID */
|
---|
1165 | Guid uuid(dvd);
|
---|
1166 | ComPtr<IDVDImage> dvdImage;
|
---|
1167 | rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam());
|
---|
1168 | if (FAILED(rc) || !dvdImage)
|
---|
1169 | {
|
---|
1170 | /* must be a filename, check if it's in the collection */
|
---|
1171 | rc = a->virtualBox->FindDVDImage(Bstr(dvd), dvdImage.asOutParam());
|
---|
1172 | /* not registered, do that on the fly */
|
---|
1173 | if (!dvdImage)
|
---|
1174 | {
|
---|
1175 | Guid emptyUUID;
|
---|
1176 | CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(dvd), emptyUUID, dvdImage.asOutParam()));
|
---|
1177 | }
|
---|
1178 | }
|
---|
1179 | if (!dvdImage)
|
---|
1180 | {
|
---|
1181 | rc = E_FAIL;
|
---|
1182 | break;
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 | dvdImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
1186 | CHECK_ERROR(dvdDrive, MountImage(uuid));
|
---|
1187 | }
|
---|
1188 | }
|
---|
1189 | if (dvdpassthrough)
|
---|
1190 | {
|
---|
1191 | ComPtr<IDVDDrive> dvdDrive;
|
---|
1192 | machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
|
---|
1193 | ASSERT(dvdDrive);
|
---|
1194 |
|
---|
1195 | CHECK_ERROR(dvdDrive, COMSETTER(Passthrough)(strcmp(dvdpassthrough, "on") == 0));
|
---|
1196 | }
|
---|
1197 | if (idecontroller)
|
---|
1198 | {
|
---|
1199 | ComPtr<IStorageController> storageController;
|
---|
1200 | CHECK_ERROR(machine, GetStorageControllerByName(Bstr("IDE"), storageController.asOutParam()));
|
---|
1201 |
|
---|
1202 | if (RTStrICmp(idecontroller, "PIIX3") == 0)
|
---|
1203 | {
|
---|
1204 | CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3));
|
---|
1205 | }
|
---|
1206 | else if (RTStrICmp(idecontroller, "PIIX4") == 0)
|
---|
1207 | {
|
---|
1208 | CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4));
|
---|
1209 | }
|
---|
1210 | else if (RTStrICmp(idecontroller, "ICH6") == 0)
|
---|
1211 | {
|
---|
1212 | CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6));
|
---|
1213 | }
|
---|
1214 | else
|
---|
1215 | {
|
---|
1216 | errorArgument("Invalid -idecontroller argument '%s'", idecontroller);
|
---|
1217 | rc = E_FAIL;
|
---|
1218 | break;
|
---|
1219 | }
|
---|
1220 | }
|
---|
1221 | if (floppy)
|
---|
1222 | {
|
---|
1223 | ComPtr<IFloppyDrive> floppyDrive;
|
---|
1224 | machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
|
---|
1225 | ASSERT(floppyDrive);
|
---|
1226 |
|
---|
1227 | /* disable? */
|
---|
1228 | if (strcmp(floppy, "disabled") == 0)
|
---|
1229 | {
|
---|
1230 | /* disable the controller */
|
---|
1231 | CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(false));
|
---|
1232 | }
|
---|
1233 | else
|
---|
1234 | {
|
---|
1235 | /* enable the controller */
|
---|
1236 | CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(true));
|
---|
1237 |
|
---|
1238 | /* unmount? */
|
---|
1239 | if (strcmp(floppy, "empty") == 0)
|
---|
1240 | {
|
---|
1241 | CHECK_ERROR(floppyDrive, Unmount());
|
---|
1242 | }
|
---|
1243 | /* host drive? */
|
---|
1244 | else if (strncmp(floppy, "host:", 5) == 0)
|
---|
1245 | {
|
---|
1246 | ComPtr<IHost> host;
|
---|
1247 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1248 | com::SafeIfaceArray <IHostFloppyDrive> hostFloppies;
|
---|
1249 | CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(hostFloppies)));
|
---|
1250 | ComPtr<IHostFloppyDrive> hostFloppyDrive;
|
---|
1251 | rc = host->FindHostFloppyDrive(Bstr(floppy + 5), hostFloppyDrive.asOutParam());
|
---|
1252 | if (!hostFloppyDrive)
|
---|
1253 | {
|
---|
1254 | errorArgument("Invalid host floppy drive name");
|
---|
1255 | rc = E_FAIL;
|
---|
1256 | break;
|
---|
1257 | }
|
---|
1258 | CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));
|
---|
1259 | }
|
---|
1260 | else
|
---|
1261 | {
|
---|
1262 | /* first assume it's a UUID */
|
---|
1263 | Guid uuid(floppy);
|
---|
1264 | ComPtr<IFloppyImage> floppyImage;
|
---|
1265 | rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam());
|
---|
1266 | if (FAILED(rc) || !floppyImage)
|
---|
1267 | {
|
---|
1268 | /* must be a filename, check if it's in the collection */
|
---|
1269 | rc = a->virtualBox->FindFloppyImage(Bstr(floppy), floppyImage.asOutParam());
|
---|
1270 | /* not registered, do that on the fly */
|
---|
1271 | if (!floppyImage)
|
---|
1272 | {
|
---|
1273 | Guid emptyUUID;
|
---|
1274 | CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(floppy), emptyUUID, floppyImage.asOutParam()));
|
---|
1275 | }
|
---|
1276 | }
|
---|
1277 | if (!floppyImage)
|
---|
1278 | {
|
---|
1279 | rc = E_FAIL;
|
---|
1280 | break;
|
---|
1281 | }
|
---|
1282 |
|
---|
1283 | floppyImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
1284 | CHECK_ERROR(floppyDrive, MountImage(uuid));
|
---|
1285 | }
|
---|
1286 | }
|
---|
1287 | }
|
---|
1288 | if (audio || audiocontroller)
|
---|
1289 | {
|
---|
1290 | ComPtr<IAudioAdapter> audioAdapter;
|
---|
1291 | machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
|
---|
1292 | ASSERT(audioAdapter);
|
---|
1293 |
|
---|
1294 | if (audio)
|
---|
1295 | {
|
---|
1296 | /* disable? */
|
---|
1297 | if (strcmp(audio, "none") == 0)
|
---|
1298 | {
|
---|
1299 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
|
---|
1300 | }
|
---|
1301 | else if (strcmp(audio, "null") == 0)
|
---|
1302 | {
|
---|
1303 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));
|
---|
1304 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1305 | }
|
---|
1306 | #ifdef RT_OS_WINDOWS
|
---|
1307 | #ifdef VBOX_WITH_WINMM
|
---|
1308 | else if (strcmp(audio, "winmm") == 0)
|
---|
1309 | {
|
---|
1310 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));
|
---|
1311 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1312 | }
|
---|
1313 | #endif
|
---|
1314 | else if (strcmp(audio, "dsound") == 0)
|
---|
1315 | {
|
---|
1316 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
|
---|
1317 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1318 | }
|
---|
1319 | #endif /* RT_OS_WINDOWS */
|
---|
1320 | #ifdef RT_OS_LINUX
|
---|
1321 | else if (strcmp(audio, "oss") == 0)
|
---|
1322 | {
|
---|
1323 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
|
---|
1324 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1325 | }
|
---|
1326 | # ifdef VBOX_WITH_ALSA
|
---|
1327 | else if (strcmp(audio, "alsa") == 0)
|
---|
1328 | {
|
---|
1329 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));
|
---|
1330 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1331 | }
|
---|
1332 | # endif
|
---|
1333 | # ifdef VBOX_WITH_PULSE
|
---|
1334 | else if (strcmp(audio, "pulse") == 0)
|
---|
1335 | {
|
---|
1336 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
|
---|
1337 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1338 | }
|
---|
1339 | # endif
|
---|
1340 | #endif /* !RT_OS_LINUX */
|
---|
1341 | #ifdef RT_OS_SOLARIS
|
---|
1342 | else if (strcmp(audio, "solaudio") == 0)
|
---|
1343 | {
|
---|
1344 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio));
|
---|
1345 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | #endif /* !RT_OS_SOLARIS */
|
---|
1349 | #ifdef RT_OS_DARWIN
|
---|
1350 | else if (strcmp(audio, "coreaudio") == 0)
|
---|
1351 | {
|
---|
1352 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));
|
---|
1353 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1354 | }
|
---|
1355 |
|
---|
1356 | #endif /* !RT_OS_DARWIN */
|
---|
1357 | else
|
---|
1358 | {
|
---|
1359 | errorArgument("Invalid -audio argument '%s'", audio);
|
---|
1360 | rc = E_FAIL;
|
---|
1361 | break;
|
---|
1362 | }
|
---|
1363 | }
|
---|
1364 | if (audiocontroller)
|
---|
1365 | {
|
---|
1366 | if (strcmp(audiocontroller, "sb16") == 0)
|
---|
1367 | CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));
|
---|
1368 | else if (strcmp(audiocontroller, "ac97") == 0)
|
---|
1369 | CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));
|
---|
1370 | else
|
---|
1371 | {
|
---|
1372 | errorArgument("Invalid -audiocontroller argument '%s'", audiocontroller);
|
---|
1373 | rc = E_FAIL;
|
---|
1374 | break;
|
---|
1375 | }
|
---|
1376 | }
|
---|
1377 | }
|
---|
1378 | /* Shared clipboard state */
|
---|
1379 | if (clipboard)
|
---|
1380 | {
|
---|
1381 | /* ComPtr<IClipboardMode> clipboardMode;
|
---|
1382 | machine->COMGETTER(ClipboardMode)(clipboardMode.asOutParam());
|
---|
1383 | ASSERT(clipboardMode);
|
---|
1384 | */
|
---|
1385 | if (strcmp(clipboard, "disabled") == 0)
|
---|
1386 | {
|
---|
1387 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled));
|
---|
1388 | }
|
---|
1389 | else if (strcmp(clipboard, "hosttoguest") == 0)
|
---|
1390 | {
|
---|
1391 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest));
|
---|
1392 | }
|
---|
1393 | else if (strcmp(clipboard, "guesttohost") == 0)
|
---|
1394 | {
|
---|
1395 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost));
|
---|
1396 | }
|
---|
1397 | else if (strcmp(clipboard, "bidirectional") == 0)
|
---|
1398 | {
|
---|
1399 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional));
|
---|
1400 | }
|
---|
1401 | else
|
---|
1402 | {
|
---|
1403 | errorArgument("Invalid -clipboard argument '%s'", clipboard);
|
---|
1404 | rc = E_FAIL;
|
---|
1405 | break;
|
---|
1406 | }
|
---|
1407 | }
|
---|
1408 | /* iterate through all possible NICs */
|
---|
1409 | for (ULONG n = 0; n < NetworkAdapterCount; n ++)
|
---|
1410 | {
|
---|
1411 | ComPtr<INetworkAdapter> nic;
|
---|
1412 | CHECK_ERROR_RET (machine, GetNetworkAdapter (n, nic.asOutParam()), 1);
|
---|
1413 |
|
---|
1414 | ASSERT(nic);
|
---|
1415 |
|
---|
1416 | /* something about the NIC? */
|
---|
1417 | if (nics[n])
|
---|
1418 | {
|
---|
1419 | if (strcmp(nics[n], "none") == 0)
|
---|
1420 | {
|
---|
1421 | CHECK_ERROR_RET(nic, COMSETTER(Enabled) (FALSE), 1);
|
---|
1422 | }
|
---|
1423 | else if (strcmp(nics[n], "null") == 0)
|
---|
1424 | {
|
---|
1425 | CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
|
---|
1426 | CHECK_ERROR_RET(nic, Detach(), 1);
|
---|
1427 | }
|
---|
1428 | else if (strcmp(nics[n], "nat") == 0)
|
---|
1429 | {
|
---|
1430 | CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
|
---|
1431 | CHECK_ERROR_RET(nic, AttachToNAT(), 1);
|
---|
1432 | }
|
---|
1433 | else if ( strcmp(nics[n], "bridged") == 0
|
---|
1434 | || strcmp(nics[n], "hostif") == 0) /* backward compatibility */
|
---|
1435 | {
|
---|
1436 | CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
|
---|
1437 | CHECK_ERROR_RET(nic, AttachToBridgedInterface(), 1);
|
---|
1438 | }
|
---|
1439 | else if (strcmp(nics[n], "intnet") == 0)
|
---|
1440 | {
|
---|
1441 | CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
|
---|
1442 | CHECK_ERROR_RET(nic, AttachToInternalNetwork(), 1);
|
---|
1443 | }
|
---|
1444 | #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
|
---|
1445 | else if (strcmp(nics[n], "hostonly") == 0)
|
---|
1446 | {
|
---|
1447 |
|
---|
1448 | CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
|
---|
1449 | CHECK_ERROR_RET(nic, AttachToHostOnlyInterface(), 1);
|
---|
1450 | }
|
---|
1451 | #endif /* defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) */
|
---|
1452 | else
|
---|
1453 | {
|
---|
1454 | errorArgument("Invalid type '%s' specfied for NIC %lu", nics[n], n + 1);
|
---|
1455 | rc = E_FAIL;
|
---|
1456 | break;
|
---|
1457 | }
|
---|
1458 | }
|
---|
1459 |
|
---|
1460 | /* something about the NIC type? */
|
---|
1461 | if (nictype[n])
|
---|
1462 | {
|
---|
1463 | if (strcmp(nictype[n], "Am79C970A") == 0)
|
---|
1464 | {
|
---|
1465 | CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A), 1);
|
---|
1466 | }
|
---|
1467 | else if (strcmp(nictype[n], "Am79C973") == 0)
|
---|
1468 | {
|
---|
1469 | CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973), 1);
|
---|
1470 | }
|
---|
1471 | #ifdef VBOX_WITH_E1000
|
---|
1472 | else if (strcmp(nictype[n], "82540EM") == 0)
|
---|
1473 | {
|
---|
1474 | CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM), 1);
|
---|
1475 | }
|
---|
1476 | else if (strcmp(nictype[n], "82543GC") == 0)
|
---|
1477 | {
|
---|
1478 | CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC), 1);
|
---|
1479 | }
|
---|
1480 | #endif
|
---|
1481 | else
|
---|
1482 | {
|
---|
1483 | errorArgument("Invalid NIC type '%s' specified for NIC %lu", nictype[n], n + 1);
|
---|
1484 | rc = E_FAIL;
|
---|
1485 | break;
|
---|
1486 | }
|
---|
1487 | }
|
---|
1488 |
|
---|
1489 | /* something about the MAC address? */
|
---|
1490 | if (macs[n])
|
---|
1491 | {
|
---|
1492 | /* generate one? */
|
---|
1493 | if (strcmp(macs[n], "auto") == 0)
|
---|
1494 | {
|
---|
1495 | CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(NULL), 1);
|
---|
1496 | }
|
---|
1497 | else
|
---|
1498 | {
|
---|
1499 | CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(Bstr(macs[n])), 1);
|
---|
1500 | }
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | /* something about the reported link speed? */
|
---|
1504 | if (nicspeed[n])
|
---|
1505 | {
|
---|
1506 | uint32_t u32LineSpeed;
|
---|
1507 |
|
---|
1508 | u32LineSpeed = RTStrToUInt32(nicspeed[n]);
|
---|
1509 |
|
---|
1510 | if (u32LineSpeed < 1000 || u32LineSpeed > 4000000)
|
---|
1511 | {
|
---|
1512 | errorArgument("Invalid -nicspeed%lu argument '%s'", n + 1, nicspeed[n]);
|
---|
1513 | rc = E_FAIL;
|
---|
1514 | break;
|
---|
1515 | }
|
---|
1516 | CHECK_ERROR_RET(nic, COMSETTER(LineSpeed)(u32LineSpeed), 1);
|
---|
1517 | }
|
---|
1518 |
|
---|
1519 | /* the link status flag? */
|
---|
1520 | if (cableconnected[n])
|
---|
1521 | {
|
---|
1522 | if (strcmp(cableconnected[n], "on") == 0)
|
---|
1523 | {
|
---|
1524 | CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(TRUE), 1);
|
---|
1525 | }
|
---|
1526 | else if (strcmp(cableconnected[n], "off") == 0)
|
---|
1527 | {
|
---|
1528 | CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(FALSE), 1);
|
---|
1529 | }
|
---|
1530 | else
|
---|
1531 | {
|
---|
1532 | errorArgument("Invalid -cableconnected%lu argument '%s'", n + 1, cableconnected[n]);
|
---|
1533 | rc = E_FAIL;
|
---|
1534 | break;
|
---|
1535 | }
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 | /* the trace flag? */
|
---|
1539 | if (nictrace[n])
|
---|
1540 | {
|
---|
1541 | if (strcmp(nictrace[n], "on") == 0)
|
---|
1542 | {
|
---|
1543 | CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(TRUE), 1);
|
---|
1544 | }
|
---|
1545 | else if (strcmp(nictrace[n], "off") == 0)
|
---|
1546 | {
|
---|
1547 | CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(FALSE), 1);
|
---|
1548 | }
|
---|
1549 | else
|
---|
1550 | {
|
---|
1551 | errorArgument("Invalid -nictrace%lu argument '%s'", n + 1, nictrace[n]);
|
---|
1552 | rc = E_FAIL;
|
---|
1553 | break;
|
---|
1554 | }
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 | /* the tracefile flag? */
|
---|
1558 | if (nictracefile[n])
|
---|
1559 | {
|
---|
1560 | CHECK_ERROR_RET(nic, COMSETTER(TraceFile)(Bstr(nictracefile[n])), 1);
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | /* the host interface device? */
|
---|
1564 | if (hostifdev[n])
|
---|
1565 | {
|
---|
1566 | /* remove it? */
|
---|
1567 | if (strcmp(hostifdev[n], "none") == 0)
|
---|
1568 | {
|
---|
1569 | CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(NULL), 1);
|
---|
1570 | }
|
---|
1571 | else
|
---|
1572 | {
|
---|
1573 | CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(Bstr(hostifdev[n])), 1);
|
---|
1574 | }
|
---|
1575 | }
|
---|
1576 |
|
---|
1577 | /* the internal network name? */
|
---|
1578 | if (intnet[n])
|
---|
1579 | {
|
---|
1580 | /* remove it? */
|
---|
1581 | if (strcmp(intnet[n], "none") == 0)
|
---|
1582 | {
|
---|
1583 | CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(NULL), 1);
|
---|
1584 | }
|
---|
1585 | else
|
---|
1586 | {
|
---|
1587 | CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(Bstr(intnet[n])), 1);
|
---|
1588 | }
|
---|
1589 | }
|
---|
1590 | /* the network of the NAT */
|
---|
1591 | if (natnet[n])
|
---|
1592 | {
|
---|
1593 | CHECK_ERROR_RET(nic, COMSETTER(NATNetwork)(Bstr(natnet[n])), 1);
|
---|
1594 | }
|
---|
1595 | }
|
---|
1596 | if (FAILED(rc))
|
---|
1597 | break;
|
---|
1598 |
|
---|
1599 | /* iterate through all possible serial ports */
|
---|
1600 | for (ULONG n = 0; n < SerialPortCount; n ++)
|
---|
1601 | {
|
---|
1602 | ComPtr<ISerialPort> uart;
|
---|
1603 | CHECK_ERROR_RET (machine, GetSerialPort (n, uart.asOutParam()), 1);
|
---|
1604 |
|
---|
1605 | ASSERT(uart);
|
---|
1606 |
|
---|
1607 | if (uarts_base[n])
|
---|
1608 | {
|
---|
1609 | if (uarts_base[n] == (ULONG)-1)
|
---|
1610 | {
|
---|
1611 | CHECK_ERROR_RET(uart, COMSETTER(Enabled) (FALSE), 1);
|
---|
1612 | }
|
---|
1613 | else
|
---|
1614 | {
|
---|
1615 | CHECK_ERROR_RET(uart, COMSETTER(IOBase) (uarts_base[n]), 1);
|
---|
1616 | CHECK_ERROR_RET(uart, COMSETTER(IRQ) (uarts_irq[n]), 1);
|
---|
1617 | CHECK_ERROR_RET(uart, COMSETTER(Enabled) (TRUE), 1);
|
---|
1618 | }
|
---|
1619 | }
|
---|
1620 | if (uarts_mode[n])
|
---|
1621 | {
|
---|
1622 | if (strcmp(uarts_mode[n], "disconnected") == 0)
|
---|
1623 | {
|
---|
1624 | CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_Disconnected), 1);
|
---|
1625 | }
|
---|
1626 | else
|
---|
1627 | {
|
---|
1628 | CHECK_ERROR_RET(uart, COMSETTER(Path) (Bstr(uarts_path[n])), 1);
|
---|
1629 | if (strcmp(uarts_mode[n], "server") == 0)
|
---|
1630 | {
|
---|
1631 | CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1);
|
---|
1632 | CHECK_ERROR_RET(uart, COMSETTER(Server) (TRUE), 1);
|
---|
1633 | }
|
---|
1634 | else if (strcmp(uarts_mode[n], "client") == 0)
|
---|
1635 | {
|
---|
1636 | CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipe), 1);
|
---|
1637 | CHECK_ERROR_RET(uart, COMSETTER(Server) (FALSE), 1);
|
---|
1638 | }
|
---|
1639 | else
|
---|
1640 | {
|
---|
1641 | CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostDevice), 1);
|
---|
1642 | }
|
---|
1643 | }
|
---|
1644 | }
|
---|
1645 | }
|
---|
1646 | if (FAILED(rc))
|
---|
1647 | break;
|
---|
1648 |
|
---|
1649 | #ifdef VBOX_WITH_VRDP
|
---|
1650 | if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon || vrdpreusecon)
|
---|
1651 | {
|
---|
1652 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1653 | machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1654 | ASSERT(vrdpServer);
|
---|
1655 | if (vrdpServer)
|
---|
1656 | {
|
---|
1657 | if (vrdp)
|
---|
1658 | {
|
---|
1659 | if (strcmp(vrdp, "on") == 0)
|
---|
1660 | {
|
---|
1661 | CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(true));
|
---|
1662 | }
|
---|
1663 | else if (strcmp(vrdp, "off") == 0)
|
---|
1664 | {
|
---|
1665 | CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(false));
|
---|
1666 | }
|
---|
1667 | else
|
---|
1668 | {
|
---|
1669 | errorArgument("Invalid -vrdp argument '%s'", vrdp);
|
---|
1670 | rc = E_FAIL;
|
---|
1671 | break;
|
---|
1672 | }
|
---|
1673 | }
|
---|
1674 | if (vrdpport != UINT16_MAX)
|
---|
1675 | {
|
---|
1676 | CHECK_ERROR(vrdpServer, COMSETTER(Port)(vrdpport));
|
---|
1677 | }
|
---|
1678 | if (vrdpaddress)
|
---|
1679 | {
|
---|
1680 | CHECK_ERROR(vrdpServer, COMSETTER(NetAddress)(Bstr(vrdpaddress)));
|
---|
1681 | }
|
---|
1682 | if (vrdpauthtype)
|
---|
1683 | {
|
---|
1684 | if (strcmp(vrdpauthtype, "null") == 0)
|
---|
1685 | {
|
---|
1686 | CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Null));
|
---|
1687 | }
|
---|
1688 | else if (strcmp(vrdpauthtype, "external") == 0)
|
---|
1689 | {
|
---|
1690 | CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_External));
|
---|
1691 | }
|
---|
1692 | else if (strcmp(vrdpauthtype, "guest") == 0)
|
---|
1693 | {
|
---|
1694 | CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Guest));
|
---|
1695 | }
|
---|
1696 | else
|
---|
1697 | {
|
---|
1698 | errorArgument("Invalid -vrdpauthtype argument '%s'", vrdpauthtype);
|
---|
1699 | rc = E_FAIL;
|
---|
1700 | break;
|
---|
1701 | }
|
---|
1702 | }
|
---|
1703 | if (vrdpmulticon)
|
---|
1704 | {
|
---|
1705 | if (strcmp(vrdpmulticon, "on") == 0)
|
---|
1706 | {
|
---|
1707 | CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(true));
|
---|
1708 | }
|
---|
1709 | else if (strcmp(vrdpmulticon, "off") == 0)
|
---|
1710 | {
|
---|
1711 | CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(false));
|
---|
1712 | }
|
---|
1713 | else
|
---|
1714 | {
|
---|
1715 | errorArgument("Invalid -vrdpmulticon argument '%s'", vrdpmulticon);
|
---|
1716 | rc = E_FAIL;
|
---|
1717 | break;
|
---|
1718 | }
|
---|
1719 | }
|
---|
1720 | if (vrdpreusecon)
|
---|
1721 | {
|
---|
1722 | if (strcmp(vrdpreusecon, "on") == 0)
|
---|
1723 | {
|
---|
1724 | CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(true));
|
---|
1725 | }
|
---|
1726 | else if (strcmp(vrdpreusecon, "off") == 0)
|
---|
1727 | {
|
---|
1728 | CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(false));
|
---|
1729 | }
|
---|
1730 | else
|
---|
1731 | {
|
---|
1732 | errorArgument("Invalid -vrdpreusecon argument '%s'", vrdpreusecon);
|
---|
1733 | rc = E_FAIL;
|
---|
1734 | break;
|
---|
1735 | }
|
---|
1736 | }
|
---|
1737 | }
|
---|
1738 | }
|
---|
1739 | #endif /* VBOX_WITH_VRDP */
|
---|
1740 |
|
---|
1741 | /*
|
---|
1742 | * USB enable/disable
|
---|
1743 | */
|
---|
1744 | if (fUsbEnabled != -1)
|
---|
1745 | {
|
---|
1746 | ComPtr<IUSBController> UsbCtl;
|
---|
1747 | CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
|
---|
1748 | if (SUCCEEDED(rc))
|
---|
1749 | {
|
---|
1750 | CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(!!fUsbEnabled));
|
---|
1751 | }
|
---|
1752 | }
|
---|
1753 | /*
|
---|
1754 | * USB EHCI enable/disable
|
---|
1755 | */
|
---|
1756 | if (fUsbEhciEnabled != -1)
|
---|
1757 | {
|
---|
1758 | ComPtr<IUSBController> UsbCtl;
|
---|
1759 | CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
|
---|
1760 | if (SUCCEEDED(rc))
|
---|
1761 | {
|
---|
1762 | CHECK_ERROR(UsbCtl, COMSETTER(EnabledEhci)(!!fUsbEhciEnabled));
|
---|
1763 | }
|
---|
1764 | }
|
---|
1765 |
|
---|
1766 | if (snapshotFolder)
|
---|
1767 | {
|
---|
1768 | if (strcmp(snapshotFolder, "default") == 0)
|
---|
1769 | {
|
---|
1770 | CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(NULL));
|
---|
1771 | }
|
---|
1772 | else
|
---|
1773 | {
|
---|
1774 | CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(snapshotFolder)));
|
---|
1775 | }
|
---|
1776 | }
|
---|
1777 |
|
---|
1778 | if (guestMemBalloonSize != (ULONG)-1)
|
---|
1779 | CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(guestMemBalloonSize));
|
---|
1780 |
|
---|
1781 | if (guestStatInterval != (ULONG)-1)
|
---|
1782 | CHECK_ERROR(machine, COMSETTER(StatisticsUpdateInterval)(guestStatInterval));
|
---|
1783 |
|
---|
1784 | /*
|
---|
1785 | * SATA controller enable/disable
|
---|
1786 | */
|
---|
1787 | if (fSataEnabled != -1)
|
---|
1788 | {
|
---|
1789 | if (fSataEnabled)
|
---|
1790 | {
|
---|
1791 | ComPtr<IStorageController> ctl;
|
---|
1792 | CHECK_ERROR(machine, AddStorageController(Bstr("SATA"), StorageBus_SATA, ctl.asOutParam()));
|
---|
1793 | CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci));
|
---|
1794 | }
|
---|
1795 | else
|
---|
1796 | CHECK_ERROR(machine, RemoveStorageController(Bstr("SATA")));
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 | for (uint32_t i = 4; i < 34; i++)
|
---|
1800 | {
|
---|
1801 | if (hdds[i])
|
---|
1802 | {
|
---|
1803 | if (strcmp(hdds[i], "none") == 0)
|
---|
1804 | {
|
---|
1805 | machine->DetachHardDisk(Bstr("SATA"), i-4, 0);
|
---|
1806 | }
|
---|
1807 | else
|
---|
1808 | {
|
---|
1809 | /* first guess is that it's a UUID */
|
---|
1810 | Guid uuid(hdds[i]);
|
---|
1811 | ComPtr<IHardDisk> hardDisk;
|
---|
1812 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
1813 | /* not successful? Then it must be a filename */
|
---|
1814 | if (!hardDisk)
|
---|
1815 | {
|
---|
1816 | CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
|
---|
1817 | if (FAILED(rc))
|
---|
1818 | {
|
---|
1819 | /* open the new hard disk object */
|
---|
1820 | CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
|
---|
1821 | }
|
---|
1822 | }
|
---|
1823 | if (hardDisk)
|
---|
1824 | {
|
---|
1825 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
1826 | CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("SATA"), i-4, 0));
|
---|
1827 | }
|
---|
1828 | else
|
---|
1829 | rc = E_FAIL;
|
---|
1830 | if (FAILED(rc))
|
---|
1831 | break;
|
---|
1832 | }
|
---|
1833 | }
|
---|
1834 | }
|
---|
1835 |
|
---|
1836 | for (uint32_t i = 0; i < 4; i++)
|
---|
1837 | {
|
---|
1838 | if (sataBootDevices[i] != -1)
|
---|
1839 | {
|
---|
1840 | ComPtr<IStorageController> SataCtl;
|
---|
1841 | CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam()));
|
---|
1842 | if (SUCCEEDED(rc))
|
---|
1843 | {
|
---|
1844 | CHECK_ERROR(SataCtl, SetIDEEmulationPort(i, sataBootDevices[i]));
|
---|
1845 | }
|
---|
1846 | }
|
---|
1847 | }
|
---|
1848 |
|
---|
1849 | if (sataPortCount != -1)
|
---|
1850 | {
|
---|
1851 | ComPtr<IStorageController> SataCtl;
|
---|
1852 | CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam()));
|
---|
1853 | if (SUCCEEDED(rc))
|
---|
1854 | {
|
---|
1855 | CHECK_ERROR(SataCtl, COMSETTER(PortCount)(sataPortCount));
|
---|
1856 | }
|
---|
1857 | }
|
---|
1858 |
|
---|
1859 | /*
|
---|
1860 | * LsiLogic controller enable/disable
|
---|
1861 | */
|
---|
1862 | if (fLsiLogicEnabled != -1)
|
---|
1863 | {
|
---|
1864 | if (fLsiLogicEnabled)
|
---|
1865 | {
|
---|
1866 | ComPtr<IStorageController> ctl;
|
---|
1867 | CHECK_ERROR(machine, AddStorageController(Bstr("LsiLogic"), StorageBus_SCSI, ctl.asOutParam()));
|
---|
1868 | CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic));
|
---|
1869 | }
|
---|
1870 | else
|
---|
1871 | CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic")));
|
---|
1872 | }
|
---|
1873 |
|
---|
1874 | for (uint32_t i = 34; i < 50; i++)
|
---|
1875 | {
|
---|
1876 | if (hdds[i])
|
---|
1877 | {
|
---|
1878 | if (strcmp(hdds[i], "none") == 0)
|
---|
1879 | {
|
---|
1880 | machine->DetachHardDisk(Bstr("LsiLogic"), i-34, 0);
|
---|
1881 | }
|
---|
1882 | else
|
---|
1883 | {
|
---|
1884 | /* first guess is that it's a UUID */
|
---|
1885 | Guid uuid(hdds[i]);
|
---|
1886 | ComPtr<IHardDisk> hardDisk;
|
---|
1887 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
1888 | /* not successful? Then it must be a filename */
|
---|
1889 | if (!hardDisk)
|
---|
1890 | {
|
---|
1891 | CHECK_ERROR(a->virtualBox, FindHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
|
---|
1892 | if (FAILED(rc))
|
---|
1893 | {
|
---|
1894 | /* open the new hard disk object */
|
---|
1895 | CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));
|
---|
1896 | }
|
---|
1897 | }
|
---|
1898 | if (hardDisk)
|
---|
1899 | {
|
---|
1900 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
1901 | CHECK_ERROR(machine, AttachHardDisk(uuid, Bstr("LsiLogic"), i-34, 0));
|
---|
1902 | }
|
---|
1903 | else
|
---|
1904 | rc = E_FAIL;
|
---|
1905 | if (FAILED(rc))
|
---|
1906 | break;
|
---|
1907 | }
|
---|
1908 | }
|
---|
1909 | }
|
---|
1910 |
|
---|
1911 | /* commit changes */
|
---|
1912 | CHECK_ERROR(machine, SaveSettings());
|
---|
1913 | }
|
---|
1914 | while (0);
|
---|
1915 |
|
---|
1916 | /* it's important to always close sessions */
|
---|
1917 | a->session->Close();
|
---|
1918 |
|
---|
1919 | return SUCCEEDED(rc) ? 0 : 1;
|
---|
1920 | }
|
---|
1921 |
|
---|
1922 | #endif /* !VBOX_ONLY_DOCS */
|
---|