VirtualBox

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

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

VBoxManage: proper handling of VRDP options for OSE

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