VirtualBox

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

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

VBoxManage: check if I/O APIC state is consistent with chipset

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