VirtualBox

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

Last change on this file since 23928 was 23928, checked in by vboxsync, 15 years ago

API: make necessary adjustments to support DVD passthrough again, together with the necessary client code changes. Unfortunately it is not possible to define the API in the ideal way due to how settings are handled in MachineImpl.cpp.

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

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