VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 8 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 169.6 KB
Line 
1/* $Id: VBoxManageModifyVM.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBoxManage - Implementation of modifyvm command.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#include <VBox/com/com.h>
33#include <VBox/com/array.h>
34#include <VBox/com/ErrorInfo.h>
35#include <VBox/com/errorprint.h>
36#include <VBox/com/VirtualBox.h>
37
38#include <iprt/cidr.h>
39#include <iprt/ctype.h>
40#include <iprt/file.h>
41#include <iprt/param.h>
42#include <iprt/path.h>
43#include <iprt/stream.h>
44#include <iprt/string.h>
45#include <iprt/getopt.h>
46#include <VBox/log.h>
47#include "VBoxManage.h"
48#include "VBoxManageUtils.h"
49
50DECLARE_TRANSLATION_CONTEXT(ModifyVM);
51
52using namespace com;
53/** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */
54#if defined(_MSC_VER)
55# pragma optimize("g", off)
56# if _MSC_VER < RT_MSC_VER_VC120
57# pragma warning(disable:4748)
58# endif
59#endif
60
61enum
62{
63 MODIFYVM_NAME = 1000,
64 MODIFYVM_GROUPS,
65 MODIFYVM_DESCRIPTION,
66 MODIFYVM_OSTYPE,
67 MODIFYVM_ICONFILE,
68 MODIFYVM_MEMORY,
69 MODIFYVM_PAGEFUSION,
70 MODIFYVM_VRAM,
71 MODIFYVM_FIRMWARE,
72 MODIFYVM_ACPI,
73 MODIFYVM_IOAPIC,
74 MODIFYVM_CPUID_PORTABILITY,
75 MODIFYVM_PARAVIRTPROVIDER,
76 MODIFYVM_PARAVIRTDEBUG,
77 MODIFYVM_CPUS,
78 MODIFYVM_CPUHOTPLUG,
79 MODIFYVM_CPU_PROFILE,
80 MODIFYVM_PLUGCPU,
81 MODIFYVM_UNPLUGCPU,
82 MODIFYVM_GRAPHICSCONTROLLER,
83 MODIFYVM_MONITORCOUNT,
84 MODIFYVM_ACCELERATE3D,
85#ifdef VBOX_WITH_VIDEOHWACCEL
86 MODIFYVM_ACCELERATE2DVIDEO,
87#endif
88 /*
89 * Firmware-specific stuff.
90 */
91 MODIFYVM_FWLOGOFADEIN,
92 MODIFYVM_FWLOGOFADEOUT,
93 MODIFYVM_FWLOGODISPLAYTIME,
94 MODIFYVM_FWLOGOIMAGEPATH,
95 MODIFYVM_FWBOOTMENU,
96 MODIFYVM_FWAPIC,
97 MODIFYVM_FWSYSTEMTIMEOFFSET,
98 MODIFYVM_FWPXEDEBUG,
99 MODIFYVM_SYSTEMUUIDLE,
100 MODIFYVM_FWAUTOSERIALNUMGEN,
101 MODIFYVM_BOOT,
102 MODIFYVM_HDA, // deprecated
103 MODIFYVM_HDB, // deprecated
104 MODIFYVM_HDD, // deprecated
105 MODIFYVM_IDECONTROLLER, // deprecated
106 MODIFYVM_SATAPORTCOUNT, // deprecated
107 MODIFYVM_SATAPORT, // deprecated
108 MODIFYVM_SATA, // deprecated
109 MODIFYVM_SCSIPORT, // deprecated
110 MODIFYVM_SCSITYPE, // deprecated
111 MODIFYVM_SCSI, // deprecated
112 MODIFYVM_DVDPASSTHROUGH, // deprecated
113 MODIFYVM_DVD, // deprecated
114 MODIFYVM_FLOPPY, // deprecated
115 MODIFYVM_NICTRACEFILE,
116 MODIFYVM_NICTRACE,
117 MODIFYVM_NICPROPERTY,
118 MODIFYVM_NICTYPE,
119 MODIFYVM_NICSPEED,
120 MODIFYVM_NICBOOTPRIO,
121 MODIFYVM_NICPROMISC,
122 MODIFYVM_NICBWGROUP,
123 MODIFYVM_NIC,
124 MODIFYVM_CABLECONNECTED,
125 MODIFYVM_BRIDGEADAPTER,
126#ifdef VBOX_WITH_CLOUD_NET
127 MODIFYVM_CLOUDNET,
128#endif /* VBOX_WITH_CLOUD_NET */
129 MODIFYVM_HOSTONLYADAPTER,
130#ifdef VBOX_WITH_VMNET
131 MODIFYVM_HOSTONLYNET,
132#endif /* VBOX_WITH_VMNET */
133 MODIFYVM_INTNET,
134 MODIFYVM_GENERICDRV,
135 MODIFYVM_NATNETWORKNAME,
136 MODIFYVM_NATNET,
137 MODIFYVM_NATBINDIP,
138 MODIFYVM_NATSETTINGS,
139 MODIFYVM_NATPF,
140 MODIFYVM_NATALIASMODE,
141 MODIFYVM_NATTFTPPREFIX,
142 MODIFYVM_NATTFTPFILE,
143 MODIFYVM_NATTFTPSERVER,
144 MODIFYVM_NATDNSPASSDOMAIN,
145 MODIFYVM_NATDNSPROXY,
146 MODIFYVM_NATDNSHOSTRESOLVER,
147 MODIFYVM_NATLOCALHOSTREACHABLE,
148 MODIFYVM_MACADDRESS,
149 MODIFYVM_HIDPTR,
150 MODIFYVM_HIDKBD,
151 MODIFYVM_UARTMODE,
152 MODIFYVM_UARTTYPE,
153 MODIFYVM_UART,
154#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
155 MODIFYVM_LPTMODE,
156 MODIFYVM_LPT,
157#endif
158 MODIFYVM_GUESTMEMORYBALLOON,
159 MODIFYVM_AUDIOCONTROLLER,
160 MODIFYVM_AUDIOCODEC,
161 MODIFYVM_AUDIODRIVER,
162 MODIFYVM_AUDIOENABLED,
163 MODIFYVM_AUDIO, /* Deprecated; remove in the next major version. */
164 MODIFYVM_AUDIOIN,
165 MODIFYVM_AUDIOOUT,
166#ifdef VBOX_WITH_SHARED_CLIPBOARD
167 MODIFYVM_CLIPBOARD_MODE,
168# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
169 MODIFYVM_CLIPBOARD_FILE_TRANSFERS,
170# endif
171#endif
172 MODIFYVM_DRAGANDDROP,
173 MODIFYVM_VRDPPORT, /* VRDE: deprecated */
174 MODIFYVM_VRDPADDRESS, /* VRDE: deprecated */
175 MODIFYVM_VRDPAUTHTYPE, /* VRDE: deprecated */
176 MODIFYVM_VRDPMULTICON, /* VRDE: deprecated */
177 MODIFYVM_VRDPREUSECON, /* VRDE: deprecated */
178 MODIFYVM_VRDPVIDEOCHANNEL, /* VRDE: deprecated */
179 MODIFYVM_VRDPVIDEOCHANNELQUALITY, /* VRDE: deprecated */
180 MODIFYVM_VRDP, /* VRDE: deprecated */
181 MODIFYVM_VRDEPROPERTY,
182 MODIFYVM_VRDEPORT,
183 MODIFYVM_VRDEADDRESS,
184 MODIFYVM_VRDEAUTHTYPE,
185 MODIFYVM_VRDEAUTHLIBRARY,
186 MODIFYVM_VRDEMULTICON,
187 MODIFYVM_VRDEREUSECON,
188 MODIFYVM_VRDEVIDEOCHANNEL,
189 MODIFYVM_VRDEVIDEOCHANNELQUALITY,
190 MODIFYVM_VRDE_EXTPACK,
191 MODIFYVM_VRDE,
192 MODIFYVM_RTCUSEUTC,
193 MODIFYVM_USBRENAME,
194 MODIFYVM_USBXHCI,
195 MODIFYVM_USBEHCI,
196 MODIFYVM_USBOHCI,
197 MODIFYVM_SNAPSHOTFOLDER,
198 MODIFYVM_TELEPORTER_ENABLED,
199 MODIFYVM_TELEPORTER_PORT,
200 MODIFYVM_TELEPORTER_ADDRESS,
201 MODIFYVM_TELEPORTER_PASSWORD,
202 MODIFYVM_TELEPORTER_PASSWORD_FILE,
203 MODIFYVM_TRACING_ENABLED,
204 MODIFYVM_TRACING_CONFIG,
205 MODIFYVM_TRACING_ALLOW_VM_ACCESS,
206 MODIFYVM_HARDWARE_UUID,
207 MODIFYVM_IOCACHE,
208 MODIFYVM_IOCACHESIZE,
209 MODIFYVM_CPU_EXECTUION_CAP,
210 MODIFYVM_AUTOSTART_ENABLED,
211 MODIFYVM_AUTOSTART_DELAY,
212 MODIFYVM_AUTOSTOP_TYPE,
213#ifdef VBOX_WITH_PCI_PASSTHROUGH
214 MODIFYVM_ATTACH_PCI,
215 MODIFYVM_DETACH_PCI,
216#endif
217#ifdef VBOX_WITH_USB_CARDREADER
218 MODIFYVM_USBCARDREADER,
219#endif
220#ifdef VBOX_WITH_RECORDING
221 MODIFYVM_RECORDING,
222 MODIFYVM_RECORDING_FEATURES,
223 MODIFYVM_RECORDING_SCREENS,
224 MODIFYVM_RECORDING_FILENAME,
225 MODIFYVM_RECORDING_VIDEO_WIDTH,
226 MODIFYVM_RECORDING_VIDEO_HEIGHT,
227 MODIFYVM_RECORDING_VIDEO_RES,
228 MODIFYVM_RECORDING_VIDEO_RATE,
229 MODIFYVM_RECORDING_VIDEO_FPS,
230 MODIFYVM_RECORDING_MAXTIME,
231 MODIFYVM_RECORDING_MAXSIZE,
232 MODIFYVM_RECORDING_OPTIONS,
233#endif
234 MODIFYVM_CHIPSET,
235#if defined(VBOX_WITH_IOMMU_AMD) || defined(VBOX_WITH_IOMMU_INTEL)
236 MODIFYVM_IOMMU,
237#endif
238#if defined(VBOX_WITH_TPM)
239 MODIFYVM_TPM_LOCATION,
240 MODIFYVM_TPM_TYPE,
241#endif
242 MODIFYVM_DEFAULTFRONTEND,
243 MODIFYVM_VMPROC_PRIORITY,
244 MODIFYVM_VMEXEC_ENGINE,
245 MODIFYVM_TESTING_ENABLED,
246 MODIFYVM_TESTING_MMIO,
247 MODIFYVM_TESTING_CFG_DWORD,
248 MODIFYVM_GUEST_DEBUG_PROVIDER,
249 MODIFYVM_GUEST_DEBUG_IO_PROVIDER,
250 MODIFYVM_GUEST_DEBUG_ADDRESS,
251 MODIFYVM_GUEST_DEBUG_PORT,
252 /*
253 * x86-specific stuff.
254 */
255 MODIFYVM_X86_APIC,
256 MODIFYVM_X86_DELCPUID,
257 MODIFYVM_X86_DELCPUID_OLD, // legacy, different syntax from MODIFYVM_DELCPUID
258 MODIFYVM_X86_DELALLCPUID,
259 MODIFYVM_X86_HPET,
260 MODIFYVM_X86_HWVIRTEX,
261 MODIFYVM_X86_IBPB_ON_VM_ENTRY,
262 MODIFYVM_X86_IBPB_ON_VM_EXIT,
263 MODIFYVM_X86_L1D_FLUSH_ON_SCHED,
264 MODIFYVM_X86_L1D_FLUSH_ON_VM_ENTRY,
265 MODIFYVM_X86_LARGEPAGES,
266 MODIFYVM_X86_LONGMODE,
267 MODIFYVM_X86_MDS_CLEAR_ON_SCHED,
268 MODIFYVM_X86_MDS_CLEAR_ON_VM_ENTRY,
269 MODIFYVM_X86_NESTED_HW_VIRT,
270 MODIFYVM_X86_NESTEDPAGING,
271 MODIFYVM_X86_PAE,
272 MODIFYVM_X86_SETCPUID,
273 MODIFYVM_X86_SPEC_CTRL,
274 MODIFYVM_X86_TFRESET,
275 MODIFYVM_X86_VIRT_VMSAVE_VMLOAD,
276 MODIFYVM_X86_VTXUX,
277 MODIFYVM_X86_VTXVPID,
278 MODIFYVM_X86_X2APIC
279};
280
281static const RTGETOPTDEF g_aModifyVMOptions[] =
282{
283 OPT1("--name", MODIFYVM_NAME, RTGETOPT_REQ_STRING),
284 OPT1("--groups", MODIFYVM_GROUPS, RTGETOPT_REQ_STRING),
285 OPT1("--description", MODIFYVM_DESCRIPTION, RTGETOPT_REQ_STRING),
286 OPT2("--os-type", "--ostype", MODIFYVM_OSTYPE, RTGETOPT_REQ_STRING),
287 OPT2("--icon-file", "--iconfile", MODIFYVM_ICONFILE, RTGETOPT_REQ_STRING),
288 OPT1("--memory", MODIFYVM_MEMORY, RTGETOPT_REQ_UINT32),
289 OPT2("--page-fusion", "--pagefusion", MODIFYVM_PAGEFUSION, RTGETOPT_REQ_BOOL_ONOFF),
290 OPT1("--vram", MODIFYVM_VRAM, RTGETOPT_REQ_UINT32),
291 OPT1("--firmware", MODIFYVM_FIRMWARE, RTGETOPT_REQ_STRING),
292 OPT1("--acpi", MODIFYVM_ACPI, RTGETOPT_REQ_BOOL_ONOFF),
293 OPT1("--ioapic", MODIFYVM_IOAPIC, RTGETOPT_REQ_BOOL_ONOFF),
294 OPT1("--cpuid-portability-level", MODIFYVM_CPUID_PORTABILITY, RTGETOPT_REQ_UINT32),
295 OPT2("--paravirt-provider", "--paravirtprovider", MODIFYVM_PARAVIRTPROVIDER, RTGETOPT_REQ_STRING),
296 OPT2("--paravirt-debug", "--paravirtdebug", MODIFYVM_PARAVIRTDEBUG, RTGETOPT_REQ_STRING),
297 OPT1("--cpus", MODIFYVM_CPUS, RTGETOPT_REQ_UINT32),
298 OPT2("--cpu-hotplug", "--cpuhotplug", MODIFYVM_CPUHOTPLUG, RTGETOPT_REQ_BOOL_ONOFF),
299 OPT1("--cpu-profile", MODIFYVM_CPU_PROFILE, RTGETOPT_REQ_STRING),
300 OPT2("--plug-cpu", "--plugcpu", MODIFYVM_PLUGCPU, RTGETOPT_REQ_UINT32),
301 OPT2("--unplug-cpu", "--unplugcpu", MODIFYVM_UNPLUGCPU, RTGETOPT_REQ_UINT32),
302 OPT2("--cpu-execution-cap", "--cpuexecutioncap", MODIFYVM_CPU_EXECTUION_CAP, RTGETOPT_REQ_UINT32),
303 OPT2("--rtc-use-utc", "--rtcuseutc", MODIFYVM_RTCUSEUTC, RTGETOPT_REQ_BOOL_ONOFF),
304 OPT2("--graphicscontroller", "--graphicscontroller", MODIFYVM_GRAPHICSCONTROLLER, RTGETOPT_REQ_STRING),
305 OPT2("--monitor-count", "--monitorcount", MODIFYVM_MONITORCOUNT, RTGETOPT_REQ_UINT32),
306 OPT2("--accelerate-3d", "--accelerate3d", MODIFYVM_ACCELERATE3D, RTGETOPT_REQ_BOOL_ONOFF),
307#ifdef VBOX_WITH_VIDEOHWACCEL
308 OPT2("--accelerate-2d-video", "--accelerate2dvideo", MODIFYVM_ACCELERATE2DVIDEO, RTGETOPT_REQ_BOOL_ONOFF),
309#endif
310 OPT1("--firmware-logo-fade-in", MODIFYVM_FWLOGOFADEIN, RTGETOPT_REQ_BOOL_ONOFF),
311 OPT1("--firmware-logo-fade-out", MODIFYVM_FWLOGOFADEOUT, RTGETOPT_REQ_BOOL_ONOFF),
312 OPT1("--firmware-logo-image-path", MODIFYVM_FWLOGOIMAGEPATH, RTGETOPT_REQ_STRING),
313 OPT1("--firmware-logo-display-time", MODIFYVM_FWLOGODISPLAYTIME, RTGETOPT_REQ_UINT32),
314 OPT1("--firmware-boot-menu", MODIFYVM_FWBOOTMENU, RTGETOPT_REQ_STRING),
315 OPT1("--firmware-system-time-offset", MODIFYVM_FWSYSTEMTIMEOFFSET, RTGETOPT_REQ_INT64),
316 OPT1("--firmware-apic", MODIFYVM_FWAPIC, RTGETOPT_REQ_STRING),
317 OPT1("--firmware-pxe-debug", MODIFYVM_FWPXEDEBUG, RTGETOPT_REQ_BOOL_ONOFF),
318 /* { Kept for backwards-compatibility */
319 OPT2("--bios-logo-fade-in", "--bioslogofadein", MODIFYVM_FWLOGOFADEIN, RTGETOPT_REQ_BOOL_ONOFF),
320 OPT1("--firmware-fade-out", MODIFYVM_FWLOGOFADEOUT, RTGETOPT_REQ_BOOL_ONOFF),
321 OPT2("--bios-logo-fade-out", "--bioslogofadeout", MODIFYVM_FWLOGOFADEOUT, RTGETOPT_REQ_BOOL_ONOFF),
322 OPT2("--bios-logo-display-time", "--bioslogodisplaytime", MODIFYVM_FWLOGODISPLAYTIME, RTGETOPT_REQ_UINT32),
323 OPT2("--bios-logo-image-path", "--bioslogoimagepath", MODIFYVM_FWLOGOIMAGEPATH, RTGETOPT_REQ_STRING),
324 OPT2("--bios-boot-menu", "--biosbootmenu", MODIFYVM_FWBOOTMENU, RTGETOPT_REQ_STRING),
325 OPT2("--bios-system-time-offset", "--biossystemtimeoffset", MODIFYVM_FWSYSTEMTIMEOFFSET, RTGETOPT_REQ_INT64),
326 OPT2("--bios-apic", "--biosapic", MODIFYVM_FWAPIC, RTGETOPT_REQ_STRING),
327 OPT2("--bios-pxe-debug", "--biospxedebug", MODIFYVM_FWPXEDEBUG, RTGETOPT_REQ_BOOL_ONOFF),
328 /* } */
329 OPT2("--system-uuid-le", "--system-uuid-le", MODIFYVM_SYSTEMUUIDLE, RTGETOPT_REQ_BOOL_ONOFF),
330 OPT2("--bios-auto-serial-num-gen", "--biosautoserialnumgen", MODIFYVM_FWAUTOSERIALNUMGEN, RTGETOPT_REQ_BOOL_ONOFF),
331 OPT1("--boot", MODIFYVM_BOOT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
332 OPT1("--hda", MODIFYVM_HDA, RTGETOPT_REQ_STRING), /* deprecated */
333 OPT1("--hdb", MODIFYVM_HDB, RTGETOPT_REQ_STRING), /* deprecated */
334 OPT1("--hdd", MODIFYVM_HDD, RTGETOPT_REQ_STRING), /* deprecated */
335 OPT2("--idec-ontroller", "--idecontroller", MODIFYVM_IDECONTROLLER, RTGETOPT_REQ_STRING), /* deprecated */
336 OPT2("--sata-port-count", "--sataportcount", MODIFYVM_SATAPORTCOUNT, RTGETOPT_REQ_UINT32), /* deprecated */
337 OPT2("--sata-port", "--sataport", MODIFYVM_SATAPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX), /* deprecated */
338 OPT1("--sata", MODIFYVM_SATA, RTGETOPT_REQ_STRING), /* deprecated */
339 OPT2("--scsi-port", "--scsiport", MODIFYVM_SCSIPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX), /* deprecated */
340 OPT2("--scsi-type", "--scsitype", MODIFYVM_SCSITYPE, RTGETOPT_REQ_STRING), /* deprecated */
341 OPT1("--scsi", MODIFYVM_SCSI, RTGETOPT_REQ_STRING), /* deprecated */
342 OPT2("--dvd-pass-through", "--dvdpassthrough", MODIFYVM_DVDPASSTHROUGH, RTGETOPT_REQ_STRING), /* deprecated */
343 OPT1("--dvd", MODIFYVM_DVD, RTGETOPT_REQ_STRING), /* deprecated */
344 OPT1("--floppy", MODIFYVM_FLOPPY, RTGETOPT_REQ_STRING), /* deprecated */
345 OPT2("--nic-trace-file", "--nictracefile", MODIFYVM_NICTRACEFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
346 OPT2("--nic-trace", "--nictrace", MODIFYVM_NICTRACE, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX),
347 OPT2("--nic-property", "--nicproperty", MODIFYVM_NICPROPERTY, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
348 OPT2("--nic-type", "--nictype", MODIFYVM_NICTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
349 OPT2("--nic-speed", "--nicspeed", MODIFYVM_NICSPEED, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX),
350 OPT2("--nic-boot-prio", "--nicbootprio", MODIFYVM_NICBOOTPRIO, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX),
351 OPT2("--nic-promisc", "--nicpromisc", MODIFYVM_NICPROMISC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
352 OPT2("--nic-bandwidth-group", "--nicbandwidthgroup", MODIFYVM_NICBWGROUP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
353 OPT1("--nic", MODIFYVM_NIC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
354 OPT2("--cable-connected", "--cableconnected", MODIFYVM_CABLECONNECTED, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX),
355 OPT2("--bridge-adapter", "--bridgeadapter", MODIFYVM_BRIDGEADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
356#ifdef VBOX_WITH_CLOUD_NET
357 OPT2("--cloud-network", "--cloudnetwork", MODIFYVM_CLOUDNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
358#endif /* VBOX_WITH_CLOUD_NET */
359 OPT2("--host-only-adapter", "--hostonlyadapter", MODIFYVM_HOSTONLYADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
360#ifdef VBOX_WITH_VMNET
361 OPT2("--host-only-net", "--hostonlynet", MODIFYVM_HOSTONLYNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
362#endif
363 OPT1("--intnet", MODIFYVM_INTNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
364 OPT2("--nic-generic-drv", "--nicgenericdrv", MODIFYVM_GENERICDRV, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
365 OPT2("--nat-network", "--natnetwork", MODIFYVM_NATNETWORKNAME, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
366 OPT2("--nat-net", "--natnet", MODIFYVM_NATNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
367 OPT2("--nat-bind-ip", "--natbindip", MODIFYVM_NATBINDIP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
368 OPT2("--nat-settings", "--natsettings", MODIFYVM_NATSETTINGS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
369 OPT2("--nat-pf", "--natpf", MODIFYVM_NATPF, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
370 OPT2("--nat-alias-mode", "--nataliasmode", MODIFYVM_NATALIASMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
371 OPT2("--nat-tftp-prefix", "--nattftpprefix", MODIFYVM_NATTFTPPREFIX, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
372 OPT2("--nat-tftp-file", "--nattftpfile", MODIFYVM_NATTFTPFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
373 OPT2("--nat-tftp-server", "--nattftpserver", MODIFYVM_NATTFTPSERVER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
374 OPT2("--nat-dns-pass-domain", "--natdnspassdomain", MODIFYVM_NATDNSPASSDOMAIN, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX),
375 OPT2("--nat-dns-proxy", "--natdnsproxy", MODIFYVM_NATDNSPROXY, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX),
376 OPT2("--nat-dns-host-resolver", "--natdnshostresolver", MODIFYVM_NATDNSHOSTRESOLVER, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX),
377 OPT2("--nat-localhostreachable", "--natlocalhostreachable", MODIFYVM_NATLOCALHOSTREACHABLE, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX),
378 OPT2("--mac-address", "--macaddress", MODIFYVM_MACADDRESS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
379 OPT1("--mouse", MODIFYVM_HIDPTR, RTGETOPT_REQ_STRING),
380 OPT1("--keyboard", MODIFYVM_HIDKBD, RTGETOPT_REQ_STRING),
381 OPT2("--uart-mode", "--uartmode", MODIFYVM_UARTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
382 OPT2("--uart-type", "--uarttype", MODIFYVM_UARTTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
383 OPT1("--uart", MODIFYVM_UART, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
384#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
385 OPT2("--lpt-mode", "--lptmode", MODIFYVM_LPTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
386 OPT1("--lpt", MODIFYVM_LPT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX),
387#endif
388 OPT2("--guest-memory-balloon", "--guestmemoryballoon", MODIFYVM_GUESTMEMORYBALLOON, RTGETOPT_REQ_UINT32),
389 OPT2("--audio-controller", "--audiocontroller", MODIFYVM_AUDIOCONTROLLER, RTGETOPT_REQ_STRING),
390 OPT2("--audio-codec", "--audiocodec", MODIFYVM_AUDIOCODEC, RTGETOPT_REQ_STRING),
391 OPT1("--audio", MODIFYVM_AUDIO, RTGETOPT_REQ_STRING),
392 OPT2("--audio-driver", "--audiodriver", MODIFYVM_AUDIODRIVER, RTGETOPT_REQ_STRING),
393 OPT2("--audio-enabled", "--audioenabled", MODIFYVM_AUDIOENABLED, RTGETOPT_REQ_BOOL_ONOFF),
394 OPT2("--audio-in", "--audioin", MODIFYVM_AUDIOIN, RTGETOPT_REQ_BOOL_ONOFF),
395 OPT2("--audio-out", "--audioout", MODIFYVM_AUDIOOUT, RTGETOPT_REQ_BOOL_ONOFF),
396#ifdef VBOX_WITH_SHARED_CLIPBOARD
397 OPT1("--clipboard-mode", MODIFYVM_CLIPBOARD_MODE, RTGETOPT_REQ_STRING),
398 OPT1("--clipboard", MODIFYVM_CLIPBOARD_MODE, RTGETOPT_REQ_STRING), /* deprecated */
399# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
400 OPT1("--clipboard-file-transfers", MODIFYVM_CLIPBOARD_FILE_TRANSFERS, RTGETOPT_REQ_STRING),
401# endif
402#endif
403 OPT2("--drag-and-drop", "--draganddrop", MODIFYVM_DRAGANDDROP, RTGETOPT_REQ_STRING),
404 OPT2("--vrdp-port", "--vrdpport", MODIFYVM_VRDPPORT, RTGETOPT_REQ_STRING), /* deprecated */
405 OPT2("--vrdp-address", "--vrdpaddress", MODIFYVM_VRDPADDRESS, RTGETOPT_REQ_STRING), /* deprecated */
406 OPT2("--vrdp-auth-type", "--vrdpauthtype", MODIFYVM_VRDPAUTHTYPE, RTGETOPT_REQ_STRING), /* deprecated */
407 OPT2("--vrdp-multi-con", "--vrdpmulticon", MODIFYVM_VRDPMULTICON, RTGETOPT_REQ_BOOL_ONOFF), /* deprecated */
408 OPT2("--vrdp-reuse-con", "--vrdpreusecon", MODIFYVM_VRDPREUSECON, RTGETOPT_REQ_BOOL_ONOFF), /* deprecated */
409 OPT2("--vrdp-video-channel", "--vrdpvideochannel", MODIFYVM_VRDPVIDEOCHANNEL, RTGETOPT_REQ_BOOL_ONOFF), /* deprecated */
410 OPT2("--vrdp-video-channel-quality", "--vrdpvideochannelquality",MODIFYVM_VRDPVIDEOCHANNELQUALITY, RTGETOPT_REQ_STRING), /* deprecated */
411 OPT1("--vrdp", MODIFYVM_VRDP, RTGETOPT_REQ_BOOL_ONOFF), /* deprecated */
412 OPT2("--vrde-property", "--vrdeproperty", MODIFYVM_VRDEPROPERTY, RTGETOPT_REQ_STRING),
413 OPT2("--vrde-port", "--vrdeport", MODIFYVM_VRDEPORT, RTGETOPT_REQ_STRING),
414 OPT2("--vrde-address", "--vrdeaddress", MODIFYVM_VRDEADDRESS, RTGETOPT_REQ_STRING),
415 OPT2("--vrde-auth-type", "--vrdeauthtype", MODIFYVM_VRDEAUTHTYPE, RTGETOPT_REQ_STRING),
416 OPT2("--vrde-auth-library", "--vrdeauthlibrary", MODIFYVM_VRDEAUTHLIBRARY, RTGETOPT_REQ_STRING),
417 OPT2("--vrde-multi-con", "--vrdemulticon", MODIFYVM_VRDEMULTICON, RTGETOPT_REQ_BOOL_ONOFF),
418 OPT2("--vrde-reuse-con", "--vrdereusecon", MODIFYVM_VRDEREUSECON, RTGETOPT_REQ_BOOL_ONOFF),
419 OPT2("--vrde-video-channel", "--vrdevideochannel", MODIFYVM_VRDEVIDEOCHANNEL, RTGETOPT_REQ_BOOL_ONOFF),
420 OPT2("--vrde-video-channel-quality", "--vrdevideochannelquality",MODIFYVM_VRDEVIDEOCHANNELQUALITY, RTGETOPT_REQ_STRING),
421 OPT2("--vrde-extpack", "--vrdeextpack", MODIFYVM_VRDE_EXTPACK, RTGETOPT_REQ_STRING),
422 OPT1("--vrde", MODIFYVM_VRDE, RTGETOPT_REQ_BOOL_ONOFF),
423 OPT2("--usb-rename", "--usbrename", MODIFYVM_USBRENAME, RTGETOPT_REQ_STRING),
424 OPT2("--usb-xhci", "--usbxhci", MODIFYVM_USBXHCI, RTGETOPT_REQ_BOOL_ONOFF),
425 OPT2("--usb-ehci", "--usbehci", MODIFYVM_USBEHCI, RTGETOPT_REQ_BOOL_ONOFF),
426 OPT2("--usb-ohci", "--usbohci", MODIFYVM_USBOHCI, RTGETOPT_REQ_BOOL_ONOFF),
427 OPT1("--usb", MODIFYVM_USBOHCI, RTGETOPT_REQ_BOOL_ONOFF), /* deprecated */
428 OPT2("--snapshot-folder", "--snapshotfolder", MODIFYVM_SNAPSHOTFOLDER, RTGETOPT_REQ_STRING),
429 OPT1("--teleporter", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF),
430 OPT2("--teleporter-enabled", "--teleporterenabled", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF), /* deprecated */
431 OPT2("--teleporter-port", "--teleporterport", MODIFYVM_TELEPORTER_PORT, RTGETOPT_REQ_UINT32),
432 OPT2("--teleporter-address", "--teleporteraddress", MODIFYVM_TELEPORTER_ADDRESS, RTGETOPT_REQ_STRING),
433 OPT2("--teleporter-password", "--teleporterpassword", MODIFYVM_TELEPORTER_PASSWORD, RTGETOPT_REQ_STRING),
434 OPT2("--teleporter-password-file", "--teleporterpasswordfile", MODIFYVM_TELEPORTER_PASSWORD_FILE, RTGETOPT_REQ_STRING),
435 OPT1("--tracing-enabled", MODIFYVM_TRACING_ENABLED, RTGETOPT_REQ_BOOL_ONOFF),
436 OPT1("--tracing-config", MODIFYVM_TRACING_CONFIG, RTGETOPT_REQ_STRING),
437 OPT1("--tracing-allow-vm-access", MODIFYVM_TRACING_ALLOW_VM_ACCESS, RTGETOPT_REQ_BOOL_ONOFF),
438 OPT2("--hardware-uuid", "--hardwareuuid", MODIFYVM_HARDWARE_UUID, RTGETOPT_REQ_STRING),
439 OPT1("--iocache", MODIFYVM_IOCACHE, RTGETOPT_REQ_BOOL_ONOFF),
440 OPT2("--iocache-size", "--iocachesize", MODIFYVM_IOCACHESIZE, RTGETOPT_REQ_UINT32),
441 OPT1("--chipset", MODIFYVM_CHIPSET, RTGETOPT_REQ_STRING),
442#if defined(VBOX_WITH_IOMMU_AMD) || defined(VBOX_WITH_IOMMU_INTEL)
443 OPT1("--iommu", MODIFYVM_IOMMU, RTGETOPT_REQ_STRING),
444#endif
445#if defined(VBOX_WITH_TPM)
446 OPT1("--tpm-type", MODIFYVM_TPM_TYPE, RTGETOPT_REQ_STRING),
447 OPT1("--tpm-location", MODIFYVM_TPM_LOCATION, RTGETOPT_REQ_STRING),
448#endif
449#ifdef VBOX_WITH_RECORDING
450 OPT1("--recording", MODIFYVM_RECORDING, RTGETOPT_REQ_BOOL_ONOFF),
451 OPT2("--recording-screens", "--recordingscreens", MODIFYVM_RECORDING_SCREENS, RTGETOPT_REQ_STRING),
452 OPT2("--recording-file", "--recordingfile", MODIFYVM_RECORDING_FILENAME, RTGETOPT_REQ_STRING),
453 OPT2("--recording-max-time", "--recordingmaxtime", MODIFYVM_RECORDING_MAXTIME, RTGETOPT_REQ_INT32),
454 OPT2("--recording-max-size", "--recordingmaxsize", MODIFYVM_RECORDING_MAXSIZE, RTGETOPT_REQ_INT32),
455 OPT2("--recording-opts", "--recordingopts", MODIFYVM_RECORDING_OPTIONS, RTGETOPT_REQ_STRING),
456 OPT2("--recording-options", "--recordingoptions", MODIFYVM_RECORDING_OPTIONS, RTGETOPT_REQ_STRING),
457 OPT2("--recording-video-res", "--recordingvideores", MODIFYVM_RECORDING_VIDEO_RES, RTGETOPT_REQ_STRING),
458 OPT2("--recording-video-resolution", "--recordingvideoresolution",MODIFYVM_RECORDING_VIDEO_RES, RTGETOPT_REQ_STRING),
459 OPT2("--recording-video-rate", "--recordingvideorate", MODIFYVM_RECORDING_VIDEO_RATE, RTGETOPT_REQ_UINT32),
460 OPT2("--recording-video-fps", "--recordingvideofps", MODIFYVM_RECORDING_VIDEO_FPS, RTGETOPT_REQ_UINT32),
461#endif
462 OPT1("--autostart-enabled", MODIFYVM_AUTOSTART_ENABLED, RTGETOPT_REQ_BOOL_ONOFF),
463 OPT1("--autostart-delay", MODIFYVM_AUTOSTART_DELAY, RTGETOPT_REQ_UINT32),
464 OPT1("--autostop-type", MODIFYVM_AUTOSTOP_TYPE, RTGETOPT_REQ_STRING),
465#ifdef VBOX_WITH_PCI_PASSTHROUGH
466 OPT2("--pci-attach", "--pciattach", MODIFYVM_ATTACH_PCI, RTGETOPT_REQ_STRING),
467 OPT2("--pci-detach", "--pcidetach", MODIFYVM_DETACH_PCI, RTGETOPT_REQ_STRING),
468#endif
469#ifdef VBOX_WITH_USB_CARDREADER
470 OPT2("--usb-card-reader", "--usbcardreader", MODIFYVM_USBCARDREADER, RTGETOPT_REQ_BOOL_ONOFF),
471#endif
472 OPT2("--default-frontend", "--defaultfrontend", MODIFYVM_DEFAULTFRONTEND, RTGETOPT_REQ_STRING),
473 OPT1("--vm-process-priority", MODIFYVM_VMPROC_PRIORITY, RTGETOPT_REQ_STRING),
474 OPT1("--vm-execution-engine", MODIFYVM_VMEXEC_ENGINE, RTGETOPT_REQ_STRING),
475 OPT1("--testing-enabled", MODIFYVM_TESTING_ENABLED, RTGETOPT_REQ_BOOL_ONOFF),
476 OPT1("--testing-mmio", MODIFYVM_TESTING_MMIO, RTGETOPT_REQ_BOOL_ONOFF),
477 OPT1("--testing-cfg-dword", MODIFYVM_TESTING_CFG_DWORD, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX),
478 OPT1("--guest-debug-provider", MODIFYVM_GUEST_DEBUG_PROVIDER, RTGETOPT_REQ_STRING),
479 OPT1("--guest-debug-io-provider", MODIFYVM_GUEST_DEBUG_IO_PROVIDER, RTGETOPT_REQ_STRING),
480 OPT1("--guest-debug-address", MODIFYVM_GUEST_DEBUG_ADDRESS, RTGETOPT_REQ_STRING),
481 OPT1("--guest-debug-port", MODIFYVM_GUEST_DEBUG_PORT, RTGETOPT_REQ_UINT32),
482
483 /*
484 * x86-only stuff.
485 *
486 * Note: The non-prefixed options (e.g. "hpet" vs. "x86-hpet") are being kept
487 * to maintain backwards compatibility, at least for a while. Remove them before going on pension.
488 *
489 * Sorted after their MODIFYVM_X86_XXX values.
490 */
491 OPT1("--x86-apic", MODIFYVM_X86_APIC, RTGETOPT_REQ_BOOL_ONOFF),
492 OPT1("--apic", MODIFYVM_X86_APIC, RTGETOPT_REQ_BOOL_ONOFF),
493 OPT1("--x86-cpuid-remove", MODIFYVM_X86_DELCPUID, RTGETOPT_REQ_UINT32_OPTIONAL_PAIR | RTGETOPT_FLAG_HEX),
494 OPT1("--cpuid-remove", MODIFYVM_X86_DELCPUID, RTGETOPT_REQ_UINT32_OPTIONAL_PAIR | RTGETOPT_FLAG_HEX),
495 OPT1("--cpuidremove", MODIFYVM_X86_DELCPUID_OLD, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX), /* legacy - syntax differs */
496 OPT1("--x86-cpuid-remove-all", MODIFYVM_X86_DELALLCPUID, RTGETOPT_REQ_NOTHING),
497 OPT2("--cpuid-remove-all", "--cpuidremoveall", MODIFYVM_X86_DELALLCPUID, RTGETOPT_REQ_NOTHING),
498 OPT1("--x86-hpet", MODIFYVM_X86_HPET, RTGETOPT_REQ_BOOL_ONOFF),
499 OPT1("--hpet", MODIFYVM_X86_HPET, RTGETOPT_REQ_BOOL_ONOFF),
500 OPT1("--x86-hwvirtex", MODIFYVM_X86_HWVIRTEX, RTGETOPT_REQ_BOOL_ONOFF),
501 OPT1("--hwvirtex", MODIFYVM_X86_HWVIRTEX, RTGETOPT_REQ_BOOL_ONOFF),
502 OPT1("--x86-ibpb-on-vm-entry", MODIFYVM_X86_IBPB_ON_VM_ENTRY, RTGETOPT_REQ_BOOL_ONOFF),
503 OPT1("--ibpb-on-vm-entry", MODIFYVM_X86_IBPB_ON_VM_ENTRY, RTGETOPT_REQ_BOOL_ONOFF),
504 OPT1("--x86-ibpb-on-vm-exit", MODIFYVM_X86_IBPB_ON_VM_EXIT, RTGETOPT_REQ_BOOL_ONOFF),
505 OPT1("--ibpb-on-vm-exit", MODIFYVM_X86_IBPB_ON_VM_EXIT, RTGETOPT_REQ_BOOL_ONOFF),
506 OPT1("--x86-l1d-flush-on-sched", MODIFYVM_X86_L1D_FLUSH_ON_SCHED, RTGETOPT_REQ_BOOL_ONOFF),
507 OPT1("--l1d-flush-on-sched", MODIFYVM_X86_L1D_FLUSH_ON_SCHED, RTGETOPT_REQ_BOOL_ONOFF),
508 OPT1("--x86-l1d-flush-on-vm-entry", MODIFYVM_X86_L1D_FLUSH_ON_VM_ENTRY, RTGETOPT_REQ_BOOL_ONOFF),
509 OPT1("--l1d-flush-on-vm-entry", MODIFYVM_X86_L1D_FLUSH_ON_VM_ENTRY, RTGETOPT_REQ_BOOL_ONOFF),
510 OPT1("--x86-large-pages", MODIFYVM_X86_LARGEPAGES, RTGETOPT_REQ_BOOL_ONOFF),
511 OPT2("--large-pages", "--largepages", MODIFYVM_X86_LARGEPAGES, RTGETOPT_REQ_BOOL_ONOFF),
512 OPT1("--x86-long-mode", MODIFYVM_X86_LONGMODE, RTGETOPT_REQ_BOOL_ONOFF),
513 OPT2("--long-mode", "--longmode", MODIFYVM_X86_LONGMODE, RTGETOPT_REQ_BOOL_ONOFF),
514 OPT1("--x86-mds-clear-on-sched", MODIFYVM_X86_MDS_CLEAR_ON_SCHED, RTGETOPT_REQ_BOOL_ONOFF),
515 OPT1("--mds-clear-on-sched", MODIFYVM_X86_MDS_CLEAR_ON_SCHED, RTGETOPT_REQ_BOOL_ONOFF),
516 OPT1("--x86-mds-clear-on-vm-entry", MODIFYVM_X86_MDS_CLEAR_ON_VM_ENTRY, RTGETOPT_REQ_BOOL_ONOFF),
517 OPT1("--mds-clear-on-vm-entry", MODIFYVM_X86_MDS_CLEAR_ON_VM_ENTRY, RTGETOPT_REQ_BOOL_ONOFF),
518 OPT1("--x86-nested-hw-virt", MODIFYVM_X86_NESTED_HW_VIRT, RTGETOPT_REQ_BOOL_ONOFF),
519 OPT1("--nested-hw-virt", MODIFYVM_X86_NESTED_HW_VIRT, RTGETOPT_REQ_BOOL_ONOFF),
520 OPT1("--x86-nested-paging", MODIFYVM_X86_NESTEDPAGING, RTGETOPT_REQ_BOOL_ONOFF),
521 OPT2("--nested-paging", "--nestedpaging", MODIFYVM_X86_NESTEDPAGING, RTGETOPT_REQ_BOOL_ONOFF),
522 OPT1("--x86-pae", MODIFYVM_X86_PAE, RTGETOPT_REQ_BOOL_ONOFF),
523 OPT1("--pae", MODIFYVM_X86_PAE, RTGETOPT_REQ_BOOL_ONOFF),
524 OPT1("--x86-cpuid-set", MODIFYVM_X86_SETCPUID, RTGETOPT_REQ_UINT32_OPTIONAL_PAIR | RTGETOPT_FLAG_HEX),
525 OPT2("--cpuid-set", "--cpuidset", MODIFYVM_X86_SETCPUID, RTGETOPT_REQ_UINT32_OPTIONAL_PAIR | RTGETOPT_FLAG_HEX),
526 OPT1("--x86-spec-ctrl", MODIFYVM_X86_SPEC_CTRL, RTGETOPT_REQ_BOOL_ONOFF),
527 OPT1("--spec-ctrl", MODIFYVM_X86_SPEC_CTRL, RTGETOPT_REQ_BOOL_ONOFF),
528 OPT1("--x86-triple-fault-reset", MODIFYVM_X86_TFRESET, RTGETOPT_REQ_BOOL_ONOFF),
529 OPT2("--triple-fault-reset", "--triplefaultreset", MODIFYVM_X86_TFRESET, RTGETOPT_REQ_BOOL_ONOFF),
530 OPT1("--virt-vmsave-vmload", MODIFYVM_X86_VIRT_VMSAVE_VMLOAD, RTGETOPT_REQ_BOOL_ONOFF),
531 OPT1("--x86-virt-vmsave-vmload", MODIFYVM_X86_VIRT_VMSAVE_VMLOAD, RTGETOPT_REQ_BOOL_ONOFF),
532 OPT1("--x86-vtx-ux", MODIFYVM_X86_VTXUX, RTGETOPT_REQ_BOOL_ONOFF),
533 OPT2("--vtx-ux", "--vtxux", MODIFYVM_X86_VTXUX, RTGETOPT_REQ_BOOL_ONOFF),
534 OPT1("--x86-vtx-vpid", MODIFYVM_X86_VTXVPID, RTGETOPT_REQ_BOOL_ONOFF),
535 OPT2("--vtx-vpid", "--vtxvpid", MODIFYVM_X86_VTXVPID, RTGETOPT_REQ_BOOL_ONOFF),
536 OPT1("--x86-x2apic", MODIFYVM_X86_X2APIC, RTGETOPT_REQ_BOOL_ONOFF),
537 OPT1("--x2apic", MODIFYVM_X86_X2APIC, RTGETOPT_REQ_BOOL_ONOFF),
538};
539
540static void vrdeWarningDeprecatedOption(const char *pszOption)
541{
542 RTStrmPrintf(g_pStdErr, ModifyVM::tr("Warning: '--vrdp%s' is deprecated. Use '--vrde%s'.\n"), pszOption, pszOption);
543}
544
545
546/**
547 * Wrapper around IMachine::SetExtraData that does the error reporting.
548 *
549 * @returns COM result code.
550 * @param rSessionMachine The IMachine.
551 * @param pszVariable The variable to set.
552 * @param pszValue The value to set. To delete pass empty string, not
553 * NULL.
554 */
555static HRESULT setExtraData(ComPtr<IMachine> &rSessionMachine, const char *pszVariable, const char *pszValue)
556{
557 HRESULT hrc = rSessionMachine->SetExtraData(Bstr(pszVariable).raw(), Bstr(pszValue).raw());
558 if (FAILED(hrc))
559 {
560 char *pszContext = RTStrAPrintf2("IMachine::SetExtraData('%s', '%s')", pszVariable, pszValue);
561 com::GlueHandleComError(rSessionMachine, pszContext, hrc, __FILE__, __LINE__);
562 RTStrFree(pszContext);
563 }
564 return hrc;
565}
566
567
568#ifdef VBOX_WITH_PCI_PASSTHROUGH
569/** Parse PCI address in format 01:02.03 and convert it to the numeric representation. */
570static int32_t parsePci(const char* szPciAddr)
571{
572 uint8_t aVals[3] = {0, 0, 0};
573
574 char *pszNext;
575 int vrc = RTStrToUInt8Ex(pszNext, &pszNext, 16, &aVals[0]);
576 if (RT_FAILURE(vrc) || pszNext == NULL || *pszNext != ':')
577 return -1;
578
579 vrc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[1]);
580 if (RT_FAILURE(vrc) || pszNext == NULL || *pszNext != '.')
581 return -1;
582
583 vrc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[2]);
584 if (RT_FAILURE(vrc) || pszNext == NULL)
585 return -1;
586
587 return (aVals[0] << 8) | (aVals[1] << 3) | (aVals[2] << 0);
588}
589#endif
590
591void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups)
592{
593 while (pcszGroups)
594 {
595 char *pComma = RTStrStr(pcszGroups, ",");
596 if (pComma)
597 {
598 Bstr(pcszGroups, pComma - pcszGroups).detachTo(pGroups->appendedRaw());
599 pcszGroups = pComma + 1;
600 }
601 else
602 {
603 Bstr(pcszGroups).detachTo(pGroups->appendedRaw());
604 pcszGroups = NULL;
605 }
606 }
607}
608
609#ifdef VBOX_WITH_RECORDING
610int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens)
611{
612 if (!RTStrICmp(pcszScreens, "all"))
613 {
614 for (uint32_t i = 0; i < pScreens->size(); i++)
615 (*pScreens)[i] = TRUE;
616 return VINF_SUCCESS;
617 }
618 if (!RTStrICmp(pcszScreens, "none"))
619 {
620 for (uint32_t i = 0; i < pScreens->size(); i++)
621 (*pScreens)[i] = FALSE;
622 return VINF_SUCCESS;
623 }
624 while (pcszScreens && *pcszScreens)
625 {
626 char *pszNext;
627 uint32_t iScreen;
628 int vrc = RTStrToUInt32Ex(pcszScreens, &pszNext, 0, &iScreen);
629 if (RT_FAILURE(vrc))
630 return VERR_PARSE_ERROR;
631 if (iScreen >= pScreens->size())
632 return VERR_PARSE_ERROR;
633 if (pszNext && *pszNext)
634 {
635 pszNext = RTStrStripL(pszNext);
636 if (*pszNext != ',')
637 return VERR_PARSE_ERROR;
638 pszNext++;
639 }
640 (*pScreens)[iScreen] = true;
641 pcszScreens = pszNext;
642 }
643 return VINF_SUCCESS;
644}
645#endif
646
647static int parseNum(uint32_t uIndex, unsigned cMaxIndex, const char *pszName)
648{
649 if ( uIndex >= 1
650 && uIndex <= cMaxIndex)
651 return uIndex;
652 errorArgument(ModifyVM::tr("Invalid %s number %u"), pszName, uIndex);
653 return 0;
654}
655
656VMProcPriority_T nameToVMProcPriority(const char *pszName)
657{
658 if (!RTStrICmp(pszName, "default"))
659 return VMProcPriority_Default;
660 if (!RTStrICmp(pszName, "flat"))
661 return VMProcPriority_Flat;
662 if (!RTStrICmp(pszName, "low"))
663 return VMProcPriority_Low;
664 if (!RTStrICmp(pszName, "normal"))
665 return VMProcPriority_Normal;
666 if (!RTStrICmp(pszName, "high"))
667 return VMProcPriority_High;
668
669 return VMProcPriority_Invalid;
670}
671
672static VMExecutionEngine_T nameToVMExecEngine(const char *pszName)
673{
674 if (!RTStrICmp(pszName, "default"))
675 return VMExecutionEngine_Default;
676 if ( !RTStrICmp(pszName, "hwvirt")
677 || !RTStrICmp(pszName, "hm"))
678 return VMExecutionEngine_HwVirt;
679 if ( !RTStrICmp(pszName, "nem")
680 || !RTStrICmp(pszName, "native-api"))
681 return VMExecutionEngine_NativeApi;
682 if (!RTStrICmp(pszName, "interpreter"))
683 return VMExecutionEngine_Interpreter;
684 if ( !RTStrICmp(pszName, "recompiler"))
685 return VMExecutionEngine_Recompiler;
686
687 return VMExecutionEngine_NotSet;
688}
689
690/**
691 * Handles the x86-specific modifyvm options.
692 *
693 * @returns HRESULT
694 * @retval E_INVALIDARG if handed-in option was not being handled.
695 * @param pGetOptState Pointer to GetOpt state to use.
696 * @param c Current GetOpt value (short form).
697 * @param pValueUnion Pointer to current value union.
698 * @param sessionMachine Session machine to use.
699 * @param platformX86 x86-specific platform object to use.
700 */
701static HRESULT handleModifyVM_x86(PRTGETOPTSTATE pGetOptState, int c, PRTGETOPTUNION pValueUnion,
702 ComPtr<IMachine> &sessionMachine, ComPtr<IPlatformX86> &platformX86)
703{
704 RT_NOREF(sessionMachine);
705
706 HRESULT hrc = S_OK;
707
708 switch (c)
709 {
710 case MODIFYVM_X86_APIC:
711 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_APIC, pValueUnion->f));
712 break;
713
714 case MODIFYVM_X86_DELCPUID:
715 CHECK_ERROR(platformX86, RemoveCPUIDLeaf(pValueUnion->PairU32.uFirst, pValueUnion->PairU32.uSecond));
716 break;
717
718 case MODIFYVM_X86_DELCPUID_OLD:
719 CHECK_ERROR(platformX86, RemoveCPUIDLeaf(pValueUnion->u32, UINT32_MAX));
720 break;
721
722 case MODIFYVM_X86_DELALLCPUID:
723 CHECK_ERROR(platformX86, RemoveAllCPUIDLeaves());
724 break;
725
726 case MODIFYVM_X86_HPET:
727 CHECK_ERROR(platformX86, COMSETTER(HPETEnabled)(pValueUnion->f));
728 break;
729
730 case MODIFYVM_X86_TFRESET:
731 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_TripleFaultReset, pValueUnion->f));
732 break;
733
734 case MODIFYVM_X86_PAE:
735 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_PAE, pValueUnion->f));
736 break;
737
738 case MODIFYVM_X86_LONGMODE:
739 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_LongMode, pValueUnion->f));
740 break;
741
742 case MODIFYVM_X86_X2APIC:
743 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_X2APIC, pValueUnion->f));
744 break;
745
746 case MODIFYVM_X86_NESTEDPAGING:
747 CHECK_ERROR(platformX86, SetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, pValueUnion->f));
748 break;
749
750 case MODIFYVM_X86_LARGEPAGES:
751 CHECK_ERROR(platformX86, SetHWVirtExProperty(HWVirtExPropertyType_LargePages, pValueUnion->f));
752 break;
753
754 case MODIFYVM_X86_VTXVPID:
755 CHECK_ERROR(platformX86, SetHWVirtExProperty(HWVirtExPropertyType_VPID, pValueUnion->f));
756 break;
757
758 case MODIFYVM_X86_VTXUX:
759 CHECK_ERROR(platformX86, SetHWVirtExProperty(HWVirtExPropertyType_UnrestrictedExecution, pValueUnion->f));
760 break;
761
762 case MODIFYVM_X86_VIRT_VMSAVE_VMLOAD:
763 CHECK_ERROR(platformX86, SetHWVirtExProperty(HWVirtExPropertyType_VirtVmsaveVmload, pValueUnion->f));
764 break;
765
766 case MODIFYVM_X86_IBPB_ON_VM_EXIT:
767 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_IBPBOnVMExit, pValueUnion->f));
768 break;
769
770 case MODIFYVM_X86_IBPB_ON_VM_ENTRY:
771 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_IBPBOnVMEntry, pValueUnion->f));
772 break;
773
774 case MODIFYVM_X86_SPEC_CTRL:
775 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_SpecCtrl, pValueUnion->f));
776 break;
777
778 case MODIFYVM_X86_L1D_FLUSH_ON_SCHED:
779 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_L1DFlushOnEMTScheduling, pValueUnion->f));
780 break;
781
782 case MODIFYVM_X86_L1D_FLUSH_ON_VM_ENTRY:
783 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_L1DFlushOnVMEntry, pValueUnion->f));
784 break;
785
786 case MODIFYVM_X86_MDS_CLEAR_ON_SCHED:
787 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_MDSClearOnEMTScheduling, pValueUnion->f));
788 break;
789
790 case MODIFYVM_X86_MDS_CLEAR_ON_VM_ENTRY:
791 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_MDSClearOnVMEntry, pValueUnion->f));
792 break;
793
794 case MODIFYVM_X86_NESTED_HW_VIRT:
795 CHECK_ERROR(platformX86, SetCPUProperty(CPUPropertyTypeX86_HWVirt, pValueUnion->f));
796 break;
797
798 case MODIFYVM_X86_HWVIRTEX:
799 CHECK_ERROR(platformX86, SetHWVirtExProperty(HWVirtExPropertyType_Enabled, pValueUnion->f));
800 break;
801
802 case MODIFYVM_X86_SETCPUID:
803 {
804 uint32_t const idx = c == MODIFYVM_X86_SETCPUID ? pValueUnion->PairU32.uFirst : pValueUnion->u32;
805 uint32_t const idxSub = c == MODIFYVM_X86_SETCPUID ? pValueUnion->PairU32.uSecond : UINT32_MAX;
806 uint32_t aValue[4];
807 for (unsigned i = 0; i < 4; i++)
808 {
809 int vrc = RTGetOptFetchValue(pGetOptState, pValueUnion, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX);
810 if (RT_FAILURE(vrc))
811 return errorSyntax(ModifyVM::tr("Missing or invalid argument to '%s'"),
812 pGetOptState->pDef->pszLong);
813 aValue[i] = pValueUnion->u32;
814 }
815 CHECK_ERROR(platformX86, SetCPUIDLeaf(idx, idxSub, aValue[0], aValue[1], aValue[2], aValue[3]));
816 break;
817 }
818
819 default:
820 hrc = E_INVALIDARG;
821 break;
822 }
823
824 return hrc;
825}
826
827RTEXITCODE handleModifyVM(HandlerArg *a)
828{
829 int c;
830 HRESULT hrc;
831 Bstr name;
832
833 /* VM ID + at least one parameter. Parameter arguments are checked
834 * individually. */
835 if (a->argc < 2)
836 return errorSyntax(ModifyVM::tr("Not enough parameters"));
837
838 /* try to find the given sessionMachine */
839 ComPtr<IMachine> machine;
840 CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(),
841 machine.asOutParam()), RTEXITCODE_FAILURE);
842
843
844 /* Get the number of network adapters */
845 ULONG NetworkAdapterCount = getMaxNics(machine);
846
847 /* open a session for the VM */
848 CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Write), RTEXITCODE_FAILURE);
849
850 /* get the mutable session sessionMachine */
851 ComPtr<IMachine> sessionMachine;
852 CHECK_ERROR_RET(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()), RTEXITCODE_FAILURE);
853
854 ComPtr<IFirmwareSettings> firmwareSettings;
855 CHECK_ERROR_RET(sessionMachine, COMGETTER(FirmwareSettings)(firmwareSettings.asOutParam()), RTEXITCODE_FAILURE);
856
857 ComPtr<IPlatform> platform;
858 CHECK_ERROR_RET(sessionMachine, COMGETTER(Platform)(platform.asOutParam()), RTEXITCODE_FAILURE);
859
860 /* For the x86-based options we need the x86-specific platform object. */
861 ComPtr<IPlatformX86> platformX86;
862 platform->COMGETTER(X86)(platformX86.asOutParam());
863
864 ComPtr<IGraphicsAdapter> pGraphicsAdapter;
865 sessionMachine->COMGETTER(GraphicsAdapter)(pGraphicsAdapter.asOutParam());
866
867 RTGETOPTSTATE GetOptState;
868 RTGetOptInit(&GetOptState, a->argc, a->argv, g_aModifyVMOptions,
869 RT_ELEMENTS(g_aModifyVMOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
870
871 RTGETOPTUNION ValueUnion;
872 while ( SUCCEEDED (hrc)
873 && (c = RTGetOpt(&GetOptState, &ValueUnion)))
874 {
875 switch (c)
876 {
877 case MODIFYVM_NAME:
878 {
879 CHECK_ERROR(sessionMachine, COMSETTER(Name)(Bstr(ValueUnion.psz).raw()));
880 break;
881 }
882 case MODIFYVM_GROUPS:
883 {
884 com::SafeArray<BSTR> groups;
885 parseGroups(ValueUnion.psz, &groups);
886 CHECK_ERROR(sessionMachine, COMSETTER(Groups)(ComSafeArrayAsInParam(groups)));
887 break;
888 }
889 case MODIFYVM_DESCRIPTION:
890 {
891 CHECK_ERROR(sessionMachine, COMSETTER(Description)(Bstr(ValueUnion.psz).raw()));
892 break;
893 }
894 case MODIFYVM_OSTYPE:
895 {
896 CHECK_ERROR(sessionMachine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz).raw()));
897 break;
898 }
899
900 case MODIFYVM_ICONFILE:
901 {
902 RTFILE iconFile;
903 int vrc = RTFileOpen(&iconFile, ValueUnion.psz, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
904 if (RT_FAILURE(vrc))
905 {
906 RTMsgError(ModifyVM::tr("Cannot open file \"%s\": %Rrc"), ValueUnion.psz, vrc);
907 hrc = E_FAIL;
908 break;
909 }
910 uint64_t cbSize;
911 vrc = RTFileQuerySize(iconFile, &cbSize);
912 if (RT_FAILURE(vrc))
913 {
914 RTMsgError(ModifyVM::tr("Cannot get size of file \"%s\": %Rrc"), ValueUnion.psz, vrc);
915 hrc = E_FAIL;
916 break;
917 }
918 if (cbSize > _256K)
919 {
920 RTMsgError(ModifyVM::tr("File \"%s\" is bigger than 256KByte"), ValueUnion.psz);
921 hrc = E_FAIL;
922 break;
923 }
924 SafeArray<BYTE> icon((size_t)cbSize);
925 hrc = RTFileRead(iconFile, icon.raw(), (size_t)cbSize, NULL);
926 if (RT_FAILURE(vrc))
927 {
928 RTMsgError(ModifyVM::tr("Cannot read contents of file \"%s\": %Rrc"), ValueUnion.psz, vrc);
929 hrc = E_FAIL;
930 break;
931 }
932 RTFileClose(iconFile);
933 CHECK_ERROR(sessionMachine, COMSETTER(Icon)(ComSafeArrayAsInParam(icon)));
934 break;
935 }
936
937 case MODIFYVM_MEMORY:
938 {
939 CHECK_ERROR(sessionMachine, COMSETTER(MemorySize)(ValueUnion.u32));
940 break;
941 }
942
943 case MODIFYVM_PAGEFUSION:
944 {
945 CHECK_ERROR(sessionMachine, COMSETTER(PageFusionEnabled)(ValueUnion.f));
946 break;
947 }
948
949 case MODIFYVM_VRAM:
950 {
951 CHECK_ERROR(pGraphicsAdapter, COMSETTER(VRAMSize)(ValueUnion.u32));
952 break;
953 }
954
955 case MODIFYVM_FIRMWARE:
956 {
957 if (!RTStrICmp(ValueUnion.psz, "efi"))
958 {
959 CHECK_ERROR(firmwareSettings, COMSETTER(FirmwareType)(FirmwareType_EFI));
960 }
961 else if (!RTStrICmp(ValueUnion.psz, "efi32"))
962 {
963 CHECK_ERROR(firmwareSettings, COMSETTER(FirmwareType)(FirmwareType_EFI32));
964 }
965 else if (!RTStrICmp(ValueUnion.psz, "efi64"))
966 {
967 CHECK_ERROR(firmwareSettings, COMSETTER(FirmwareType)(FirmwareType_EFI64));
968 }
969 else if (!RTStrICmp(ValueUnion.psz, "efidual"))
970 {
971 CHECK_ERROR(firmwareSettings, COMSETTER(FirmwareType)(FirmwareType_EFIDUAL));
972 }
973 else if (!RTStrICmp(ValueUnion.psz, "bios"))
974 {
975 CHECK_ERROR(firmwareSettings, COMSETTER(FirmwareType)(FirmwareType_BIOS));
976 }
977 else
978 {
979 errorArgument(ModifyVM::tr("Invalid --firmware argument '%s'"), ValueUnion.psz);
980 hrc = E_FAIL;
981 }
982 break;
983 }
984
985 case MODIFYVM_ACPI:
986 {
987 CHECK_ERROR(firmwareSettings, COMSETTER(ACPIEnabled)(ValueUnion.f));
988 break;
989 }
990
991 case MODIFYVM_IOAPIC:
992 {
993 CHECK_ERROR(firmwareSettings, COMSETTER(IOAPICEnabled)(ValueUnion.f));
994 break;
995 }
996
997 case MODIFYVM_CPUID_PORTABILITY:
998 {
999 CHECK_ERROR(sessionMachine, COMSETTER(CPUIDPortabilityLevel)(ValueUnion.u32));
1000 break;
1001 }
1002
1003 case MODIFYVM_PARAVIRTPROVIDER:
1004 {
1005 if ( !RTStrICmp(ValueUnion.psz, "none")
1006 || !RTStrICmp(ValueUnion.psz, "disabled"))
1007 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_None));
1008 else if (!RTStrICmp(ValueUnion.psz, "default"))
1009 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Default));
1010 else if (!RTStrICmp(ValueUnion.psz, "legacy"))
1011 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Legacy));
1012 else if (!RTStrICmp(ValueUnion.psz, "minimal"))
1013 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Minimal));
1014 else if (!RTStrICmp(ValueUnion.psz, "hyperv"))
1015 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_HyperV));
1016 else if (!RTStrICmp(ValueUnion.psz, "kvm"))
1017 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_KVM));
1018 else
1019 {
1020 errorArgument(ModifyVM::tr("Invalid --paravirtprovider argument '%s'"), ValueUnion.psz);
1021 hrc = E_FAIL;
1022 }
1023 break;
1024 }
1025
1026 case MODIFYVM_PARAVIRTDEBUG:
1027 {
1028 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtDebug)(Bstr(ValueUnion.psz).raw()));
1029 break;
1030 }
1031
1032 case MODIFYVM_CPUS:
1033 {
1034 CHECK_ERROR(sessionMachine, COMSETTER(CPUCount)(ValueUnion.u32));
1035 break;
1036 }
1037
1038 case MODIFYVM_RTCUSEUTC:
1039 {
1040 CHECK_ERROR(platform, COMSETTER(RTCUseUTC)(ValueUnion.f));
1041 break;
1042 }
1043
1044 case MODIFYVM_CPUHOTPLUG:
1045 {
1046 CHECK_ERROR(sessionMachine, COMSETTER(CPUHotPlugEnabled)(ValueUnion.f));
1047 break;
1048 }
1049
1050 case MODIFYVM_CPU_PROFILE:
1051 {
1052 CHECK_ERROR(sessionMachine, COMSETTER(CPUProfile)(Bstr(ValueUnion.psz).raw()));
1053 break;
1054 }
1055
1056 case MODIFYVM_PLUGCPU:
1057 {
1058 CHECK_ERROR(sessionMachine, HotPlugCPU(ValueUnion.u32));
1059 break;
1060 }
1061
1062 case MODIFYVM_UNPLUGCPU:
1063 {
1064 CHECK_ERROR(sessionMachine, HotUnplugCPU(ValueUnion.u32));
1065 break;
1066 }
1067
1068 case MODIFYVM_CPU_EXECTUION_CAP:
1069 {
1070 CHECK_ERROR(sessionMachine, COMSETTER(CPUExecutionCap)(ValueUnion.u32));
1071 break;
1072 }
1073
1074 case MODIFYVM_GRAPHICSCONTROLLER:
1075 {
1076 if ( !RTStrICmp(ValueUnion.psz, "none")
1077 || !RTStrICmp(ValueUnion.psz, "disabled"))
1078 CHECK_ERROR(pGraphicsAdapter, COMSETTER(GraphicsControllerType)(GraphicsControllerType_Null));
1079 else if ( !RTStrICmp(ValueUnion.psz, "vboxvga")
1080 || !RTStrICmp(ValueUnion.psz, "vbox")
1081 || !RTStrICmp(ValueUnion.psz, "vga")
1082 || !RTStrICmp(ValueUnion.psz, "vesa"))
1083 CHECK_ERROR(pGraphicsAdapter, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VBoxVGA));
1084#ifdef VBOX_WITH_VMSVGA
1085 else if ( !RTStrICmp(ValueUnion.psz, "vmsvga")
1086 || !RTStrICmp(ValueUnion.psz, "vmware"))
1087 CHECK_ERROR(pGraphicsAdapter, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VMSVGA));
1088 else if ( !RTStrICmp(ValueUnion.psz, "vboxsvga")
1089 || !RTStrICmp(ValueUnion.psz, "svga"))
1090 CHECK_ERROR(pGraphicsAdapter, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VBoxSVGA));
1091#endif
1092 else
1093 {
1094 errorArgument(ModifyVM::tr("Invalid --graphicscontroller argument '%s'"), ValueUnion.psz);
1095 hrc = E_FAIL;
1096 }
1097 break;
1098 }
1099
1100 case MODIFYVM_MONITORCOUNT:
1101 {
1102 CHECK_ERROR(pGraphicsAdapter, COMSETTER(MonitorCount)(ValueUnion.u32));
1103 break;
1104 }
1105
1106 case MODIFYVM_ACCELERATE3D:
1107 {
1108 CHECK_ERROR(pGraphicsAdapter, SetFeature(GraphicsFeature_Acceleration3D, ValueUnion.f));
1109 break;
1110 }
1111
1112#ifdef VBOX_WITH_VIDEOHWACCEL
1113 case MODIFYVM_ACCELERATE2DVIDEO:
1114 {
1115 CHECK_ERROR(pGraphicsAdapter, SetFeature(GraphicsFeature_Acceleration2DVideo, ValueUnion.f));
1116 break;
1117 }
1118#endif
1119 case MODIFYVM_FWLOGOFADEIN:
1120 {
1121 CHECK_ERROR(firmwareSettings, COMSETTER(LogoFadeIn)(ValueUnion.f));
1122 break;
1123 }
1124
1125 case MODIFYVM_FWLOGOFADEOUT:
1126 {
1127 CHECK_ERROR(firmwareSettings, COMSETTER(LogoFadeOut)(ValueUnion.f));
1128 break;
1129 }
1130
1131 case MODIFYVM_FWLOGODISPLAYTIME:
1132 {
1133 CHECK_ERROR(firmwareSettings, COMSETTER(LogoDisplayTime)(ValueUnion.u32));
1134 break;
1135 }
1136
1137 case MODIFYVM_FWLOGOIMAGEPATH:
1138 {
1139 CHECK_ERROR(firmwareSettings, COMSETTER(LogoImagePath)(Bstr(ValueUnion.psz).raw()));
1140 break;
1141 }
1142
1143 case MODIFYVM_FWBOOTMENU:
1144 {
1145 if (!RTStrICmp(ValueUnion.psz, "disabled"))
1146 {
1147 CHECK_ERROR(firmwareSettings, COMSETTER(BootMenuMode)(FirmwareBootMenuMode_Disabled));
1148 }
1149 else if (!RTStrICmp(ValueUnion.psz, "menuonly"))
1150 {
1151 CHECK_ERROR(firmwareSettings, COMSETTER(BootMenuMode)(FirmwareBootMenuMode_MenuOnly));
1152 }
1153 else if (!RTStrICmp(ValueUnion.psz, "messageandmenu"))
1154 {
1155 CHECK_ERROR(firmwareSettings, COMSETTER(BootMenuMode)(FirmwareBootMenuMode_MessageAndMenu));
1156 }
1157 else
1158 {
1159 errorArgument(ModifyVM::tr("Invalid --biosbootmenu argument '%s'"), ValueUnion.psz);
1160 hrc = E_FAIL;
1161 }
1162 break;
1163 }
1164
1165 case MODIFYVM_FWAPIC:
1166 {
1167 if (!RTStrICmp(ValueUnion.psz, "disabled"))
1168 {
1169 CHECK_ERROR(firmwareSettings, COMSETTER(APICMode)(APICMode_Disabled));
1170 }
1171 else if ( !RTStrICmp(ValueUnion.psz, "apic")
1172 || !RTStrICmp(ValueUnion.psz, "lapic")
1173 || !RTStrICmp(ValueUnion.psz, "xapic"))
1174 {
1175 CHECK_ERROR(firmwareSettings, COMSETTER(APICMode)(APICMode_APIC));
1176 }
1177 else if (!RTStrICmp(ValueUnion.psz, "x2apic"))
1178 {
1179 CHECK_ERROR(firmwareSettings, COMSETTER(APICMode)(APICMode_X2APIC));
1180 }
1181 else
1182 {
1183 errorArgument(ModifyVM::tr("Invalid --biosapic argument '%s'"), ValueUnion.psz);
1184 hrc = E_FAIL;
1185 }
1186 break;
1187 }
1188
1189 case MODIFYVM_FWSYSTEMTIMEOFFSET:
1190 {
1191 CHECK_ERROR(firmwareSettings, COMSETTER(TimeOffset)(ValueUnion.i64));
1192 break;
1193 }
1194
1195 case MODIFYVM_FWPXEDEBUG:
1196 {
1197 CHECK_ERROR(firmwareSettings, COMSETTER(PXEDebugEnabled)(ValueUnion.f));
1198 break;
1199 }
1200
1201 case MODIFYVM_SYSTEMUUIDLE:
1202 {
1203 CHECK_ERROR(firmwareSettings, COMSETTER(SMBIOSUuidLittleEndian)(ValueUnion.f));
1204 break;
1205 }
1206
1207 case MODIFYVM_FWAUTOSERIALNUMGEN:
1208 {
1209 CHECK_ERROR(firmwareSettings, COMSETTER(AutoSerialNumGen)(ValueUnion.f));
1210 break;
1211 }
1212
1213 case MODIFYVM_BOOT:
1214 {
1215 if (!RTStrICmp(ValueUnion.psz, "none"))
1216 {
1217 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Null));
1218 }
1219 else if (!RTStrICmp(ValueUnion.psz, "floppy"))
1220 {
1221 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Floppy));
1222 }
1223 else if (!RTStrICmp(ValueUnion.psz, "dvd"))
1224 {
1225 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_DVD));
1226 }
1227 else if (!RTStrICmp(ValueUnion.psz, "disk"))
1228 {
1229 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_HardDisk));
1230 }
1231 else if (!RTStrICmp(ValueUnion.psz, "net"))
1232 {
1233 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Network));
1234 }
1235 else
1236 return errorArgument(ModifyVM::tr("Invalid boot device '%s'"), ValueUnion.psz);
1237 break;
1238 }
1239
1240 case MODIFYVM_HDA: // deprecated
1241 case MODIFYVM_HDB: // deprecated
1242 case MODIFYVM_HDD: // deprecated
1243 case MODIFYVM_SATAPORT: // deprecated
1244 {
1245 uint32_t u1 = 0, u2 = 0;
1246 Bstr bstrController = L"IDE Controller";
1247
1248 switch (c)
1249 {
1250 case MODIFYVM_HDA: // deprecated
1251 u1 = 0;
1252 break;
1253
1254 case MODIFYVM_HDB: // deprecated
1255 u1 = 0;
1256 u2 = 1;
1257 break;
1258
1259 case MODIFYVM_HDD: // deprecated
1260 u1 = 1;
1261 u2 = 1;
1262 break;
1263
1264 case MODIFYVM_SATAPORT: // deprecated
1265 u1 = GetOptState.uIndex;
1266 bstrController = L"SATA";
1267 break;
1268 }
1269
1270 if (!RTStrICmp(ValueUnion.psz, "none"))
1271 {
1272 sessionMachine->DetachDevice(bstrController.raw(), u1, u2);
1273 }
1274 else
1275 {
1276 ComPtr<IMedium> hardDisk;
1277 hrc = openMedium(a, ValueUnion.psz, DeviceType_HardDisk,
1278 AccessMode_ReadWrite, hardDisk,
1279 false /* fForceNewUuidOnOpen */,
1280 false /* fSilent */);
1281 if (FAILED(hrc))
1282 break;
1283 if (hardDisk)
1284 {
1285 CHECK_ERROR(sessionMachine, AttachDevice(bstrController.raw(),
1286 u1, u2,
1287 DeviceType_HardDisk,
1288 hardDisk));
1289 }
1290 else
1291 hrc = E_FAIL;
1292 }
1293 break;
1294 }
1295
1296 case MODIFYVM_IDECONTROLLER: // deprecated
1297 {
1298 ComPtr<IStorageController> storageController;
1299 CHECK_ERROR(sessionMachine, GetStorageControllerByName(Bstr("IDE Controller").raw(),
1300 storageController.asOutParam()));
1301
1302 if (!RTStrICmp(ValueUnion.psz, "PIIX3"))
1303 {
1304 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3));
1305 }
1306 else if (!RTStrICmp(ValueUnion.psz, "PIIX4"))
1307 {
1308 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4));
1309 }
1310 else if (!RTStrICmp(ValueUnion.psz, "ICH6"))
1311 {
1312 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6));
1313 }
1314 else
1315 {
1316 errorArgument(ModifyVM::tr("Invalid --idecontroller argument '%s'"), ValueUnion.psz);
1317 hrc = E_FAIL;
1318 }
1319 break;
1320 }
1321
1322 case MODIFYVM_SATAPORTCOUNT: // deprecated
1323 {
1324 ComPtr<IStorageController> SataCtl;
1325 CHECK_ERROR(sessionMachine, GetStorageControllerByName(Bstr("SATA").raw(),
1326 SataCtl.asOutParam()));
1327
1328 if (SUCCEEDED(hrc) && ValueUnion.u32 > 0)
1329 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(ValueUnion.u32));
1330 break;
1331 }
1332
1333 case MODIFYVM_SATA: // deprecated
1334 {
1335 if (!RTStrICmp(ValueUnion.psz, "on") || !RTStrICmp(ValueUnion.psz, "enable"))
1336 {
1337 ComPtr<IStorageController> ctl;
1338 CHECK_ERROR(sessionMachine, AddStorageController(Bstr("SATA").raw(),
1339 StorageBus_SATA,
1340 ctl.asOutParam()));
1341 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci));
1342 }
1343 else if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
1344 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("SATA").raw()));
1345 else
1346 return errorArgument(ModifyVM::tr("Invalid --usb argument '%s'"), ValueUnion.psz);
1347 break;
1348 }
1349
1350 case MODIFYVM_SCSIPORT: // deprecated
1351 {
1352 if (!RTStrICmp(ValueUnion.psz, "none"))
1353 {
1354 hrc = sessionMachine->DetachDevice(Bstr("LsiLogic").raw(),
1355 GetOptState.uIndex, 0);
1356 if (FAILED(hrc))
1357 CHECK_ERROR(sessionMachine, DetachDevice(Bstr("BusLogic").raw(),
1358 GetOptState.uIndex, 0));
1359 }
1360 else
1361 {
1362 ComPtr<IMedium> hardDisk;
1363 hrc = openMedium(a, ValueUnion.psz, DeviceType_HardDisk,
1364 AccessMode_ReadWrite, hardDisk,
1365 false /* fForceNewUuidOnOpen */,
1366 false /* fSilent */);
1367 if (FAILED(hrc))
1368 break;
1369 if (hardDisk)
1370 {
1371 hrc = sessionMachine->AttachDevice(Bstr("LsiLogic").raw(),
1372 GetOptState.uIndex, 0,
1373 DeviceType_HardDisk,
1374 hardDisk);
1375 if (FAILED(hrc))
1376 CHECK_ERROR(sessionMachine,
1377 AttachDevice(Bstr("BusLogic").raw(),
1378 GetOptState.uIndex, 0,
1379 DeviceType_HardDisk,
1380 hardDisk));
1381 }
1382 else
1383 hrc = E_FAIL;
1384 }
1385 break;
1386 }
1387
1388 case MODIFYVM_SCSITYPE: // deprecated
1389 {
1390 ComPtr<IStorageController> ctl;
1391
1392 if (!RTStrICmp(ValueUnion.psz, "LsiLogic"))
1393 {
1394 hrc = sessionMachine->RemoveStorageController(Bstr("BusLogic").raw());
1395 if (FAILED(hrc))
1396 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("LsiLogic").raw()));
1397
1398 CHECK_ERROR(sessionMachine,
1399 AddStorageController(Bstr("LsiLogic").raw(),
1400 StorageBus_SCSI,
1401 ctl.asOutParam()));
1402
1403 if (SUCCEEDED(hrc))
1404 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic));
1405 }
1406 else if (!RTStrICmp(ValueUnion.psz, "BusLogic"))
1407 {
1408 hrc = sessionMachine->RemoveStorageController(Bstr("LsiLogic").raw());
1409 if (FAILED(hrc))
1410 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("BusLogic").raw()));
1411
1412 CHECK_ERROR(sessionMachine,
1413 AddStorageController(Bstr("BusLogic").raw(),
1414 StorageBus_SCSI,
1415 ctl.asOutParam()));
1416
1417 if (SUCCEEDED(hrc))
1418 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
1419 }
1420 else
1421 return errorArgument(ModifyVM::tr("Invalid --scsitype argument '%s'"), ValueUnion.psz);
1422 break;
1423 }
1424
1425 case MODIFYVM_SCSI: // deprecated
1426 {
1427 if (!RTStrICmp(ValueUnion.psz, "on") || !RTStrICmp(ValueUnion.psz, "enable"))
1428 {
1429 ComPtr<IStorageController> ctl;
1430
1431 CHECK_ERROR(sessionMachine, AddStorageController(Bstr("BusLogic").raw(),
1432 StorageBus_SCSI,
1433 ctl.asOutParam()));
1434 if (SUCCEEDED(hrc))
1435 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
1436 }
1437 else if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
1438 {
1439 hrc = sessionMachine->RemoveStorageController(Bstr("BusLogic").raw());
1440 if (FAILED(hrc))
1441 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("LsiLogic").raw()));
1442 }
1443 break;
1444 }
1445
1446 case MODIFYVM_DVDPASSTHROUGH: // deprecated
1447 {
1448 CHECK_ERROR(sessionMachine, PassthroughDevice(Bstr("IDE Controller").raw(),
1449 1, 0,
1450 !RTStrICmp(ValueUnion.psz, "on")));
1451 break;
1452 }
1453
1454 case MODIFYVM_DVD: // deprecated
1455 {
1456 ComPtr<IMedium> dvdMedium;
1457
1458 /* unmount? */
1459 if (!RTStrICmp(ValueUnion.psz, "none"))
1460 {
1461 /* nothing to do, NULL object will cause unmount */
1462 }
1463 /* host drive? */
1464 else if (!RTStrNICmp(ValueUnion.psz, RT_STR_TUPLE("host:")))
1465 {
1466 ComPtr<IHost> host;
1467 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
1468 hrc = host->FindHostDVDDrive(Bstr(ValueUnion.psz + 5).raw(),
1469 dvdMedium.asOutParam());
1470 if (!dvdMedium)
1471 {
1472 /* 2nd try: try with the real name, important on Linux+libhal */
1473 char szPathReal[RTPATH_MAX];
1474 if (RT_FAILURE(RTPathReal(ValueUnion.psz + 5, szPathReal, sizeof(szPathReal))))
1475 {
1476 errorArgument(ModifyVM::tr("Invalid host DVD drive name \"%s\""), ValueUnion.psz + 5);
1477 hrc = E_FAIL;
1478 break;
1479 }
1480 hrc = host->FindHostDVDDrive(Bstr(szPathReal).raw(),
1481 dvdMedium.asOutParam());
1482 if (!dvdMedium)
1483 {
1484 errorArgument(ModifyVM::tr("Invalid host DVD drive name \"%s\""), ValueUnion.psz + 5);
1485 hrc = E_FAIL;
1486 break;
1487 }
1488 }
1489 }
1490 else
1491 {
1492 hrc = openMedium(a, ValueUnion.psz, DeviceType_DVD,
1493 AccessMode_ReadOnly, dvdMedium,
1494 false /* fForceNewUuidOnOpen */,
1495 false /* fSilent */);
1496 if (FAILED(hrc))
1497 break;
1498 if (!dvdMedium)
1499 {
1500 hrc = E_FAIL;
1501 break;
1502 }
1503 }
1504
1505 CHECK_ERROR(sessionMachine, MountMedium(Bstr("IDE Controller").raw(),
1506 1, 0,
1507 dvdMedium,
1508 FALSE /* aForce */));
1509 break;
1510 }
1511
1512 case MODIFYVM_FLOPPY: // deprecated
1513 {
1514 ComPtr<IMedium> floppyMedium;
1515 ComPtr<IMediumAttachment> floppyAttachment;
1516 sessionMachine->GetMediumAttachment(Bstr("Floppy Controller").raw(),
1517 0, 0, floppyAttachment.asOutParam());
1518
1519 /* disable? */
1520 if (!RTStrICmp(ValueUnion.psz, "disabled"))
1521 {
1522 /* disable the controller */
1523 if (floppyAttachment)
1524 CHECK_ERROR(sessionMachine, DetachDevice(Bstr("Floppy Controller").raw(),
1525 0, 0));
1526 }
1527 else
1528 {
1529 /* enable the controller */
1530 if (!floppyAttachment)
1531 CHECK_ERROR(sessionMachine, AttachDeviceWithoutMedium(Bstr("Floppy Controller").raw(),
1532 0, 0,
1533 DeviceType_Floppy));
1534
1535 /* unmount? */
1536 if ( !RTStrICmp(ValueUnion.psz, "none")
1537 || !RTStrICmp(ValueUnion.psz, "empty")) // deprecated
1538 {
1539 /* nothing to do, NULL object will cause unmount */
1540 }
1541 /* host drive? */
1542 else if (!RTStrNICmp(ValueUnion.psz, RT_STR_TUPLE("host:")))
1543 {
1544 ComPtr<IHost> host;
1545 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
1546 hrc = host->FindHostFloppyDrive(Bstr(ValueUnion.psz + 5).raw(),
1547 floppyMedium.asOutParam());
1548 if (!floppyMedium)
1549 {
1550 errorArgument(ModifyVM::tr("Invalid host floppy drive name \"%s\""), ValueUnion.psz + 5);
1551 hrc = E_FAIL;
1552 break;
1553 }
1554 }
1555 else
1556 {
1557 hrc = openMedium(a, ValueUnion.psz, DeviceType_Floppy,
1558 AccessMode_ReadWrite, floppyMedium,
1559 false /* fForceNewUuidOnOpen */,
1560 false /* fSilent */);
1561 if (FAILED(hrc))
1562 break;
1563 if (!floppyMedium)
1564 {
1565 hrc = E_FAIL;
1566 break;
1567 }
1568 }
1569 CHECK_ERROR(sessionMachine, MountMedium(Bstr("Floppy Controller").raw(),
1570 0, 0,
1571 floppyMedium,
1572 FALSE /* aForce */));
1573 }
1574 break;
1575 }
1576
1577 case MODIFYVM_NICTRACEFILE:
1578 {
1579
1580 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1581 break;
1582
1583 ComPtr<INetworkAdapter> nic;
1584 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1585 ASSERT(nic);
1586
1587 CHECK_ERROR(nic, COMSETTER(TraceFile)(Bstr(ValueUnion.psz).raw()));
1588 break;
1589 }
1590
1591 case MODIFYVM_NICTRACE:
1592 {
1593 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1594 break;
1595
1596 ComPtr<INetworkAdapter> nic;
1597 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1598 ASSERT(nic);
1599
1600 CHECK_ERROR(nic, COMSETTER(TraceEnabled)(ValueUnion.f));
1601 break;
1602 }
1603
1604 case MODIFYVM_NICPROPERTY:
1605 {
1606 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1607 break;
1608
1609 ComPtr<INetworkAdapter> nic;
1610 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1611 ASSERT(nic);
1612
1613 if (nic)
1614 {
1615 /* Parse 'name=value' */
1616 char *pszProperty = RTStrDup(ValueUnion.psz);
1617 if (pszProperty)
1618 {
1619 char *pDelimiter = strchr(pszProperty, '=');
1620 if (pDelimiter)
1621 {
1622 *pDelimiter = '\0';
1623
1624 Bstr bstrName = pszProperty;
1625 Bstr bstrValue = &pDelimiter[1];
1626 CHECK_ERROR(nic, SetProperty(bstrName.raw(), bstrValue.raw()));
1627 }
1628 else
1629 {
1630 errorArgument(ModifyVM::tr("Invalid --nicproperty%d argument '%s'"), GetOptState.uIndex, ValueUnion.psz);
1631 hrc = E_FAIL;
1632 }
1633 RTStrFree(pszProperty);
1634 }
1635 else
1636 {
1637 RTStrmPrintf(g_pStdErr, ModifyVM::tr("Error: Failed to allocate memory for --nicproperty%d '%s'\n"),
1638 GetOptState.uIndex, ValueUnion.psz);
1639 hrc = E_FAIL;
1640 }
1641 }
1642 break;
1643 }
1644 case MODIFYVM_NICTYPE:
1645 {
1646 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1647 break;
1648
1649 ComPtr<INetworkAdapter> nic;
1650 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1651 ASSERT(nic);
1652
1653 if (!RTStrICmp(ValueUnion.psz, "Am79C970A"))
1654 {
1655 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A));
1656 }
1657 else if (!RTStrICmp(ValueUnion.psz, "Am79C973"))
1658 {
1659 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973));
1660 }
1661 else if (!RTStrICmp(ValueUnion.psz, "Am79C960"))
1662 {
1663 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C960));
1664 }
1665#ifdef VBOX_WITH_E1000
1666 else if (!RTStrICmp(ValueUnion.psz, "82540EM"))
1667 {
1668 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM));
1669 }
1670 else if (!RTStrICmp(ValueUnion.psz, "82543GC"))
1671 {
1672 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC));
1673 }
1674 else if (!RTStrICmp(ValueUnion.psz, "82545EM"))
1675 {
1676 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82545EM));
1677 }
1678#endif
1679#ifdef VBOX_WITH_VIRTIO
1680 else if (!RTStrICmp(ValueUnion.psz, "virtio"))
1681 {
1682 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Virtio));
1683 }
1684#endif /* VBOX_WITH_VIRTIO */
1685 else if (!RTStrICmp(ValueUnion.psz, "NE1000"))
1686 {
1687 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_NE1000));
1688 }
1689 else if (!RTStrICmp(ValueUnion.psz, "NE2000"))
1690 {
1691 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_NE2000));
1692 }
1693 else if (!RTStrICmp(ValueUnion.psz, "WD8003"))
1694 {
1695 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_WD8003));
1696 }
1697 else if (!RTStrICmp(ValueUnion.psz, "WD8013"))
1698 {
1699 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_WD8013));
1700 }
1701 else if (!RTStrICmp(ValueUnion.psz, "3C503"))
1702 {
1703 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_ELNK2));
1704 }
1705 else if (!RTStrICmp(ValueUnion.psz, "3C501"))
1706 {
1707 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_ELNK1));
1708 }
1709 else
1710 {
1711 errorArgument(ModifyVM::tr("Invalid NIC type '%s' specified for NIC %u"),
1712 ValueUnion.psz, GetOptState.uIndex);
1713 hrc = E_FAIL;
1714 }
1715 break;
1716 }
1717
1718 case MODIFYVM_NICSPEED:
1719 {
1720 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1721 break;
1722
1723 ComPtr<INetworkAdapter> nic;
1724 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1725 ASSERT(nic);
1726
1727 CHECK_ERROR(nic, COMSETTER(LineSpeed)(ValueUnion.u32));
1728 break;
1729 }
1730
1731 case MODIFYVM_NICBOOTPRIO:
1732 {
1733 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1734 break;
1735
1736 ComPtr<INetworkAdapter> nic;
1737 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1738 ASSERT(nic);
1739
1740 /* Somewhat arbitrary limitation - we can pass a list of up to 4 PCI devices
1741 * to the PXE ROM, hence only boot priorities 1-4 are allowed (in addition to
1742 * 0 for the default lowest priority).
1743 */
1744 if (ValueUnion.u32 > 4)
1745 {
1746 errorArgument(ModifyVM::tr("Invalid boot priority '%u' specfied for NIC %u"), ValueUnion.u32, GetOptState.uIndex);
1747 hrc = E_FAIL;
1748 }
1749 else
1750 {
1751 CHECK_ERROR(nic, COMSETTER(BootPriority)(ValueUnion.u32));
1752 }
1753 break;
1754 }
1755
1756 case MODIFYVM_NICPROMISC:
1757 {
1758 NetworkAdapterPromiscModePolicy_T enmPromiscModePolicy;
1759 if (!RTStrICmp(ValueUnion.psz, "deny"))
1760 enmPromiscModePolicy = NetworkAdapterPromiscModePolicy_Deny;
1761 else if ( !RTStrICmp(ValueUnion.psz, "allow-vms")
1762 || !RTStrICmp(ValueUnion.psz, "allow-network"))
1763 enmPromiscModePolicy = NetworkAdapterPromiscModePolicy_AllowNetwork;
1764 else if (!RTStrICmp(ValueUnion.psz, "allow-all"))
1765 enmPromiscModePolicy = NetworkAdapterPromiscModePolicy_AllowAll;
1766 else
1767 {
1768 errorArgument(ModifyVM::tr("Unknown promiscuous mode policy '%s'"), ValueUnion.psz);
1769 hrc = E_INVALIDARG;
1770 break;
1771 }
1772
1773 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1774 break;
1775
1776 ComPtr<INetworkAdapter> nic;
1777 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1778 ASSERT(nic);
1779
1780 CHECK_ERROR(nic, COMSETTER(PromiscModePolicy)(enmPromiscModePolicy));
1781 break;
1782 }
1783
1784 case MODIFYVM_NICBWGROUP:
1785 {
1786 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1787 break;
1788
1789 ComPtr<INetworkAdapter> nic;
1790 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1791 ASSERT(nic);
1792
1793 if (!RTStrICmp(ValueUnion.psz, "none"))
1794 {
1795 /* Just remove the bandwidth group. */
1796 CHECK_ERROR(nic, COMSETTER(BandwidthGroup)(NULL));
1797 }
1798 else
1799 {
1800 ComPtr<IBandwidthControl> bwCtrl;
1801 ComPtr<IBandwidthGroup> bwGroup;
1802
1803 CHECK_ERROR(sessionMachine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam()));
1804
1805 if (SUCCEEDED(hrc))
1806 {
1807 CHECK_ERROR(bwCtrl, GetBandwidthGroup(Bstr(ValueUnion.psz).raw(), bwGroup.asOutParam()));
1808 if (SUCCEEDED(hrc))
1809 {
1810 CHECK_ERROR(nic, COMSETTER(BandwidthGroup)(bwGroup));
1811 }
1812 }
1813 }
1814 break;
1815 }
1816
1817 case MODIFYVM_NIC:
1818 {
1819 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1820 break;
1821
1822 ComPtr<INetworkAdapter> nic;
1823 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1824 ASSERT(nic);
1825
1826 /*
1827 * Check if the NIC is already enabled. Do not try to
1828 * enable it if it already is. That makes a
1829 * difference for saved VMs for which you can change
1830 * the NIC attachment, but can't change the NIC
1831 * enabled status (yes, the setter also should not
1832 * freak out about a no-op request).
1833 */
1834 BOOL fEnabled;;
1835 CHECK_ERROR(nic, COMGETTER(Enabled)(&fEnabled));
1836
1837 if (!RTStrICmp(ValueUnion.psz, "none"))
1838 {
1839 if (RT_BOOL(fEnabled))
1840 CHECK_ERROR(nic, COMSETTER(Enabled)(FALSE));
1841 }
1842 else if (!RTStrICmp(ValueUnion.psz, "null"))
1843 {
1844 if (!fEnabled)
1845 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1846 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Null));
1847 }
1848 else if (!RTStrICmp(ValueUnion.psz, "nat"))
1849 {
1850 if (!fEnabled)
1851 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1852 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NAT));
1853 }
1854 else if ( !RTStrICmp(ValueUnion.psz, "bridged")
1855 || !RTStrICmp(ValueUnion.psz, "hostif")) /* backward compatibility */
1856 {
1857 if (!fEnabled)
1858 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1859 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Bridged));
1860 }
1861 else if (!RTStrICmp(ValueUnion.psz, "intnet"))
1862 {
1863 if (!fEnabled)
1864 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1865 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Internal));
1866 }
1867 else if (!RTStrICmp(ValueUnion.psz, "hostonly"))
1868 {
1869 if (!fEnabled)
1870 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1871 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_HostOnly));
1872 }
1873#ifdef VBOX_WITH_VMNET
1874 else if (!RTStrICmp(ValueUnion.psz, "hostonlynet"))
1875 {
1876 if (!fEnabled)
1877 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1878 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_HostOnlyNetwork));
1879 }
1880#endif /* VBOX_WITH_VMNET */
1881 else if (!RTStrICmp(ValueUnion.psz, "generic"))
1882 {
1883 if (!fEnabled)
1884 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1885 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Generic));
1886 }
1887 else if (!RTStrICmp(ValueUnion.psz, "natnetwork"))
1888 {
1889 if (!fEnabled)
1890 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1891 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NATNetwork));
1892 }
1893#ifdef VBOX_WITH_CLOUD_NET
1894 else if (!RTStrICmp(ValueUnion.psz, "cloud"))
1895 {
1896 if (!fEnabled)
1897 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1898 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Cloud));
1899 }
1900#endif /* VBOX_WITH_CLOUD_NET */
1901 else
1902 {
1903 errorArgument(ModifyVM::tr("Invalid type '%s' specfied for NIC %u"), ValueUnion.psz, GetOptState.uIndex);
1904 hrc = E_FAIL;
1905 }
1906 break;
1907 }
1908
1909 case MODIFYVM_CABLECONNECTED:
1910 {
1911 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1912 break;
1913
1914 ComPtr<INetworkAdapter> nic;
1915 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1916 ASSERT(nic);
1917
1918 CHECK_ERROR(nic, COMSETTER(CableConnected)(ValueUnion.f));
1919 break;
1920 }
1921
1922 case MODIFYVM_BRIDGEADAPTER:
1923 {
1924 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1925 break;
1926
1927 ComPtr<INetworkAdapter> nic;
1928 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1929 ASSERT(nic);
1930
1931 /* remove it? */
1932 if (!RTStrICmp(ValueUnion.psz, "none"))
1933 {
1934 CHECK_ERROR(nic, COMSETTER(BridgedInterface)(Bstr().raw()));
1935 }
1936 else
1937 {
1938 CHECK_ERROR(nic, COMSETTER(BridgedInterface)(Bstr(ValueUnion.psz).raw()));
1939 verifyHostNetworkInterfaceName(a->virtualBox, ValueUnion.psz,
1940 HostNetworkInterfaceType_Bridged);
1941 }
1942 break;
1943 }
1944
1945#ifdef VBOX_WITH_CLOUD_NET
1946 case MODIFYVM_CLOUDNET:
1947 {
1948 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1949 break;
1950
1951 ComPtr<INetworkAdapter> nic;
1952 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1953 ASSERT(nic);
1954
1955 /* remove it? */
1956 if (!RTStrICmp(ValueUnion.psz, "none"))
1957 {
1958 CHECK_ERROR(nic, COMSETTER(CloudNetwork)(Bstr().raw()));
1959 }
1960 else
1961 {
1962 CHECK_ERROR(nic, COMSETTER(CloudNetwork)(Bstr(ValueUnion.psz).raw()));
1963 }
1964 break;
1965 }
1966#endif /* VBOX_WITH_CLOUD_NET */
1967
1968 case MODIFYVM_HOSTONLYADAPTER:
1969 {
1970 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1971 break;
1972
1973 ComPtr<INetworkAdapter> nic;
1974 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1975 ASSERT(nic);
1976
1977 /* remove it? */
1978 if (!RTStrICmp(ValueUnion.psz, "none"))
1979 {
1980 CHECK_ERROR(nic, COMSETTER(HostOnlyInterface)(Bstr().raw()));
1981 }
1982 else
1983 {
1984 CHECK_ERROR(nic, COMSETTER(HostOnlyInterface)(Bstr(ValueUnion.psz).raw()));
1985 verifyHostNetworkInterfaceName(a->virtualBox, ValueUnion.psz,
1986 HostNetworkInterfaceType_HostOnly);
1987 }
1988 break;
1989 }
1990
1991#ifdef VBOX_WITH_VMNET
1992 case MODIFYVM_HOSTONLYNET:
1993 {
1994 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1995 break;
1996
1997 ComPtr<INetworkAdapter> nic;
1998 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1999 ASSERT(nic);
2000
2001 /* remove it? */
2002 if (!RTStrICmp(ValueUnion.psz, "none"))
2003 {
2004 CHECK_ERROR(nic, COMSETTER(HostOnlyNetwork)(Bstr().raw()));
2005 }
2006 else
2007 {
2008 CHECK_ERROR(nic, COMSETTER(HostOnlyNetwork)(Bstr(ValueUnion.psz).raw()));
2009 }
2010 break;
2011 }
2012#endif /* VBOX_WITH_VMNET */
2013
2014 case MODIFYVM_INTNET:
2015 {
2016 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2017 break;
2018
2019 ComPtr<INetworkAdapter> nic;
2020 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2021 ASSERT(nic);
2022
2023 /* remove it? */
2024 if (!RTStrICmp(ValueUnion.psz, "none"))
2025 {
2026 CHECK_ERROR(nic, COMSETTER(InternalNetwork)(Bstr().raw()));
2027 }
2028 else
2029 {
2030 CHECK_ERROR(nic, COMSETTER(InternalNetwork)(Bstr(ValueUnion.psz).raw()));
2031 }
2032 break;
2033 }
2034
2035 case MODIFYVM_GENERICDRV:
2036 {
2037 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2038 break;
2039
2040 ComPtr<INetworkAdapter> nic;
2041 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2042 ASSERT(nic);
2043
2044 CHECK_ERROR(nic, COMSETTER(GenericDriver)(Bstr(ValueUnion.psz).raw()));
2045 break;
2046 }
2047
2048 case MODIFYVM_NATNETWORKNAME:
2049 {
2050 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2051 break;
2052
2053 ComPtr<INetworkAdapter> nic;
2054 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2055 ASSERT(nic);
2056
2057 CHECK_ERROR(nic, COMSETTER(NATNetwork)(Bstr(ValueUnion.psz).raw()));
2058 break;
2059 }
2060
2061 case MODIFYVM_NATNET:
2062 {
2063 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2064 break;
2065
2066 ComPtr<INetworkAdapter> nic;
2067 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2068 ASSERT(nic);
2069
2070 ComPtr<INATEngine> engine;
2071 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2072
2073 const char *psz = ValueUnion.psz;
2074 if (!RTStrICmp("default", psz))
2075 psz = "";
2076
2077 CHECK_ERROR(engine, COMSETTER(Network)(Bstr(psz).raw()));
2078 break;
2079 }
2080
2081 case MODIFYVM_NATBINDIP:
2082 {
2083 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2084 break;
2085
2086 ComPtr<INetworkAdapter> nic;
2087 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2088 ASSERT(nic);
2089
2090 ComPtr<INATEngine> engine;
2091 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2092
2093 CHECK_ERROR(engine, COMSETTER(HostIP)(Bstr(ValueUnion.psz).raw()));
2094 break;
2095 }
2096
2097#define ITERATE_TO_NEXT_TERM(ch) \
2098 do { \
2099 while (*ch != ',') \
2100 { \
2101 if (*ch == 0) \
2102 { \
2103 return errorSyntax(ModifyVM::tr("Missing or invalid argument to '%s'"), \
2104 GetOptState.pDef->pszLong); \
2105 } \
2106 ch++; \
2107 } \
2108 *ch = '\0'; \
2109 ch++; \
2110 } while(0)
2111
2112 case MODIFYVM_NATSETTINGS:
2113 {
2114 ComPtr<INetworkAdapter> nic;
2115 ComPtr<INATEngine> engine;
2116 char *strMtu;
2117 char *strSockSnd;
2118 char *strSockRcv;
2119 char *strTcpSnd;
2120 char *strTcpRcv;
2121 char *strRaw = RTStrDup(ValueUnion.psz);
2122 char *ch = strRaw;
2123 strMtu = RTStrStrip(ch);
2124 ITERATE_TO_NEXT_TERM(ch);
2125 strSockSnd = RTStrStrip(ch);
2126 ITERATE_TO_NEXT_TERM(ch);
2127 strSockRcv = RTStrStrip(ch);
2128 ITERATE_TO_NEXT_TERM(ch);
2129 strTcpSnd = RTStrStrip(ch);
2130 ITERATE_TO_NEXT_TERM(ch);
2131 strTcpRcv = RTStrStrip(ch);
2132
2133 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2134 break;
2135
2136 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2137 ASSERT(nic);
2138
2139 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2140 CHECK_ERROR(engine, SetNetworkSettings(RTStrToUInt32(strMtu), RTStrToUInt32(strSockSnd), RTStrToUInt32(strSockRcv),
2141 RTStrToUInt32(strTcpSnd), RTStrToUInt32(strTcpRcv)));
2142 break;
2143 }
2144
2145
2146 case MODIFYVM_NATPF:
2147 {
2148 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2149 break;
2150
2151 ComPtr<INetworkAdapter> nic;
2152 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2153 ASSERT(nic);
2154
2155 ComPtr<INATEngine> engine;
2156 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2157
2158 /* format name:proto:hostip:hostport:guestip:guestport*/
2159 if (RTStrCmp(ValueUnion.psz, "delete") != 0)
2160 {
2161 char *strName;
2162 char *strProto;
2163 char *strHostIp;
2164 char *strHostPort;
2165 char *strGuestIp;
2166 char *strGuestPort;
2167 char *strRaw = RTStrDup(ValueUnion.psz);
2168 char *ch = strRaw;
2169 strName = RTStrStrip(ch);
2170 ITERATE_TO_NEXT_TERM(ch);
2171 strProto = RTStrStrip(ch);
2172 ITERATE_TO_NEXT_TERM(ch);
2173 strHostIp = RTStrStrip(ch);
2174 ITERATE_TO_NEXT_TERM(ch);
2175 strHostPort = RTStrStrip(ch);
2176 ITERATE_TO_NEXT_TERM(ch);
2177 strGuestIp = RTStrStrip(ch);
2178 ITERATE_TO_NEXT_TERM(ch);
2179 strGuestPort = RTStrStrip(ch);
2180 NATProtocol_T proto;
2181 if (RTStrICmp(strProto, "udp") == 0)
2182 proto = NATProtocol_UDP;
2183 else if (RTStrICmp(strProto, "tcp") == 0)
2184 proto = NATProtocol_TCP;
2185 else
2186 {
2187 errorArgument(ModifyVM::tr("Invalid proto '%s' specfied for NIC %u"), ValueUnion.psz, GetOptState.uIndex);
2188 hrc = E_FAIL;
2189 break;
2190 }
2191 CHECK_ERROR(engine, AddRedirect(Bstr(strName).raw(), proto,
2192 Bstr(strHostIp).raw(),
2193 RTStrToUInt16(strHostPort),
2194 Bstr(strGuestIp).raw(),
2195 RTStrToUInt16(strGuestPort)));
2196 }
2197 else
2198 {
2199 /* delete NAT Rule operation */
2200 int vrc;
2201 vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
2202 if (RT_FAILURE(vrc))
2203 return errorSyntax(ModifyVM::tr("Not enough parameters"));
2204 CHECK_ERROR(engine, RemoveRedirect(Bstr(ValueUnion.psz).raw()));
2205 }
2206 break;
2207 }
2208 #undef ITERATE_TO_NEXT_TERM
2209 case MODIFYVM_NATALIASMODE:
2210 {
2211 ComPtr<INetworkAdapter> nic;
2212 ComPtr<INATEngine> engine;
2213 uint32_t aliasMode = 0;
2214
2215 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2216 ASSERT(nic);
2217
2218 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2219 if (RTStrCmp(ValueUnion.psz, "default") == 0)
2220 aliasMode = 0;
2221 else
2222 {
2223 char *token = (char *)ValueUnion.psz;
2224 while (token)
2225 {
2226 if (RTStrNCmp(token, RT_STR_TUPLE("log")) == 0)
2227 aliasMode |= NATAliasMode_AliasLog;
2228 else if (RTStrNCmp(token, RT_STR_TUPLE("proxyonly")) == 0)
2229 aliasMode |= NATAliasMode_AliasProxyOnly;
2230 else if (RTStrNCmp(token, RT_STR_TUPLE("sameports")) == 0)
2231 aliasMode |= NATAliasMode_AliasUseSamePorts;
2232 token = RTStrStr(token, ",");
2233 if (token == NULL)
2234 break;
2235 token++;
2236 }
2237 }
2238 CHECK_ERROR(engine, COMSETTER(AliasMode)(aliasMode));
2239 break;
2240 }
2241
2242 case MODIFYVM_NATTFTPPREFIX:
2243 {
2244 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2245 break;
2246
2247 ComPtr<INetworkAdapter> nic;
2248 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2249 ASSERT(nic);
2250
2251 ComPtr<INATEngine> engine;
2252 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2253
2254 CHECK_ERROR(engine, COMSETTER(TFTPPrefix)(Bstr(ValueUnion.psz).raw()));
2255 break;
2256 }
2257
2258 case MODIFYVM_NATTFTPFILE:
2259 {
2260 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2261 break;
2262
2263 ComPtr<INetworkAdapter> nic;
2264 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2265 ASSERT(nic);
2266
2267 ComPtr<INATEngine> engine;
2268 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2269
2270 CHECK_ERROR(engine, COMSETTER(TFTPBootFile)(Bstr(ValueUnion.psz).raw()));
2271 break;
2272 }
2273
2274 case MODIFYVM_NATTFTPSERVER:
2275 {
2276 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2277 break;
2278
2279 ComPtr<INetworkAdapter> nic;
2280 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2281 ASSERT(nic);
2282
2283 ComPtr<INATEngine> engine;
2284 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2285
2286 CHECK_ERROR(engine, COMSETTER(TFTPNextServer)(Bstr(ValueUnion.psz).raw()));
2287 break;
2288 }
2289 case MODIFYVM_NATDNSPASSDOMAIN:
2290 {
2291 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2292 break;
2293
2294 ComPtr<INetworkAdapter> nic;
2295 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2296 ASSERT(nic);
2297
2298 ComPtr<INATEngine> engine;
2299 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2300
2301 CHECK_ERROR(engine, COMSETTER(DNSPassDomain)(ValueUnion.f));
2302 break;
2303 }
2304
2305 case MODIFYVM_NATDNSPROXY:
2306 {
2307 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2308 break;
2309
2310 ComPtr<INetworkAdapter> nic;
2311 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2312 ASSERT(nic);
2313
2314 ComPtr<INATEngine> engine;
2315 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2316
2317 CHECK_ERROR(engine, COMSETTER(DNSProxy)(ValueUnion.f));
2318 break;
2319 }
2320
2321 case MODIFYVM_NATDNSHOSTRESOLVER:
2322 {
2323 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2324 break;
2325
2326 ComPtr<INetworkAdapter> nic;
2327 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2328 ASSERT(nic);
2329
2330 ComPtr<INATEngine> engine;
2331 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2332
2333 CHECK_ERROR(engine, COMSETTER(DNSUseHostResolver)(ValueUnion.f));
2334 break;
2335 }
2336
2337 case MODIFYVM_NATLOCALHOSTREACHABLE:
2338 {
2339 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2340 break;
2341
2342 ComPtr<INetworkAdapter> nic;
2343 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2344 ASSERT(nic);
2345
2346 ComPtr<INATEngine> engine;
2347 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
2348
2349 CHECK_ERROR(engine, COMSETTER(LocalhostReachable)(ValueUnion.f));
2350 break;
2351 }
2352
2353 case MODIFYVM_MACADDRESS:
2354 {
2355 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
2356 break;
2357
2358 ComPtr<INetworkAdapter> nic;
2359 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
2360 ASSERT(nic);
2361
2362 /* generate one? */
2363 if (!RTStrICmp(ValueUnion.psz, "auto"))
2364 {
2365 CHECK_ERROR(nic, COMSETTER(MACAddress)(Bstr().raw()));
2366 }
2367 else
2368 {
2369 CHECK_ERROR(nic, COMSETTER(MACAddress)(Bstr(ValueUnion.psz).raw()));
2370 }
2371 break;
2372 }
2373
2374 case MODIFYVM_HIDPTR:
2375 {
2376 bool fEnableUsb = false;
2377 if (!RTStrICmp(ValueUnion.psz, "ps2"))
2378 {
2379 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_PS2Mouse));
2380 }
2381 else if (!RTStrICmp(ValueUnion.psz, "usb"))
2382 {
2383 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBMouse));
2384 if (SUCCEEDED(hrc))
2385 fEnableUsb = true;
2386 }
2387 else if (!RTStrICmp(ValueUnion.psz, "usbtablet"))
2388 {
2389 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBTablet));
2390 if (SUCCEEDED(hrc))
2391 fEnableUsb = true;
2392 }
2393 else if (!RTStrICmp(ValueUnion.psz, "usbmultitouch"))
2394 {
2395 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBMultiTouch));
2396 if (SUCCEEDED(hrc))
2397 fEnableUsb = true;
2398 }
2399 else if (!RTStrICmp(ValueUnion.psz, "usbmtscreenpluspad"))
2400 {
2401 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBMultiTouchScreenPlusPad));
2402 if (SUCCEEDED(hrc))
2403 fEnableUsb = true;
2404 }
2405 else if (!RTStrICmp(ValueUnion.psz, "none"))
2406 {
2407 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_None));
2408 }
2409 else
2410 {
2411 errorArgument(ModifyVM::tr("Invalid type '%s' specfied for pointing device"), ValueUnion.psz);
2412 hrc = E_FAIL;
2413 }
2414 if (fEnableUsb)
2415 {
2416 /* Make sure either the OHCI or xHCI controller is enabled. */
2417 ULONG cOhciCtrls = 0;
2418 ULONG cXhciCtrls = 0;
2419 hrc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
2420 if (SUCCEEDED(hrc)) {
2421 hrc = sessionMachine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
2422 if ( SUCCEEDED(hrc)
2423 && cOhciCtrls + cXhciCtrls == 0)
2424 {
2425 /* If there's nothing, enable OHCI (always available). */
2426 ComPtr<IUSBController> UsbCtl;
2427 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
2428 UsbCtl.asOutParam()));
2429 }
2430 }
2431 }
2432 break;
2433 }
2434
2435 case MODIFYVM_HIDKBD:
2436 {
2437 bool fEnableUsb = false;
2438 if (!RTStrICmp(ValueUnion.psz, "ps2"))
2439 {
2440 CHECK_ERROR(sessionMachine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_PS2Keyboard));
2441 }
2442 else if (!RTStrICmp(ValueUnion.psz, "usb"))
2443 {
2444 CHECK_ERROR(sessionMachine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_USBKeyboard));
2445 if (SUCCEEDED(hrc))
2446 fEnableUsb = true;
2447 }
2448 else if (!RTStrICmp(ValueUnion.psz, "none"))
2449 {
2450 CHECK_ERROR(sessionMachine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_None));
2451 if (SUCCEEDED(hrc))
2452 fEnableUsb = true;
2453 }
2454 else
2455 {
2456 errorArgument(ModifyVM::tr("Invalid type '%s' specfied for keyboard"), ValueUnion.psz);
2457 hrc = E_FAIL;
2458 }
2459 if (fEnableUsb)
2460 {
2461 /* Make sure either the OHCI or xHCI controller is enabled. */
2462 ULONG cOhciCtrls = 0;
2463 ULONG cXhciCtrls = 0;
2464 hrc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
2465 if (SUCCEEDED(hrc)) {
2466 hrc = sessionMachine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
2467 if ( SUCCEEDED(hrc)
2468 && cOhciCtrls + cXhciCtrls == 0)
2469 {
2470 /* If there's nothing, enable OHCI (always available). */
2471 ComPtr<IUSBController> UsbCtl;
2472 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
2473 UsbCtl.asOutParam()));
2474 }
2475 }
2476 }
2477 break;
2478 }
2479
2480 case MODIFYVM_UARTMODE:
2481 {
2482 ComPtr<ISerialPort> uart;
2483
2484 CHECK_ERROR_BREAK(sessionMachine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
2485 ASSERT(uart);
2486
2487 if (!RTStrICmp(ValueUnion.psz, "disconnected"))
2488 {
2489 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_Disconnected));
2490 }
2491 else if ( !RTStrICmp(ValueUnion.psz, "server")
2492 || !RTStrICmp(ValueUnion.psz, "client")
2493 || !RTStrICmp(ValueUnion.psz, "tcpserver")
2494 || !RTStrICmp(ValueUnion.psz, "tcpclient")
2495 || !RTStrICmp(ValueUnion.psz, "file"))
2496 {
2497 const char *pszMode = ValueUnion.psz;
2498
2499 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
2500 if (RT_FAILURE(vrc))
2501 return errorSyntax(ModifyVM::tr("Missing or invalid argument to '%s'"),
2502 GetOptState.pDef->pszLong);
2503
2504 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
2505
2506 if (!RTStrICmp(pszMode, "server"))
2507 {
2508 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
2509 CHECK_ERROR(uart, COMSETTER(Server)(TRUE));
2510 }
2511 else if (!RTStrICmp(pszMode, "client"))
2512 {
2513 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
2514 CHECK_ERROR(uart, COMSETTER(Server)(FALSE));
2515 }
2516 else if (!RTStrICmp(pszMode, "tcpserver"))
2517 {
2518 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_TCP));
2519 CHECK_ERROR(uart, COMSETTER(Server)(TRUE));
2520 }
2521 else if (!RTStrICmp(pszMode, "tcpclient"))
2522 {
2523 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_TCP));
2524 CHECK_ERROR(uart, COMSETTER(Server)(FALSE));
2525 }
2526 else if (!RTStrICmp(pszMode, "file"))
2527 {
2528 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_RawFile));
2529 }
2530 }
2531 else
2532 {
2533 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
2534 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostDevice));
2535 }
2536 break;
2537 }
2538
2539 case MODIFYVM_UARTTYPE:
2540 {
2541 ComPtr<ISerialPort> uart;
2542
2543 CHECK_ERROR_BREAK(sessionMachine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
2544 ASSERT(uart);
2545
2546 if (!RTStrICmp(ValueUnion.psz, "16450"))
2547 {
2548 CHECK_ERROR(uart, COMSETTER(UartType)(UartType_U16450));
2549 }
2550 else if (!RTStrICmp(ValueUnion.psz, "16550A"))
2551 {
2552 CHECK_ERROR(uart, COMSETTER(UartType)(UartType_U16550A));
2553 }
2554 else if (!RTStrICmp(ValueUnion.psz, "16750"))
2555 {
2556 CHECK_ERROR(uart, COMSETTER(UartType)(UartType_U16750));
2557 }
2558 else
2559 return errorSyntax(ModifyVM::tr("Invalid argument to '%s'"),
2560 GetOptState.pDef->pszLong);
2561 break;
2562 }
2563
2564 case MODIFYVM_UART:
2565 {
2566 ComPtr<ISerialPort> uart;
2567
2568 CHECK_ERROR_BREAK(sessionMachine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
2569 ASSERT(uart);
2570
2571 if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
2572 CHECK_ERROR(uart, COMSETTER(Enabled)(FALSE));
2573 else
2574 {
2575 const char *pszIOBase = ValueUnion.psz;
2576 uint32_t uVal = 0;
2577
2578 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_UART;
2579 if (RT_FAILURE(vrc))
2580 return errorSyntax(ModifyVM::tr("Missing or invalid argument to '%s'"),
2581 GetOptState.pDef->pszLong);
2582
2583 CHECK_ERROR(uart, COMSETTER(IRQ)(ValueUnion.u32));
2584
2585 vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
2586 if (vrc != VINF_SUCCESS || uVal == 0)
2587 return errorArgument(ModifyVM::tr("Error parsing UART I/O base '%s'"), pszIOBase);
2588 CHECK_ERROR(uart, COMSETTER(IOAddress)(uVal));
2589
2590 CHECK_ERROR(uart, COMSETTER(Enabled)(TRUE));
2591 }
2592 break;
2593 }
2594
2595#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
2596 case MODIFYVM_LPTMODE:
2597 {
2598 ComPtr<IParallelPort> lpt;
2599
2600 CHECK_ERROR_BREAK(sessionMachine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
2601 ASSERT(lpt);
2602
2603 CHECK_ERROR(lpt, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
2604 break;
2605 }
2606
2607 case MODIFYVM_LPT:
2608 {
2609 ComPtr<IParallelPort> lpt;
2610
2611 CHECK_ERROR_BREAK(sessionMachine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
2612 ASSERT(lpt);
2613
2614 if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
2615 CHECK_ERROR(lpt, COMSETTER(Enabled)(FALSE));
2616 else
2617 {
2618 const char *pszIOBase = ValueUnion.psz;
2619 uint32_t uVal = 0;
2620
2621 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_LPT;
2622 if (RT_FAILURE(vrc))
2623 return errorSyntax(ModifyVM::tr("Missing or invalid argument to '%s'"),
2624 GetOptState.pDef->pszLong);
2625
2626 CHECK_ERROR(lpt, COMSETTER(IRQ)(ValueUnion.u32));
2627
2628 vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
2629 if (vrc != VINF_SUCCESS || uVal == 0)
2630 return errorArgument(ModifyVM::tr("Error parsing LPT I/O base '%s'"), pszIOBase);
2631 CHECK_ERROR(lpt, COMSETTER(IOBase)(uVal));
2632
2633 CHECK_ERROR(lpt, COMSETTER(Enabled)(TRUE));
2634 }
2635 break;
2636 }
2637#endif
2638
2639 case MODIFYVM_GUESTMEMORYBALLOON:
2640 {
2641 CHECK_ERROR(sessionMachine, COMSETTER(MemoryBalloonSize)(ValueUnion.u32));
2642 break;
2643 }
2644
2645 case MODIFYVM_AUDIOCONTROLLER:
2646 {
2647 ComPtr<IAudioSettings> audioSettings;
2648 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(AudioSettings)(audioSettings.asOutParam()));
2649 ComPtr<IAudioAdapter> audioAdapter;
2650 CHECK_ERROR_BREAK(audioSettings, COMGETTER(Adapter)(audioAdapter.asOutParam()));
2651 ASSERT(audioAdapter);
2652
2653 if (!RTStrICmp(ValueUnion.psz, "sb16"))
2654 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));
2655 else if (!RTStrICmp(ValueUnion.psz, "ac97"))
2656 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));
2657 else if (!RTStrICmp(ValueUnion.psz, "hda"))
2658 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_HDA));
2659 else
2660 {
2661 errorArgument(ModifyVM::tr("Invalid --audiocontroller argument '%s'"), ValueUnion.psz);
2662 hrc = E_FAIL;
2663 }
2664 break;
2665 }
2666
2667 case MODIFYVM_AUDIOCODEC:
2668 {
2669 ComPtr<IAudioSettings> audioSettings;
2670 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(AudioSettings)(audioSettings.asOutParam()));
2671 ComPtr<IAudioAdapter> audioAdapter;
2672 CHECK_ERROR_BREAK(audioSettings, COMGETTER(Adapter)(audioAdapter.asOutParam()));
2673 ASSERT(audioAdapter);
2674
2675 if (!RTStrICmp(ValueUnion.psz, "sb16"))
2676 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_SB16));
2677 else if (!RTStrICmp(ValueUnion.psz, "stac9700"))
2678 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_STAC9700));
2679 else if (!RTStrICmp(ValueUnion.psz, "ad1980"))
2680 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_AD1980));
2681 else if (!RTStrICmp(ValueUnion.psz, "stac9221"))
2682 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_STAC9221));
2683 else
2684 {
2685 errorArgument(ModifyVM::tr("Invalid --audiocodec argument '%s'"), ValueUnion.psz);
2686 hrc = E_FAIL;
2687 }
2688 break;
2689 }
2690
2691 case MODIFYVM_AUDIODRIVER:
2692 RT_FALL_THROUGH();
2693 case MODIFYVM_AUDIO: /** @todo Deprecated; remove. */
2694 {
2695 if (c == MODIFYVM_AUDIO)
2696 RTStrmPrintf(g_pStdErr,
2697 ModifyVM::tr("Warning: --audio is deprecated and will be removed soon. Use --audio-driver instead!\n"));
2698
2699 ComPtr<IAudioSettings> audioSettings;
2700 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(AudioSettings)(audioSettings.asOutParam()));
2701 ComPtr<IAudioAdapter> audioAdapter;
2702 CHECK_ERROR_BREAK(audioSettings, COMGETTER(Adapter)(audioAdapter.asOutParam()));
2703 ASSERT(audioAdapter);
2704 /* disable? */
2705 if ( !RTStrICmp(ValueUnion.psz, "none")
2706 || !RTStrICmp(ValueUnion.psz, "null"))
2707 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));
2708 else if (!RTStrICmp(ValueUnion.psz, "default"))
2709 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Default));
2710#ifdef RT_OS_WINDOWS
2711# ifdef VBOX_WITH_WINMM
2712 else if (!RTStrICmp(ValueUnion.psz, "winmm"))
2713 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));
2714# endif
2715 else if (!RTStrICmp(ValueUnion.psz, "dsound"))
2716 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
2717 else if (!RTStrICmp(ValueUnion.psz, "was"))
2718 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WAS));
2719#endif /* RT_OS_WINDOWS */
2720#ifdef VBOX_WITH_AUDIO_OSS
2721 else if (!RTStrICmp(ValueUnion.psz, "oss"))
2722 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
2723#endif
2724#ifdef VBOX_WITH_AUDIO_ALSA
2725 else if (!RTStrICmp(ValueUnion.psz, "alsa"))
2726 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));
2727#endif
2728#ifdef VBOX_WITH_AUDIO_PULSE
2729 else if (!RTStrICmp(ValueUnion.psz, "pulse"))
2730 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
2731#endif
2732#ifdef RT_OS_DARWIN
2733 else if (!RTStrICmp(ValueUnion.psz, "coreaudio"))
2734 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));
2735#endif /* !RT_OS_DARWIN */
2736 else
2737 {
2738 errorArgument(ModifyVM::tr("Invalid %s argument '%s'"),
2739 c == MODIFYVM_AUDIO ? "--audio" : "--audio-driver", ValueUnion.psz);
2740 hrc = E_FAIL;
2741 }
2742
2743 if ( SUCCEEDED(hrc)
2744 && c == MODIFYVM_AUDIO) /* To keep the original behavior until we remove the command. */
2745 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(RTStrICmp(ValueUnion.psz, "none") == false ? false : true));
2746
2747 break;
2748 }
2749
2750 case MODIFYVM_AUDIOENABLED:
2751 {
2752 ComPtr<IAudioSettings> audioSettings;
2753 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(AudioSettings)(audioSettings.asOutParam()));
2754 ComPtr<IAudioAdapter> audioAdapter;
2755 CHECK_ERROR_BREAK(audioSettings, COMGETTER(Adapter)(audioAdapter.asOutParam()));
2756 ASSERT(audioAdapter);
2757
2758 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(ValueUnion.f));
2759 break;
2760 }
2761
2762 case MODIFYVM_AUDIOIN:
2763 {
2764 ComPtr<IAudioSettings> audioSettings;
2765 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(AudioSettings)(audioSettings.asOutParam()));
2766 ComPtr<IAudioAdapter> audioAdapter;
2767 CHECK_ERROR_BREAK(audioSettings, COMGETTER(Adapter)(audioAdapter.asOutParam()));
2768 ASSERT(audioAdapter);
2769
2770 CHECK_ERROR(audioAdapter, COMSETTER(EnabledIn)(ValueUnion.f));
2771 break;
2772 }
2773
2774 case MODIFYVM_AUDIOOUT:
2775 {
2776 ComPtr<IAudioSettings> audioSettings;
2777 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(AudioSettings)(audioSettings.asOutParam()));
2778 ComPtr<IAudioAdapter> audioAdapter;
2779 CHECK_ERROR_BREAK(audioSettings, COMGETTER(Adapter)(audioAdapter.asOutParam()));
2780 ASSERT(audioAdapter);
2781
2782 CHECK_ERROR(audioAdapter, COMSETTER(EnabledOut)(ValueUnion.f));
2783 break;
2784 }
2785
2786#ifdef VBOX_WITH_SHARED_CLIPBOARD
2787 case MODIFYVM_CLIPBOARD_MODE:
2788 {
2789 ClipboardMode_T mode = ClipboardMode_Disabled; /* Shut up MSC */
2790 if (!RTStrICmp(ValueUnion.psz, "disabled"))
2791 mode = ClipboardMode_Disabled;
2792 else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
2793 mode = ClipboardMode_HostToGuest;
2794 else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
2795 mode = ClipboardMode_GuestToHost;
2796 else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
2797 mode = ClipboardMode_Bidirectional;
2798 else
2799 {
2800 errorArgument(ModifyVM::tr("Invalid --clipboard-mode argument '%s'"), ValueUnion.psz);
2801 hrc = E_FAIL;
2802 }
2803 if (SUCCEEDED(hrc))
2804 {
2805 CHECK_ERROR(sessionMachine, COMSETTER(ClipboardMode)(mode));
2806 }
2807 break;
2808 }
2809
2810# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
2811 case MODIFYVM_CLIPBOARD_FILE_TRANSFERS:
2812 {
2813 BOOL fEnabled = false; /* Shut up MSC */
2814 if (!RTStrICmp(ValueUnion.psz, "enabled"))
2815 fEnabled = true;
2816 else if (!RTStrICmp(ValueUnion.psz, "disabled"))
2817 fEnabled = false;
2818 else
2819 {
2820 errorArgument(ModifyVM::tr("Invalid --clipboard-file-transfers argument '%s'"), ValueUnion.psz);
2821 hrc = E_FAIL;
2822 }
2823 if (SUCCEEDED(hrc))
2824 {
2825 CHECK_ERROR(sessionMachine, COMSETTER(ClipboardFileTransfersEnabled)(fEnabled));
2826 }
2827 break;
2828 }
2829# endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
2830#endif /* VBOX_WITH_SHARED_CLIPBOARD */
2831
2832 case MODIFYVM_DRAGANDDROP:
2833 {
2834 DnDMode_T mode = DnDMode_Disabled; /* Shut up MSC */
2835 if (!RTStrICmp(ValueUnion.psz, "disabled"))
2836 mode = DnDMode_Disabled;
2837 else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
2838 mode = DnDMode_HostToGuest;
2839 else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
2840 mode = DnDMode_GuestToHost;
2841 else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
2842 mode = DnDMode_Bidirectional;
2843 else
2844 {
2845 errorArgument(ModifyVM::tr("Invalid --draganddrop argument '%s'"), ValueUnion.psz);
2846 hrc = E_FAIL;
2847 }
2848 if (SUCCEEDED(hrc))
2849 {
2850 CHECK_ERROR(sessionMachine, COMSETTER(DnDMode)(mode));
2851 }
2852 break;
2853 }
2854
2855 case MODIFYVM_VRDE_EXTPACK:
2856 {
2857 ComPtr<IVRDEServer> vrdeServer;
2858 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2859 ASSERT(vrdeServer);
2860
2861 if (vrdeServer)
2862 {
2863 if (RTStrICmp(ValueUnion.psz, "default") != 0)
2864 {
2865 Bstr bstr(ValueUnion.psz);
2866 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(bstr.raw()));
2867 }
2868 else
2869 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(Bstr().raw()));
2870 }
2871 break;
2872 }
2873
2874 case MODIFYVM_VRDEPROPERTY:
2875 {
2876 ComPtr<IVRDEServer> vrdeServer;
2877 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2878 ASSERT(vrdeServer);
2879
2880 if (vrdeServer)
2881 {
2882 /* Parse 'name=value' */
2883 char *pszProperty = RTStrDup(ValueUnion.psz);
2884 if (pszProperty)
2885 {
2886 char *pDelimiter = strchr(pszProperty, '=');
2887 if (pDelimiter)
2888 {
2889 *pDelimiter = '\0';
2890
2891 Bstr bstrName = pszProperty;
2892 Bstr bstrValue = &pDelimiter[1];
2893 CHECK_ERROR(vrdeServer, SetVRDEProperty(bstrName.raw(), bstrValue.raw()));
2894 }
2895 else
2896 {
2897 RTStrFree(pszProperty);
2898
2899 errorArgument(ModifyVM::tr("Invalid --vrdeproperty argument '%s'"), ValueUnion.psz);
2900 hrc = E_FAIL;
2901 break;
2902 }
2903 RTStrFree(pszProperty);
2904 }
2905 else
2906 {
2907 RTStrmPrintf(g_pStdErr, ModifyVM::tr("Error: Failed to allocate memory for VRDE property '%s'\n"),
2908 ValueUnion.psz);
2909 hrc = E_FAIL;
2910 }
2911 }
2912 break;
2913 }
2914
2915 case MODIFYVM_VRDPPORT:
2916 vrdeWarningDeprecatedOption("port");
2917 RT_FALL_THRU();
2918
2919 case MODIFYVM_VRDEPORT:
2920 {
2921 ComPtr<IVRDEServer> vrdeServer;
2922 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2923 ASSERT(vrdeServer);
2924
2925 if (!RTStrICmp(ValueUnion.psz, "default"))
2926 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr("0").raw()));
2927 else
2928 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr(ValueUnion.psz).raw()));
2929 break;
2930 }
2931
2932 case MODIFYVM_VRDPADDRESS:
2933 vrdeWarningDeprecatedOption("address");
2934 RT_FALL_THRU();
2935
2936 case MODIFYVM_VRDEADDRESS:
2937 {
2938 ComPtr<IVRDEServer> vrdeServer;
2939 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2940 ASSERT(vrdeServer);
2941
2942 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Address").raw(), Bstr(ValueUnion.psz).raw()));
2943 break;
2944 }
2945
2946 case MODIFYVM_VRDPAUTHTYPE:
2947 vrdeWarningDeprecatedOption("authtype");
2948 RT_FALL_THRU();
2949 case MODIFYVM_VRDEAUTHTYPE:
2950 {
2951 ComPtr<IVRDEServer> vrdeServer;
2952 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2953 ASSERT(vrdeServer);
2954
2955 if (!RTStrICmp(ValueUnion.psz, "null"))
2956 {
2957 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Null));
2958 }
2959 else if (!RTStrICmp(ValueUnion.psz, "external"))
2960 {
2961 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_External));
2962 }
2963 else if (!RTStrICmp(ValueUnion.psz, "guest"))
2964 {
2965 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Guest));
2966 }
2967 else
2968 {
2969 errorArgument(ModifyVM::tr("Invalid --vrdeauthtype argument '%s'"), ValueUnion.psz);
2970 hrc = E_FAIL;
2971 }
2972 break;
2973 }
2974
2975 case MODIFYVM_VRDEAUTHLIBRARY:
2976 {
2977 ComPtr<IVRDEServer> vrdeServer;
2978 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2979 ASSERT(vrdeServer);
2980
2981 if (vrdeServer)
2982 {
2983 if (RTStrICmp(ValueUnion.psz, "default") != 0)
2984 {
2985 Bstr bstr(ValueUnion.psz);
2986 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(bstr.raw()));
2987 }
2988 else
2989 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(Bstr().raw()));
2990 }
2991 break;
2992 }
2993
2994 case MODIFYVM_VRDPMULTICON:
2995 vrdeWarningDeprecatedOption("multicon");
2996 RT_FALL_THRU();
2997 case MODIFYVM_VRDEMULTICON:
2998 {
2999 ComPtr<IVRDEServer> vrdeServer;
3000 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
3001 ASSERT(vrdeServer);
3002
3003 CHECK_ERROR(vrdeServer, COMSETTER(AllowMultiConnection)(ValueUnion.f));
3004 break;
3005 }
3006
3007 case MODIFYVM_VRDPREUSECON:
3008 vrdeWarningDeprecatedOption("reusecon");
3009 RT_FALL_THRU();
3010 case MODIFYVM_VRDEREUSECON:
3011 {
3012 ComPtr<IVRDEServer> vrdeServer;
3013 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
3014 ASSERT(vrdeServer);
3015
3016 CHECK_ERROR(vrdeServer, COMSETTER(ReuseSingleConnection)(ValueUnion.f));
3017 break;
3018 }
3019
3020 case MODIFYVM_VRDPVIDEOCHANNEL:
3021 vrdeWarningDeprecatedOption("videochannel");
3022 RT_FALL_THRU();
3023 case MODIFYVM_VRDEVIDEOCHANNEL:
3024 {
3025 ComPtr<IVRDEServer> vrdeServer;
3026 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
3027 ASSERT(vrdeServer);
3028
3029 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("VideoChannel/Enabled").raw(),
3030 ValueUnion.f? Bstr("true").raw(): Bstr("false").raw()));
3031 break;
3032 }
3033
3034 case MODIFYVM_VRDPVIDEOCHANNELQUALITY:
3035 vrdeWarningDeprecatedOption("videochannelquality");
3036 RT_FALL_THRU();
3037 case MODIFYVM_VRDEVIDEOCHANNELQUALITY:
3038 {
3039 ComPtr<IVRDEServer> vrdeServer;
3040 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
3041 ASSERT(vrdeServer);
3042
3043 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("VideoChannel/Quality").raw(),
3044 Bstr(ValueUnion.psz).raw()));
3045 break;
3046 }
3047
3048 case MODIFYVM_VRDP:
3049 vrdeWarningDeprecatedOption("");
3050 RT_FALL_THRU();
3051 case MODIFYVM_VRDE:
3052 {
3053 ComPtr<IVRDEServer> vrdeServer;
3054 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
3055 ASSERT(vrdeServer);
3056
3057 CHECK_ERROR(vrdeServer, COMSETTER(Enabled)(ValueUnion.f));
3058 break;
3059 }
3060
3061 case MODIFYVM_USBRENAME:
3062 {
3063 const char *pszName = ValueUnion.psz;
3064 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
3065 if (RT_FAILURE(vrc))
3066 return errorSyntax(ModifyVM::tr("Missing or invalid argument to '%s'"),
3067 GetOptState.pDef->pszLong);
3068 const char *pszNewName = ValueUnion.psz;
3069
3070 SafeIfaceArray<IUSBController> ctrls;
3071 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
3072 bool fRenamed = false;
3073 for (size_t i = 0; i < ctrls.size(); i++)
3074 {
3075 ComPtr<IUSBController> pCtrl = ctrls[i];
3076 Bstr bstrName;
3077 CHECK_ERROR(pCtrl, COMGETTER(Name)(bstrName.asOutParam()));
3078 if (bstrName == pszName)
3079 {
3080 bstrName = pszNewName;
3081 CHECK_ERROR(pCtrl, COMSETTER(Name)(bstrName.raw()));
3082 fRenamed = true;
3083 }
3084 }
3085 if (!fRenamed)
3086 {
3087 errorArgument(ModifyVM::tr("Invalid --usbrename parameters, nothing renamed"));
3088 hrc = E_FAIL;
3089 }
3090 break;
3091 }
3092
3093 case MODIFYVM_USBXHCI:
3094 {
3095 ULONG cXhciCtrls = 0;
3096 hrc = sessionMachine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
3097 if (SUCCEEDED(hrc))
3098 {
3099 if (!cXhciCtrls && ValueUnion.f)
3100 {
3101 ComPtr<IUSBController> UsbCtl;
3102 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("xHCI").raw(), USBControllerType_XHCI,
3103 UsbCtl.asOutParam()));
3104 }
3105 else if (cXhciCtrls && !ValueUnion.f)
3106 {
3107 SafeIfaceArray<IUSBController> ctrls;
3108 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
3109 for (size_t i = 0; i < ctrls.size(); i++)
3110 {
3111 ComPtr<IUSBController> pCtrl = ctrls[i];
3112 USBControllerType_T enmType;
3113 CHECK_ERROR(pCtrl, COMGETTER(Type)(&enmType));
3114 if (enmType == USBControllerType_XHCI)
3115 {
3116 Bstr ctrlName;
3117 CHECK_ERROR(pCtrl, COMGETTER(Name)(ctrlName.asOutParam()));
3118 CHECK_ERROR(sessionMachine, RemoveUSBController(ctrlName.raw()));
3119 }
3120 }
3121 }
3122 }
3123 break;
3124 }
3125
3126 case MODIFYVM_USBEHCI:
3127 {
3128 ULONG cEhciCtrls = 0;
3129 hrc = sessionMachine->GetUSBControllerCountByType(USBControllerType_EHCI, &cEhciCtrls);
3130 if (SUCCEEDED(hrc))
3131 {
3132 if (!cEhciCtrls && ValueUnion.f)
3133 {
3134 ComPtr<IUSBController> UsbCtl;
3135 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("EHCI").raw(), USBControllerType_EHCI,
3136 UsbCtl.asOutParam()));
3137 }
3138 else if (cEhciCtrls && !ValueUnion.f)
3139 {
3140 SafeIfaceArray<IUSBController> ctrls;
3141 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
3142 for (size_t i = 0; i < ctrls.size(); i++)
3143 {
3144 ComPtr<IUSBController> pCtrl = ctrls[i];
3145 USBControllerType_T enmType;
3146 CHECK_ERROR(pCtrl, COMGETTER(Type)(&enmType));
3147 if (enmType == USBControllerType_EHCI)
3148 {
3149 Bstr ctrlName;
3150 CHECK_ERROR(pCtrl, COMGETTER(Name)(ctrlName.asOutParam()));
3151 CHECK_ERROR(sessionMachine, RemoveUSBController(ctrlName.raw()));
3152 }
3153 }
3154 }
3155 }
3156 break;
3157 }
3158
3159 case MODIFYVM_USBOHCI:
3160 {
3161 ULONG cOhciCtrls = 0;
3162 hrc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
3163 if (SUCCEEDED(hrc))
3164 {
3165 if (!cOhciCtrls && ValueUnion.f)
3166 {
3167 ComPtr<IUSBController> UsbCtl;
3168 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
3169 UsbCtl.asOutParam()));
3170 }
3171 else if (cOhciCtrls && !ValueUnion.f)
3172 {
3173 SafeIfaceArray<IUSBController> ctrls;
3174 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
3175 for (size_t i = 0; i < ctrls.size(); i++)
3176 {
3177 ComPtr<IUSBController> pCtrl = ctrls[i];
3178 USBControllerType_T enmType;
3179 CHECK_ERROR(pCtrl, COMGETTER(Type)(&enmType));
3180 if (enmType == USBControllerType_OHCI)
3181 {
3182 Bstr ctrlName;
3183 CHECK_ERROR(pCtrl, COMGETTER(Name)(ctrlName.asOutParam()));
3184 CHECK_ERROR(sessionMachine, RemoveUSBController(ctrlName.raw()));
3185 }
3186 }
3187 }
3188 }
3189 break;
3190 }
3191
3192 case MODIFYVM_SNAPSHOTFOLDER:
3193 {
3194 if (!RTStrICmp(ValueUnion.psz, "default"))
3195 CHECK_ERROR(sessionMachine, COMSETTER(SnapshotFolder)(Bstr().raw()));
3196 else
3197 CHECK_ERROR(sessionMachine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz).raw()));
3198 break;
3199 }
3200
3201 case MODIFYVM_TELEPORTER_ENABLED:
3202 {
3203 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterEnabled)(ValueUnion.f));
3204 break;
3205 }
3206
3207 case MODIFYVM_TELEPORTER_PORT:
3208 {
3209 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPort)(ValueUnion.u32));
3210 break;
3211 }
3212
3213 case MODIFYVM_TELEPORTER_ADDRESS:
3214 {
3215 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterAddress)(Bstr(ValueUnion.psz).raw()));
3216 break;
3217 }
3218
3219 case MODIFYVM_TELEPORTER_PASSWORD:
3220 {
3221 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPassword)(Bstr(ValueUnion.psz).raw()));
3222 break;
3223 }
3224
3225 case MODIFYVM_TELEPORTER_PASSWORD_FILE:
3226 {
3227 Utf8Str password;
3228 RTEXITCODE rcExit = readPasswordFile(ValueUnion.psz, &password);
3229 if (rcExit != RTEXITCODE_SUCCESS)
3230 hrc = E_FAIL;
3231 else
3232 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPassword)(Bstr(password).raw()));
3233 break;
3234 }
3235
3236 case MODIFYVM_TRACING_ENABLED:
3237 {
3238 CHECK_ERROR(sessionMachine, COMSETTER(TracingEnabled)(ValueUnion.f));
3239 break;
3240 }
3241
3242 case MODIFYVM_TRACING_CONFIG:
3243 {
3244 CHECK_ERROR(sessionMachine, COMSETTER(TracingConfig)(Bstr(ValueUnion.psz).raw()));
3245 break;
3246 }
3247
3248 case MODIFYVM_TRACING_ALLOW_VM_ACCESS:
3249 {
3250 CHECK_ERROR(sessionMachine, COMSETTER(AllowTracingToAccessVM)(ValueUnion.f));
3251 break;
3252 }
3253
3254 case MODIFYVM_HARDWARE_UUID:
3255 {
3256 CHECK_ERROR(sessionMachine, COMSETTER(HardwareUUID)(Bstr(ValueUnion.psz).raw()));
3257 break;
3258 }
3259
3260 case MODIFYVM_IOCACHE:
3261 {
3262 CHECK_ERROR(sessionMachine, COMSETTER(IOCacheEnabled)(ValueUnion.f));
3263 break;
3264 }
3265
3266 case MODIFYVM_IOCACHESIZE:
3267 {
3268 CHECK_ERROR(sessionMachine, COMSETTER(IOCacheSize)(ValueUnion.u32));
3269 break;
3270 }
3271
3272 case MODIFYVM_CHIPSET:
3273 {
3274 if (!RTStrICmp(ValueUnion.psz, "piix3"))
3275 {
3276 CHECK_ERROR(platform, COMSETTER(ChipsetType)(ChipsetType_PIIX3));
3277 }
3278 else if (!RTStrICmp(ValueUnion.psz, "ich9"))
3279 {
3280 CHECK_ERROR(platform, COMSETTER(ChipsetType)(ChipsetType_ICH9));
3281 BOOL fIoApic = FALSE;
3282 CHECK_ERROR(firmwareSettings, COMGETTER(IOAPICEnabled)(&fIoApic));
3283 if (!fIoApic)
3284 {
3285 RTStrmPrintf(g_pStdErr, ModifyVM::tr("*** I/O APIC must be enabled for ICH9, enabling. ***\n"));
3286 CHECK_ERROR(firmwareSettings, COMSETTER(IOAPICEnabled)(TRUE));
3287 }
3288 }
3289 else if ( !RTStrICmp(ValueUnion.psz, "armv8")
3290 || !RTStrICmp(ValueUnion.psz, "armv8virtual"))
3291 {
3292 CHECK_ERROR(platform, COMSETTER(ChipsetType)(ChipsetType_ARMv8Virtual));
3293 }
3294 else
3295 {
3296 errorArgument(ModifyVM::tr("Invalid --chipset argument '%s' (valid: piix3,ich9,armv8virtual)"),
3297 ValueUnion.psz);
3298 hrc = E_FAIL;
3299 }
3300 break;
3301 }
3302#if defined(VBOX_WITH_IOMMU_AMD) || defined(VBOX_WITH_IOMMU_INTEL)
3303 case MODIFYVM_IOMMU:
3304 {
3305 if ( !RTStrICmp(ValueUnion.psz, "none")
3306 || !RTStrICmp(ValueUnion.psz, "disabled"))
3307 CHECK_ERROR(platform, COMSETTER(IommuType)(IommuType_None));
3308 else if (!RTStrICmp(ValueUnion.psz, "amd"))
3309 CHECK_ERROR(platform, COMSETTER(IommuType)(IommuType_AMD));
3310 else if (!RTStrICmp(ValueUnion.psz, "intel"))
3311 {
3312#ifdef VBOX_WITH_IOMMU_INTEL
3313 CHECK_ERROR(platform, COMSETTER(IommuType)(IommuType_Intel));
3314#else
3315 errorArgument(ModifyVM::tr("Invalid --iommu argument '%s' (valid: none,amd,automatic)"), ValueUnion.psz);
3316 hrc = E_FAIL;
3317#endif
3318 }
3319 else if (!RTStrICmp(ValueUnion.psz, "automatic"))
3320 {
3321 CHECK_ERROR(platform, COMSETTER(IommuType)(IommuType_Automatic));
3322#ifndef VBOX_WITH_IOMMU_INTEL
3323 RTStrmPrintf(g_pStdErr,
3324 ModifyVM::tr("Warning: On Intel hosts, 'automatic' will not enable an IOMMU since the Intel IOMMU device is not supported yet.\n"));
3325#endif
3326 }
3327 else
3328 {
3329 errorArgument(ModifyVM::tr("Invalid --iommu argument '%s'"), ValueUnion.psz);
3330 hrc = E_FAIL;
3331 }
3332 break;
3333 }
3334#endif
3335#if defined(VBOX_WITH_TPM)
3336 case MODIFYVM_TPM_TYPE:
3337 {
3338 ComPtr<ITrustedPlatformModule> tpm;
3339 sessionMachine->COMGETTER(TrustedPlatformModule)(tpm.asOutParam());
3340
3341 if ( !RTStrICmp(ValueUnion.psz, "none")
3342 || !RTStrICmp(ValueUnion.psz, "disabled"))
3343 CHECK_ERROR(tpm, COMSETTER(Type)(TpmType_None));
3344 else if (!RTStrICmp(ValueUnion.psz, "1.2"))
3345 CHECK_ERROR(tpm, COMSETTER(Type)(TpmType_v1_2));
3346 else if (!RTStrICmp(ValueUnion.psz, "2.0"))
3347 CHECK_ERROR(tpm, COMSETTER(Type)(TpmType_v2_0));
3348 else if (!RTStrICmp(ValueUnion.psz, "host"))
3349 CHECK_ERROR(tpm, COMSETTER(Type)(TpmType_Host));
3350 else if (!RTStrICmp(ValueUnion.psz, "swtpm"))
3351 CHECK_ERROR(tpm, COMSETTER(Type)(TpmType_Swtpm));
3352 else
3353 {
3354 errorArgument(ModifyVM::tr("Invalid --tpm-type argument '%s'"), ValueUnion.psz);
3355 hrc = E_FAIL;
3356 }
3357 break;
3358 }
3359
3360 case MODIFYVM_TPM_LOCATION:
3361 {
3362 ComPtr<ITrustedPlatformModule> tpm;
3363 sessionMachine->COMGETTER(TrustedPlatformModule)(tpm.asOutParam());
3364
3365 CHECK_ERROR(tpm, COMSETTER(Location)(Bstr(ValueUnion.psz).raw()));
3366 break;
3367 }
3368#endif
3369#ifdef VBOX_WITH_RECORDING
3370 case MODIFYVM_RECORDING:
3371 RT_FALL_THROUGH();
3372 case MODIFYVM_RECORDING_SCREENS:
3373 RT_FALL_THROUGH();
3374 case MODIFYVM_RECORDING_FILENAME:
3375 RT_FALL_THROUGH();
3376 case MODIFYVM_RECORDING_VIDEO_WIDTH:
3377 RT_FALL_THROUGH();
3378 case MODIFYVM_RECORDING_VIDEO_HEIGHT:
3379 RT_FALL_THROUGH();
3380 case MODIFYVM_RECORDING_VIDEO_RES:
3381 RT_FALL_THROUGH();
3382 case MODIFYVM_RECORDING_VIDEO_RATE:
3383 RT_FALL_THROUGH();
3384 case MODIFYVM_RECORDING_VIDEO_FPS:
3385 RT_FALL_THROUGH();
3386 case MODIFYVM_RECORDING_MAXTIME:
3387 RT_FALL_THROUGH();
3388 case MODIFYVM_RECORDING_MAXSIZE:
3389 RT_FALL_THROUGH();
3390 case MODIFYVM_RECORDING_OPTIONS:
3391 {
3392 ComPtr<IRecordingSettings> recordingSettings;
3393 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(RecordingSettings)(recordingSettings.asOutParam()));
3394 SafeIfaceArray <IRecordingScreenSettings> saRecordingScreenScreens;
3395 CHECK_ERROR_BREAK(recordingSettings, COMGETTER(Screens)(ComSafeArrayAsOutParam(saRecordingScreenScreens)));
3396
3397 switch (c)
3398 {
3399 case MODIFYVM_RECORDING:
3400 {
3401 CHECK_ERROR(recordingSettings, COMSETTER(Enabled)(ValueUnion.f));
3402 break;
3403 }
3404 case MODIFYVM_RECORDING_SCREENS:
3405 {
3406 ULONG cMonitors = 64;
3407 CHECK_ERROR(pGraphicsAdapter, COMGETTER(MonitorCount)(&cMonitors));
3408 com::SafeArray<BOOL> screens(cMonitors);
3409 if (RT_FAILURE(parseScreens(ValueUnion.psz, &screens)))
3410 {
3411 errorArgument(ModifyVM::tr("Invalid list of screens specified\n"));
3412 hrc = E_FAIL;
3413 break;
3414 }
3415
3416 if (cMonitors > saRecordingScreenScreens.size()) /* Paranoia. */
3417 cMonitors = (ULONG)saRecordingScreenScreens.size();
3418
3419 for (size_t i = 0; i < cMonitors; ++i)
3420 CHECK_ERROR_BREAK(saRecordingScreenScreens[i], COMSETTER(Enabled)(screens[i]));
3421 break;
3422 }
3423 case MODIFYVM_RECORDING_FILENAME:
3424 {
3425 Bstr bstr;
3426 /* empty string will fall through, leaving bstr empty */
3427 if (*ValueUnion.psz)
3428 {
3429 char szVCFileAbs[RTPATH_MAX] = "";
3430 int vrc = RTPathAbs(ValueUnion.psz, szVCFileAbs, sizeof(szVCFileAbs));
3431 if (RT_FAILURE(vrc))
3432 {
3433 errorArgument(ModifyVM::tr("Cannot convert filename \"%s\" to absolute path\n"), ValueUnion.psz);
3434 hrc = E_FAIL;
3435 break;
3436 }
3437 bstr = szVCFileAbs;
3438 }
3439
3440 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3441 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(Filename)(bstr.raw()));
3442 break;
3443 }
3444 case MODIFYVM_RECORDING_VIDEO_WIDTH:
3445 {
3446 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3447 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(VideoWidth)(ValueUnion.u32));
3448 break;
3449 }
3450 case MODIFYVM_RECORDING_VIDEO_HEIGHT:
3451 {
3452 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3453 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(VideoHeight)(ValueUnion.u32));
3454 break;
3455 }
3456 case MODIFYVM_RECORDING_VIDEO_RES:
3457 {
3458 uint32_t uWidth = 0;
3459 char *pszNext;
3460 int vrc = RTStrToUInt32Ex(ValueUnion.psz, &pszNext, 0, &uWidth);
3461 if (RT_FAILURE(vrc) || vrc != VWRN_TRAILING_CHARS || !pszNext || *pszNext != 'x')
3462 {
3463 errorArgument(ModifyVM::tr("Error parsing video resolution '%s' (expected <width>x<height>)"),
3464 ValueUnion.psz);
3465 hrc = E_FAIL;
3466 break;
3467 }
3468 uint32_t uHeight = 0;
3469 vrc = RTStrToUInt32Ex(pszNext+1, NULL, 0, &uHeight);
3470 if (vrc != VINF_SUCCESS)
3471 {
3472 errorArgument(ModifyVM::tr("Error parsing video resolution '%s' (expected <width>x<height>)"),
3473 ValueUnion.psz);
3474 hrc = E_FAIL;
3475 break;
3476 }
3477
3478 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3479 {
3480 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(VideoWidth)(uWidth));
3481 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(VideoHeight)(uHeight));
3482 }
3483 break;
3484 }
3485 case MODIFYVM_RECORDING_VIDEO_RATE:
3486 {
3487 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3488 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(VideoRate)(ValueUnion.u32));
3489 break;
3490 }
3491 case MODIFYVM_RECORDING_VIDEO_FPS:
3492 {
3493 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3494 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(VideoFPS)(ValueUnion.u32));
3495 break;
3496 }
3497 case MODIFYVM_RECORDING_MAXTIME:
3498 {
3499 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3500 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(MaxTime)(ValueUnion.u32));
3501 break;
3502 }
3503 case MODIFYVM_RECORDING_MAXSIZE:
3504 {
3505 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3506 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(MaxFileSize)(ValueUnion.u32));
3507 break;
3508 }
3509 case MODIFYVM_RECORDING_OPTIONS:
3510 {
3511 Bstr bstr(ValueUnion.psz);
3512 for (size_t i = 0; i < saRecordingScreenScreens.size(); ++i)
3513 CHECK_ERROR(saRecordingScreenScreens[i], COMSETTER(Options)(bstr.raw()));
3514 break;
3515 }
3516 }
3517
3518 break;
3519 }
3520#endif
3521 case MODIFYVM_AUTOSTART_ENABLED:
3522 {
3523 CHECK_ERROR(sessionMachine, COMSETTER(AutostartEnabled)(ValueUnion.f));
3524 break;
3525 }
3526
3527 case MODIFYVM_AUTOSTART_DELAY:
3528 {
3529 CHECK_ERROR(sessionMachine, COMSETTER(AutostartDelay)(ValueUnion.u32));
3530 break;
3531 }
3532
3533 case MODIFYVM_AUTOSTOP_TYPE:
3534 {
3535 AutostopType_T enmAutostopType = AutostopType_Disabled;
3536
3537 if (!RTStrICmp(ValueUnion.psz, "disabled"))
3538 enmAutostopType = AutostopType_Disabled;
3539 else if (!RTStrICmp(ValueUnion.psz, "savestate"))
3540 enmAutostopType = AutostopType_SaveState;
3541 else if (!RTStrICmp(ValueUnion.psz, "poweroff"))
3542 enmAutostopType = AutostopType_PowerOff;
3543 else if (!RTStrICmp(ValueUnion.psz, "acpishutdown"))
3544 enmAutostopType = AutostopType_AcpiShutdown;
3545 else
3546 {
3547 errorArgument(ModifyVM::tr("Invalid --autostop-type argument '%s' (valid: disabled, savestate, poweroff, acpishutdown)"),
3548 ValueUnion.psz);
3549 hrc = E_FAIL;
3550 }
3551
3552 if (SUCCEEDED(hrc))
3553 CHECK_ERROR(sessionMachine, COMSETTER(AutostopType)(enmAutostopType));
3554 break;
3555 }
3556#ifdef VBOX_WITH_PCI_PASSTHROUGH
3557 case MODIFYVM_ATTACH_PCI:
3558 {
3559 const char* pAt = strchr(ValueUnion.psz, '@');
3560 int32_t iHostAddr, iGuestAddr;
3561
3562 iHostAddr = parsePci(ValueUnion.psz);
3563 iGuestAddr = pAt != NULL ? parsePci(pAt + 1) : iHostAddr;
3564
3565 if (iHostAddr == -1 || iGuestAddr == -1)
3566 {
3567 errorArgument(ModifyVM::tr("Invalid --pciattach argument '%s' (valid: 'HB:HD.HF@GB:GD.GF' or just 'HB:HD.HF')"),
3568 ValueUnion.psz);
3569 hrc = E_FAIL;
3570 }
3571 else
3572 {
3573 CHECK_ERROR(sessionMachine, AttachHostPCIDevice(iHostAddr, iGuestAddr, TRUE));
3574 }
3575
3576 break;
3577 }
3578 case MODIFYVM_DETACH_PCI:
3579 {
3580 int32_t iHostAddr;
3581
3582 iHostAddr = parsePci(ValueUnion.psz);
3583 if (iHostAddr == -1)
3584 {
3585 errorArgument(ModifyVM::tr("Invalid --pcidetach argument '%s' (valid: 'HB:HD.HF')"), ValueUnion.psz);
3586 hrc = E_FAIL;
3587 }
3588 else
3589 {
3590 CHECK_ERROR(sessionMachine, DetachHostPCIDevice(iHostAddr));
3591 }
3592
3593 break;
3594 }
3595#endif
3596
3597#ifdef VBOX_WITH_USB_CARDREADER
3598 case MODIFYVM_USBCARDREADER:
3599 {
3600 CHECK_ERROR(sessionMachine, COMSETTER(EmulatedUSBCardReaderEnabled)(ValueUnion.f));
3601 break;
3602 }
3603#endif /* VBOX_WITH_USB_CARDREADER */
3604
3605 case MODIFYVM_DEFAULTFRONTEND:
3606 {
3607 Bstr bstr(ValueUnion.psz);
3608 if (bstr == "default")
3609 bstr = Bstr::Empty;
3610 CHECK_ERROR(sessionMachine, COMSETTER(DefaultFrontend)(bstr.raw()));
3611 break;
3612 }
3613
3614 case MODIFYVM_VMPROC_PRIORITY:
3615 {
3616 VMProcPriority_T enmPriority = nameToVMProcPriority(ValueUnion.psz);
3617 if (enmPriority == VMProcPriority_Invalid)
3618 {
3619 errorArgument(ModifyVM::tr("Invalid --vm-process-priority '%s'"), ValueUnion.psz);
3620 hrc = E_FAIL;
3621 }
3622 else
3623 {
3624 CHECK_ERROR(sessionMachine, COMSETTER(VMProcessPriority)(enmPriority));
3625 }
3626 break;
3627 }
3628
3629 case MODIFYVM_VMEXEC_ENGINE:
3630 {
3631 VMExecutionEngine_T enmExecEngine = nameToVMExecEngine(ValueUnion.psz);
3632 if (enmExecEngine == VMExecutionEngine_NotSet)
3633 {
3634 errorArgument(ModifyVM::tr("Invalid --vm-execution-engine '%s'"), ValueUnion.psz);
3635 hrc = E_FAIL;
3636 }
3637 else
3638 {
3639 CHECK_ERROR(sessionMachine, COMSETTER(VMExecutionEngine)(enmExecEngine));
3640 }
3641 break;
3642 }
3643
3644 case MODIFYVM_TESTING_ENABLED:
3645 hrc = setExtraData(sessionMachine, "VBoxInternal/Devices/VMMDev/0/Config/TestingEnabled", ValueUnion.f ? "1" : "");
3646 break;
3647
3648 case MODIFYVM_TESTING_MMIO:
3649 hrc = setExtraData(sessionMachine, "VBoxInternal/Devices/VMMDev/0/Config/TestingMMIO", ValueUnion.f ? "1" : "");
3650 break;
3651
3652 case MODIFYVM_TESTING_CFG_DWORD:
3653 if (GetOptState.uIndex <= 9)
3654 {
3655 char szVar[128];
3656 RTStrPrintf(szVar, sizeof(szVar), "VBoxInternal/Devices/VMMDev/0/Config/TestingCfgDword%u",
3657 GetOptState.uIndex);
3658 char szValue[32];
3659 RTStrPrintf(szValue, sizeof(szValue), "%u", ValueUnion.u32);
3660 hrc = setExtraData(sessionMachine, szVar, szValue);
3661 }
3662 else
3663 hrc = errorArgumentHr(ModifyVM::tr("--testing-cfg-dword index %u is out of range: 0 thru 9"),
3664 GetOptState.uIndex);
3665 break;
3666
3667 case MODIFYVM_GUEST_DEBUG_PROVIDER:
3668 {
3669 ComPtr<IGuestDebugControl> gstDbgCtrl;
3670 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(GuestDebugControl)(gstDbgCtrl.asOutParam()));
3671
3672 GuestDebugProvider_T enmDebugProvider = GuestDebugProvider_None;
3673
3674 if (!RTStrICmp(ValueUnion.psz, "none"))
3675 enmDebugProvider = GuestDebugProvider_None;
3676 else if (!RTStrICmp(ValueUnion.psz, "native"))
3677 enmDebugProvider = GuestDebugProvider_Native;
3678 else if (!RTStrICmp(ValueUnion.psz, "gdb"))
3679 enmDebugProvider = GuestDebugProvider_GDB;
3680 else if (!RTStrICmp(ValueUnion.psz, "kd"))
3681 enmDebugProvider = GuestDebugProvider_KD;
3682 else
3683 {
3684 errorArgument(ModifyVM::tr("Invalid --guest-debug-provider '%s' (valid: none, native, gdb, kd)"),
3685 ValueUnion.psz);
3686 hrc = E_FAIL;
3687 }
3688
3689 if (SUCCEEDED(hrc))
3690 CHECK_ERROR(gstDbgCtrl, COMSETTER(DebugProvider)(enmDebugProvider));
3691 break;
3692 }
3693
3694 case MODIFYVM_GUEST_DEBUG_IO_PROVIDER:
3695 {
3696 ComPtr<IGuestDebugControl> gstDbgCtrl;
3697 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(GuestDebugControl)(gstDbgCtrl.asOutParam()));
3698
3699 GuestDebugIoProvider_T enmDebugIoProvider = GuestDebugIoProvider_None;
3700
3701 if (!RTStrICmp(ValueUnion.psz, "none"))
3702 enmDebugIoProvider = GuestDebugIoProvider_None;
3703 else if (!RTStrICmp(ValueUnion.psz, "tcp"))
3704 enmDebugIoProvider = GuestDebugIoProvider_TCP;
3705 else if (!RTStrICmp(ValueUnion.psz, "udp"))
3706 enmDebugIoProvider = GuestDebugIoProvider_UDP;
3707 else if (!RTStrICmp(ValueUnion.psz, "ipc"))
3708 enmDebugIoProvider = GuestDebugIoProvider_IPC;
3709 else
3710 {
3711 errorArgument(ModifyVM::tr("Invalid --guest-debug-io-provider '%s' (valid: none, tcp, udp, ipc)"),
3712 ValueUnion.psz);
3713 hrc = E_FAIL;
3714 }
3715
3716 if (SUCCEEDED(hrc))
3717 CHECK_ERROR(gstDbgCtrl, COMSETTER(DebugIoProvider)(enmDebugIoProvider));
3718 break;
3719 }
3720
3721 case MODIFYVM_GUEST_DEBUG_ADDRESS:
3722 {
3723 ComPtr<IGuestDebugControl> gstDbgCtrl;
3724 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(GuestDebugControl)(gstDbgCtrl.asOutParam()));
3725
3726 Bstr bstr(ValueUnion.psz);
3727 CHECK_ERROR(gstDbgCtrl, COMSETTER(DebugAddress)(bstr.raw()));
3728 break;
3729 }
3730
3731 case MODIFYVM_GUEST_DEBUG_PORT:
3732 {
3733 ComPtr<IGuestDebugControl> gstDbgCtrl;
3734 CHECK_ERROR_BREAK(sessionMachine, COMGETTER(GuestDebugControl)(gstDbgCtrl.asOutParam()));
3735 CHECK_ERROR(gstDbgCtrl, COMSETTER(DebugPort)(ValueUnion.u32));
3736 break;
3737 }
3738
3739 default:
3740 {
3741 hrc = handleModifyVM_x86(&GetOptState, c, &ValueUnion, sessionMachine, platformX86);
3742 if (FAILED(hrc))
3743 errorGetOpt(c, &ValueUnion);
3744 break;
3745 }
3746 }
3747 }
3748
3749 /* commit changes */
3750 if (SUCCEEDED(hrc))
3751 CHECK_ERROR(sessionMachine, SaveSettings());
3752
3753 /* it's important to always close sessions */
3754 a->session->UnlockMachine();
3755
3756 return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
3757}
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