VirtualBox

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

Last change on this file since 107338 was 107267, checked in by vboxsync, 7 weeks ago

Main/API,UI: bugref:10810 Based on Brent's patch, added UsbNet support into Main API and UI

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