VirtualBox

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

Last change on this file since 103068 was 101418, checked in by vboxsync, 9 months ago

Main: Added VM setting (AutoSerialNumGen) for enabling automatic VM serial number generation jiraref:VBP-238

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

© 2023 Oracle
ContactPrivacy policyTerms of Use