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