VirtualBox

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

Last change on this file since 36101 was 36082, checked in by vboxsync, 14 years ago

Added a promiscModePolicy attribute to INetworkAdapter, three values: deny (default), allow-network (i.e. VMs), allow-all (i.e. include unrelated host traffic).

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