VirtualBox

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

Last change on this file since 34878 was 34574, checked in by vboxsync, 14 years ago

Make vrde auth library configurable per VM.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 88.4 KB
Line 
1/* $Id: VBoxManageModifyVM.cpp 34574 2010-12-01 15:01:02Z vboxsync $ */
2/** @file
3 * VBoxManage - Implementation of modifyvm command.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
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
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#ifndef VBOX_ONLY_DOCS
22#include <VBox/com/com.h>
23#include <VBox/com/array.h>
24#include <VBox/com/ErrorInfo.h>
25#include <VBox/com/errorprint.h>
26#include <VBox/com/EventQueue.h>
27
28#include <VBox/com/VirtualBox.h>
29#endif /* !VBOX_ONLY_DOCS */
30
31#include <iprt/cidr.h>
32#include <iprt/param.h>
33#include <iprt/path.h>
34#include <iprt/stream.h>
35#include <iprt/string.h>
36#include <iprt/getopt.h>
37#include <VBox/log.h>
38
39#include "VBoxManage.h"
40
41#ifndef VBOX_ONLY_DOCS
42using namespace com;
43
44
45/** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */
46#if defined(_MSC_VER)
47# pragma optimize("g", off)
48#endif
49
50enum
51{
52 MODIFYVM_NAME = 1000,
53 MODIFYVM_OSTYPE,
54 MODIFYVM_MEMORY,
55 MODIFYVM_PAGEFUSION,
56 MODIFYVM_VRAM,
57 MODIFYVM_FIRMWARE,
58 MODIFYVM_ACPI,
59 MODIFYVM_IOAPIC,
60 MODIFYVM_PAE,
61 MODIFYVM_SYNTHCPU,
62 MODIFYVM_HWVIRTEX,
63 MODIFYVM_HWVIRTEXEXCLUSIVE,
64 MODIFYVM_NESTEDPAGING,
65 MODIFYVM_LARGEPAGES,
66 MODIFYVM_VTXVPID,
67 MODIFYVM_CPUS,
68 MODIFYVM_CPUHOTPLUG,
69 MODIFYVM_PLUGCPU,
70 MODIFYVM_UNPLUGCPU,
71 MODIFYVM_SETCPUID,
72 MODIFYVM_DELCPUID,
73 MODIFYVM_DELALLCPUID,
74 MODIFYVM_MONITORCOUNT,
75 MODIFYVM_ACCELERATE3D,
76#ifdef VBOX_WITH_VIDEOHWACCEL
77 MODIFYVM_ACCELERATE2DVIDEO,
78#endif
79 MODIFYVM_BIOSLOGOFADEIN,
80 MODIFYVM_BIOSLOGOFADEOUT,
81 MODIFYVM_BIOSLOGODISPLAYTIME,
82 MODIFYVM_BIOSLOGOIMAGEPATH,
83 MODIFYVM_BIOSBOOTMENU,
84 MODIFYVM_BIOSSYSTEMTIMEOFFSET,
85 MODIFYVM_BIOSPXEDEBUG,
86 MODIFYVM_BOOT,
87 MODIFYVM_HDA, // deprecated
88 MODIFYVM_HDB, // deprecated
89 MODIFYVM_HDD, // deprecated
90 MODIFYVM_IDECONTROLLER, // deprecated
91 MODIFYVM_SATAIDEEMULATION, // deprecated
92 MODIFYVM_SATAPORTCOUNT, // deprecated
93 MODIFYVM_SATAPORT, // deprecated
94 MODIFYVM_SATA, // deprecated
95 MODIFYVM_SCSIPORT, // deprecated
96 MODIFYVM_SCSITYPE, // deprecated
97 MODIFYVM_SCSI, // deprecated
98 MODIFYVM_DVDPASSTHROUGH, // deprecated
99 MODIFYVM_DVD, // deprecated
100 MODIFYVM_FLOPPY, // deprecated
101 MODIFYVM_NICTRACEFILE,
102 MODIFYVM_NICTRACE,
103 MODIFYVM_NICTYPE,
104 MODIFYVM_NICSPEED,
105 MODIFYVM_NICBOOTPRIO,
106 MODIFYVM_NIC,
107 MODIFYVM_CABLECONNECTED,
108 MODIFYVM_BRIDGEADAPTER,
109 MODIFYVM_HOSTONLYADAPTER,
110 MODIFYVM_INTNET,
111 MODIFYVM_NATNET,
112#ifdef VBOX_WITH_VDE
113 MODIFYVM_VDENET,
114#endif
115 MODIFYVM_NATBINDIP,
116 MODIFYVM_NATSETTINGS,
117 MODIFYVM_NATPF,
118 MODIFYVM_NATALIASMODE,
119 MODIFYVM_NATTFTPPREFIX,
120 MODIFYVM_NATTFTPFILE,
121 MODIFYVM_NATTFTPSERVER,
122 MODIFYVM_NATDNSPASSDOMAIN,
123 MODIFYVM_NATDNSPROXY,
124 MODIFYVM_NATDNSHOSTRESOLVER,
125 MODIFYVM_MACADDRESS,
126 MODIFYVM_HIDPTR,
127 MODIFYVM_HIDKBD,
128 MODIFYVM_UARTMODE,
129 MODIFYVM_UART,
130 MODIFYVM_GUESTMEMORYBALLOON,
131 MODIFYVM_AUDIOCONTROLLER,
132 MODIFYVM_AUDIO,
133 MODIFYVM_CLIPBOARD,
134 MODIFYVM_VRDPPORT, /* VRDE: deprecated */
135 MODIFYVM_VRDPADDRESS, /* VRDE: deprecated */
136 MODIFYVM_VRDPAUTHTYPE, /* VRDE: deprecated */
137 MODIFYVM_VRDPMULTICON, /* VRDE: deprecated */
138 MODIFYVM_VRDPREUSECON, /* VRDE: deprecated */
139 MODIFYVM_VRDPVIDEOCHANNEL, /* VRDE: deprecated */
140 MODIFYVM_VRDPVIDEOCHANNELQUALITY, /* VRDE: deprecated */
141 MODIFYVM_VRDP, /* VRDE: deprecated */
142 MODIFYVM_VRDEPROPERTY,
143 MODIFYVM_VRDEAUTHTYPE,
144 MODIFYVM_VRDEAUTHLIBRARY,
145 MODIFYVM_VRDEMULTICON,
146 MODIFYVM_VRDEREUSECON,
147 MODIFYVM_VRDEVIDEOCHANNEL,
148 MODIFYVM_VRDEVIDEOCHANNELQUALITY,
149 MODIFYVM_VRDE_EXTPACK,
150 MODIFYVM_VRDE,
151 MODIFYVM_RTCUSEUTC,
152 MODIFYVM_USBEHCI,
153 MODIFYVM_USB,
154 MODIFYVM_SNAPSHOTFOLDER,
155 MODIFYVM_TELEPORTER_ENABLED,
156 MODIFYVM_TELEPORTER_PORT,
157 MODIFYVM_TELEPORTER_ADDRESS,
158 MODIFYVM_TELEPORTER_PASSWORD,
159 MODIFYVM_HARDWARE_UUID,
160 MODIFYVM_HPET,
161 MODIFYVM_IOCACHE,
162 MODIFYVM_IOCACHESIZE,
163 MODIFYVM_FAULT_TOLERANCE,
164 MODIFYVM_FAULT_TOLERANCE_ADDRESS,
165 MODIFYVM_FAULT_TOLERANCE_PORT,
166 MODIFYVM_FAULT_TOLERANCE_PASSWORD,
167 MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL,
168 MODIFYVM_CPU_EXECTUION_CAP,
169 MODIFYVM_CHIPSET
170};
171
172static const RTGETOPTDEF g_aModifyVMOptions[] =
173{
174 { "--name", MODIFYVM_NAME, RTGETOPT_REQ_STRING },
175 { "--ostype", MODIFYVM_OSTYPE, RTGETOPT_REQ_STRING },
176 { "--memory", MODIFYVM_MEMORY, RTGETOPT_REQ_UINT32 },
177 { "--pagefusion", MODIFYVM_PAGEFUSION, RTGETOPT_REQ_BOOL_ONOFF },
178 { "--vram", MODIFYVM_VRAM, RTGETOPT_REQ_UINT32 },
179 { "--firmware", MODIFYVM_FIRMWARE, RTGETOPT_REQ_STRING },
180 { "--acpi", MODIFYVM_ACPI, RTGETOPT_REQ_BOOL_ONOFF },
181 { "--ioapic", MODIFYVM_IOAPIC, RTGETOPT_REQ_BOOL_ONOFF },
182 { "--pae", MODIFYVM_PAE, RTGETOPT_REQ_BOOL_ONOFF },
183 { "--synthcpu", MODIFYVM_SYNTHCPU, RTGETOPT_REQ_BOOL_ONOFF },
184 { "--hwvirtex", MODIFYVM_HWVIRTEX, RTGETOPT_REQ_BOOL_ONOFF },
185 { "--hwvirtexexcl", MODIFYVM_HWVIRTEXEXCLUSIVE, RTGETOPT_REQ_BOOL_ONOFF },
186 { "--nestedpaging", MODIFYVM_NESTEDPAGING, RTGETOPT_REQ_BOOL_ONOFF },
187 { "--largepages", MODIFYVM_LARGEPAGES, RTGETOPT_REQ_BOOL_ONOFF },
188 { "--vtxvpid", MODIFYVM_VTXVPID, RTGETOPT_REQ_BOOL_ONOFF },
189 { "--cpuidset", MODIFYVM_SETCPUID, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX},
190 { "--cpuidremove", MODIFYVM_DELCPUID, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX},
191 { "--cpuidremoveall", MODIFYVM_DELALLCPUID, RTGETOPT_REQ_NOTHING},
192 { "--cpus", MODIFYVM_CPUS, RTGETOPT_REQ_UINT32 },
193 { "--cpuhotplug", MODIFYVM_CPUHOTPLUG, RTGETOPT_REQ_BOOL_ONOFF },
194 { "--plugcpu", MODIFYVM_PLUGCPU, RTGETOPT_REQ_UINT32 },
195 { "--unplugcpu", MODIFYVM_UNPLUGCPU, RTGETOPT_REQ_UINT32 },
196 { "--cpuexecutioncap", MODIFYVM_CPU_EXECTUION_CAP, RTGETOPT_REQ_UINT32 },
197 { "--rtcuseutc", MODIFYVM_RTCUSEUTC, RTGETOPT_REQ_BOOL_ONOFF },
198 { "--monitorcount", MODIFYVM_MONITORCOUNT, RTGETOPT_REQ_UINT32 },
199 { "--accelerate3d", MODIFYVM_ACCELERATE3D, RTGETOPT_REQ_BOOL_ONOFF },
200#ifdef VBOX_WITH_VIDEOHWACCEL
201 { "--accelerate2dvideo", MODIFYVM_ACCELERATE2DVIDEO, RTGETOPT_REQ_BOOL_ONOFF },
202#endif
203 { "--bioslogofadein", MODIFYVM_BIOSLOGOFADEIN, RTGETOPT_REQ_BOOL_ONOFF },
204 { "--bioslogofadeout", MODIFYVM_BIOSLOGOFADEOUT, RTGETOPT_REQ_BOOL_ONOFF },
205 { "--bioslogodisplaytime", MODIFYVM_BIOSLOGODISPLAYTIME, RTGETOPT_REQ_UINT32 },
206 { "--bioslogoimagepath", MODIFYVM_BIOSLOGOIMAGEPATH, RTGETOPT_REQ_STRING },
207 { "--biosbootmenu", MODIFYVM_BIOSBOOTMENU, RTGETOPT_REQ_STRING },
208 { "--biossystemtimeoffset", MODIFYVM_BIOSSYSTEMTIMEOFFSET, RTGETOPT_REQ_INT64 },
209 { "--biospxedebug", MODIFYVM_BIOSPXEDEBUG, RTGETOPT_REQ_BOOL_ONOFF },
210 { "--boot", MODIFYVM_BOOT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
211 { "--hda", MODIFYVM_HDA, RTGETOPT_REQ_STRING },
212 { "--hdb", MODIFYVM_HDB, RTGETOPT_REQ_STRING },
213 { "--hdd", MODIFYVM_HDD, RTGETOPT_REQ_STRING },
214 { "--idecontroller", MODIFYVM_IDECONTROLLER, RTGETOPT_REQ_STRING },
215 { "--sataideemulation", MODIFYVM_SATAIDEEMULATION, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
216 { "--sataportcount", MODIFYVM_SATAPORTCOUNT, RTGETOPT_REQ_UINT32 },
217 { "--sataport", MODIFYVM_SATAPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
218 { "--sata", MODIFYVM_SATA, RTGETOPT_REQ_STRING },
219 { "--scsiport", MODIFYVM_SCSIPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
220 { "--scsitype", MODIFYVM_SCSITYPE, RTGETOPT_REQ_STRING },
221 { "--scsi", MODIFYVM_SCSI, RTGETOPT_REQ_STRING },
222 { "--dvdpassthrough", MODIFYVM_DVDPASSTHROUGH, RTGETOPT_REQ_STRING },
223 { "--dvd", MODIFYVM_DVD, RTGETOPT_REQ_STRING },
224 { "--floppy", MODIFYVM_FLOPPY, RTGETOPT_REQ_STRING },
225 { "--nictracefile", MODIFYVM_NICTRACEFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
226 { "--nictrace", MODIFYVM_NICTRACE, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
227 { "--nictype", MODIFYVM_NICTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
228 { "--nicspeed", MODIFYVM_NICSPEED, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
229 { "--nicbootprio", MODIFYVM_NICBOOTPRIO, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
230 { "--nic", MODIFYVM_NIC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
231 { "--cableconnected", MODIFYVM_CABLECONNECTED, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
232 { "--bridgeadapter", MODIFYVM_BRIDGEADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
233 { "--hostonlyadapter", MODIFYVM_HOSTONLYADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
234 { "--intnet", MODIFYVM_INTNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
235 { "--natnet", MODIFYVM_NATNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
236#ifdef VBOX_WITH_VDE
237 { "--vdenet", MODIFYVM_VDENET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
238#endif
239 { "--natbindip", MODIFYVM_NATBINDIP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
240 { "--natsettings", MODIFYVM_NATSETTINGS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
241 { "--natpf", MODIFYVM_NATPF, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
242 { "--nataliasmode", MODIFYVM_NATALIASMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
243 { "--nattftpprefix", MODIFYVM_NATTFTPPREFIX, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
244 { "--nattftpfile", MODIFYVM_NATTFTPFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
245 { "--nattftpserver", MODIFYVM_NATTFTPSERVER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
246 { "--natdnspassdomain", MODIFYVM_NATDNSPASSDOMAIN, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
247 { "--natdnsproxy", MODIFYVM_NATDNSPROXY, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
248 { "--natdnshostresolver", MODIFYVM_NATDNSHOSTRESOLVER, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
249 { "--macaddress", MODIFYVM_MACADDRESS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
250 { "--mouse", MODIFYVM_HIDPTR, RTGETOPT_REQ_STRING },
251 { "--keyboard", MODIFYVM_HIDKBD, RTGETOPT_REQ_STRING },
252 { "--uartmode", MODIFYVM_UARTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
253 { "--uart", MODIFYVM_UART, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
254 { "--guestmemoryballoon", MODIFYVM_GUESTMEMORYBALLOON, RTGETOPT_REQ_UINT32 },
255 { "--audiocontroller", MODIFYVM_AUDIOCONTROLLER, RTGETOPT_REQ_STRING },
256 { "--audio", MODIFYVM_AUDIO, RTGETOPT_REQ_STRING },
257 { "--clipboard", MODIFYVM_CLIPBOARD, RTGETOPT_REQ_STRING },
258 { "--vrdpport", MODIFYVM_VRDPPORT, RTGETOPT_REQ_STRING }, /* deprecated */
259 { "--vrdpaddress", MODIFYVM_VRDPADDRESS, RTGETOPT_REQ_STRING }, /* deprecated */
260 { "--vrdpauthtype", MODIFYVM_VRDPAUTHTYPE, RTGETOPT_REQ_STRING }, /* deprecated */
261 { "--vrdpmulticon", MODIFYVM_VRDPMULTICON, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
262 { "--vrdpreusecon", MODIFYVM_VRDPREUSECON, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
263 { "--vrdpvideochannel", MODIFYVM_VRDPVIDEOCHANNEL, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
264 { "--vrdpvideochannelquality", MODIFYVM_VRDPVIDEOCHANNELQUALITY, RTGETOPT_REQ_UINT32 }, /* deprecated */
265 { "--vrdp", MODIFYVM_VRDP, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
266 { "--vrdeproperty", MODIFYVM_VRDEPROPERTY, RTGETOPT_REQ_STRING },
267 { "--vrdeauthtype", MODIFYVM_VRDEAUTHTYPE, RTGETOPT_REQ_STRING },
268 { "--vrdeauthlibrary", MODIFYVM_VRDEAUTHLIBRARY, RTGETOPT_REQ_STRING },
269 { "--vrdemulticon", MODIFYVM_VRDEMULTICON, RTGETOPT_REQ_BOOL_ONOFF },
270 { "--vrdereusecon", MODIFYVM_VRDEREUSECON, RTGETOPT_REQ_BOOL_ONOFF },
271 { "--vrdevideochannel", MODIFYVM_VRDEVIDEOCHANNEL, RTGETOPT_REQ_BOOL_ONOFF },
272 { "--vrdevideochannelquality", MODIFYVM_VRDEVIDEOCHANNELQUALITY, RTGETOPT_REQ_UINT32 },
273 { "--vrdeextpack", MODIFYVM_VRDE_EXTPACK, RTGETOPT_REQ_STRING },
274 { "--vrde", MODIFYVM_VRDE, RTGETOPT_REQ_BOOL_ONOFF },
275 { "--usbehci", MODIFYVM_USBEHCI, RTGETOPT_REQ_BOOL_ONOFF },
276 { "--usb", MODIFYVM_USB, RTGETOPT_REQ_BOOL_ONOFF },
277 { "--snapshotfolder", MODIFYVM_SNAPSHOTFOLDER, RTGETOPT_REQ_STRING },
278 { "--teleporter", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF },
279 { "--teleporterenabled", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
280 { "--teleporterport", MODIFYVM_TELEPORTER_PORT, RTGETOPT_REQ_UINT32 },
281 { "--teleporteraddress", MODIFYVM_TELEPORTER_ADDRESS, RTGETOPT_REQ_STRING },
282 { "--teleporterpassword", MODIFYVM_TELEPORTER_PASSWORD, RTGETOPT_REQ_STRING },
283 { "--hardwareuuid", MODIFYVM_HARDWARE_UUID, RTGETOPT_REQ_STRING },
284 { "--hpet", MODIFYVM_HPET, RTGETOPT_REQ_BOOL_ONOFF },
285 { "--iocache", MODIFYVM_IOCACHE, RTGETOPT_REQ_BOOL_ONOFF },
286 { "--iocachesize", MODIFYVM_IOCACHESIZE, RTGETOPT_REQ_UINT32 },
287 { "--faulttolerance", MODIFYVM_FAULT_TOLERANCE, RTGETOPT_REQ_STRING },
288 { "--faulttoleranceaddress", MODIFYVM_FAULT_TOLERANCE_ADDRESS, RTGETOPT_REQ_STRING },
289 { "--faulttoleranceport", MODIFYVM_FAULT_TOLERANCE_PORT, RTGETOPT_REQ_UINT32 },
290 { "--faulttolerancepassword", MODIFYVM_FAULT_TOLERANCE_PASSWORD, RTGETOPT_REQ_STRING },
291 { "--faulttolerancesyncinterval", MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL, RTGETOPT_REQ_UINT32 },
292 { "--chipset", MODIFYVM_CHIPSET, RTGETOPT_REQ_STRING },
293};
294
295static void vrdeWarningDeprecatedOption(const char *pszOption)
296{
297 RTStrmPrintf(g_pStdErr, "Warning: '--vrdp%s' is deprecated. Use '--vrde%s'.\n", pszOption, pszOption);
298}
299
300static void vrdeWarningDeprecatedProperty(const char *pszOption, const char *pszProperty, const char *pszArg)
301{
302 RTStrmPrintf(g_pStdErr, "Warning: '--%s' is deprecated. Use '--vrdeproperty \"%s=%s\"'.\n",
303 pszOption, pszProperty, pszArg);
304}
305
306
307int handleModifyVM(HandlerArg *a)
308{
309 int c;
310 HRESULT rc;
311 Bstr name;
312 RTGETOPTUNION ValueUnion;
313 RTGETOPTSTATE GetOptState;
314 ComPtr <IMachine> machine;
315 ComPtr <IBIOSSettings> biosSettings;
316
317 /* VM ID + at least one parameter. Parameter arguments are checked
318 * individually. */
319 if (a->argc < 2)
320 return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
321
322 /* Get the number of network adapters */
323 ULONG NetworkAdapterCount = 0;
324 {
325 ComPtr <ISystemProperties> info;
326 CHECK_ERROR_RET(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()), 1);
327 CHECK_ERROR_RET(info, COMGETTER(NetworkAdapterCount)(&NetworkAdapterCount), 1);
328 }
329 ULONG SerialPortCount = 0;
330 {
331 ComPtr <ISystemProperties> info;
332 CHECK_ERROR_RET(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()), 1);
333 CHECK_ERROR_RET(info, COMGETTER(SerialPortCount)(&SerialPortCount), 1);
334 }
335
336 /* try to find the given machine */
337 CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(),
338 machine.asOutParam()), 1);
339
340 /* open a session for the VM */
341 CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Write), 1);
342
343 /* get the mutable session machine */
344 a->session->COMGETTER(Machine)(machine.asOutParam());
345 machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
346
347 RTGetOptInit(&GetOptState, a->argc, a->argv, g_aModifyVMOptions,
348 RT_ELEMENTS(g_aModifyVMOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
349
350 while ( SUCCEEDED (rc)
351 && (c = RTGetOpt(&GetOptState, &ValueUnion)))
352 {
353 switch (c)
354 {
355 case MODIFYVM_NAME:
356 {
357 CHECK_ERROR(machine, COMSETTER(Name)(Bstr(ValueUnion.psz).raw()));
358 break;
359 }
360 case MODIFYVM_OSTYPE:
361 {
362 ComPtr<IGuestOSType> guestOSType;
363 CHECK_ERROR(a->virtualBox, GetGuestOSType(Bstr(ValueUnion.psz).raw(),
364 guestOSType.asOutParam()));
365 if (SUCCEEDED(rc) && guestOSType)
366 {
367 CHECK_ERROR(machine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz).raw()));
368 }
369 else
370 {
371 errorArgument("Invalid guest OS type '%s'", Utf8Str(ValueUnion.psz).c_str());
372 rc = E_FAIL;
373 }
374 break;
375 }
376
377 case MODIFYVM_MEMORY:
378 {
379 CHECK_ERROR(machine, COMSETTER(MemorySize)(ValueUnion.u32));
380 break;
381 }
382
383 case MODIFYVM_PAGEFUSION:
384 {
385 CHECK_ERROR(machine, COMSETTER(PageFusionEnabled)(ValueUnion.f));
386 break;
387 }
388
389 case MODIFYVM_VRAM:
390 {
391 CHECK_ERROR(machine, COMSETTER(VRAMSize)(ValueUnion.u32));
392 break;
393 }
394
395 case MODIFYVM_FIRMWARE:
396 {
397 if (!strcmp(ValueUnion.psz, "efi"))
398 {
399 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI));
400 }
401 else if (!strcmp(ValueUnion.psz, "efi32"))
402 {
403 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI32));
404 }
405 else if (!strcmp(ValueUnion.psz, "efi64"))
406 {
407 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI64));
408 }
409 else if (!strcmp(ValueUnion.psz, "efidual"))
410 {
411 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFIDUAL));
412 }
413 else if (!strcmp(ValueUnion.psz, "bios"))
414 {
415 CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_BIOS));
416 }
417 else
418 {
419 errorArgument("Invalid --firmware argument '%s'", ValueUnion.psz);
420 rc = E_FAIL;
421 }
422 break;
423 }
424
425 case MODIFYVM_ACPI:
426 {
427 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(ValueUnion.f));
428 break;
429 }
430
431 case MODIFYVM_IOAPIC:
432 {
433 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(ValueUnion.f));
434 break;
435 }
436
437 case MODIFYVM_PAE:
438 {
439 CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_PAE, ValueUnion.f));
440 break;
441 }
442
443 case MODIFYVM_SYNTHCPU:
444 {
445 CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_Synthetic, ValueUnion.f));
446 break;
447 }
448
449 case MODIFYVM_HWVIRTEX:
450 {
451 CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_Enabled, ValueUnion.f));
452 break;
453 }
454
455 case MODIFYVM_HWVIRTEXEXCLUSIVE:
456 {
457 CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_Exclusive, ValueUnion.f));
458 break;
459 }
460
461 case MODIFYVM_SETCPUID:
462 {
463 uint32_t id = ValueUnion.u32;
464 uint32_t aValue[4];
465
466 for (unsigned i = 0 ; i < 4 ; i++)
467 {
468 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX);
469 if (RT_FAILURE(vrc))
470 return errorSyntax(USAGE_MODIFYVM,
471 "Missing or Invalid argument to '%s'",
472 GetOptState.pDef->pszLong);
473 aValue[i] = ValueUnion.u32;
474 }
475 CHECK_ERROR(machine, SetCPUIDLeaf(id, aValue[0], aValue[1], aValue[2], aValue[3]));
476 break;
477 }
478
479 case MODIFYVM_DELCPUID:
480 {
481 CHECK_ERROR(machine, RemoveCPUIDLeaf(ValueUnion.u32));
482 break;
483 }
484
485 case MODIFYVM_DELALLCPUID:
486 {
487 CHECK_ERROR(machine, RemoveAllCPUIDLeaves());
488 break;
489 }
490
491 case MODIFYVM_NESTEDPAGING:
492 {
493 CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, ValueUnion.f));
494 break;
495 }
496
497 case MODIFYVM_LARGEPAGES:
498 {
499 CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_LargePages, ValueUnion.f));
500 break;
501 }
502
503 case MODIFYVM_VTXVPID:
504 {
505 CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_VPID, ValueUnion.f));
506 break;
507 }
508
509 case MODIFYVM_CPUS:
510 {
511 CHECK_ERROR(machine, COMSETTER(CPUCount)(ValueUnion.u32));
512 break;
513 }
514
515 case MODIFYVM_RTCUSEUTC:
516 {
517 CHECK_ERROR(machine, COMSETTER(RTCUseUTC)(ValueUnion.f));
518 break;
519 }
520
521 case MODIFYVM_CPUHOTPLUG:
522 {
523 CHECK_ERROR(machine, COMSETTER(CPUHotPlugEnabled)(ValueUnion.f));
524 break;
525 }
526
527 case MODIFYVM_PLUGCPU:
528 {
529 CHECK_ERROR(machine, HotPlugCPU(ValueUnion.u32));
530 break;
531 }
532
533 case MODIFYVM_UNPLUGCPU:
534 {
535 CHECK_ERROR(machine, HotUnplugCPU(ValueUnion.u32));
536 break;
537 }
538
539 case MODIFYVM_CPU_EXECTUION_CAP:
540 {
541 CHECK_ERROR(machine, COMSETTER(CPUExecutionCap)(ValueUnion.u32));
542 break;
543 }
544
545 case MODIFYVM_MONITORCOUNT:
546 {
547 CHECK_ERROR(machine, COMSETTER(MonitorCount)(ValueUnion.u32));
548 break;
549 }
550
551 case MODIFYVM_ACCELERATE3D:
552 {
553 CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(ValueUnion.f));
554 break;
555 }
556
557#ifdef VBOX_WITH_VIDEOHWACCEL
558 case MODIFYVM_ACCELERATE2DVIDEO:
559 {
560 CHECK_ERROR(machine, COMSETTER(Accelerate2DVideoEnabled)(ValueUnion.f));
561 break;
562 }
563#endif
564
565 case MODIFYVM_BIOSLOGOFADEIN:
566 {
567 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(ValueUnion.f));
568 break;
569 }
570
571 case MODIFYVM_BIOSLOGOFADEOUT:
572 {
573 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(ValueUnion.f));
574 break;
575 }
576
577 case MODIFYVM_BIOSLOGODISPLAYTIME:
578 {
579 CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(ValueUnion.u32));
580 break;
581 }
582
583 case MODIFYVM_BIOSLOGOIMAGEPATH:
584 {
585 CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(ValueUnion.psz).raw()));
586 break;
587 }
588
589 case MODIFYVM_BIOSBOOTMENU:
590 {
591 if (!strcmp(ValueUnion.psz, "disabled"))
592 {
593 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled));
594 }
595 else if (!strcmp(ValueUnion.psz, "menuonly"))
596 {
597 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly));
598 }
599 else if (!strcmp(ValueUnion.psz, "messageandmenu"))
600 {
601 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu));
602 }
603 else
604 {
605 errorArgument("Invalid --biosbootmenu argument '%s'", ValueUnion.psz);
606 rc = E_FAIL;
607 }
608 break;
609 }
610
611 case MODIFYVM_BIOSSYSTEMTIMEOFFSET:
612 {
613 CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(ValueUnion.i64));
614 break;
615 }
616
617 case MODIFYVM_BIOSPXEDEBUG:
618 {
619 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(ValueUnion.f));
620 break;
621 }
622
623 case MODIFYVM_BOOT:
624 {
625 if (!strcmp(ValueUnion.psz, "none"))
626 {
627 CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Null));
628 }
629 else if (!strcmp(ValueUnion.psz, "floppy"))
630 {
631 CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Floppy));
632 }
633 else if (!strcmp(ValueUnion.psz, "dvd"))
634 {
635 CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_DVD));
636 }
637 else if (!strcmp(ValueUnion.psz, "disk"))
638 {
639 CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_HardDisk));
640 }
641 else if (!strcmp(ValueUnion.psz, "net"))
642 {
643 CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Network));
644 }
645 else
646 return errorArgument("Invalid boot device '%s'", ValueUnion.psz);
647 break;
648 }
649
650 case MODIFYVM_HDA: // deprecated
651 case MODIFYVM_HDB: // deprecated
652 case MODIFYVM_HDD: // deprecated
653 case MODIFYVM_SATAPORT: // deprecated
654 {
655 uint32_t u1 = 0, u2 = 0;
656 Bstr bstrController = L"IDE Controller";
657
658 switch (c)
659 {
660 case MODIFYVM_HDA: // deprecated
661 u1 = 0;
662 break;
663
664 case MODIFYVM_HDB: // deprecated
665 u1 = 0;
666 u2 = 1;
667 break;
668
669 case MODIFYVM_HDD: // deprecated
670 u1 = 1;
671 u2 = 1;
672 break;
673
674 case MODIFYVM_SATAPORT: // deprecated
675 u1 = GetOptState.uIndex;
676 bstrController = L"SATA";
677 break;
678 }
679
680 if (!strcmp(ValueUnion.psz, "none"))
681 {
682 machine->DetachDevice(bstrController.raw(), u1, u2);
683 }
684 else
685 {
686 ComPtr<IMedium> hardDisk;
687 rc = a->virtualBox->FindMedium(Bstr(ValueUnion.psz).raw(),
688 DeviceType_HardDisk,
689 hardDisk.asOutParam());
690 if (FAILED(rc))
691 {
692 /* open the new hard disk object */
693 CHECK_ERROR(a->virtualBox,
694 OpenMedium(Bstr(ValueUnion.psz).raw(),
695 DeviceType_HardDisk,
696 AccessMode_ReadWrite,
697 hardDisk.asOutParam()));
698 }
699 if (hardDisk)
700 {
701 CHECK_ERROR(machine, AttachDevice(bstrController.raw(),
702 u1, u2,
703 DeviceType_HardDisk,
704 hardDisk));
705 }
706 else
707 rc = E_FAIL;
708 }
709 break;
710 }
711
712 case MODIFYVM_IDECONTROLLER: // deprecated
713 {
714 ComPtr<IStorageController> storageController;
715 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("IDE Controller").raw(),
716 storageController.asOutParam()));
717
718 if (!RTStrICmp(ValueUnion.psz, "PIIX3"))
719 {
720 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3));
721 }
722 else if (!RTStrICmp(ValueUnion.psz, "PIIX4"))
723 {
724 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4));
725 }
726 else if (!RTStrICmp(ValueUnion.psz, "ICH6"))
727 {
728 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6));
729 }
730 else
731 {
732 errorArgument("Invalid --idecontroller argument '%s'", ValueUnion.psz);
733 rc = E_FAIL;
734 }
735 break;
736 }
737
738 case MODIFYVM_SATAIDEEMULATION: // deprecated
739 {
740 ComPtr<IStorageController> SataCtl;
741 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA").raw(),
742 SataCtl.asOutParam()));
743
744 if (SUCCEEDED(rc))
745 CHECK_ERROR(SataCtl, SetIDEEmulationPort(GetOptState.uIndex, ValueUnion.u32));
746 break;
747 }
748
749 case MODIFYVM_SATAPORTCOUNT: // deprecated
750 {
751 ComPtr<IStorageController> SataCtl;
752 CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA").raw(),
753 SataCtl.asOutParam()));
754
755 if (SUCCEEDED(rc) && ValueUnion.u32 > 0)
756 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(ValueUnion.u32));
757 break;
758 }
759
760 case MODIFYVM_SATA: // deprecated
761 {
762 if (!strcmp(ValueUnion.psz, "on") || !strcmp(ValueUnion.psz, "enable"))
763 {
764 ComPtr<IStorageController> ctl;
765 CHECK_ERROR(machine, AddStorageController(Bstr("SATA").raw(),
766 StorageBus_SATA,
767 ctl.asOutParam()));
768 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci));
769 }
770 else if (!strcmp(ValueUnion.psz, "off") || !strcmp(ValueUnion.psz, "disable"))
771 CHECK_ERROR(machine, RemoveStorageController(Bstr("SATA").raw()));
772 else
773 return errorArgument("Invalid --usb argument '%s'", ValueUnion.psz);
774 break;
775 }
776
777 case MODIFYVM_SCSIPORT: // deprecated
778 {
779 if (!strcmp(ValueUnion.psz, "none"))
780 {
781 rc = machine->DetachDevice(Bstr("LsiLogic").raw(),
782 GetOptState.uIndex, 0);
783 if (FAILED(rc))
784 CHECK_ERROR(machine, DetachDevice(Bstr("BusLogic").raw(),
785 GetOptState.uIndex, 0));
786 }
787 else
788 {
789 /* first guess is that it's a UUID */
790 ComPtr<IMedium> hardDisk;
791 rc = a->virtualBox->FindMedium(Bstr(ValueUnion.psz).raw(),
792 DeviceType_HardDisk,
793 hardDisk.asOutParam());
794 /* not successful? Then it must be a filename */
795 if (FAILED(rc))
796 {
797 /* open the new hard disk object */
798 CHECK_ERROR(a->virtualBox,
799 OpenMedium(Bstr(ValueUnion.psz).raw(),
800 DeviceType_HardDisk,
801 AccessMode_ReadWrite,
802 hardDisk.asOutParam()));
803 }
804 if (hardDisk)
805 {
806 rc = machine->AttachDevice(Bstr("LsiLogic").raw(),
807 GetOptState.uIndex, 0,
808 DeviceType_HardDisk,
809 hardDisk);
810 if (FAILED(rc))
811 CHECK_ERROR(machine,
812 AttachDevice(Bstr("BusLogic").raw(),
813 GetOptState.uIndex, 0,
814 DeviceType_HardDisk,
815 hardDisk));
816 }
817 else
818 rc = E_FAIL;
819 }
820 break;
821 }
822
823 case MODIFYVM_SCSITYPE: // deprecated
824 {
825 ComPtr<IStorageController> ctl;
826
827 if (!RTStrICmp(ValueUnion.psz, "LsiLogic"))
828 {
829 rc = machine->RemoveStorageController(Bstr("BusLogic").raw());
830 if (FAILED(rc))
831 CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic").raw()));
832
833 CHECK_ERROR(machine,
834 AddStorageController(Bstr("LsiLogic").raw(),
835 StorageBus_SCSI,
836 ctl.asOutParam()));
837
838 if (SUCCEEDED(rc))
839 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic));
840 }
841 else if (!RTStrICmp(ValueUnion.psz, "BusLogic"))
842 {
843 rc = machine->RemoveStorageController(Bstr("LsiLogic").raw());
844 if (FAILED(rc))
845 CHECK_ERROR(machine, RemoveStorageController(Bstr("BusLogic").raw()));
846
847 CHECK_ERROR(machine,
848 AddStorageController(Bstr("BusLogic").raw(),
849 StorageBus_SCSI,
850 ctl.asOutParam()));
851
852 if (SUCCEEDED(rc))
853 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
854 }
855 else
856 return errorArgument("Invalid --scsitype argument '%s'", ValueUnion.psz);
857 break;
858 }
859
860 case MODIFYVM_SCSI: // deprecated
861 {
862 if (!strcmp(ValueUnion.psz, "on") || !strcmp(ValueUnion.psz, "enable"))
863 {
864 ComPtr<IStorageController> ctl;
865
866 CHECK_ERROR(machine, AddStorageController(Bstr("BusLogic").raw(),
867 StorageBus_SCSI,
868 ctl.asOutParam()));
869 if (SUCCEEDED(rc))
870 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
871 }
872 else if (!strcmp(ValueUnion.psz, "off") || !strcmp(ValueUnion.psz, "disable"))
873 {
874 rc = machine->RemoveStorageController(Bstr("BusLogic").raw());
875 if (FAILED(rc))
876 CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic").raw()));
877 }
878 break;
879 }
880
881 case MODIFYVM_DVDPASSTHROUGH: // deprecated
882 {
883 CHECK_ERROR(machine, PassthroughDevice(Bstr("IDE Controller").raw(),
884 1, 0,
885 !strcmp(ValueUnion.psz, "on")));
886 break;
887 }
888
889 case MODIFYVM_DVD: // deprecated
890 {
891 ComPtr<IMedium> dvdMedium;
892
893 /* unmount? */
894 if (!strcmp(ValueUnion.psz, "none"))
895 {
896 /* nothing to do, NULL object will cause unmount */
897 }
898 /* host drive? */
899 else if (!strncmp(ValueUnion.psz, "host:", 5))
900 {
901 ComPtr<IHost> host;
902 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
903 rc = host->FindHostDVDDrive(Bstr(ValueUnion.psz + 5).raw(),
904 dvdMedium.asOutParam());
905 if (!dvdMedium)
906 {
907 /* 2nd try: try with the real name, important on Linux+libhal */
908 char szPathReal[RTPATH_MAX];
909 if (RT_FAILURE(RTPathReal(ValueUnion.psz + 5, szPathReal, sizeof(szPathReal))))
910 {
911 errorArgument("Invalid host DVD drive name \"%s\"", ValueUnion.psz + 5);
912 rc = E_FAIL;
913 break;
914 }
915 rc = host->FindHostDVDDrive(Bstr(szPathReal).raw(),
916 dvdMedium.asOutParam());
917 if (!dvdMedium)
918 {
919 errorArgument("Invalid host DVD drive name \"%s\"", ValueUnion.psz + 5);
920 rc = E_FAIL;
921 break;
922 }
923 }
924 }
925 else
926 {
927 /* first assume it's a UUID */
928 rc = a->virtualBox->FindMedium(Bstr(ValueUnion.psz).raw(),
929 DeviceType_DVD,
930 dvdMedium.asOutParam());
931 if (FAILED(rc) || !dvdMedium)
932 {
933 /* not registered, do that on the fly */
934 Bstr emptyUUID;
935 CHECK_ERROR(a->virtualBox,
936 OpenMedium(Bstr(ValueUnion.psz).raw(),
937 DeviceType_DVD,
938 AccessMode_ReadWrite,
939 dvdMedium.asOutParam()));
940 }
941 if (!dvdMedium)
942 {
943 rc = E_FAIL;
944 break;
945 }
946 }
947
948 CHECK_ERROR(machine, MountMedium(Bstr("IDE Controller").raw(),
949 1, 0,
950 dvdMedium,
951 FALSE /* aForce */));
952 break;
953 }
954
955 case MODIFYVM_FLOPPY: // deprecated
956 {
957 ComPtr<IMedium> floppyMedium;
958 ComPtr<IMediumAttachment> floppyAttachment;
959 machine->GetMediumAttachment(Bstr("Floppy Controller").raw(),
960 0, 0, floppyAttachment.asOutParam());
961
962 /* disable? */
963 if (!strcmp(ValueUnion.psz, "disabled"))
964 {
965 /* disable the controller */
966 if (floppyAttachment)
967 CHECK_ERROR(machine, DetachDevice(Bstr("Floppy Controller").raw(),
968 0, 0));
969 }
970 else
971 {
972 /* enable the controller */
973 if (!floppyAttachment)
974 CHECK_ERROR(machine, AttachDevice(Bstr("Floppy Controller").raw(),
975 0, 0,
976 DeviceType_Floppy, NULL));
977
978 /* unmount? */
979 if ( !strcmp(ValueUnion.psz, "none")
980 || !strcmp(ValueUnion.psz, "empty")) // deprecated
981 {
982 /* nothing to do, NULL object will cause unmount */
983 }
984 /* host drive? */
985 else if (!strncmp(ValueUnion.psz, "host:", 5))
986 {
987 ComPtr<IHost> host;
988 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
989 rc = host->FindHostFloppyDrive(Bstr(ValueUnion.psz + 5).raw(),
990 floppyMedium.asOutParam());
991 if (!floppyMedium)
992 {
993 errorArgument("Invalid host floppy drive name \"%s\"", ValueUnion.psz + 5);
994 rc = E_FAIL;
995 break;
996 }
997 }
998 else
999 {
1000 /* first assume it's a UUID */
1001 rc = a->virtualBox->FindMedium(Bstr(ValueUnion.psz).raw(),
1002 DeviceType_Floppy,
1003 floppyMedium.asOutParam());
1004 if (FAILED(rc) || !floppyMedium)
1005 {
1006 /* not registered, do that on the fly */
1007 Bstr emptyUUID;
1008 CHECK_ERROR(a->virtualBox,
1009 OpenMedium(Bstr(ValueUnion.psz).raw(),
1010 DeviceType_Floppy,
1011 AccessMode_ReadWrite,
1012 floppyMedium.asOutParam()));
1013 }
1014 if (!floppyMedium)
1015 {
1016 rc = E_FAIL;
1017 break;
1018 }
1019 }
1020 CHECK_ERROR(machine, MountMedium(Bstr("Floppy Controller").raw(),
1021 0, 0,
1022 floppyMedium,
1023 FALSE /* aForce */));
1024 }
1025 break;
1026 }
1027
1028 case MODIFYVM_NICTRACEFILE:
1029 {
1030 ComPtr<INetworkAdapter> nic;
1031
1032 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1033 ASSERT(nic);
1034
1035 CHECK_ERROR(nic, COMSETTER(TraceFile)(Bstr(ValueUnion.psz).raw()));
1036 break;
1037 }
1038
1039 case MODIFYVM_NICTRACE:
1040 {
1041 ComPtr<INetworkAdapter> nic;
1042
1043 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1044 ASSERT(nic);
1045
1046 CHECK_ERROR(nic, COMSETTER(TraceEnabled)(ValueUnion.f));
1047 break;
1048 }
1049
1050 case MODIFYVM_NICTYPE:
1051 {
1052 ComPtr<INetworkAdapter> nic;
1053
1054 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1055 ASSERT(nic);
1056
1057 if (!strcmp(ValueUnion.psz, "Am79C970A"))
1058 {
1059 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A));
1060 }
1061 else if (!strcmp(ValueUnion.psz, "Am79C973"))
1062 {
1063 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973));
1064 }
1065#ifdef VBOX_WITH_E1000
1066 else if (!strcmp(ValueUnion.psz, "82540EM"))
1067 {
1068 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM));
1069 }
1070 else if (!strcmp(ValueUnion.psz, "82543GC"))
1071 {
1072 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC));
1073 }
1074 else if (!strcmp(ValueUnion.psz, "82545EM"))
1075 {
1076 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82545EM));
1077 }
1078#endif
1079#ifdef VBOX_WITH_VIRTIO
1080 else if (!strcmp(ValueUnion.psz, "virtio"))
1081 {
1082 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Virtio));
1083 }
1084#endif /* VBOX_WITH_VIRTIO */
1085 else
1086 {
1087 errorArgument("Invalid NIC type '%s' specified for NIC %u", ValueUnion.psz, GetOptState.uIndex);
1088 rc = E_FAIL;
1089 }
1090 break;
1091 }
1092
1093 case MODIFYVM_NICSPEED:
1094 {
1095 ComPtr<INetworkAdapter> nic;
1096
1097 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1098 ASSERT(nic);
1099
1100 CHECK_ERROR(nic, COMSETTER(LineSpeed)(ValueUnion.u32));
1101 break;
1102 }
1103
1104 case MODIFYVM_NICBOOTPRIO:
1105 {
1106 ComPtr<INetworkAdapter> nic;
1107
1108 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1109 ASSERT(nic);
1110
1111 /* Somewhat arbitrary limitation - we can pass a list of up to 4 PCI devices
1112 * to the PXE ROM, hence only boot priorities 1-4 are allowed (in addition to
1113 * 0 for the default lowest priority).
1114 */
1115 if (ValueUnion.u32 > 4)
1116 {
1117 errorArgument("Invalid boot priority '%u' specfied for NIC %u", ValueUnion.u32, GetOptState.uIndex);
1118 rc = E_FAIL;
1119 }
1120 else
1121 {
1122 CHECK_ERROR(nic, COMSETTER(BootPriority)(ValueUnion.u32));
1123 }
1124 break;
1125 }
1126
1127 case MODIFYVM_NIC:
1128 {
1129 ComPtr<INetworkAdapter> nic;
1130
1131 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1132 ASSERT(nic);
1133
1134 if (!strcmp(ValueUnion.psz, "none"))
1135 {
1136 CHECK_ERROR(nic, COMSETTER(Enabled)(FALSE));
1137 }
1138 else if (!strcmp(ValueUnion.psz, "null"))
1139 {
1140 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1141 CHECK_ERROR(nic, Detach());
1142 }
1143 else if (!strcmp(ValueUnion.psz, "nat"))
1144 {
1145 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1146 CHECK_ERROR(nic, AttachToNAT());
1147 }
1148 else if ( !strcmp(ValueUnion.psz, "bridged")
1149 || !strcmp(ValueUnion.psz, "hostif")) /* backward compatibility */
1150 {
1151 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1152 CHECK_ERROR(nic, AttachToBridgedInterface());
1153 }
1154 else if (!strcmp(ValueUnion.psz, "intnet"))
1155 {
1156 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1157 CHECK_ERROR(nic, AttachToInternalNetwork());
1158 }
1159#if defined(VBOX_WITH_NETFLT)
1160 else if (!strcmp(ValueUnion.psz, "hostonly"))
1161 {
1162
1163 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1164 CHECK_ERROR(nic, AttachToHostOnlyInterface());
1165 }
1166#endif
1167#ifdef VBOX_WITH_VDE
1168 else if (!strcmp(ValueUnion.psz, "vde"))
1169 {
1170
1171 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1172 CHECK_ERROR(nic, AttachToVDE());
1173 }
1174#endif
1175 else
1176 {
1177 errorArgument("Invalid type '%s' specfied for NIC %u", ValueUnion.psz, GetOptState.uIndex);
1178 rc = E_FAIL;
1179 }
1180 break;
1181 }
1182
1183 case MODIFYVM_CABLECONNECTED:
1184 {
1185 ComPtr<INetworkAdapter> nic;
1186
1187 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1188 ASSERT(nic);
1189
1190 CHECK_ERROR(nic, COMSETTER(CableConnected)(ValueUnion.f));
1191 break;
1192 }
1193
1194 case MODIFYVM_BRIDGEADAPTER:
1195 case MODIFYVM_HOSTONLYADAPTER:
1196 {
1197 ComPtr<INetworkAdapter> nic;
1198
1199 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1200 ASSERT(nic);
1201
1202 /** @todo NULL string deprecated */
1203 /* remove it? */
1204 if (!strcmp(ValueUnion.psz, "none"))
1205 {
1206 CHECK_ERROR(nic, COMSETTER(HostInterface)(NULL));
1207 }
1208 else
1209 {
1210 CHECK_ERROR(nic, COMSETTER(HostInterface)(Bstr(ValueUnion.psz).raw()));
1211 }
1212 break;
1213 }
1214
1215 case MODIFYVM_INTNET:
1216 {
1217 ComPtr<INetworkAdapter> nic;
1218
1219 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1220 ASSERT(nic);
1221
1222 /** @todo NULL string deprecated */
1223 /* remove it? */
1224 if (!strcmp(ValueUnion.psz, "none"))
1225 {
1226 CHECK_ERROR(nic, COMSETTER(InternalNetwork)(NULL));
1227 }
1228 else
1229 {
1230 CHECK_ERROR(nic, COMSETTER(InternalNetwork)(Bstr(ValueUnion.psz).raw()));
1231 }
1232 break;
1233 }
1234
1235#ifdef VBOX_WITH_VDE
1236 case MODIFYVM_VDENET:
1237 {
1238 ComPtr<INetworkAdapter> nic;
1239
1240 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1241 ASSERT(nic);
1242
1243 /** @todo NULL string deprecated */
1244 /* remove it? */
1245 if (!strcmp(ValueUnion.psz, "default"))
1246 {
1247 CHECK_ERROR(nic, COMSETTER(VDENetwork)(NULL));
1248 }
1249 else
1250 {
1251 CHECK_ERROR(nic, COMSETTER(VDENetwork)(Bstr(ValueUnion.psz).raw()));
1252 }
1253 break;
1254 }
1255#endif
1256 case MODIFYVM_NATNET:
1257 {
1258 ComPtr<INetworkAdapter> nic;
1259 ComPtr<INATEngine> driver;
1260
1261 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1262 ASSERT(nic);
1263
1264 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1265
1266 const char *psz = ValueUnion.psz;
1267 if (!strcmp("default", psz))
1268 psz = "";
1269
1270 CHECK_ERROR(driver, COMSETTER(Network)(Bstr(psz).raw()));
1271 break;
1272 }
1273
1274 case MODIFYVM_NATBINDIP:
1275 {
1276 ComPtr<INetworkAdapter> nic;
1277 ComPtr<INATEngine> driver;
1278
1279 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1280 ASSERT(nic);
1281
1282 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1283 CHECK_ERROR(driver, COMSETTER(HostIP)(Bstr(ValueUnion.psz).raw()));
1284 break;
1285 }
1286
1287#define ITERATE_TO_NEXT_TERM(ch) \
1288 do { \
1289 while (*ch != ',') \
1290 { \
1291 if (*ch == 0) \
1292 { \
1293 return errorSyntax(USAGE_MODIFYVM, \
1294 "Missing or Invalid argument to '%s'", \
1295 GetOptState.pDef->pszLong); \
1296 } \
1297 ch++; \
1298 } \
1299 *ch = '\0'; \
1300 ch++; \
1301 } while(0)
1302
1303 case MODIFYVM_NATSETTINGS:
1304 {
1305 ComPtr<INetworkAdapter> nic;
1306 ComPtr<INATEngine> driver;
1307 char *strMtu;
1308 char *strSockSnd;
1309 char *strSockRcv;
1310 char *strTcpSnd;
1311 char *strTcpRcv;
1312 char *strRaw = RTStrDup(ValueUnion.psz);
1313 char *ch = strRaw;
1314 strMtu = RTStrStrip(ch);
1315 ITERATE_TO_NEXT_TERM(ch);
1316 strSockSnd = RTStrStrip(ch);
1317 ITERATE_TO_NEXT_TERM(ch);
1318 strSockRcv = RTStrStrip(ch);
1319 ITERATE_TO_NEXT_TERM(ch);
1320 strTcpSnd = RTStrStrip(ch);
1321 ITERATE_TO_NEXT_TERM(ch);
1322 strTcpRcv = RTStrStrip(ch);
1323
1324 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1325 ASSERT(nic);
1326
1327 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1328 CHECK_ERROR(driver, SetNetworkSettings(RTStrToUInt32(strMtu), RTStrToUInt32(strSockSnd), RTStrToUInt32(strSockRcv),
1329 RTStrToUInt32(strTcpSnd), RTStrToUInt32(strTcpRcv)));
1330 break;
1331 }
1332
1333
1334 case MODIFYVM_NATPF:
1335 {
1336 ComPtr<INetworkAdapter> nic;
1337 ComPtr<INATEngine> driver;
1338
1339 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1340 ASSERT(nic);
1341
1342 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1343 /* format name:proto:hostip:hostport:guestip:guestport*/
1344 if (RTStrCmp(ValueUnion.psz, "delete") != 0)
1345 {
1346 char *strName;
1347 char *strProto;
1348 char *strHostIp;
1349 char *strHostPort;
1350 char *strGuestIp;
1351 char *strGuestPort;
1352 char *strRaw = RTStrDup(ValueUnion.psz);
1353 char *ch = strRaw;
1354 strName = RTStrStrip(ch);
1355 ITERATE_TO_NEXT_TERM(ch);
1356 strProto = RTStrStrip(ch);
1357 ITERATE_TO_NEXT_TERM(ch);
1358 strHostIp = RTStrStrip(ch);
1359 ITERATE_TO_NEXT_TERM(ch);
1360 strHostPort = RTStrStrip(ch);
1361 ITERATE_TO_NEXT_TERM(ch);
1362 strGuestIp = RTStrStrip(ch);
1363 ITERATE_TO_NEXT_TERM(ch);
1364 strGuestPort = RTStrStrip(ch);
1365 NATProtocol_T proto;
1366 if (RTStrICmp(strProto, "udp") == 0)
1367 proto = NATProtocol_UDP;
1368 else if (RTStrICmp(strProto, "tcp") == 0)
1369 proto = NATProtocol_TCP;
1370 else
1371 {
1372 errorArgument("Invalid proto '%s' specfied for NIC %u", ValueUnion.psz, GetOptState.uIndex);
1373 rc = E_FAIL;
1374 break;
1375 }
1376 CHECK_ERROR(driver, AddRedirect(Bstr(strName).raw(), proto,
1377 Bstr(strHostIp).raw(),
1378 RTStrToUInt16(strHostPort),
1379 Bstr(strGuestIp).raw(),
1380 RTStrToUInt16(strGuestPort)));
1381 }
1382 else
1383 {
1384 /* delete NAT Rule operation */
1385 int vrc;
1386 vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
1387 if (RT_FAILURE(vrc))
1388 return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
1389 CHECK_ERROR(driver, RemoveRedirect(Bstr(ValueUnion.psz).raw()));
1390 }
1391 break;
1392 }
1393 #undef ITERATE_TO_NEXT_TERM
1394 case MODIFYVM_NATALIASMODE:
1395 {
1396 ComPtr<INetworkAdapter> nic;
1397 ComPtr<INATEngine> driver;
1398 uint32_t aliasMode = 0;
1399
1400 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1401 ASSERT(nic);
1402
1403 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1404 if (RTStrCmp(ValueUnion.psz,"default") == 0)
1405 {
1406 aliasMode = 0;
1407 }
1408 else
1409 {
1410 char *token = (char *)ValueUnion.psz;
1411 while(token)
1412 {
1413 if (RTStrNCmp(token, "log", 3) == 0)
1414 aliasMode |= 0x1;
1415 else if (RTStrNCmp(token, "proxyonly", 9) == 0)
1416 aliasMode |= 0x2;
1417 else if (RTStrNCmp(token, "sameports", 9) == 0)
1418 aliasMode |= 0x4;
1419 token = RTStrStr(token, ",");
1420 if (token == NULL)
1421 break;
1422 token++;
1423 }
1424 }
1425 CHECK_ERROR(driver, COMSETTER(AliasMode)(aliasMode));
1426 break;
1427 }
1428
1429 case MODIFYVM_NATTFTPPREFIX:
1430 {
1431 ComPtr<INetworkAdapter> nic;
1432 ComPtr<INATEngine> driver;
1433
1434 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1435 ASSERT(nic);
1436
1437 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1438 CHECK_ERROR(driver, COMSETTER(TftpPrefix)(Bstr(ValueUnion.psz).raw()));
1439 break;
1440 }
1441
1442 case MODIFYVM_NATTFTPFILE:
1443 {
1444 ComPtr<INetworkAdapter> nic;
1445 ComPtr<INATEngine> driver;
1446
1447 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1448 ASSERT(nic);
1449
1450 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1451 CHECK_ERROR(driver, COMSETTER(TftpBootFile)(Bstr(ValueUnion.psz).raw()));
1452 break;
1453 }
1454
1455 case MODIFYVM_NATTFTPSERVER:
1456 {
1457 ComPtr<INetworkAdapter> nic;
1458 ComPtr<INATEngine> driver;
1459
1460 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1461 ASSERT(nic);
1462
1463 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1464 CHECK_ERROR(driver, COMSETTER(TftpNextServer)(Bstr(ValueUnion.psz).raw()));
1465 break;
1466 }
1467 case MODIFYVM_NATDNSPASSDOMAIN:
1468 {
1469 ComPtr<INetworkAdapter> nic;
1470 ComPtr<INATEngine> driver;
1471
1472 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1473 ASSERT(nic);
1474
1475 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1476 CHECK_ERROR(driver, COMSETTER(DnsPassDomain)(ValueUnion.f));
1477 break;
1478 }
1479
1480 case MODIFYVM_NATDNSPROXY:
1481 {
1482 ComPtr<INetworkAdapter> nic;
1483 ComPtr<INATEngine> driver;
1484
1485 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1486 ASSERT(nic);
1487
1488 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1489 CHECK_ERROR(driver, COMSETTER(DnsProxy)(ValueUnion.f));
1490 break;
1491 }
1492
1493 case MODIFYVM_NATDNSHOSTRESOLVER:
1494 {
1495 ComPtr<INetworkAdapter> nic;
1496 ComPtr<INATEngine> driver;
1497
1498 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1499 ASSERT(nic);
1500
1501 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
1502 CHECK_ERROR(driver, COMSETTER(DnsUseHostResolver)(ValueUnion.f));
1503 break;
1504 }
1505 case MODIFYVM_MACADDRESS:
1506 {
1507 ComPtr<INetworkAdapter> nic;
1508
1509 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1510 ASSERT(nic);
1511
1512 /* generate one? */
1513 if (!strcmp(ValueUnion.psz, "auto"))
1514 {
1515 CHECK_ERROR(nic, COMSETTER(MACAddress)(NULL));
1516 }
1517 else
1518 {
1519 CHECK_ERROR(nic, COMSETTER(MACAddress)(Bstr(ValueUnion.psz).raw()));
1520 }
1521 break;
1522 }
1523
1524 case MODIFYVM_HIDPTR:
1525 {
1526 bool fEnableUsb = false;
1527 if (!strcmp(ValueUnion.psz, "ps2"))
1528 {
1529 CHECK_ERROR(machine, COMSETTER(PointingHidType)(PointingHidType_PS2Mouse));
1530 }
1531 else if (!strcmp(ValueUnion.psz, "usb"))
1532 {
1533 CHECK_ERROR(machine, COMSETTER(PointingHidType)(PointingHidType_USBMouse));
1534 if (SUCCEEDED(rc))
1535 fEnableUsb = true;
1536 }
1537 else if (!strcmp(ValueUnion.psz, "usbtablet"))
1538 {
1539 CHECK_ERROR(machine, COMSETTER(PointingHidType)(PointingHidType_USBTablet));
1540 if (SUCCEEDED(rc))
1541 fEnableUsb = true;
1542 }
1543 else
1544 {
1545 errorArgument("Invalid type '%s' specfied for pointing device", ValueUnion.psz);
1546 rc = E_FAIL;
1547 }
1548 if (fEnableUsb)
1549 {
1550 /* Make sure the OHCI controller is enabled. */
1551 ComPtr<IUSBController> UsbCtl;
1552 rc = machine->COMGETTER(USBController)(UsbCtl.asOutParam());
1553 if (SUCCEEDED(rc))
1554 {
1555 BOOL fEnabled;
1556 rc = UsbCtl->COMGETTER(Enabled)(&fEnabled);
1557 if (FAILED(rc))
1558 fEnabled = false;
1559 if (!fEnabled)
1560 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(true));
1561 }
1562 }
1563 break;
1564 }
1565
1566 case MODIFYVM_HIDKBD:
1567 {
1568 bool fEnableUsb = false;
1569 if (!strcmp(ValueUnion.psz, "ps2"))
1570 {
1571 CHECK_ERROR(machine, COMSETTER(KeyboardHidType)(KeyboardHidType_PS2Keyboard));
1572 }
1573 else if (!strcmp(ValueUnion.psz, "usb"))
1574 {
1575 CHECK_ERROR(machine, COMSETTER(KeyboardHidType)(KeyboardHidType_USBKeyboard));
1576 if (SUCCEEDED(rc))
1577 fEnableUsb = true;
1578 }
1579 else
1580 {
1581 errorArgument("Invalid type '%s' specfied for keyboard", ValueUnion.psz);
1582 rc = E_FAIL;
1583 }
1584 if (fEnableUsb)
1585 {
1586 /* Make sure the OHCI controller is enabled. */
1587 ComPtr<IUSBController> UsbCtl;
1588 rc = machine->COMGETTER(USBController)(UsbCtl.asOutParam());
1589 if (SUCCEEDED(rc))
1590 {
1591 BOOL fEnabled;
1592 rc = UsbCtl->COMGETTER(Enabled)(&fEnabled);
1593 if (FAILED(rc))
1594 fEnabled = false;
1595 if (!fEnabled)
1596 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(true));
1597 }
1598 }
1599 break;
1600 }
1601
1602 case MODIFYVM_UARTMODE:
1603 {
1604 ComPtr<ISerialPort> uart;
1605 char *pszIRQ = NULL;
1606
1607 CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
1608 ASSERT(uart);
1609
1610 if (!strcmp(ValueUnion.psz, "disconnected"))
1611 {
1612 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_Disconnected));
1613 }
1614 else if ( !strcmp(ValueUnion.psz, "server")
1615 || !strcmp(ValueUnion.psz, "client")
1616 || !strcmp(ValueUnion.psz, "file"))
1617 {
1618 const char *pszMode = ValueUnion.psz;
1619
1620 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
1621 if (RT_FAILURE(vrc))
1622 return errorSyntax(USAGE_MODIFYVM,
1623 "Missing or Invalid argument to '%s'",
1624 GetOptState.pDef->pszLong);
1625
1626 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
1627
1628 if (!strcmp(pszMode, "server"))
1629 {
1630 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
1631 CHECK_ERROR(uart, COMSETTER(Server)(TRUE));
1632 }
1633 else if (!strcmp(pszMode, "client"))
1634 {
1635 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
1636 CHECK_ERROR(uart, COMSETTER(Server)(FALSE));
1637 }
1638 else if (!strcmp(pszMode, "file"))
1639 {
1640 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_RawFile));
1641 }
1642 }
1643 else
1644 {
1645 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
1646 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostDevice));
1647 }
1648 break;
1649 }
1650
1651 case MODIFYVM_UART:
1652 {
1653 ComPtr<ISerialPort> uart;
1654
1655 CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
1656 ASSERT(uart);
1657
1658 if (!strcmp(ValueUnion.psz, "off") || !strcmp(ValueUnion.psz, "disable"))
1659 CHECK_ERROR(uart, COMSETTER(Enabled)(FALSE));
1660 else
1661 {
1662 const char *pszIOBase = ValueUnion.psz;
1663 uint32_t uVal = 0;
1664
1665 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_UART;
1666 if (RT_FAILURE(vrc))
1667 return errorSyntax(USAGE_MODIFYVM,
1668 "Missing or Invalid argument to '%s'",
1669 GetOptState.pDef->pszLong);
1670
1671 CHECK_ERROR(uart, COMSETTER(IRQ)(ValueUnion.u32));
1672
1673 vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
1674 if (vrc != VINF_SUCCESS || uVal == 0)
1675 return errorArgument("Error parsing UART I/O base '%s'", pszIOBase);
1676 CHECK_ERROR(uart, COMSETTER(IOBase)(uVal));
1677
1678 CHECK_ERROR(uart, COMSETTER(Enabled)(TRUE));
1679 }
1680 break;
1681 }
1682
1683 case MODIFYVM_GUESTMEMORYBALLOON:
1684 {
1685 CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(ValueUnion.u32));
1686 break;
1687 }
1688
1689 case MODIFYVM_AUDIOCONTROLLER:
1690 {
1691 ComPtr<IAudioAdapter> audioAdapter;
1692 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
1693 ASSERT(audioAdapter);
1694
1695 if (!strcmp(ValueUnion.psz, "sb16"))
1696 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));
1697 else if (!strcmp(ValueUnion.psz, "ac97"))
1698 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));
1699 else if (!strcmp(ValueUnion.psz, "hda"))
1700 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_HDA));
1701 else
1702 {
1703 errorArgument("Invalid --audiocontroller argument '%s'", ValueUnion.psz);
1704 rc = E_FAIL;
1705 }
1706 break;
1707 }
1708
1709 case MODIFYVM_AUDIO:
1710 {
1711 ComPtr<IAudioAdapter> audioAdapter;
1712 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
1713 ASSERT(audioAdapter);
1714
1715 /* disable? */
1716 if (!strcmp(ValueUnion.psz, "none"))
1717 {
1718 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
1719 }
1720 else if (!strcmp(ValueUnion.psz, "null"))
1721 {
1722 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));
1723 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1724 }
1725#ifdef RT_OS_WINDOWS
1726#ifdef VBOX_WITH_WINMM
1727 else if (!strcmp(ValueUnion.psz, "winmm"))
1728 {
1729 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));
1730 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1731 }
1732#endif
1733 else if (!strcmp(ValueUnion.psz, "dsound"))
1734 {
1735 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
1736 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1737 }
1738#endif /* RT_OS_WINDOWS */
1739#ifdef RT_OS_LINUX
1740# ifdef VBOX_WITH_ALSA
1741 else if (!strcmp(ValueUnion.psz, "alsa"))
1742 {
1743 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));
1744 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1745 }
1746# endif
1747# ifdef VBOX_WITH_PULSE
1748 else if (!strcmp(ValueUnion.psz, "pulse"))
1749 {
1750 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
1751 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1752 }
1753# endif
1754#endif /* !RT_OS_LINUX */
1755#ifdef RT_OS_SOLARIS
1756 else if (!strcmp(ValueUnion.psz, "solaudio"))
1757 {
1758 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio));
1759 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1760 }
1761#endif /* !RT_OS_SOLARIS */
1762#ifdef RT_OS_FREEBSD
1763 else if (!strcmp(ValueUnion.psz, "oss"))
1764 {
1765 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
1766 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1767 }
1768# ifdef VBOX_WITH_PULSE
1769 else if (!strcmp(ValueUnion.psz, "pulse"))
1770 {
1771 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
1772 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1773 }
1774# endif
1775#endif /* !RT_OS_FREEBSD */
1776#ifdef RT_OS_DARWIN
1777 else if (!strcmp(ValueUnion.psz, "coreaudio"))
1778 {
1779 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));
1780 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1781 }
1782
1783#endif /* !RT_OS_DARWIN */
1784# if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(VBOX_WITH_SOLARIS_OSS)
1785 else if (!strcmp(ValueUnion.psz, "oss"))
1786 {
1787 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
1788 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1789 }
1790# endif
1791 else
1792 {
1793 errorArgument("Invalid --audio argument '%s'", ValueUnion.psz);
1794 rc = E_FAIL;
1795 }
1796 break;
1797 }
1798
1799 case MODIFYVM_CLIPBOARD:
1800 {
1801 if (!strcmp(ValueUnion.psz, "disabled"))
1802 {
1803 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled));
1804 }
1805 else if (!strcmp(ValueUnion.psz, "hosttoguest"))
1806 {
1807 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest));
1808 }
1809 else if (!strcmp(ValueUnion.psz, "guesttohost"))
1810 {
1811 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost));
1812 }
1813 else if (!strcmp(ValueUnion.psz, "bidirectional"))
1814 {
1815 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional));
1816 }
1817 else
1818 {
1819 errorArgument("Invalid --clipboard argument '%s'", ValueUnion.psz);
1820 rc = E_FAIL;
1821 }
1822 break;
1823 }
1824
1825 case MODIFYVM_VRDE_EXTPACK:
1826 {
1827 ComPtr<IVRDEServer> vrdeServer;
1828 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1829 ASSERT(vrdeServer);
1830
1831 if (vrdeServer)
1832 {
1833 if (strcmp(ValueUnion.psz, "default") != 0)
1834 {
1835 Bstr bstr(ValueUnion.psz);
1836 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(bstr.raw()));
1837 }
1838 else
1839 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(NULL));
1840 }
1841 break;
1842 }
1843
1844 case MODIFYVM_VRDEPROPERTY:
1845 {
1846 ComPtr<IVRDEServer> vrdeServer;
1847 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1848 ASSERT(vrdeServer);
1849
1850 if (vrdeServer)
1851 {
1852 /* Parse 'name=value' */
1853 char *pszProperty = RTStrDup(ValueUnion.psz);
1854 if (pszProperty)
1855 {
1856 char *pDelimiter = strchr(pszProperty, '=');
1857 if (pDelimiter)
1858 {
1859 *pDelimiter = '\0';
1860
1861 Bstr bstrName = pszProperty;
1862 Bstr bstrValue = &pDelimiter[1];
1863 CHECK_ERROR(vrdeServer, SetVRDEProperty(bstrName.raw(), bstrValue.raw()));
1864 }
1865 else
1866 {
1867 RTStrFree(pszProperty);
1868
1869 errorArgument("Invalid --vrdeproperty argument '%s'", ValueUnion.psz);
1870 rc = E_FAIL;
1871 break;
1872 }
1873 RTStrFree(pszProperty);
1874 }
1875 else
1876 {
1877 RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for VRDE property '%s'\n", ValueUnion.psz);
1878 rc = E_FAIL;
1879 }
1880 }
1881 break;
1882 }
1883
1884 case MODIFYVM_VRDPPORT:
1885 {
1886 vrdeWarningDeprecatedProperty("vrdpport", "TCP/Ports", ValueUnion.psz);
1887
1888 ComPtr<IVRDEServer> vrdeServer;
1889 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1890 ASSERT(vrdeServer);
1891
1892 if (!strcmp(ValueUnion.psz, "default"))
1893 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr("0").raw()));
1894 else
1895 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr(ValueUnion.psz).raw()));
1896 break;
1897 }
1898
1899 case MODIFYVM_VRDPADDRESS:
1900 {
1901 vrdeWarningDeprecatedProperty("vrdpaddress", "TCP/Address", ValueUnion.psz);
1902
1903 ComPtr<IVRDEServer> vrdeServer;
1904 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1905 ASSERT(vrdeServer);
1906
1907 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Address").raw(), Bstr(ValueUnion.psz).raw()));
1908 break;
1909 }
1910
1911 case MODIFYVM_VRDPAUTHTYPE:
1912 vrdeWarningDeprecatedOption("authtype");
1913 case MODIFYVM_VRDEAUTHTYPE:
1914 {
1915 ComPtr<IVRDEServer> vrdeServer;
1916 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1917 ASSERT(vrdeServer);
1918
1919 if (!strcmp(ValueUnion.psz, "null"))
1920 {
1921 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Null));
1922 }
1923 else if (!strcmp(ValueUnion.psz, "external"))
1924 {
1925 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_External));
1926 }
1927 else if (!strcmp(ValueUnion.psz, "guest"))
1928 {
1929 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Guest));
1930 }
1931 else
1932 {
1933 errorArgument("Invalid --vrdeauthtype argument '%s'", ValueUnion.psz);
1934 rc = E_FAIL;
1935 }
1936 break;
1937 }
1938
1939 case MODIFYVM_VRDEAUTHLIBRARY:
1940 {
1941 ComPtr<IVRDEServer> vrdeServer;
1942 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1943 ASSERT(vrdeServer);
1944
1945 if (vrdeServer)
1946 {
1947 if (strcmp(ValueUnion.psz, "default") != 0)
1948 {
1949 Bstr bstr(ValueUnion.psz);
1950 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(bstr.raw()));
1951 }
1952 else
1953 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(NULL));
1954 }
1955 break;
1956 }
1957
1958 case MODIFYVM_VRDPMULTICON:
1959 vrdeWarningDeprecatedOption("multicon");
1960 case MODIFYVM_VRDEMULTICON:
1961 {
1962 ComPtr<IVRDEServer> vrdeServer;
1963 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1964 ASSERT(vrdeServer);
1965
1966 CHECK_ERROR(vrdeServer, COMSETTER(AllowMultiConnection)(ValueUnion.f));
1967 break;
1968 }
1969
1970 case MODIFYVM_VRDPREUSECON:
1971 vrdeWarningDeprecatedOption("reusecon");
1972 case MODIFYVM_VRDEREUSECON:
1973 {
1974 ComPtr<IVRDEServer> vrdeServer;
1975 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1976 ASSERT(vrdeServer);
1977
1978 CHECK_ERROR(vrdeServer, COMSETTER(ReuseSingleConnection)(ValueUnion.f));
1979 break;
1980 }
1981
1982 case MODIFYVM_VRDPVIDEOCHANNEL:
1983 vrdeWarningDeprecatedOption("videochannel");
1984 case MODIFYVM_VRDEVIDEOCHANNEL:
1985 {
1986 ComPtr<IVRDEServer> vrdeServer;
1987 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
1988 ASSERT(vrdeServer);
1989
1990 CHECK_ERROR(vrdeServer, COMSETTER(VideoChannel)(ValueUnion.f));
1991 break;
1992 }
1993
1994 case MODIFYVM_VRDPVIDEOCHANNELQUALITY:
1995 vrdeWarningDeprecatedOption("videochannelquality");
1996 case MODIFYVM_VRDEVIDEOCHANNELQUALITY:
1997 {
1998 ComPtr<IVRDEServer> vrdeServer;
1999 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2000 ASSERT(vrdeServer);
2001
2002 CHECK_ERROR(vrdeServer, COMSETTER(VideoChannelQuality)(ValueUnion.u32));
2003 break;
2004 }
2005
2006 case MODIFYVM_VRDP:
2007 vrdeWarningDeprecatedOption("");
2008 case MODIFYVM_VRDE:
2009 {
2010 ComPtr<IVRDEServer> vrdeServer;
2011 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2012 ASSERT(vrdeServer);
2013
2014 CHECK_ERROR(vrdeServer, COMSETTER(Enabled)(ValueUnion.f));
2015 break;
2016 }
2017
2018 case MODIFYVM_USBEHCI:
2019 {
2020 ComPtr<IUSBController> UsbCtl;
2021 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
2022 if (SUCCEEDED(rc))
2023 CHECK_ERROR(UsbCtl, COMSETTER(EnabledEhci)(ValueUnion.f));
2024 break;
2025 }
2026
2027 case MODIFYVM_USB:
2028 {
2029 ComPtr<IUSBController> UsbCtl;
2030 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
2031 if (SUCCEEDED(rc))
2032 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(ValueUnion.f));
2033 break;
2034 }
2035
2036 case MODIFYVM_SNAPSHOTFOLDER:
2037 {
2038 if (!strcmp(ValueUnion.psz, "default"))
2039 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(NULL));
2040 else
2041 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz).raw()));
2042 break;
2043 }
2044
2045 case MODIFYVM_TELEPORTER_ENABLED:
2046 {
2047 CHECK_ERROR(machine, COMSETTER(TeleporterEnabled)(ValueUnion.f));
2048 break;
2049 }
2050
2051 case MODIFYVM_TELEPORTER_PORT:
2052 {
2053 CHECK_ERROR(machine, COMSETTER(TeleporterPort)(ValueUnion.u32));
2054 break;
2055 }
2056
2057 case MODIFYVM_TELEPORTER_ADDRESS:
2058 {
2059 CHECK_ERROR(machine, COMSETTER(TeleporterAddress)(Bstr(ValueUnion.psz).raw()));
2060 break;
2061 }
2062
2063 case MODIFYVM_TELEPORTER_PASSWORD:
2064 {
2065 CHECK_ERROR(machine, COMSETTER(TeleporterPassword)(Bstr(ValueUnion.psz).raw()));
2066 break;
2067 }
2068
2069 case MODIFYVM_FAULT_TOLERANCE:
2070 {
2071 if (!strcmp(ValueUnion.psz, "master"))
2072 {
2073 CHECK_ERROR(machine, COMSETTER(FaultToleranceState(FaultToleranceState_Master)));
2074 }
2075 else
2076 if (!strcmp(ValueUnion.psz, "standby"))
2077 {
2078 CHECK_ERROR(machine, COMSETTER(FaultToleranceState(FaultToleranceState_Standby)));
2079 }
2080 else
2081 {
2082 errorArgument("Invalid --faulttolerance argument '%s'", ValueUnion.psz);
2083 rc = E_FAIL;
2084 }
2085 break;
2086 }
2087
2088 case MODIFYVM_FAULT_TOLERANCE_ADDRESS:
2089 {
2090 CHECK_ERROR(machine, COMSETTER(FaultToleranceAddress)(Bstr(ValueUnion.psz).raw()));
2091 break;
2092 }
2093
2094 case MODIFYVM_FAULT_TOLERANCE_PORT:
2095 {
2096 CHECK_ERROR(machine, COMSETTER(FaultTolerancePort)(ValueUnion.u32));
2097 break;
2098 }
2099
2100 case MODIFYVM_FAULT_TOLERANCE_PASSWORD:
2101 {
2102 CHECK_ERROR(machine, COMSETTER(FaultTolerancePassword)(Bstr(ValueUnion.psz).raw()));
2103 break;
2104 }
2105
2106 case MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL:
2107 {
2108 CHECK_ERROR(machine, COMSETTER(FaultToleranceSyncInterval)(ValueUnion.u32));
2109 break;
2110 }
2111
2112 case MODIFYVM_HARDWARE_UUID:
2113 {
2114 CHECK_ERROR(machine, COMSETTER(HardwareUUID)(Bstr(ValueUnion.psz).raw()));
2115 break;
2116 }
2117
2118 case MODIFYVM_HPET:
2119 {
2120 CHECK_ERROR(machine, COMSETTER(HpetEnabled)(ValueUnion.f));
2121 break;
2122 }
2123
2124 case MODIFYVM_IOCACHE:
2125 {
2126 CHECK_ERROR(machine, COMSETTER(IoCacheEnabled)(ValueUnion.f));
2127 break;
2128 }
2129
2130 case MODIFYVM_IOCACHESIZE:
2131 {
2132 CHECK_ERROR(machine, COMSETTER(IoCacheSize)(ValueUnion.u32));
2133 break;
2134 }
2135
2136 case MODIFYVM_CHIPSET:
2137 {
2138 if (!strcmp(ValueUnion.psz, "piix3"))
2139 {
2140 CHECK_ERROR(machine, COMSETTER(ChipsetType)(ChipsetType_PIIX3));
2141 }
2142 else if (!strcmp(ValueUnion.psz, "ich9"))
2143 {
2144 CHECK_ERROR(machine, COMSETTER(ChipsetType)(ChipsetType_ICH9));
2145 BOOL fIoApic = FALSE;
2146 CHECK_ERROR(biosSettings, COMGETTER(IOAPICEnabled)(&fIoApic));
2147 if (!fIoApic)
2148 {
2149 RTStrmPrintf(g_pStdErr, "*** I/O APIC must be enabled for ICH9, enabling. ***\n");
2150 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(TRUE));
2151 }
2152 }
2153 else
2154 {
2155 errorArgument("Invalid --chipset argument '%s' (valid: piix3,ich9)", ValueUnion.psz);
2156 rc = E_FAIL;
2157 }
2158 break;
2159 }
2160
2161 default:
2162 {
2163 errorGetOpt(USAGE_MODIFYVM, c, &ValueUnion);
2164 rc = E_FAIL;
2165 break;
2166 }
2167 }
2168 }
2169
2170 /* commit changes */
2171 if (SUCCEEDED(rc))
2172 CHECK_ERROR(machine, SaveSettings());
2173
2174 /* it's important to always close sessions */
2175 a->session->UnlockMachine();
2176
2177 return SUCCEEDED(rc) ? 0 : 1;
2178}
2179
2180#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