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