VirtualBox

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

Last change on this file since 68485 was 68485, checked in by vboxsync, 7 years ago

Audio: Implemented ability to enable / disable audio input / output on-the-fly via API.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 129.0 KB
Line 
1/* $Id: VBoxManageModifyVM.cpp 68485 2017-08-21 13:48:12Z vboxsync $ */
2/** @file
3 * VBoxManage - Implementation of modifyvm command.
4 */
5
6/*
7 * Copyright (C) 2006-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#ifndef VBOX_ONLY_DOCS
23#include <VBox/com/com.h>
24#include <VBox/com/array.h>
25#include <VBox/com/ErrorInfo.h>
26#include <VBox/com/errorprint.h>
27#include <VBox/com/VirtualBox.h>
28#endif /* !VBOX_ONLY_DOCS */
29
30#include <iprt/cidr.h>
31#include <iprt/ctype.h>
32#include <iprt/file.h>
33#include <iprt/param.h>
34#include <iprt/path.h>
35#include <iprt/stream.h>
36#include <iprt/string.h>
37#include <iprt/getopt.h>
38#include <VBox/log.h>
39#include "VBoxManage.h"
40
41#ifndef VBOX_ONLY_DOCS
42using namespace com;
43/** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */
44#if defined(_MSC_VER)
45# pragma optimize("g", off)
46# if _MSC_VER < RT_MSC_VER_VC120
47# pragma warning(disable:4748)
48# endif
49#endif
50
51enum
52{
53 MODIFYVM_NAME = 1000,
54 MODIFYVM_GROUPS,
55 MODIFYVM_DESCRIPTION,
56 MODIFYVM_OSTYPE,
57 MODIFYVM_ICONFILE,
58 MODIFYVM_MEMORY,
59 MODIFYVM_PAGEFUSION,
60 MODIFYVM_VRAM,
61 MODIFYVM_FIRMWARE,
62 MODIFYVM_ACPI,
63 MODIFYVM_IOAPIC,
64 MODIFYVM_PAE,
65 MODIFYVM_LONGMODE,
66 MODIFYVM_CPUID_PORTABILITY,
67 MODIFYVM_TFRESET,
68 MODIFYVM_APIC,
69 MODIFYVM_X2APIC,
70 MODIFYVM_PARAVIRTPROVIDER,
71 MODIFYVM_PARAVIRTDEBUG,
72 MODIFYVM_HWVIRTEX,
73 MODIFYVM_NESTEDPAGING,
74 MODIFYVM_LARGEPAGES,
75 MODIFYVM_VTXVPID,
76 MODIFYVM_VTXUX,
77 MODIFYVM_CPUS,
78 MODIFYVM_CPUHOTPLUG,
79 MODIFYVM_CPU_PROFILE,
80 MODIFYVM_PLUGCPU,
81 MODIFYVM_UNPLUGCPU,
82 MODIFYVM_SETCPUID,
83 MODIFYVM_DELCPUID,
84 MODIFYVM_DELALLCPUID,
85 MODIFYVM_GRAPHICSCONTROLLER,
86 MODIFYVM_MONITORCOUNT,
87 MODIFYVM_ACCELERATE3D,
88#ifdef VBOX_WITH_VIDEOHWACCEL
89 MODIFYVM_ACCELERATE2DVIDEO,
90#endif
91 MODIFYVM_BIOSLOGOFADEIN,
92 MODIFYVM_BIOSLOGOFADEOUT,
93 MODIFYVM_BIOSLOGODISPLAYTIME,
94 MODIFYVM_BIOSLOGOIMAGEPATH,
95 MODIFYVM_BIOSBOOTMENU,
96 MODIFYVM_BIOSAPIC,
97 MODIFYVM_BIOSSYSTEMTIMEOFFSET,
98 MODIFYVM_BIOSPXEDEBUG,
99 MODIFYVM_BOOT,
100 MODIFYVM_HDA, // deprecated
101 MODIFYVM_HDB, // deprecated
102 MODIFYVM_HDD, // deprecated
103 MODIFYVM_IDECONTROLLER, // deprecated
104 MODIFYVM_SATAPORTCOUNT, // deprecated
105 MODIFYVM_SATAPORT, // deprecated
106 MODIFYVM_SATA, // deprecated
107 MODIFYVM_SCSIPORT, // deprecated
108 MODIFYVM_SCSITYPE, // deprecated
109 MODIFYVM_SCSI, // deprecated
110 MODIFYVM_DVDPASSTHROUGH, // deprecated
111 MODIFYVM_DVD, // deprecated
112 MODIFYVM_FLOPPY, // deprecated
113 MODIFYVM_NICTRACEFILE,
114 MODIFYVM_NICTRACE,
115 MODIFYVM_NICPROPERTY,
116 MODIFYVM_NICTYPE,
117 MODIFYVM_NICSPEED,
118 MODIFYVM_NICBOOTPRIO,
119 MODIFYVM_NICPROMISC,
120 MODIFYVM_NICBWGROUP,
121 MODIFYVM_NIC,
122 MODIFYVM_CABLECONNECTED,
123 MODIFYVM_BRIDGEADAPTER,
124 MODIFYVM_HOSTONLYADAPTER,
125 MODIFYVM_INTNET,
126 MODIFYVM_GENERICDRV,
127 MODIFYVM_NATNETWORKNAME,
128 MODIFYVM_NATNET,
129 MODIFYVM_NATBINDIP,
130 MODIFYVM_NATSETTINGS,
131 MODIFYVM_NATPF,
132 MODIFYVM_NATALIASMODE,
133 MODIFYVM_NATTFTPPREFIX,
134 MODIFYVM_NATTFTPFILE,
135 MODIFYVM_NATTFTPSERVER,
136 MODIFYVM_NATDNSPASSDOMAIN,
137 MODIFYVM_NATDNSPROXY,
138 MODIFYVM_NATDNSHOSTRESOLVER,
139 MODIFYVM_MACADDRESS,
140 MODIFYVM_HIDPTR,
141 MODIFYVM_HIDKBD,
142 MODIFYVM_UARTMODE,
143 MODIFYVM_UART,
144#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
145 MODIFYVM_LPTMODE,
146 MODIFYVM_LPT,
147#endif
148 MODIFYVM_GUESTMEMORYBALLOON,
149 MODIFYVM_AUDIOCONTROLLER,
150 MODIFYVM_AUDIOCODEC,
151 MODIFYVM_AUDIO,
152 MODIFYVM_AUDIOIN,
153 MODIFYVM_AUDIOOUT,
154 MODIFYVM_CLIPBOARD,
155 MODIFYVM_DRAGANDDROP,
156 MODIFYVM_VRDPPORT, /* VRDE: deprecated */
157 MODIFYVM_VRDPADDRESS, /* VRDE: deprecated */
158 MODIFYVM_VRDPAUTHTYPE, /* VRDE: deprecated */
159 MODIFYVM_VRDPMULTICON, /* VRDE: deprecated */
160 MODIFYVM_VRDPREUSECON, /* VRDE: deprecated */
161 MODIFYVM_VRDPVIDEOCHANNEL, /* VRDE: deprecated */
162 MODIFYVM_VRDPVIDEOCHANNELQUALITY, /* VRDE: deprecated */
163 MODIFYVM_VRDP, /* VRDE: deprecated */
164 MODIFYVM_VRDEPROPERTY,
165 MODIFYVM_VRDEPORT,
166 MODIFYVM_VRDEADDRESS,
167 MODIFYVM_VRDEAUTHTYPE,
168 MODIFYVM_VRDEAUTHLIBRARY,
169 MODIFYVM_VRDEMULTICON,
170 MODIFYVM_VRDEREUSECON,
171 MODIFYVM_VRDEVIDEOCHANNEL,
172 MODIFYVM_VRDEVIDEOCHANNELQUALITY,
173 MODIFYVM_VRDE_EXTPACK,
174 MODIFYVM_VRDE,
175 MODIFYVM_RTCUSEUTC,
176 MODIFYVM_USBRENAME,
177 MODIFYVM_USBXHCI,
178 MODIFYVM_USBEHCI,
179 MODIFYVM_USB,
180 MODIFYVM_SNAPSHOTFOLDER,
181 MODIFYVM_TELEPORTER_ENABLED,
182 MODIFYVM_TELEPORTER_PORT,
183 MODIFYVM_TELEPORTER_ADDRESS,
184 MODIFYVM_TELEPORTER_PASSWORD,
185 MODIFYVM_TELEPORTER_PASSWORD_FILE,
186 MODIFYVM_TRACING_ENABLED,
187 MODIFYVM_TRACING_CONFIG,
188 MODIFYVM_TRACING_ALLOW_VM_ACCESS,
189 MODIFYVM_HARDWARE_UUID,
190 MODIFYVM_HPET,
191 MODIFYVM_IOCACHE,
192 MODIFYVM_IOCACHESIZE,
193 MODIFYVM_FAULT_TOLERANCE,
194 MODIFYVM_FAULT_TOLERANCE_ADDRESS,
195 MODIFYVM_FAULT_TOLERANCE_PORT,
196 MODIFYVM_FAULT_TOLERANCE_PASSWORD,
197 MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL,
198 MODIFYVM_CPU_EXECTUION_CAP,
199 MODIFYVM_AUTOSTART_ENABLED,
200 MODIFYVM_AUTOSTART_DELAY,
201 MODIFYVM_AUTOSTOP_TYPE,
202#ifdef VBOX_WITH_PCI_PASSTHROUGH
203 MODIFYVM_ATTACH_PCI,
204 MODIFYVM_DETACH_PCI,
205#endif
206#ifdef VBOX_WITH_USB_CARDREADER
207 MODIFYVM_USBCARDREADER,
208#endif
209#ifdef VBOX_WITH_VIDEOREC
210 MODIFYVM_VIDEOCAP,
211 MODIFYVM_VIDEOCAP_SCREENS,
212 MODIFYVM_VIDEOCAP_FILENAME,
213 MODIFYVM_VIDEOCAP_WIDTH,
214 MODIFYVM_VIDEOCAP_HEIGHT,
215 MODIFYVM_VIDEOCAP_RES,
216 MODIFYVM_VIDEOCAP_RATE,
217 MODIFYVM_VIDEOCAP_FPS,
218 MODIFYVM_VIDEOCAP_MAXTIME,
219 MODIFYVM_VIDEOCAP_MAXSIZE,
220 MODIFYVM_VIDEOCAP_OPTIONS,
221#endif
222 MODIFYVM_CHIPSET,
223 MODIFYVM_DEFAULTFRONTEND
224};
225
226static const RTGETOPTDEF g_aModifyVMOptions[] =
227{
228/** @todo Convert to dash separated names like --triple-fault-reset! Please
229 * do that for all new options as we don't need more character soups
230 * around VirtualBox - typedefs more than covers that demand! */
231 { "--name", MODIFYVM_NAME, RTGETOPT_REQ_STRING },
232 { "--groups", MODIFYVM_GROUPS, RTGETOPT_REQ_STRING },
233 { "--description", MODIFYVM_DESCRIPTION, RTGETOPT_REQ_STRING },
234 { "--ostype", MODIFYVM_OSTYPE, RTGETOPT_REQ_STRING },
235 { "--iconfile", MODIFYVM_ICONFILE, RTGETOPT_REQ_STRING },
236 { "--memory", MODIFYVM_MEMORY, RTGETOPT_REQ_UINT32 },
237 { "--pagefusion", MODIFYVM_PAGEFUSION, RTGETOPT_REQ_BOOL_ONOFF },
238 { "--vram", MODIFYVM_VRAM, RTGETOPT_REQ_UINT32 },
239 { "--firmware", MODIFYVM_FIRMWARE, RTGETOPT_REQ_STRING },
240 { "--acpi", MODIFYVM_ACPI, RTGETOPT_REQ_BOOL_ONOFF },
241 { "--ioapic", MODIFYVM_IOAPIC, RTGETOPT_REQ_BOOL_ONOFF },
242 { "--pae", MODIFYVM_PAE, RTGETOPT_REQ_BOOL_ONOFF },
243 { "--longmode", MODIFYVM_LONGMODE, RTGETOPT_REQ_BOOL_ONOFF },
244 { "--cpuid-portability-level", MODIFYVM_CPUID_PORTABILITY, RTGETOPT_REQ_UINT32 },
245 { "--triplefaultreset", MODIFYVM_TFRESET, RTGETOPT_REQ_BOOL_ONOFF },
246 { "--apic", MODIFYVM_APIC, RTGETOPT_REQ_BOOL_ONOFF },
247 { "--x2apic", MODIFYVM_X2APIC, RTGETOPT_REQ_BOOL_ONOFF },
248 { "--paravirtprovider", MODIFYVM_PARAVIRTPROVIDER, RTGETOPT_REQ_STRING },
249 { "--paravirtdebug", MODIFYVM_PARAVIRTDEBUG, RTGETOPT_REQ_STRING },
250 { "--hwvirtex", MODIFYVM_HWVIRTEX, RTGETOPT_REQ_BOOL_ONOFF },
251 { "--nestedpaging", MODIFYVM_NESTEDPAGING, RTGETOPT_REQ_BOOL_ONOFF },
252 { "--largepages", MODIFYVM_LARGEPAGES, RTGETOPT_REQ_BOOL_ONOFF },
253 { "--vtxvpid", MODIFYVM_VTXVPID, RTGETOPT_REQ_BOOL_ONOFF },
254 { "--vtxux", MODIFYVM_VTXUX, RTGETOPT_REQ_BOOL_ONOFF },
255 { "--cpuidset", MODIFYVM_SETCPUID, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX},
256 { "--cpuidremove", MODIFYVM_DELCPUID, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX},
257 { "--cpuidremoveall", MODIFYVM_DELALLCPUID, RTGETOPT_REQ_NOTHING},
258 { "--cpus", MODIFYVM_CPUS, RTGETOPT_REQ_UINT32 },
259 { "--cpuhotplug", MODIFYVM_CPUHOTPLUG, RTGETOPT_REQ_BOOL_ONOFF },
260 { "--cpu-profile", MODIFYVM_CPU_PROFILE, RTGETOPT_REQ_STRING },
261 { "--plugcpu", MODIFYVM_PLUGCPU, RTGETOPT_REQ_UINT32 },
262 { "--unplugcpu", MODIFYVM_UNPLUGCPU, RTGETOPT_REQ_UINT32 },
263 { "--cpuexecutioncap", MODIFYVM_CPU_EXECTUION_CAP, RTGETOPT_REQ_UINT32 },
264 { "--rtcuseutc", MODIFYVM_RTCUSEUTC, RTGETOPT_REQ_BOOL_ONOFF },
265 { "--graphicscontroller", MODIFYVM_GRAPHICSCONTROLLER, RTGETOPT_REQ_STRING },
266 { "--monitorcount", MODIFYVM_MONITORCOUNT, RTGETOPT_REQ_UINT32 },
267 { "--accelerate3d", MODIFYVM_ACCELERATE3D, RTGETOPT_REQ_BOOL_ONOFF },
268#ifdef VBOX_WITH_VIDEOHWACCEL
269 { "--accelerate2dvideo", MODIFYVM_ACCELERATE2DVIDEO, RTGETOPT_REQ_BOOL_ONOFF },
270#endif
271 { "--bioslogofadein", MODIFYVM_BIOSLOGOFADEIN, RTGETOPT_REQ_BOOL_ONOFF },
272 { "--bioslogofadeout", MODIFYVM_BIOSLOGOFADEOUT, RTGETOPT_REQ_BOOL_ONOFF },
273 { "--bioslogodisplaytime", MODIFYVM_BIOSLOGODISPLAYTIME, RTGETOPT_REQ_UINT32 },
274 { "--bioslogoimagepath", MODIFYVM_BIOSLOGOIMAGEPATH, RTGETOPT_REQ_STRING },
275 { "--biosbootmenu", MODIFYVM_BIOSBOOTMENU, RTGETOPT_REQ_STRING },
276 { "--biossystemtimeoffset", MODIFYVM_BIOSSYSTEMTIMEOFFSET, RTGETOPT_REQ_INT64 },
277 { "--biosapic", MODIFYVM_BIOSAPIC, RTGETOPT_REQ_STRING },
278 { "--biospxedebug", MODIFYVM_BIOSPXEDEBUG, RTGETOPT_REQ_BOOL_ONOFF },
279 { "--boot", MODIFYVM_BOOT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
280 { "--hda", MODIFYVM_HDA, RTGETOPT_REQ_STRING },
281 { "--hdb", MODIFYVM_HDB, RTGETOPT_REQ_STRING },
282 { "--hdd", MODIFYVM_HDD, RTGETOPT_REQ_STRING },
283 { "--idecontroller", MODIFYVM_IDECONTROLLER, RTGETOPT_REQ_STRING },
284 { "--sataportcount", MODIFYVM_SATAPORTCOUNT, RTGETOPT_REQ_UINT32 },
285 { "--sataport", MODIFYVM_SATAPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
286 { "--sata", MODIFYVM_SATA, RTGETOPT_REQ_STRING },
287 { "--scsiport", MODIFYVM_SCSIPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
288 { "--scsitype", MODIFYVM_SCSITYPE, RTGETOPT_REQ_STRING },
289 { "--scsi", MODIFYVM_SCSI, RTGETOPT_REQ_STRING },
290 { "--dvdpassthrough", MODIFYVM_DVDPASSTHROUGH, RTGETOPT_REQ_STRING },
291 { "--dvd", MODIFYVM_DVD, RTGETOPT_REQ_STRING },
292 { "--floppy", MODIFYVM_FLOPPY, RTGETOPT_REQ_STRING },
293 { "--nictracefile", MODIFYVM_NICTRACEFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
294 { "--nictrace", MODIFYVM_NICTRACE, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
295 { "--nicproperty", MODIFYVM_NICPROPERTY, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
296 { "--nictype", MODIFYVM_NICTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
297 { "--nicspeed", MODIFYVM_NICSPEED, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
298 { "--nicbootprio", MODIFYVM_NICBOOTPRIO, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
299 { "--nicpromisc", MODIFYVM_NICPROMISC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
300 { "--nicbandwidthgroup", MODIFYVM_NICBWGROUP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
301 { "--nic", MODIFYVM_NIC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
302 { "--cableconnected", MODIFYVM_CABLECONNECTED, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
303 { "--bridgeadapter", MODIFYVM_BRIDGEADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
304 { "--hostonlyadapter", MODIFYVM_HOSTONLYADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
305 { "--intnet", MODIFYVM_INTNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
306 { "--nicgenericdrv", MODIFYVM_GENERICDRV, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
307 { "--nat-network", MODIFYVM_NATNETWORKNAME, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
308 { "--natnetwork", MODIFYVM_NATNETWORKNAME, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
309 { "--natnet", MODIFYVM_NATNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
310 { "--natbindip", MODIFYVM_NATBINDIP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
311 { "--natsettings", MODIFYVM_NATSETTINGS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
312 { "--natpf", MODIFYVM_NATPF, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
313 { "--nataliasmode", MODIFYVM_NATALIASMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
314 { "--nattftpprefix", MODIFYVM_NATTFTPPREFIX, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
315 { "--nattftpfile", MODIFYVM_NATTFTPFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
316 { "--nattftpserver", MODIFYVM_NATTFTPSERVER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
317 { "--natdnspassdomain", MODIFYVM_NATDNSPASSDOMAIN, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
318 { "--natdnsproxy", MODIFYVM_NATDNSPROXY, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
319 { "--natdnshostresolver", MODIFYVM_NATDNSHOSTRESOLVER, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
320 { "--macaddress", MODIFYVM_MACADDRESS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
321 { "--mouse", MODIFYVM_HIDPTR, RTGETOPT_REQ_STRING },
322 { "--keyboard", MODIFYVM_HIDKBD, RTGETOPT_REQ_STRING },
323 { "--uartmode", MODIFYVM_UARTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
324 { "--uart", MODIFYVM_UART, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
325#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
326 { "--lptmode", MODIFYVM_LPTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
327 { "--lpt", MODIFYVM_LPT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
328#endif
329 { "--guestmemoryballoon", MODIFYVM_GUESTMEMORYBALLOON, RTGETOPT_REQ_UINT32 },
330 { "--audiocontroller", MODIFYVM_AUDIOCONTROLLER, RTGETOPT_REQ_STRING },
331 { "--audiocodec", MODIFYVM_AUDIOCODEC, RTGETOPT_REQ_STRING },
332 { "--audio", MODIFYVM_AUDIO, RTGETOPT_REQ_STRING },
333 { "--audioin", MODIFYVM_AUDIOIN, RTGETOPT_REQ_BOOL_ONOFF },
334 { "--audioout", MODIFYVM_AUDIOOUT, RTGETOPT_REQ_BOOL_ONOFF },
335 { "--clipboard", MODIFYVM_CLIPBOARD, RTGETOPT_REQ_STRING },
336 { "--draganddrop", MODIFYVM_DRAGANDDROP, RTGETOPT_REQ_STRING },
337 { "--vrdpport", MODIFYVM_VRDPPORT, RTGETOPT_REQ_STRING }, /* deprecated */
338 { "--vrdpaddress", MODIFYVM_VRDPADDRESS, RTGETOPT_REQ_STRING }, /* deprecated */
339 { "--vrdpauthtype", MODIFYVM_VRDPAUTHTYPE, RTGETOPT_REQ_STRING }, /* deprecated */
340 { "--vrdpmulticon", MODIFYVM_VRDPMULTICON, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
341 { "--vrdpreusecon", MODIFYVM_VRDPREUSECON, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
342 { "--vrdpvideochannel", MODIFYVM_VRDPVIDEOCHANNEL, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
343 { "--vrdpvideochannelquality", MODIFYVM_VRDPVIDEOCHANNELQUALITY, RTGETOPT_REQ_STRING }, /* deprecated */
344 { "--vrdp", MODIFYVM_VRDP, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
345 { "--vrdeproperty", MODIFYVM_VRDEPROPERTY, RTGETOPT_REQ_STRING },
346 { "--vrdeport", MODIFYVM_VRDEPORT, RTGETOPT_REQ_STRING },
347 { "--vrdeaddress", MODIFYVM_VRDEADDRESS, RTGETOPT_REQ_STRING },
348 { "--vrdeauthtype", MODIFYVM_VRDEAUTHTYPE, RTGETOPT_REQ_STRING },
349 { "--vrdeauthlibrary", MODIFYVM_VRDEAUTHLIBRARY, RTGETOPT_REQ_STRING },
350 { "--vrdemulticon", MODIFYVM_VRDEMULTICON, RTGETOPT_REQ_BOOL_ONOFF },
351 { "--vrdereusecon", MODIFYVM_VRDEREUSECON, RTGETOPT_REQ_BOOL_ONOFF },
352 { "--vrdevideochannel", MODIFYVM_VRDEVIDEOCHANNEL, RTGETOPT_REQ_BOOL_ONOFF },
353 { "--vrdevideochannelquality", MODIFYVM_VRDEVIDEOCHANNELQUALITY, RTGETOPT_REQ_STRING },
354 { "--vrdeextpack", MODIFYVM_VRDE_EXTPACK, RTGETOPT_REQ_STRING },
355 { "--vrde", MODIFYVM_VRDE, RTGETOPT_REQ_BOOL_ONOFF },
356 { "--usbrename", MODIFYVM_USBRENAME, RTGETOPT_REQ_STRING },
357 { "--usbxhci", MODIFYVM_USBXHCI, RTGETOPT_REQ_BOOL_ONOFF },
358 { "--usbehci", MODIFYVM_USBEHCI, RTGETOPT_REQ_BOOL_ONOFF },
359 { "--usb", MODIFYVM_USB, RTGETOPT_REQ_BOOL_ONOFF },
360 { "--snapshotfolder", MODIFYVM_SNAPSHOTFOLDER, RTGETOPT_REQ_STRING },
361 { "--teleporter", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF },
362 { "--teleporterenabled", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
363 { "--teleporterport", MODIFYVM_TELEPORTER_PORT, RTGETOPT_REQ_UINT32 },
364 { "--teleporteraddress", MODIFYVM_TELEPORTER_ADDRESS, RTGETOPT_REQ_STRING },
365 { "--teleporterpassword", MODIFYVM_TELEPORTER_PASSWORD, RTGETOPT_REQ_STRING },
366 { "--teleporterpasswordfile", MODIFYVM_TELEPORTER_PASSWORD_FILE, RTGETOPT_REQ_STRING },
367 { "--tracing-enabled", MODIFYVM_TRACING_ENABLED, RTGETOPT_REQ_BOOL_ONOFF },
368 { "--tracing-config", MODIFYVM_TRACING_CONFIG, RTGETOPT_REQ_STRING },
369 { "--tracing-allow-vm-access", MODIFYVM_TRACING_ALLOW_VM_ACCESS, RTGETOPT_REQ_BOOL_ONOFF },
370 { "--hardwareuuid", MODIFYVM_HARDWARE_UUID, RTGETOPT_REQ_STRING },
371 { "--hpet", MODIFYVM_HPET, RTGETOPT_REQ_BOOL_ONOFF },
372 { "--iocache", MODIFYVM_IOCACHE, RTGETOPT_REQ_BOOL_ONOFF },
373 { "--iocachesize", MODIFYVM_IOCACHESIZE, RTGETOPT_REQ_UINT32 },
374 { "--faulttolerance", MODIFYVM_FAULT_TOLERANCE, RTGETOPT_REQ_STRING },
375 { "--faulttoleranceaddress", MODIFYVM_FAULT_TOLERANCE_ADDRESS, RTGETOPT_REQ_STRING },
376 { "--faulttoleranceport", MODIFYVM_FAULT_TOLERANCE_PORT, RTGETOPT_REQ_UINT32 },
377 { "--faulttolerancepassword", MODIFYVM_FAULT_TOLERANCE_PASSWORD, RTGETOPT_REQ_STRING },
378 { "--faulttolerancesyncinterval", MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL, RTGETOPT_REQ_UINT32 },
379 { "--chipset", MODIFYVM_CHIPSET, RTGETOPT_REQ_STRING },
380#ifdef VBOX_WITH_VIDEOREC
381 { "--videocap", MODIFYVM_VIDEOCAP, RTGETOPT_REQ_BOOL_ONOFF },
382 { "--vcpenabled", MODIFYVM_VIDEOCAP, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
383 { "--videocapscreens", MODIFYVM_VIDEOCAP_SCREENS, RTGETOPT_REQ_STRING },
384 { "--vcpscreens", MODIFYVM_VIDEOCAP_SCREENS, RTGETOPT_REQ_STRING }, /* deprecated */
385 { "--videocapfile", MODIFYVM_VIDEOCAP_FILENAME, RTGETOPT_REQ_STRING },
386 { "--vcpfile", MODIFYVM_VIDEOCAP_FILENAME, RTGETOPT_REQ_STRING }, /* deprecated */
387 { "--videocapres", MODIFYVM_VIDEOCAP_RES, RTGETOPT_REQ_STRING },
388 { "--vcpwidth", MODIFYVM_VIDEOCAP_WIDTH, RTGETOPT_REQ_UINT32 }, /* deprecated */
389 { "--vcpheight", MODIFYVM_VIDEOCAP_HEIGHT, RTGETOPT_REQ_UINT32 }, /* deprecated */
390 { "--videocaprate", MODIFYVM_VIDEOCAP_RATE, RTGETOPT_REQ_UINT32 },
391 { "--vcprate", MODIFYVM_VIDEOCAP_RATE, RTGETOPT_REQ_UINT32 }, /* deprecated */
392 { "--videocapfps", MODIFYVM_VIDEOCAP_FPS, RTGETOPT_REQ_UINT32 },
393 { "--vcpfps", MODIFYVM_VIDEOCAP_FPS, RTGETOPT_REQ_UINT32 }, /* deprecated */
394 { "--videocapmaxtime", MODIFYVM_VIDEOCAP_MAXTIME, RTGETOPT_REQ_INT32 },
395 { "--vcpmaxtime", MODIFYVM_VIDEOCAP_MAXTIME, RTGETOPT_REQ_INT32 }, /* deprecated */
396 { "--videocapmaxsize", MODIFYVM_VIDEOCAP_MAXSIZE, RTGETOPT_REQ_INT32 },
397 { "--vcpmaxsize", MODIFYVM_VIDEOCAP_MAXSIZE, RTGETOPT_REQ_INT32 }, /* deprecated */
398 { "--videocapopts", MODIFYVM_VIDEOCAP_OPTIONS, RTGETOPT_REQ_STRING },
399 { "--vcpoptions", MODIFYVM_VIDEOCAP_OPTIONS, RTGETOPT_REQ_STRING }, /* deprecated */
400#endif
401 { "--autostart-enabled", MODIFYVM_AUTOSTART_ENABLED, RTGETOPT_REQ_BOOL_ONOFF },
402 { "--autostart-delay", MODIFYVM_AUTOSTART_DELAY, RTGETOPT_REQ_UINT32 },
403 { "--autostop-type", MODIFYVM_AUTOSTOP_TYPE, RTGETOPT_REQ_STRING },
404#ifdef VBOX_WITH_PCI_PASSTHROUGH
405 { "--pciattach", MODIFYVM_ATTACH_PCI, RTGETOPT_REQ_STRING },
406 { "--pcidetach", MODIFYVM_DETACH_PCI, RTGETOPT_REQ_STRING },
407#endif
408#ifdef VBOX_WITH_USB_CARDREADER
409 { "--usbcardreader", MODIFYVM_USBCARDREADER, RTGETOPT_REQ_BOOL_ONOFF },
410#endif
411 { "--defaultfrontend", MODIFYVM_DEFAULTFRONTEND, RTGETOPT_REQ_STRING },
412};
413
414static void vrdeWarningDeprecatedOption(const char *pszOption)
415{
416 RTStrmPrintf(g_pStdErr, "Warning: '--vrdp%s' is deprecated. Use '--vrde%s'.\n", pszOption, pszOption);
417}
418
419/** Parse PCI address in format 01:02.03 and convert it to the numeric representation. */
420static int32_t parsePci(const char* szPciAddr)
421{
422 char* pszNext = (char*)szPciAddr;
423 int rc;
424 uint8_t aVals[3] = {0, 0, 0};
425
426 rc = RTStrToUInt8Ex(pszNext, &pszNext, 16, &aVals[0]);
427 if (RT_FAILURE(rc) || pszNext == NULL || *pszNext != ':')
428 return -1;
429
430 rc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[1]);
431 if (RT_FAILURE(rc) || pszNext == NULL || *pszNext != '.')
432 return -1;
433
434 rc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[2]);
435 if (RT_FAILURE(rc) || pszNext == NULL)
436 return -1;
437
438 return (aVals[0] << 8) | (aVals[1] << 3) | (aVals[2] << 0);
439}
440
441void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups)
442{
443 while (pcszGroups)
444 {
445 char *pComma = RTStrStr(pcszGroups, ",");
446 if (pComma)
447 {
448 Bstr(pcszGroups, pComma - pcszGroups).detachTo(pGroups->appendedRaw());
449 pcszGroups = pComma + 1;
450 }
451 else
452 {
453 Bstr(pcszGroups).detachTo(pGroups->appendedRaw());
454 pcszGroups = NULL;
455 }
456 }
457}
458
459#ifdef VBOX_WITH_VIDEOREC
460static int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens)
461{
462 while (pcszScreens && *pcszScreens)
463 {
464 char *pszNext;
465 uint32_t iScreen;
466 int rc = RTStrToUInt32Ex(pcszScreens, &pszNext, 0, &iScreen);
467 if (RT_FAILURE(rc))
468 return 1;
469 if (iScreen >= pScreens->size())
470 return 1;
471 if (pszNext && *pszNext)
472 {
473 pszNext = RTStrStripL(pszNext);
474 if (*pszNext != ',')
475 return 1;
476 pszNext++;
477 }
478 (*pScreens)[iScreen] = true;
479 pcszScreens = pszNext;
480 }
481 return 0;
482}
483#endif
484
485static int parseNum(uint32_t uIndex, unsigned cMaxIndex, const char *pszName)
486{
487 if ( uIndex >= 1
488 && uIndex <= cMaxIndex)
489 return uIndex;
490 errorArgument("Invalid %s number %u", pszName, uIndex);
491 return 0;
492}
493
494RTEXITCODE handleModifyVM(HandlerArg *a)
495{
496 int c;
497 HRESULT rc;
498 Bstr name;
499
500 /* VM ID + at least one parameter. Parameter arguments are checked
501 * individually. */
502 if (a->argc < 2)
503 return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
504
505 /* try to find the given sessionMachine */
506 ComPtr<IMachine> machine;
507 CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(),
508 machine.asOutParam()), RTEXITCODE_FAILURE);
509
510
511 /* Get the number of network adapters */
512 ULONG NetworkAdapterCount = getMaxNics(a->virtualBox, machine);
513
514 /* open a session for the VM */
515 CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Write), RTEXITCODE_FAILURE);
516
517 /* get the mutable session sessionMachine */
518 ComPtr<IMachine> sessionMachine;
519 CHECK_ERROR_RET(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()), RTEXITCODE_FAILURE);
520
521 ComPtr<IBIOSSettings> biosSettings;
522 sessionMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
523
524 RTGETOPTSTATE GetOptState;
525 RTGetOptInit(&GetOptState, a->argc, a->argv, g_aModifyVMOptions,
526 RT_ELEMENTS(g_aModifyVMOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
527
528 RTGETOPTUNION ValueUnion;
529 while ( SUCCEEDED (rc)
530 && (c = RTGetOpt(&GetOptState, &ValueUnion)))
531 {
532 switch (c)
533 {
534 case MODIFYVM_NAME:
535 {
536 CHECK_ERROR(sessionMachine, COMSETTER(Name)(Bstr(ValueUnion.psz).raw()));
537 break;
538 }
539 case MODIFYVM_GROUPS:
540 {
541 com::SafeArray<BSTR> groups;
542 parseGroups(ValueUnion.psz, &groups);
543 CHECK_ERROR(sessionMachine, COMSETTER(Groups)(ComSafeArrayAsInParam(groups)));
544 break;
545 }
546 case MODIFYVM_DESCRIPTION:
547 {
548 CHECK_ERROR(sessionMachine, COMSETTER(Description)(Bstr(ValueUnion.psz).raw()));
549 break;
550 }
551 case MODIFYVM_OSTYPE:
552 {
553 ComPtr<IGuestOSType> guestOSType;
554 CHECK_ERROR(a->virtualBox, GetGuestOSType(Bstr(ValueUnion.psz).raw(),
555 guestOSType.asOutParam()));
556 if (SUCCEEDED(rc) && guestOSType)
557 {
558 CHECK_ERROR(sessionMachine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz).raw()));
559 }
560 else
561 {
562 errorArgument("Invalid guest OS type '%s'", ValueUnion.psz);
563 rc = E_FAIL;
564 }
565 break;
566 }
567
568 case MODIFYVM_ICONFILE:
569 {
570 RTFILE iconFile;
571 int vrc = RTFileOpen(&iconFile, ValueUnion.psz, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
572 if (RT_FAILURE(vrc))
573 {
574 RTMsgError("Cannot open file \"%s\": %Rrc", ValueUnion.psz, vrc);
575 rc = E_FAIL;
576 break;
577 }
578 uint64_t cbSize;
579 vrc = RTFileGetSize(iconFile, &cbSize);
580 if (RT_FAILURE(vrc))
581 {
582 RTMsgError("Cannot get size of file \"%s\": %Rrc", ValueUnion.psz, vrc);
583 rc = E_FAIL;
584 break;
585 }
586 if (cbSize > _256K)
587 {
588 RTMsgError("File \"%s\" is bigger than 256KByte", ValueUnion.psz);
589 rc = E_FAIL;
590 break;
591 }
592 SafeArray<BYTE> icon((size_t)cbSize);
593 rc = RTFileRead(iconFile, icon.raw(), (size_t)cbSize, NULL);
594 if (RT_FAILURE(vrc))
595 {
596 RTMsgError("Cannot read contents of file \"%s\": %Rrc", ValueUnion.psz, vrc);
597 rc = E_FAIL;
598 break;
599 }
600 RTFileClose(iconFile);
601 CHECK_ERROR(sessionMachine, COMSETTER(Icon)(ComSafeArrayAsInParam(icon)));
602 break;
603 }
604
605 case MODIFYVM_MEMORY:
606 {
607 CHECK_ERROR(sessionMachine, COMSETTER(MemorySize)(ValueUnion.u32));
608 break;
609 }
610
611 case MODIFYVM_PAGEFUSION:
612 {
613 CHECK_ERROR(sessionMachine, COMSETTER(PageFusionEnabled)(ValueUnion.f));
614 break;
615 }
616
617 case MODIFYVM_VRAM:
618 {
619 CHECK_ERROR(sessionMachine, COMSETTER(VRAMSize)(ValueUnion.u32));
620 break;
621 }
622
623 case MODIFYVM_FIRMWARE:
624 {
625 if (!RTStrICmp(ValueUnion.psz, "efi"))
626 {
627 CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFI));
628 }
629 else if (!RTStrICmp(ValueUnion.psz, "efi32"))
630 {
631 CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFI32));
632 }
633 else if (!RTStrICmp(ValueUnion.psz, "efi64"))
634 {
635 CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFI64));
636 }
637 else if (!RTStrICmp(ValueUnion.psz, "efidual"))
638 {
639 CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFIDUAL));
640 }
641 else if (!RTStrICmp(ValueUnion.psz, "bios"))
642 {
643 CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_BIOS));
644 }
645 else
646 {
647 errorArgument("Invalid --firmware argument '%s'", ValueUnion.psz);
648 rc = E_FAIL;
649 }
650 break;
651 }
652
653 case MODIFYVM_ACPI:
654 {
655 CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(ValueUnion.f));
656 break;
657 }
658
659 case MODIFYVM_IOAPIC:
660 {
661 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(ValueUnion.f));
662 break;
663 }
664
665 case MODIFYVM_PAE:
666 {
667 CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_PAE, ValueUnion.f));
668 break;
669 }
670
671 case MODIFYVM_LONGMODE:
672 {
673 CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_LongMode, ValueUnion.f));
674 break;
675 }
676
677 case MODIFYVM_CPUID_PORTABILITY:
678 {
679 CHECK_ERROR(sessionMachine, COMSETTER(CPUIDPortabilityLevel)(ValueUnion.u32));
680 break;
681 }
682
683 case MODIFYVM_TFRESET:
684 {
685 CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_TripleFaultReset, ValueUnion.f));
686 break;
687 }
688
689 case MODIFYVM_APIC:
690 {
691 CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_APIC, ValueUnion.f));
692 break;
693 }
694
695 case MODIFYVM_X2APIC:
696 {
697 CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_X2APIC, ValueUnion.f));
698 break;
699 }
700
701 case MODIFYVM_PARAVIRTPROVIDER:
702 {
703 if ( !RTStrICmp(ValueUnion.psz, "none")
704 || !RTStrICmp(ValueUnion.psz, "disabled"))
705 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_None));
706 else if (!RTStrICmp(ValueUnion.psz, "default"))
707 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Default));
708 else if (!RTStrICmp(ValueUnion.psz, "legacy"))
709 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Legacy));
710 else if (!RTStrICmp(ValueUnion.psz, "minimal"))
711 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Minimal));
712 else if (!RTStrICmp(ValueUnion.psz, "hyperv"))
713 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_HyperV));
714 else if (!RTStrICmp(ValueUnion.psz, "kvm"))
715 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_KVM));
716 else
717 {
718 errorArgument("Invalid --paravirtprovider argument '%s'", ValueUnion.psz);
719 rc = E_FAIL;
720 }
721 break;
722 }
723
724 case MODIFYVM_PARAVIRTDEBUG:
725 {
726 CHECK_ERROR(sessionMachine, COMSETTER(ParavirtDebug)(Bstr(ValueUnion.psz).raw()));
727 break;
728 }
729
730 case MODIFYVM_HWVIRTEX:
731 {
732 CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_Enabled, ValueUnion.f));
733 break;
734 }
735
736 case MODIFYVM_SETCPUID:
737 {
738 uint32_t id = ValueUnion.u32;
739 uint32_t aValue[4];
740
741 for (unsigned i = 0; i < 4; i++)
742 {
743 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX);
744 if (RT_FAILURE(vrc))
745 return errorSyntax(USAGE_MODIFYVM,
746 "Missing or Invalid argument to '%s'",
747 GetOptState.pDef->pszLong);
748 aValue[i] = ValueUnion.u32;
749 }
750 CHECK_ERROR(sessionMachine, SetCPUIDLeaf(id, aValue[0], aValue[1], aValue[2], aValue[3]));
751 break;
752 }
753
754 case MODIFYVM_DELCPUID:
755 {
756 CHECK_ERROR(sessionMachine, RemoveCPUIDLeaf(ValueUnion.u32));
757 break;
758 }
759
760 case MODIFYVM_DELALLCPUID:
761 {
762 CHECK_ERROR(sessionMachine, RemoveAllCPUIDLeaves());
763 break;
764 }
765
766 case MODIFYVM_NESTEDPAGING:
767 {
768 CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, ValueUnion.f));
769 break;
770 }
771
772 case MODIFYVM_LARGEPAGES:
773 {
774 CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_LargePages, ValueUnion.f));
775 break;
776 }
777
778 case MODIFYVM_VTXVPID:
779 {
780 CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_VPID, ValueUnion.f));
781 break;
782 }
783
784 case MODIFYVM_VTXUX:
785 {
786 CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_UnrestrictedExecution, ValueUnion.f));
787 break;
788 }
789
790 case MODIFYVM_CPUS:
791 {
792 CHECK_ERROR(sessionMachine, COMSETTER(CPUCount)(ValueUnion.u32));
793 break;
794 }
795
796 case MODIFYVM_RTCUSEUTC:
797 {
798 CHECK_ERROR(sessionMachine, COMSETTER(RTCUseUTC)(ValueUnion.f));
799 break;
800 }
801
802 case MODIFYVM_CPUHOTPLUG:
803 {
804 CHECK_ERROR(sessionMachine, COMSETTER(CPUHotPlugEnabled)(ValueUnion.f));
805 break;
806 }
807
808 case MODIFYVM_CPU_PROFILE:
809 {
810 CHECK_ERROR(sessionMachine, COMSETTER(CPUProfile)(Bstr(ValueUnion.psz).raw()));
811 break;
812 }
813
814 case MODIFYVM_PLUGCPU:
815 {
816 CHECK_ERROR(sessionMachine, HotPlugCPU(ValueUnion.u32));
817 break;
818 }
819
820 case MODIFYVM_UNPLUGCPU:
821 {
822 CHECK_ERROR(sessionMachine, HotUnplugCPU(ValueUnion.u32));
823 break;
824 }
825
826 case MODIFYVM_CPU_EXECTUION_CAP:
827 {
828 CHECK_ERROR(sessionMachine, COMSETTER(CPUExecutionCap)(ValueUnion.u32));
829 break;
830 }
831
832 case MODIFYVM_GRAPHICSCONTROLLER:
833 {
834 if ( !RTStrICmp(ValueUnion.psz, "none")
835 || !RTStrICmp(ValueUnion.psz, "disabled"))
836 CHECK_ERROR(sessionMachine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_Null));
837 else if ( !RTStrICmp(ValueUnion.psz, "vboxvga")
838 || !RTStrICmp(ValueUnion.psz, "vbox")
839 || !RTStrICmp(ValueUnion.psz, "vga")
840 || !RTStrICmp(ValueUnion.psz, "vesa"))
841 CHECK_ERROR(sessionMachine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VBoxVGA));
842#ifdef VBOX_WITH_VMSVGA
843 else if ( !RTStrICmp(ValueUnion.psz, "vmsvga")
844 || !RTStrICmp(ValueUnion.psz, "vmware"))
845 CHECK_ERROR(sessionMachine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VMSVGA));
846#endif
847 else
848 {
849 errorArgument("Invalid --graphicscontroller argument '%s'", ValueUnion.psz);
850 rc = E_FAIL;
851 }
852 break;
853 }
854
855 case MODIFYVM_MONITORCOUNT:
856 {
857 CHECK_ERROR(sessionMachine, COMSETTER(MonitorCount)(ValueUnion.u32));
858 break;
859 }
860
861 case MODIFYVM_ACCELERATE3D:
862 {
863 CHECK_ERROR(sessionMachine, COMSETTER(Accelerate3DEnabled)(ValueUnion.f));
864 break;
865 }
866
867#ifdef VBOX_WITH_VIDEOHWACCEL
868 case MODIFYVM_ACCELERATE2DVIDEO:
869 {
870 CHECK_ERROR(sessionMachine, COMSETTER(Accelerate2DVideoEnabled)(ValueUnion.f));
871 break;
872 }
873#endif
874
875 case MODIFYVM_BIOSLOGOFADEIN:
876 {
877 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(ValueUnion.f));
878 break;
879 }
880
881 case MODIFYVM_BIOSLOGOFADEOUT:
882 {
883 CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(ValueUnion.f));
884 break;
885 }
886
887 case MODIFYVM_BIOSLOGODISPLAYTIME:
888 {
889 CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(ValueUnion.u32));
890 break;
891 }
892
893 case MODIFYVM_BIOSLOGOIMAGEPATH:
894 {
895 CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(ValueUnion.psz).raw()));
896 break;
897 }
898
899 case MODIFYVM_BIOSBOOTMENU:
900 {
901 if (!RTStrICmp(ValueUnion.psz, "disabled"))
902 {
903 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled));
904 }
905 else if (!RTStrICmp(ValueUnion.psz, "menuonly"))
906 {
907 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly));
908 }
909 else if (!RTStrICmp(ValueUnion.psz, "messageandmenu"))
910 {
911 CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu));
912 }
913 else
914 {
915 errorArgument("Invalid --biosbootmenu argument '%s'", ValueUnion.psz);
916 rc = E_FAIL;
917 }
918 break;
919 }
920
921 case MODIFYVM_BIOSAPIC:
922 {
923 if (!RTStrICmp(ValueUnion.psz, "disabled"))
924 {
925 CHECK_ERROR(biosSettings, COMSETTER(APICMode)(APICMode_Disabled));
926 }
927 else if ( !RTStrICmp(ValueUnion.psz, "apic")
928 || !RTStrICmp(ValueUnion.psz, "lapic")
929 || !RTStrICmp(ValueUnion.psz, "xapic"))
930 {
931 CHECK_ERROR(biosSettings, COMSETTER(APICMode)(APICMode_APIC));
932 }
933 else if (!RTStrICmp(ValueUnion.psz, "x2apic"))
934 {
935 CHECK_ERROR(biosSettings, COMSETTER(APICMode)(APICMode_X2APIC));
936 }
937 else
938 {
939 errorArgument("Invalid --biosapic argument '%s'", ValueUnion.psz);
940 rc = E_FAIL;
941 }
942 break;
943 }
944
945 case MODIFYVM_BIOSSYSTEMTIMEOFFSET:
946 {
947 CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(ValueUnion.i64));
948 break;
949 }
950
951 case MODIFYVM_BIOSPXEDEBUG:
952 {
953 CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(ValueUnion.f));
954 break;
955 }
956
957 case MODIFYVM_BOOT:
958 {
959 if (!RTStrICmp(ValueUnion.psz, "none"))
960 {
961 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Null));
962 }
963 else if (!RTStrICmp(ValueUnion.psz, "floppy"))
964 {
965 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Floppy));
966 }
967 else if (!RTStrICmp(ValueUnion.psz, "dvd"))
968 {
969 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_DVD));
970 }
971 else if (!RTStrICmp(ValueUnion.psz, "disk"))
972 {
973 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_HardDisk));
974 }
975 else if (!RTStrICmp(ValueUnion.psz, "net"))
976 {
977 CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Network));
978 }
979 else
980 return errorArgument("Invalid boot device '%s'", ValueUnion.psz);
981 break;
982 }
983
984 case MODIFYVM_HDA: // deprecated
985 case MODIFYVM_HDB: // deprecated
986 case MODIFYVM_HDD: // deprecated
987 case MODIFYVM_SATAPORT: // deprecated
988 {
989 uint32_t u1 = 0, u2 = 0;
990 Bstr bstrController = L"IDE Controller";
991
992 switch (c)
993 {
994 case MODIFYVM_HDA: // deprecated
995 u1 = 0;
996 break;
997
998 case MODIFYVM_HDB: // deprecated
999 u1 = 0;
1000 u2 = 1;
1001 break;
1002
1003 case MODIFYVM_HDD: // deprecated
1004 u1 = 1;
1005 u2 = 1;
1006 break;
1007
1008 case MODIFYVM_SATAPORT: // deprecated
1009 u1 = GetOptState.uIndex;
1010 bstrController = L"SATA";
1011 break;
1012 }
1013
1014 if (!RTStrICmp(ValueUnion.psz, "none"))
1015 {
1016 sessionMachine->DetachDevice(bstrController.raw(), u1, u2);
1017 }
1018 else
1019 {
1020 ComPtr<IMedium> hardDisk;
1021 rc = openMedium(a, ValueUnion.psz, DeviceType_HardDisk,
1022 AccessMode_ReadWrite, hardDisk,
1023 false /* fForceNewUuidOnOpen */,
1024 false /* fSilent */);
1025 if (FAILED(rc))
1026 break;
1027 if (hardDisk)
1028 {
1029 CHECK_ERROR(sessionMachine, AttachDevice(bstrController.raw(),
1030 u1, u2,
1031 DeviceType_HardDisk,
1032 hardDisk));
1033 }
1034 else
1035 rc = E_FAIL;
1036 }
1037 break;
1038 }
1039
1040 case MODIFYVM_IDECONTROLLER: // deprecated
1041 {
1042 ComPtr<IStorageController> storageController;
1043 CHECK_ERROR(sessionMachine, GetStorageControllerByName(Bstr("IDE Controller").raw(),
1044 storageController.asOutParam()));
1045
1046 if (!RTStrICmp(ValueUnion.psz, "PIIX3"))
1047 {
1048 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3));
1049 }
1050 else if (!RTStrICmp(ValueUnion.psz, "PIIX4"))
1051 {
1052 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4));
1053 }
1054 else if (!RTStrICmp(ValueUnion.psz, "ICH6"))
1055 {
1056 CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6));
1057 }
1058 else
1059 {
1060 errorArgument("Invalid --idecontroller argument '%s'", ValueUnion.psz);
1061 rc = E_FAIL;
1062 }
1063 break;
1064 }
1065
1066 case MODIFYVM_SATAPORTCOUNT: // deprecated
1067 {
1068 ComPtr<IStorageController> SataCtl;
1069 CHECK_ERROR(sessionMachine, GetStorageControllerByName(Bstr("SATA").raw(),
1070 SataCtl.asOutParam()));
1071
1072 if (SUCCEEDED(rc) && ValueUnion.u32 > 0)
1073 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(ValueUnion.u32));
1074 break;
1075 }
1076
1077 case MODIFYVM_SATA: // deprecated
1078 {
1079 if (!RTStrICmp(ValueUnion.psz, "on") || !RTStrICmp(ValueUnion.psz, "enable"))
1080 {
1081 ComPtr<IStorageController> ctl;
1082 CHECK_ERROR(sessionMachine, AddStorageController(Bstr("SATA").raw(),
1083 StorageBus_SATA,
1084 ctl.asOutParam()));
1085 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci));
1086 }
1087 else if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
1088 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("SATA").raw()));
1089 else
1090 return errorArgument("Invalid --usb argument '%s'", ValueUnion.psz);
1091 break;
1092 }
1093
1094 case MODIFYVM_SCSIPORT: // deprecated
1095 {
1096 if (!RTStrICmp(ValueUnion.psz, "none"))
1097 {
1098 rc = sessionMachine->DetachDevice(Bstr("LsiLogic").raw(),
1099 GetOptState.uIndex, 0);
1100 if (FAILED(rc))
1101 CHECK_ERROR(sessionMachine, DetachDevice(Bstr("BusLogic").raw(),
1102 GetOptState.uIndex, 0));
1103 }
1104 else
1105 {
1106 ComPtr<IMedium> hardDisk;
1107 rc = openMedium(a, ValueUnion.psz, DeviceType_HardDisk,
1108 AccessMode_ReadWrite, hardDisk,
1109 false /* fForceNewUuidOnOpen */,
1110 false /* fSilent */);
1111 if (FAILED(rc))
1112 break;
1113 if (hardDisk)
1114 {
1115 rc = sessionMachine->AttachDevice(Bstr("LsiLogic").raw(),
1116 GetOptState.uIndex, 0,
1117 DeviceType_HardDisk,
1118 hardDisk);
1119 if (FAILED(rc))
1120 CHECK_ERROR(sessionMachine,
1121 AttachDevice(Bstr("BusLogic").raw(),
1122 GetOptState.uIndex, 0,
1123 DeviceType_HardDisk,
1124 hardDisk));
1125 }
1126 else
1127 rc = E_FAIL;
1128 }
1129 break;
1130 }
1131
1132 case MODIFYVM_SCSITYPE: // deprecated
1133 {
1134 ComPtr<IStorageController> ctl;
1135
1136 if (!RTStrICmp(ValueUnion.psz, "LsiLogic"))
1137 {
1138 rc = sessionMachine->RemoveStorageController(Bstr("BusLogic").raw());
1139 if (FAILED(rc))
1140 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("LsiLogic").raw()));
1141
1142 CHECK_ERROR(sessionMachine,
1143 AddStorageController(Bstr("LsiLogic").raw(),
1144 StorageBus_SCSI,
1145 ctl.asOutParam()));
1146
1147 if (SUCCEEDED(rc))
1148 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic));
1149 }
1150 else if (!RTStrICmp(ValueUnion.psz, "BusLogic"))
1151 {
1152 rc = sessionMachine->RemoveStorageController(Bstr("LsiLogic").raw());
1153 if (FAILED(rc))
1154 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("BusLogic").raw()));
1155
1156 CHECK_ERROR(sessionMachine,
1157 AddStorageController(Bstr("BusLogic").raw(),
1158 StorageBus_SCSI,
1159 ctl.asOutParam()));
1160
1161 if (SUCCEEDED(rc))
1162 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
1163 }
1164 else
1165 return errorArgument("Invalid --scsitype argument '%s'", ValueUnion.psz);
1166 break;
1167 }
1168
1169 case MODIFYVM_SCSI: // deprecated
1170 {
1171 if (!RTStrICmp(ValueUnion.psz, "on") || !RTStrICmp(ValueUnion.psz, "enable"))
1172 {
1173 ComPtr<IStorageController> ctl;
1174
1175 CHECK_ERROR(sessionMachine, AddStorageController(Bstr("BusLogic").raw(),
1176 StorageBus_SCSI,
1177 ctl.asOutParam()));
1178 if (SUCCEEDED(rc))
1179 CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
1180 }
1181 else if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
1182 {
1183 rc = sessionMachine->RemoveStorageController(Bstr("BusLogic").raw());
1184 if (FAILED(rc))
1185 CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("LsiLogic").raw()));
1186 }
1187 break;
1188 }
1189
1190 case MODIFYVM_DVDPASSTHROUGH: // deprecated
1191 {
1192 CHECK_ERROR(sessionMachine, PassthroughDevice(Bstr("IDE Controller").raw(),
1193 1, 0,
1194 !RTStrICmp(ValueUnion.psz, "on")));
1195 break;
1196 }
1197
1198 case MODIFYVM_DVD: // deprecated
1199 {
1200 ComPtr<IMedium> dvdMedium;
1201
1202 /* unmount? */
1203 if (!RTStrICmp(ValueUnion.psz, "none"))
1204 {
1205 /* nothing to do, NULL object will cause unmount */
1206 }
1207 /* host drive? */
1208 else if (!RTStrNICmp(ValueUnion.psz, RT_STR_TUPLE("host:")))
1209 {
1210 ComPtr<IHost> host;
1211 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
1212 rc = host->FindHostDVDDrive(Bstr(ValueUnion.psz + 5).raw(),
1213 dvdMedium.asOutParam());
1214 if (!dvdMedium)
1215 {
1216 /* 2nd try: try with the real name, important on Linux+libhal */
1217 char szPathReal[RTPATH_MAX];
1218 if (RT_FAILURE(RTPathReal(ValueUnion.psz + 5, szPathReal, sizeof(szPathReal))))
1219 {
1220 errorArgument("Invalid host DVD drive name \"%s\"", ValueUnion.psz + 5);
1221 rc = E_FAIL;
1222 break;
1223 }
1224 rc = host->FindHostDVDDrive(Bstr(szPathReal).raw(),
1225 dvdMedium.asOutParam());
1226 if (!dvdMedium)
1227 {
1228 errorArgument("Invalid host DVD drive name \"%s\"", ValueUnion.psz + 5);
1229 rc = E_FAIL;
1230 break;
1231 }
1232 }
1233 }
1234 else
1235 {
1236 rc = openMedium(a, ValueUnion.psz, DeviceType_DVD,
1237 AccessMode_ReadOnly, dvdMedium,
1238 false /* fForceNewUuidOnOpen */,
1239 false /* fSilent */);
1240 if (FAILED(rc))
1241 break;
1242 if (!dvdMedium)
1243 {
1244 rc = E_FAIL;
1245 break;
1246 }
1247 }
1248
1249 CHECK_ERROR(sessionMachine, MountMedium(Bstr("IDE Controller").raw(),
1250 1, 0,
1251 dvdMedium,
1252 FALSE /* aForce */));
1253 break;
1254 }
1255
1256 case MODIFYVM_FLOPPY: // deprecated
1257 {
1258 ComPtr<IMedium> floppyMedium;
1259 ComPtr<IMediumAttachment> floppyAttachment;
1260 sessionMachine->GetMediumAttachment(Bstr("Floppy Controller").raw(),
1261 0, 0, floppyAttachment.asOutParam());
1262
1263 /* disable? */
1264 if (!RTStrICmp(ValueUnion.psz, "disabled"))
1265 {
1266 /* disable the controller */
1267 if (floppyAttachment)
1268 CHECK_ERROR(sessionMachine, DetachDevice(Bstr("Floppy Controller").raw(),
1269 0, 0));
1270 }
1271 else
1272 {
1273 /* enable the controller */
1274 if (!floppyAttachment)
1275 CHECK_ERROR(sessionMachine, AttachDeviceWithoutMedium(Bstr("Floppy Controller").raw(),
1276 0, 0,
1277 DeviceType_Floppy));
1278
1279 /* unmount? */
1280 if ( !RTStrICmp(ValueUnion.psz, "none")
1281 || !RTStrICmp(ValueUnion.psz, "empty")) // deprecated
1282 {
1283 /* nothing to do, NULL object will cause unmount */
1284 }
1285 /* host drive? */
1286 else if (!RTStrNICmp(ValueUnion.psz, RT_STR_TUPLE("host:")))
1287 {
1288 ComPtr<IHost> host;
1289 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
1290 rc = host->FindHostFloppyDrive(Bstr(ValueUnion.psz + 5).raw(),
1291 floppyMedium.asOutParam());
1292 if (!floppyMedium)
1293 {
1294 errorArgument("Invalid host floppy drive name \"%s\"", ValueUnion.psz + 5);
1295 rc = E_FAIL;
1296 break;
1297 }
1298 }
1299 else
1300 {
1301 rc = openMedium(a, ValueUnion.psz, DeviceType_Floppy,
1302 AccessMode_ReadWrite, floppyMedium,
1303 false /* fForceNewUuidOnOpen */,
1304 false /* fSilent */);
1305 if (FAILED(rc))
1306 break;
1307 if (!floppyMedium)
1308 {
1309 rc = E_FAIL;
1310 break;
1311 }
1312 }
1313 CHECK_ERROR(sessionMachine, MountMedium(Bstr("Floppy Controller").raw(),
1314 0, 0,
1315 floppyMedium,
1316 FALSE /* aForce */));
1317 }
1318 break;
1319 }
1320
1321 case MODIFYVM_NICTRACEFILE:
1322 {
1323
1324 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1325 break;
1326
1327 ComPtr<INetworkAdapter> nic;
1328 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1329 ASSERT(nic);
1330
1331 CHECK_ERROR(nic, COMSETTER(TraceFile)(Bstr(ValueUnion.psz).raw()));
1332 break;
1333 }
1334
1335 case MODIFYVM_NICTRACE:
1336 {
1337 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1338 break;
1339
1340 ComPtr<INetworkAdapter> nic;
1341 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1342 ASSERT(nic);
1343
1344 CHECK_ERROR(nic, COMSETTER(TraceEnabled)(ValueUnion.f));
1345 break;
1346 }
1347
1348 case MODIFYVM_NICPROPERTY:
1349 {
1350 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1351 break;
1352
1353 ComPtr<INetworkAdapter> nic;
1354 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1355 ASSERT(nic);
1356
1357 if (nic)
1358 {
1359 /* Parse 'name=value' */
1360 char *pszProperty = RTStrDup(ValueUnion.psz);
1361 if (pszProperty)
1362 {
1363 char *pDelimiter = strchr(pszProperty, '=');
1364 if (pDelimiter)
1365 {
1366 *pDelimiter = '\0';
1367
1368 Bstr bstrName = pszProperty;
1369 Bstr bstrValue = &pDelimiter[1];
1370 CHECK_ERROR(nic, SetProperty(bstrName.raw(), bstrValue.raw()));
1371 }
1372 else
1373 {
1374 errorArgument("Invalid --nicproperty%d argument '%s'", GetOptState.uIndex, ValueUnion.psz);
1375 rc = E_FAIL;
1376 }
1377 RTStrFree(pszProperty);
1378 }
1379 else
1380 {
1381 RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for --nicproperty%d '%s'\n", GetOptState.uIndex, ValueUnion.psz);
1382 rc = E_FAIL;
1383 }
1384 }
1385 break;
1386 }
1387 case MODIFYVM_NICTYPE:
1388 {
1389 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1390 break;
1391
1392 ComPtr<INetworkAdapter> nic;
1393 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1394 ASSERT(nic);
1395
1396 if (!RTStrICmp(ValueUnion.psz, "Am79C970A"))
1397 {
1398 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A));
1399 }
1400 else if (!RTStrICmp(ValueUnion.psz, "Am79C973"))
1401 {
1402 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973));
1403 }
1404#ifdef VBOX_WITH_E1000
1405 else if (!RTStrICmp(ValueUnion.psz, "82540EM"))
1406 {
1407 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM));
1408 }
1409 else if (!RTStrICmp(ValueUnion.psz, "82543GC"))
1410 {
1411 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC));
1412 }
1413 else if (!RTStrICmp(ValueUnion.psz, "82545EM"))
1414 {
1415 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82545EM));
1416 }
1417#endif
1418#ifdef VBOX_WITH_VIRTIO
1419 else if (!RTStrICmp(ValueUnion.psz, "virtio"))
1420 {
1421 CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Virtio));
1422 }
1423#endif /* VBOX_WITH_VIRTIO */
1424 else
1425 {
1426 errorArgument("Invalid NIC type '%s' specified for NIC %u", ValueUnion.psz, GetOptState.uIndex);
1427 rc = E_FAIL;
1428 }
1429 break;
1430 }
1431
1432 case MODIFYVM_NICSPEED:
1433 {
1434 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1435 break;
1436
1437 ComPtr<INetworkAdapter> nic;
1438 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1439 ASSERT(nic);
1440
1441 CHECK_ERROR(nic, COMSETTER(LineSpeed)(ValueUnion.u32));
1442 break;
1443 }
1444
1445 case MODIFYVM_NICBOOTPRIO:
1446 {
1447 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1448 break;
1449
1450 ComPtr<INetworkAdapter> nic;
1451 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1452 ASSERT(nic);
1453
1454 /* Somewhat arbitrary limitation - we can pass a list of up to 4 PCI devices
1455 * to the PXE ROM, hence only boot priorities 1-4 are allowed (in addition to
1456 * 0 for the default lowest priority).
1457 */
1458 if (ValueUnion.u32 > 4)
1459 {
1460 errorArgument("Invalid boot priority '%u' specfied for NIC %u", ValueUnion.u32, GetOptState.uIndex);
1461 rc = E_FAIL;
1462 }
1463 else
1464 {
1465 CHECK_ERROR(nic, COMSETTER(BootPriority)(ValueUnion.u32));
1466 }
1467 break;
1468 }
1469
1470 case MODIFYVM_NICPROMISC:
1471 {
1472 NetworkAdapterPromiscModePolicy_T enmPromiscModePolicy;
1473 if (!RTStrICmp(ValueUnion.psz, "deny"))
1474 enmPromiscModePolicy = NetworkAdapterPromiscModePolicy_Deny;
1475 else if ( !RTStrICmp(ValueUnion.psz, "allow-vms")
1476 || !RTStrICmp(ValueUnion.psz, "allow-network"))
1477 enmPromiscModePolicy = NetworkAdapterPromiscModePolicy_AllowNetwork;
1478 else if (!RTStrICmp(ValueUnion.psz, "allow-all"))
1479 enmPromiscModePolicy = NetworkAdapterPromiscModePolicy_AllowAll;
1480 else
1481 {
1482 errorArgument("Unknown promiscuous mode policy '%s'", ValueUnion.psz);
1483 rc = E_INVALIDARG;
1484 break;
1485 }
1486
1487 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1488 break;
1489
1490 ComPtr<INetworkAdapter> nic;
1491 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1492 ASSERT(nic);
1493
1494 CHECK_ERROR(nic, COMSETTER(PromiscModePolicy)(enmPromiscModePolicy));
1495 break;
1496 }
1497
1498 case MODIFYVM_NICBWGROUP:
1499 {
1500 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1501 break;
1502
1503 ComPtr<INetworkAdapter> nic;
1504 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1505 ASSERT(nic);
1506
1507 if (!RTStrICmp(ValueUnion.psz, "none"))
1508 {
1509 /* Just remove the bandwidth group. */
1510 CHECK_ERROR(nic, COMSETTER(BandwidthGroup)(NULL));
1511 }
1512 else
1513 {
1514 ComPtr<IBandwidthControl> bwCtrl;
1515 ComPtr<IBandwidthGroup> bwGroup;
1516
1517 CHECK_ERROR(sessionMachine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam()));
1518
1519 if (SUCCEEDED(rc))
1520 {
1521 CHECK_ERROR(bwCtrl, GetBandwidthGroup(Bstr(ValueUnion.psz).raw(), bwGroup.asOutParam()));
1522 if (SUCCEEDED(rc))
1523 {
1524 CHECK_ERROR(nic, COMSETTER(BandwidthGroup)(bwGroup));
1525 }
1526 }
1527 }
1528 break;
1529 }
1530
1531 case MODIFYVM_NIC:
1532 {
1533 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1534 break;
1535
1536 ComPtr<INetworkAdapter> nic;
1537 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1538 ASSERT(nic);
1539
1540 if (!RTStrICmp(ValueUnion.psz, "none"))
1541 {
1542 CHECK_ERROR(nic, COMSETTER(Enabled)(FALSE));
1543 }
1544 else if (!RTStrICmp(ValueUnion.psz, "null"))
1545 {
1546 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1547 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Null));
1548 }
1549 else if (!RTStrICmp(ValueUnion.psz, "nat"))
1550 {
1551 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1552 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NAT));
1553 }
1554 else if ( !RTStrICmp(ValueUnion.psz, "bridged")
1555 || !RTStrICmp(ValueUnion.psz, "hostif")) /* backward compatibility */
1556 {
1557 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1558 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Bridged));
1559 }
1560 else if (!RTStrICmp(ValueUnion.psz, "intnet"))
1561 {
1562 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1563 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Internal));
1564 }
1565 else if (!RTStrICmp(ValueUnion.psz, "hostonly"))
1566 {
1567
1568 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1569 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_HostOnly));
1570 }
1571 else if (!RTStrICmp(ValueUnion.psz, "generic"))
1572 {
1573
1574 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1575 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Generic));
1576 }
1577 else if (!RTStrICmp(ValueUnion.psz, "natnetwork"))
1578 {
1579
1580 CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
1581 CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NATNetwork));
1582 }
1583 else
1584 {
1585 errorArgument("Invalid type '%s' specfied for NIC %u", ValueUnion.psz, GetOptState.uIndex);
1586 rc = E_FAIL;
1587 }
1588 break;
1589 }
1590
1591 case MODIFYVM_CABLECONNECTED:
1592 {
1593 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1594 break;
1595
1596 ComPtr<INetworkAdapter> nic;
1597 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1598 ASSERT(nic);
1599
1600 CHECK_ERROR(nic, COMSETTER(CableConnected)(ValueUnion.f));
1601 break;
1602 }
1603
1604 case MODIFYVM_BRIDGEADAPTER:
1605 {
1606 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1607 break;
1608
1609 ComPtr<INetworkAdapter> nic;
1610 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1611 ASSERT(nic);
1612
1613 /* remove it? */
1614 if (!RTStrICmp(ValueUnion.psz, "none"))
1615 {
1616 CHECK_ERROR(nic, COMSETTER(BridgedInterface)(Bstr().raw()));
1617 }
1618 else
1619 {
1620 CHECK_ERROR(nic, COMSETTER(BridgedInterface)(Bstr(ValueUnion.psz).raw()));
1621 }
1622 break;
1623 }
1624
1625 case MODIFYVM_HOSTONLYADAPTER:
1626 {
1627 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1628 break;
1629
1630 ComPtr<INetworkAdapter> nic;
1631 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1632 ASSERT(nic);
1633
1634 /* remove it? */
1635 if (!RTStrICmp(ValueUnion.psz, "none"))
1636 {
1637 CHECK_ERROR(nic, COMSETTER(HostOnlyInterface)(Bstr().raw()));
1638 }
1639 else
1640 {
1641 CHECK_ERROR(nic, COMSETTER(HostOnlyInterface)(Bstr(ValueUnion.psz).raw()));
1642 }
1643 break;
1644 }
1645
1646 case MODIFYVM_INTNET:
1647 {
1648 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1649 break;
1650
1651 ComPtr<INetworkAdapter> nic;
1652 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1653 ASSERT(nic);
1654
1655 /* remove it? */
1656 if (!RTStrICmp(ValueUnion.psz, "none"))
1657 {
1658 CHECK_ERROR(nic, COMSETTER(InternalNetwork)(Bstr().raw()));
1659 }
1660 else
1661 {
1662 CHECK_ERROR(nic, COMSETTER(InternalNetwork)(Bstr(ValueUnion.psz).raw()));
1663 }
1664 break;
1665 }
1666
1667 case MODIFYVM_GENERICDRV:
1668 {
1669 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1670 break;
1671
1672 ComPtr<INetworkAdapter> nic;
1673 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1674 ASSERT(nic);
1675
1676 CHECK_ERROR(nic, COMSETTER(GenericDriver)(Bstr(ValueUnion.psz).raw()));
1677 break;
1678 }
1679
1680 case MODIFYVM_NATNETWORKNAME:
1681 {
1682 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1683 break;
1684
1685 ComPtr<INetworkAdapter> nic;
1686 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1687 ASSERT(nic);
1688
1689 CHECK_ERROR(nic, COMSETTER(NATNetwork)(Bstr(ValueUnion.psz).raw()));
1690 break;
1691 }
1692
1693 case MODIFYVM_NATNET:
1694 {
1695 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1696 break;
1697
1698 ComPtr<INetworkAdapter> nic;
1699 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1700 ASSERT(nic);
1701
1702 ComPtr<INATEngine> engine;
1703 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1704
1705 const char *psz = ValueUnion.psz;
1706 if (!RTStrICmp("default", psz))
1707 psz = "";
1708
1709 CHECK_ERROR(engine, COMSETTER(Network)(Bstr(psz).raw()));
1710 break;
1711 }
1712
1713 case MODIFYVM_NATBINDIP:
1714 {
1715 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1716 break;
1717
1718 ComPtr<INetworkAdapter> nic;
1719 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1720 ASSERT(nic);
1721
1722 ComPtr<INATEngine> engine;
1723 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1724
1725 CHECK_ERROR(engine, COMSETTER(HostIP)(Bstr(ValueUnion.psz).raw()));
1726 break;
1727 }
1728
1729#define ITERATE_TO_NEXT_TERM(ch) \
1730 do { \
1731 while (*ch != ',') \
1732 { \
1733 if (*ch == 0) \
1734 { \
1735 return errorSyntax(USAGE_MODIFYVM, \
1736 "Missing or Invalid argument to '%s'", \
1737 GetOptState.pDef->pszLong); \
1738 } \
1739 ch++; \
1740 } \
1741 *ch = '\0'; \
1742 ch++; \
1743 } while(0)
1744
1745 case MODIFYVM_NATSETTINGS:
1746 {
1747 ComPtr<INetworkAdapter> nic;
1748 ComPtr<INATEngine> engine;
1749 char *strMtu;
1750 char *strSockSnd;
1751 char *strSockRcv;
1752 char *strTcpSnd;
1753 char *strTcpRcv;
1754 char *strRaw = RTStrDup(ValueUnion.psz);
1755 char *ch = strRaw;
1756 strMtu = RTStrStrip(ch);
1757 ITERATE_TO_NEXT_TERM(ch);
1758 strSockSnd = RTStrStrip(ch);
1759 ITERATE_TO_NEXT_TERM(ch);
1760 strSockRcv = RTStrStrip(ch);
1761 ITERATE_TO_NEXT_TERM(ch);
1762 strTcpSnd = RTStrStrip(ch);
1763 ITERATE_TO_NEXT_TERM(ch);
1764 strTcpRcv = RTStrStrip(ch);
1765
1766 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1767 break;
1768
1769 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1770 ASSERT(nic);
1771
1772 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1773 CHECK_ERROR(engine, SetNetworkSettings(RTStrToUInt32(strMtu), RTStrToUInt32(strSockSnd), RTStrToUInt32(strSockRcv),
1774 RTStrToUInt32(strTcpSnd), RTStrToUInt32(strTcpRcv)));
1775 break;
1776 }
1777
1778
1779 case MODIFYVM_NATPF:
1780 {
1781 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1782 break;
1783
1784 ComPtr<INetworkAdapter> nic;
1785 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1786 ASSERT(nic);
1787
1788 ComPtr<INATEngine> engine;
1789 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1790
1791 /* format name:proto:hostip:hostport:guestip:guestport*/
1792 if (RTStrCmp(ValueUnion.psz, "delete") != 0)
1793 {
1794 char *strName;
1795 char *strProto;
1796 char *strHostIp;
1797 char *strHostPort;
1798 char *strGuestIp;
1799 char *strGuestPort;
1800 char *strRaw = RTStrDup(ValueUnion.psz);
1801 char *ch = strRaw;
1802 strName = RTStrStrip(ch);
1803 ITERATE_TO_NEXT_TERM(ch);
1804 strProto = RTStrStrip(ch);
1805 ITERATE_TO_NEXT_TERM(ch);
1806 strHostIp = RTStrStrip(ch);
1807 ITERATE_TO_NEXT_TERM(ch);
1808 strHostPort = RTStrStrip(ch);
1809 ITERATE_TO_NEXT_TERM(ch);
1810 strGuestIp = RTStrStrip(ch);
1811 ITERATE_TO_NEXT_TERM(ch);
1812 strGuestPort = RTStrStrip(ch);
1813 NATProtocol_T proto;
1814 if (RTStrICmp(strProto, "udp") == 0)
1815 proto = NATProtocol_UDP;
1816 else if (RTStrICmp(strProto, "tcp") == 0)
1817 proto = NATProtocol_TCP;
1818 else
1819 {
1820 errorArgument("Invalid proto '%s' specfied for NIC %u", ValueUnion.psz, GetOptState.uIndex);
1821 rc = E_FAIL;
1822 break;
1823 }
1824 CHECK_ERROR(engine, AddRedirect(Bstr(strName).raw(), proto,
1825 Bstr(strHostIp).raw(),
1826 RTStrToUInt16(strHostPort),
1827 Bstr(strGuestIp).raw(),
1828 RTStrToUInt16(strGuestPort)));
1829 }
1830 else
1831 {
1832 /* delete NAT Rule operation */
1833 int vrc;
1834 vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
1835 if (RT_FAILURE(vrc))
1836 return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
1837 CHECK_ERROR(engine, RemoveRedirect(Bstr(ValueUnion.psz).raw()));
1838 }
1839 break;
1840 }
1841 #undef ITERATE_TO_NEXT_TERM
1842 case MODIFYVM_NATALIASMODE:
1843 {
1844 ComPtr<INetworkAdapter> nic;
1845 ComPtr<INATEngine> engine;
1846 uint32_t aliasMode = 0;
1847
1848 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1849 ASSERT(nic);
1850
1851 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1852 if (RTStrCmp(ValueUnion.psz, "default") == 0)
1853 aliasMode = 0;
1854 else
1855 {
1856 char *token = (char *)ValueUnion.psz;
1857 while (token)
1858 {
1859 if (RTStrNCmp(token, RT_STR_TUPLE("log")) == 0)
1860 aliasMode |= NATAliasMode_AliasLog;
1861 else if (RTStrNCmp(token, RT_STR_TUPLE("proxyonly")) == 0)
1862 aliasMode |= NATAliasMode_AliasProxyOnly;
1863 else if (RTStrNCmp(token, RT_STR_TUPLE("sameports")) == 0)
1864 aliasMode |= NATAliasMode_AliasUseSamePorts;
1865 token = RTStrStr(token, ",");
1866 if (token == NULL)
1867 break;
1868 token++;
1869 }
1870 }
1871 CHECK_ERROR(engine, COMSETTER(AliasMode)(aliasMode));
1872 break;
1873 }
1874
1875 case MODIFYVM_NATTFTPPREFIX:
1876 {
1877 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1878 break;
1879
1880 ComPtr<INetworkAdapter> nic;
1881 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1882 ASSERT(nic);
1883
1884 ComPtr<INATEngine> engine;
1885 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1886
1887 CHECK_ERROR(engine, COMSETTER(TFTPPrefix)(Bstr(ValueUnion.psz).raw()));
1888 break;
1889 }
1890
1891 case MODIFYVM_NATTFTPFILE:
1892 {
1893 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1894 break;
1895
1896 ComPtr<INetworkAdapter> nic;
1897 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1898 ASSERT(nic);
1899
1900 ComPtr<INATEngine> engine;
1901 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1902
1903 CHECK_ERROR(engine, COMSETTER(TFTPBootFile)(Bstr(ValueUnion.psz).raw()));
1904 break;
1905 }
1906
1907 case MODIFYVM_NATTFTPSERVER:
1908 {
1909 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1910 break;
1911
1912 ComPtr<INetworkAdapter> nic;
1913 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1914 ASSERT(nic);
1915
1916 ComPtr<INATEngine> engine;
1917 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1918
1919 CHECK_ERROR(engine, COMSETTER(TFTPNextServer)(Bstr(ValueUnion.psz).raw()));
1920 break;
1921 }
1922 case MODIFYVM_NATDNSPASSDOMAIN:
1923 {
1924 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1925 break;
1926
1927 ComPtr<INetworkAdapter> nic;
1928 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1929 ASSERT(nic);
1930
1931 ComPtr<INATEngine> engine;
1932 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1933
1934 CHECK_ERROR(engine, COMSETTER(DNSPassDomain)(ValueUnion.f));
1935 break;
1936 }
1937
1938 case MODIFYVM_NATDNSPROXY:
1939 {
1940 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1941 break;
1942
1943 ComPtr<INetworkAdapter> nic;
1944 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1945 ASSERT(nic);
1946
1947 ComPtr<INATEngine> engine;
1948 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1949
1950 CHECK_ERROR(engine, COMSETTER(DNSProxy)(ValueUnion.f));
1951 break;
1952 }
1953
1954 case MODIFYVM_NATDNSHOSTRESOLVER:
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 ComPtr<INATEngine> engine;
1964 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
1965
1966 CHECK_ERROR(engine, COMSETTER(DNSUseHostResolver)(ValueUnion.f));
1967 break;
1968 }
1969 case MODIFYVM_MACADDRESS:
1970 {
1971 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC"))
1972 break;
1973
1974 ComPtr<INetworkAdapter> nic;
1975 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
1976 ASSERT(nic);
1977
1978 /* generate one? */
1979 if (!RTStrICmp(ValueUnion.psz, "auto"))
1980 {
1981 CHECK_ERROR(nic, COMSETTER(MACAddress)(Bstr().raw()));
1982 }
1983 else
1984 {
1985 CHECK_ERROR(nic, COMSETTER(MACAddress)(Bstr(ValueUnion.psz).raw()));
1986 }
1987 break;
1988 }
1989
1990 case MODIFYVM_HIDPTR:
1991 {
1992 bool fEnableUsb = false;
1993 if (!RTStrICmp(ValueUnion.psz, "ps2"))
1994 {
1995 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_PS2Mouse));
1996 }
1997 else if (!RTStrICmp(ValueUnion.psz, "usb"))
1998 {
1999 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBMouse));
2000 if (SUCCEEDED(rc))
2001 fEnableUsb = true;
2002 }
2003 else if (!RTStrICmp(ValueUnion.psz, "usbtablet"))
2004 {
2005 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBTablet));
2006 if (SUCCEEDED(rc))
2007 fEnableUsb = true;
2008 }
2009 else if (!RTStrICmp(ValueUnion.psz, "usbmultitouch"))
2010 {
2011 CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBMultiTouch));
2012 if (SUCCEEDED(rc))
2013 fEnableUsb = true;
2014 }
2015 else
2016 {
2017 errorArgument("Invalid type '%s' specfied for pointing device", ValueUnion.psz);
2018 rc = E_FAIL;
2019 }
2020 if (fEnableUsb)
2021 {
2022 /* Make sure either the OHCI or xHCI controller is enabled. */
2023 ULONG cOhciCtrls = 0;
2024 ULONG cXhciCtrls = 0;
2025 rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
2026 if (SUCCEEDED(rc)) {
2027 rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
2028 if ( SUCCEEDED(rc)
2029 && cOhciCtrls + cXhciCtrls == 0)
2030 {
2031 /* If there's nothing, enable OHCI (always available). */
2032 ComPtr<IUSBController> UsbCtl;
2033 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
2034 UsbCtl.asOutParam()));
2035 }
2036 }
2037 }
2038 break;
2039 }
2040
2041 case MODIFYVM_HIDKBD:
2042 {
2043 bool fEnableUsb = false;
2044 if (!RTStrICmp(ValueUnion.psz, "ps2"))
2045 {
2046 CHECK_ERROR(sessionMachine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_PS2Keyboard));
2047 }
2048 else if (!RTStrICmp(ValueUnion.psz, "usb"))
2049 {
2050 CHECK_ERROR(sessionMachine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_USBKeyboard));
2051 if (SUCCEEDED(rc))
2052 fEnableUsb = true;
2053 }
2054 else
2055 {
2056 errorArgument("Invalid type '%s' specfied for keyboard", ValueUnion.psz);
2057 rc = E_FAIL;
2058 }
2059 if (fEnableUsb)
2060 {
2061 /* Make sure either the OHCI or xHCI controller is enabled. */
2062 ULONG cOhciCtrls = 0;
2063 ULONG cXhciCtrls = 0;
2064 rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
2065 if (SUCCEEDED(rc)) {
2066 rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
2067 if ( SUCCEEDED(rc)
2068 && cOhciCtrls + cXhciCtrls == 0)
2069 {
2070 /* If there's nothing, enable OHCI (always available). */
2071 ComPtr<IUSBController> UsbCtl;
2072 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
2073 UsbCtl.asOutParam()));
2074 }
2075 }
2076 }
2077 break;
2078 }
2079
2080 case MODIFYVM_UARTMODE:
2081 {
2082 ComPtr<ISerialPort> uart;
2083
2084 CHECK_ERROR_BREAK(sessionMachine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
2085 ASSERT(uart);
2086
2087 if (!RTStrICmp(ValueUnion.psz, "disconnected"))
2088 {
2089 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_Disconnected));
2090 }
2091 else if ( !RTStrICmp(ValueUnion.psz, "server")
2092 || !RTStrICmp(ValueUnion.psz, "client")
2093 || !RTStrICmp(ValueUnion.psz, "tcpserver")
2094 || !RTStrICmp(ValueUnion.psz, "tcpclient")
2095 || !RTStrICmp(ValueUnion.psz, "file"))
2096 {
2097 const char *pszMode = ValueUnion.psz;
2098
2099 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
2100 if (RT_FAILURE(vrc))
2101 return errorSyntax(USAGE_MODIFYVM,
2102 "Missing or Invalid argument to '%s'",
2103 GetOptState.pDef->pszLong);
2104
2105 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
2106
2107 if (!RTStrICmp(pszMode, "server"))
2108 {
2109 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
2110 CHECK_ERROR(uart, COMSETTER(Server)(TRUE));
2111 }
2112 else if (!RTStrICmp(pszMode, "client"))
2113 {
2114 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
2115 CHECK_ERROR(uart, COMSETTER(Server)(FALSE));
2116 }
2117 else if (!RTStrICmp(pszMode, "tcpserver"))
2118 {
2119 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_TCP));
2120 CHECK_ERROR(uart, COMSETTER(Server)(TRUE));
2121 }
2122 else if (!RTStrICmp(pszMode, "tcpclient"))
2123 {
2124 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_TCP));
2125 CHECK_ERROR(uart, COMSETTER(Server)(FALSE));
2126 }
2127 else if (!RTStrICmp(pszMode, "file"))
2128 {
2129 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_RawFile));
2130 }
2131 }
2132 else
2133 {
2134 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
2135 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostDevice));
2136 }
2137 break;
2138 }
2139
2140 case MODIFYVM_UART:
2141 {
2142 ComPtr<ISerialPort> uart;
2143
2144 CHECK_ERROR_BREAK(sessionMachine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
2145 ASSERT(uart);
2146
2147 if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
2148 CHECK_ERROR(uart, COMSETTER(Enabled)(FALSE));
2149 else
2150 {
2151 const char *pszIOBase = ValueUnion.psz;
2152 uint32_t uVal = 0;
2153
2154 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_UART;
2155 if (RT_FAILURE(vrc))
2156 return errorSyntax(USAGE_MODIFYVM,
2157 "Missing or Invalid argument to '%s'",
2158 GetOptState.pDef->pszLong);
2159
2160 CHECK_ERROR(uart, COMSETTER(IRQ)(ValueUnion.u32));
2161
2162 vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
2163 if (vrc != VINF_SUCCESS || uVal == 0)
2164 return errorArgument("Error parsing UART I/O base '%s'", pszIOBase);
2165 CHECK_ERROR(uart, COMSETTER(IOBase)(uVal));
2166
2167 CHECK_ERROR(uart, COMSETTER(Enabled)(TRUE));
2168 }
2169 break;
2170 }
2171
2172#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
2173 case MODIFYVM_LPTMODE:
2174 {
2175 ComPtr<IParallelPort> lpt;
2176
2177 CHECK_ERROR_BREAK(sessionMachine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
2178 ASSERT(lpt);
2179
2180 CHECK_ERROR(lpt, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
2181 break;
2182 }
2183
2184 case MODIFYVM_LPT:
2185 {
2186 ComPtr<IParallelPort> lpt;
2187
2188 CHECK_ERROR_BREAK(sessionMachine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
2189 ASSERT(lpt);
2190
2191 if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
2192 CHECK_ERROR(lpt, COMSETTER(Enabled)(FALSE));
2193 else
2194 {
2195 const char *pszIOBase = ValueUnion.psz;
2196 uint32_t uVal = 0;
2197
2198 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_LPT;
2199 if (RT_FAILURE(vrc))
2200 return errorSyntax(USAGE_MODIFYVM,
2201 "Missing or Invalid argument to '%s'",
2202 GetOptState.pDef->pszLong);
2203
2204 CHECK_ERROR(lpt, COMSETTER(IRQ)(ValueUnion.u32));
2205
2206 vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
2207 if (vrc != VINF_SUCCESS || uVal == 0)
2208 return errorArgument("Error parsing LPT I/O base '%s'", pszIOBase);
2209 CHECK_ERROR(lpt, COMSETTER(IOBase)(uVal));
2210
2211 CHECK_ERROR(lpt, COMSETTER(Enabled)(TRUE));
2212 }
2213 break;
2214 }
2215#endif
2216
2217 case MODIFYVM_GUESTMEMORYBALLOON:
2218 {
2219 CHECK_ERROR(sessionMachine, COMSETTER(MemoryBalloonSize)(ValueUnion.u32));
2220 break;
2221 }
2222
2223 case MODIFYVM_AUDIOCONTROLLER:
2224 {
2225 ComPtr<IAudioAdapter> audioAdapter;
2226 sessionMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
2227 ASSERT(audioAdapter);
2228
2229 if (!RTStrICmp(ValueUnion.psz, "sb16"))
2230 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));
2231 else if (!RTStrICmp(ValueUnion.psz, "ac97"))
2232 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));
2233 else if (!RTStrICmp(ValueUnion.psz, "hda"))
2234 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_HDA));
2235 else
2236 {
2237 errorArgument("Invalid --audiocontroller argument '%s'", ValueUnion.psz);
2238 rc = E_FAIL;
2239 }
2240 break;
2241 }
2242
2243 case MODIFYVM_AUDIOCODEC:
2244 {
2245 ComPtr<IAudioAdapter> audioAdapter;
2246 sessionMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
2247 ASSERT(audioAdapter);
2248
2249 if (!RTStrICmp(ValueUnion.psz, "sb16"))
2250 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_SB16));
2251 else if (!RTStrICmp(ValueUnion.psz, "stac9700"))
2252 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_STAC9700));
2253 else if (!RTStrICmp(ValueUnion.psz, "ad1980"))
2254 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_AD1980));
2255 else if (!RTStrICmp(ValueUnion.psz, "stac9221"))
2256 CHECK_ERROR(audioAdapter, COMSETTER(AudioCodec)(AudioCodecType_STAC9221));
2257 else
2258 {
2259 errorArgument("Invalid --audiocodec argument '%s'", ValueUnion.psz);
2260 rc = E_FAIL;
2261 }
2262 break;
2263 }
2264
2265 case MODIFYVM_AUDIO:
2266 {
2267 ComPtr<IAudioAdapter> audioAdapter;
2268 sessionMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
2269 ASSERT(audioAdapter);
2270
2271 /* disable? */
2272 if (!RTStrICmp(ValueUnion.psz, "none"))
2273 {
2274 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
2275 }
2276 else if (!RTStrICmp(ValueUnion.psz, "null"))
2277 {
2278 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));
2279 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2280 }
2281#ifdef RT_OS_WINDOWS
2282#ifdef VBOX_WITH_WINMM
2283 else if (!RTStrICmp(ValueUnion.psz, "winmm"))
2284 {
2285 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));
2286 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2287 }
2288#endif
2289 else if (!RTStrICmp(ValueUnion.psz, "dsound"))
2290 {
2291 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
2292 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2293 }
2294#endif /* RT_OS_WINDOWS */
2295#ifdef VBOX_WITH_AUDIO_OSS
2296 else if (!RTStrICmp(ValueUnion.psz, "oss"))
2297 {
2298 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
2299 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2300 }
2301#endif
2302#ifdef VBOX_WITH_AUDIO_ALSA
2303 else if (!RTStrICmp(ValueUnion.psz, "alsa"))
2304 {
2305 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));
2306 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2307 }
2308#endif
2309#ifdef VBOX_WITH_AUDIO_PULSE
2310 else if (!RTStrICmp(ValueUnion.psz, "pulse"))
2311 {
2312 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
2313 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2314 }
2315#endif
2316#ifdef RT_OS_DARWIN
2317 else if (!RTStrICmp(ValueUnion.psz, "coreaudio"))
2318 {
2319 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));
2320 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2321 }
2322#endif /* !RT_OS_DARWIN */
2323 else
2324 {
2325 errorArgument("Invalid --audio argument '%s'", ValueUnion.psz);
2326 rc = E_FAIL;
2327 }
2328 break;
2329 }
2330
2331 case MODIFYVM_AUDIOIN:
2332 {
2333 ComPtr<IAudioAdapter> audioAdapter;
2334 sessionMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
2335 ASSERT(audioAdapter);
2336
2337 CHECK_ERROR(audioAdapter, COMSETTER(EnabledIn)(ValueUnion.f));
2338 break;
2339 }
2340
2341 case MODIFYVM_AUDIOOUT:
2342 {
2343 ComPtr<IAudioAdapter> audioAdapter;
2344 sessionMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
2345 ASSERT(audioAdapter);
2346
2347 CHECK_ERROR(audioAdapter, COMSETTER(EnabledIn)(ValueUnion.f));
2348 break;
2349 }
2350
2351 case MODIFYVM_CLIPBOARD:
2352 {
2353 ClipboardMode_T mode = ClipboardMode_Disabled; /* Shut up MSC */
2354 if (!RTStrICmp(ValueUnion.psz, "disabled"))
2355 mode = ClipboardMode_Disabled;
2356 else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
2357 mode = ClipboardMode_HostToGuest;
2358 else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
2359 mode = ClipboardMode_GuestToHost;
2360 else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
2361 mode = ClipboardMode_Bidirectional;
2362 else
2363 {
2364 errorArgument("Invalid --clipboard argument '%s'", ValueUnion.psz);
2365 rc = E_FAIL;
2366 }
2367 if (SUCCEEDED(rc))
2368 {
2369 CHECK_ERROR(sessionMachine, COMSETTER(ClipboardMode)(mode));
2370 }
2371 break;
2372 }
2373
2374 case MODIFYVM_DRAGANDDROP:
2375 {
2376 DnDMode_T mode = DnDMode_Disabled; /* Shut up MSC */
2377 if (!RTStrICmp(ValueUnion.psz, "disabled"))
2378 mode = DnDMode_Disabled;
2379 else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
2380 mode = DnDMode_HostToGuest;
2381 else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
2382 mode = DnDMode_GuestToHost;
2383 else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
2384 mode = DnDMode_Bidirectional;
2385 else
2386 {
2387 errorArgument("Invalid --draganddrop argument '%s'", ValueUnion.psz);
2388 rc = E_FAIL;
2389 }
2390 if (SUCCEEDED(rc))
2391 {
2392 CHECK_ERROR(sessionMachine, COMSETTER(DnDMode)(mode));
2393 }
2394 break;
2395 }
2396
2397 case MODIFYVM_VRDE_EXTPACK:
2398 {
2399 ComPtr<IVRDEServer> vrdeServer;
2400 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2401 ASSERT(vrdeServer);
2402
2403 if (vrdeServer)
2404 {
2405 if (RTStrICmp(ValueUnion.psz, "default") != 0)
2406 {
2407 Bstr bstr(ValueUnion.psz);
2408 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(bstr.raw()));
2409 }
2410 else
2411 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(Bstr().raw()));
2412 }
2413 break;
2414 }
2415
2416 case MODIFYVM_VRDEPROPERTY:
2417 {
2418 ComPtr<IVRDEServer> vrdeServer;
2419 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2420 ASSERT(vrdeServer);
2421
2422 if (vrdeServer)
2423 {
2424 /* Parse 'name=value' */
2425 char *pszProperty = RTStrDup(ValueUnion.psz);
2426 if (pszProperty)
2427 {
2428 char *pDelimiter = strchr(pszProperty, '=');
2429 if (pDelimiter)
2430 {
2431 *pDelimiter = '\0';
2432
2433 Bstr bstrName = pszProperty;
2434 Bstr bstrValue = &pDelimiter[1];
2435 CHECK_ERROR(vrdeServer, SetVRDEProperty(bstrName.raw(), bstrValue.raw()));
2436 }
2437 else
2438 {
2439 RTStrFree(pszProperty);
2440
2441 errorArgument("Invalid --vrdeproperty argument '%s'", ValueUnion.psz);
2442 rc = E_FAIL;
2443 break;
2444 }
2445 RTStrFree(pszProperty);
2446 }
2447 else
2448 {
2449 RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for VRDE property '%s'\n", ValueUnion.psz);
2450 rc = E_FAIL;
2451 }
2452 }
2453 break;
2454 }
2455
2456 case MODIFYVM_VRDPPORT:
2457 vrdeWarningDeprecatedOption("port");
2458 /* fall thru */
2459
2460 case MODIFYVM_VRDEPORT:
2461 {
2462 ComPtr<IVRDEServer> vrdeServer;
2463 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2464 ASSERT(vrdeServer);
2465
2466 if (!RTStrICmp(ValueUnion.psz, "default"))
2467 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr("0").raw()));
2468 else
2469 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr(ValueUnion.psz).raw()));
2470 break;
2471 }
2472
2473 case MODIFYVM_VRDPADDRESS:
2474 vrdeWarningDeprecatedOption("address");
2475 /* fall thru */
2476
2477 case MODIFYVM_VRDEADDRESS:
2478 {
2479 ComPtr<IVRDEServer> vrdeServer;
2480 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2481 ASSERT(vrdeServer);
2482
2483 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Address").raw(), Bstr(ValueUnion.psz).raw()));
2484 break;
2485 }
2486
2487 case MODIFYVM_VRDPAUTHTYPE:
2488 vrdeWarningDeprecatedOption("authtype");
2489 /* fall thru */
2490 case MODIFYVM_VRDEAUTHTYPE:
2491 {
2492 ComPtr<IVRDEServer> vrdeServer;
2493 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2494 ASSERT(vrdeServer);
2495
2496 if (!RTStrICmp(ValueUnion.psz, "null"))
2497 {
2498 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Null));
2499 }
2500 else if (!RTStrICmp(ValueUnion.psz, "external"))
2501 {
2502 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_External));
2503 }
2504 else if (!RTStrICmp(ValueUnion.psz, "guest"))
2505 {
2506 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Guest));
2507 }
2508 else
2509 {
2510 errorArgument("Invalid --vrdeauthtype argument '%s'", ValueUnion.psz);
2511 rc = E_FAIL;
2512 }
2513 break;
2514 }
2515
2516 case MODIFYVM_VRDEAUTHLIBRARY:
2517 {
2518 ComPtr<IVRDEServer> vrdeServer;
2519 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2520 ASSERT(vrdeServer);
2521
2522 if (vrdeServer)
2523 {
2524 if (RTStrICmp(ValueUnion.psz, "default") != 0)
2525 {
2526 Bstr bstr(ValueUnion.psz);
2527 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(bstr.raw()));
2528 }
2529 else
2530 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(Bstr().raw()));
2531 }
2532 break;
2533 }
2534
2535 case MODIFYVM_VRDPMULTICON:
2536 vrdeWarningDeprecatedOption("multicon");
2537 /* fall thru */
2538 case MODIFYVM_VRDEMULTICON:
2539 {
2540 ComPtr<IVRDEServer> vrdeServer;
2541 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2542 ASSERT(vrdeServer);
2543
2544 CHECK_ERROR(vrdeServer, COMSETTER(AllowMultiConnection)(ValueUnion.f));
2545 break;
2546 }
2547
2548 case MODIFYVM_VRDPREUSECON:
2549 vrdeWarningDeprecatedOption("reusecon");
2550 /* fall thru */
2551 case MODIFYVM_VRDEREUSECON:
2552 {
2553 ComPtr<IVRDEServer> vrdeServer;
2554 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2555 ASSERT(vrdeServer);
2556
2557 CHECK_ERROR(vrdeServer, COMSETTER(ReuseSingleConnection)(ValueUnion.f));
2558 break;
2559 }
2560
2561 case MODIFYVM_VRDPVIDEOCHANNEL:
2562 vrdeWarningDeprecatedOption("videochannel");
2563 /* fall thru */
2564 case MODIFYVM_VRDEVIDEOCHANNEL:
2565 {
2566 ComPtr<IVRDEServer> vrdeServer;
2567 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2568 ASSERT(vrdeServer);
2569
2570 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("VideoChannel/Enabled").raw(),
2571 ValueUnion.f? Bstr("true").raw(): Bstr("false").raw()));
2572 break;
2573 }
2574
2575 case MODIFYVM_VRDPVIDEOCHANNELQUALITY:
2576 vrdeWarningDeprecatedOption("videochannelquality");
2577 /* fall thru */
2578 case MODIFYVM_VRDEVIDEOCHANNELQUALITY:
2579 {
2580 ComPtr<IVRDEServer> vrdeServer;
2581 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2582 ASSERT(vrdeServer);
2583
2584 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("VideoChannel/Quality").raw(),
2585 Bstr(ValueUnion.psz).raw()));
2586 break;
2587 }
2588
2589 case MODIFYVM_VRDP:
2590 vrdeWarningDeprecatedOption("");
2591 /* fall thru */
2592 case MODIFYVM_VRDE:
2593 {
2594 ComPtr<IVRDEServer> vrdeServer;
2595 sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2596 ASSERT(vrdeServer);
2597
2598 CHECK_ERROR(vrdeServer, COMSETTER(Enabled)(ValueUnion.f));
2599 break;
2600 }
2601
2602 case MODIFYVM_USBRENAME:
2603 {
2604 const char *pszName = ValueUnion.psz;
2605 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
2606 if (RT_FAILURE(vrc))
2607 return errorSyntax(USAGE_MODIFYVM,
2608 "Missing or Invalid argument to '%s'",
2609 GetOptState.pDef->pszLong);
2610 const char *pszNewName = ValueUnion.psz;
2611
2612 SafeIfaceArray<IUSBController> ctrls;
2613 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
2614 bool fRenamed = false;
2615 for (size_t i = 0; i < ctrls.size(); i++)
2616 {
2617 ComPtr<IUSBController> pCtrl = ctrls[i];
2618 Bstr bstrName;
2619 CHECK_ERROR(pCtrl, COMGETTER(Name)(bstrName.asOutParam()));
2620 if (bstrName == pszName)
2621 {
2622 bstrName = pszNewName;
2623 CHECK_ERROR(pCtrl, COMSETTER(Name)(bstrName.raw()));
2624 fRenamed = true;
2625 }
2626 }
2627 if (!fRenamed)
2628 {
2629 errorArgument("Invalid --usbrename parameters, nothing renamed");
2630 rc = E_FAIL;
2631 }
2632 break;
2633 }
2634
2635 case MODIFYVM_USBXHCI:
2636 {
2637 ULONG cXhciCtrls = 0;
2638 rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
2639 if (SUCCEEDED(rc))
2640 {
2641 if (!cXhciCtrls && ValueUnion.f)
2642 {
2643 ComPtr<IUSBController> UsbCtl;
2644 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("xHCI").raw(), USBControllerType_XHCI,
2645 UsbCtl.asOutParam()));
2646 }
2647 else if (cXhciCtrls && !ValueUnion.f)
2648 {
2649 SafeIfaceArray<IUSBController> ctrls;
2650 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
2651 for (size_t i = 0; i < ctrls.size(); i++)
2652 {
2653 ComPtr<IUSBController> pCtrl = ctrls[i];
2654 USBControllerType_T enmType;
2655 CHECK_ERROR(pCtrl, COMGETTER(Type)(&enmType));
2656 if (enmType == USBControllerType_XHCI)
2657 {
2658 Bstr ctrlName;
2659 CHECK_ERROR(pCtrl, COMGETTER(Name)(ctrlName.asOutParam()));
2660 CHECK_ERROR(sessionMachine, RemoveUSBController(ctrlName.raw()));
2661 }
2662 }
2663 }
2664 }
2665 break;
2666 }
2667
2668 case MODIFYVM_USBEHCI:
2669 {
2670 ULONG cEhciCtrls = 0;
2671 rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_EHCI, &cEhciCtrls);
2672 if (SUCCEEDED(rc))
2673 {
2674 if (!cEhciCtrls && ValueUnion.f)
2675 {
2676 ComPtr<IUSBController> UsbCtl;
2677 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("EHCI").raw(), USBControllerType_EHCI,
2678 UsbCtl.asOutParam()));
2679 }
2680 else if (cEhciCtrls && !ValueUnion.f)
2681 {
2682 SafeIfaceArray<IUSBController> ctrls;
2683 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
2684 for (size_t i = 0; i < ctrls.size(); i++)
2685 {
2686 ComPtr<IUSBController> pCtrl = ctrls[i];
2687 USBControllerType_T enmType;
2688 CHECK_ERROR(pCtrl, COMGETTER(Type)(&enmType));
2689 if (enmType == USBControllerType_EHCI)
2690 {
2691 Bstr ctrlName;
2692 CHECK_ERROR(pCtrl, COMGETTER(Name)(ctrlName.asOutParam()));
2693 CHECK_ERROR(sessionMachine, RemoveUSBController(ctrlName.raw()));
2694 }
2695 }
2696 }
2697 }
2698 break;
2699 }
2700
2701 case MODIFYVM_USB:
2702 {
2703 ULONG cOhciCtrls = 0;
2704 rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
2705 if (SUCCEEDED(rc))
2706 {
2707 if (!cOhciCtrls && ValueUnion.f)
2708 {
2709 ComPtr<IUSBController> UsbCtl;
2710 CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
2711 UsbCtl.asOutParam()));
2712 }
2713 else if (cOhciCtrls && !ValueUnion.f)
2714 {
2715 SafeIfaceArray<IUSBController> ctrls;
2716 CHECK_ERROR(sessionMachine, COMGETTER(USBControllers)(ComSafeArrayAsOutParam(ctrls)));
2717 for (size_t i = 0; i < ctrls.size(); i++)
2718 {
2719 ComPtr<IUSBController> pCtrl = ctrls[i];
2720 USBControllerType_T enmType;
2721 CHECK_ERROR(pCtrl, COMGETTER(Type)(&enmType));
2722 if (enmType == USBControllerType_OHCI)
2723 {
2724 Bstr ctrlName;
2725 CHECK_ERROR(pCtrl, COMGETTER(Name)(ctrlName.asOutParam()));
2726 CHECK_ERROR(sessionMachine, RemoveUSBController(ctrlName.raw()));
2727 }
2728 }
2729 }
2730 }
2731 break;
2732 }
2733
2734 case MODIFYVM_SNAPSHOTFOLDER:
2735 {
2736 if (!RTStrICmp(ValueUnion.psz, "default"))
2737 CHECK_ERROR(sessionMachine, COMSETTER(SnapshotFolder)(Bstr().raw()));
2738 else
2739 CHECK_ERROR(sessionMachine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz).raw()));
2740 break;
2741 }
2742
2743 case MODIFYVM_TELEPORTER_ENABLED:
2744 {
2745 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterEnabled)(ValueUnion.f));
2746 break;
2747 }
2748
2749 case MODIFYVM_TELEPORTER_PORT:
2750 {
2751 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPort)(ValueUnion.u32));
2752 break;
2753 }
2754
2755 case MODIFYVM_TELEPORTER_ADDRESS:
2756 {
2757 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterAddress)(Bstr(ValueUnion.psz).raw()));
2758 break;
2759 }
2760
2761 case MODIFYVM_TELEPORTER_PASSWORD:
2762 {
2763 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPassword)(Bstr(ValueUnion.psz).raw()));
2764 break;
2765 }
2766
2767 case MODIFYVM_TELEPORTER_PASSWORD_FILE:
2768 {
2769 Utf8Str password;
2770 RTEXITCODE rcExit = readPasswordFile(ValueUnion.psz, &password);
2771 if (rcExit != RTEXITCODE_SUCCESS)
2772 rc = E_FAIL;
2773 else
2774 CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPassword)(Bstr(password).raw()));
2775 break;
2776 }
2777
2778 case MODIFYVM_TRACING_ENABLED:
2779 {
2780 CHECK_ERROR(sessionMachine, COMSETTER(TracingEnabled)(ValueUnion.f));
2781 break;
2782 }
2783
2784 case MODIFYVM_TRACING_CONFIG:
2785 {
2786 CHECK_ERROR(sessionMachine, COMSETTER(TracingConfig)(Bstr(ValueUnion.psz).raw()));
2787 break;
2788 }
2789
2790 case MODIFYVM_TRACING_ALLOW_VM_ACCESS:
2791 {
2792 CHECK_ERROR(sessionMachine, COMSETTER(AllowTracingToAccessVM)(ValueUnion.f));
2793 break;
2794 }
2795
2796 case MODIFYVM_FAULT_TOLERANCE:
2797 {
2798 if (!RTStrICmp(ValueUnion.psz, "master"))
2799 {
2800 CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceState(FaultToleranceState_Master)));
2801 }
2802 else
2803 if (!RTStrICmp(ValueUnion.psz, "standby"))
2804 {
2805 CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceState(FaultToleranceState_Standby)));
2806 }
2807 else
2808 {
2809 errorArgument("Invalid --faulttolerance argument '%s'", ValueUnion.psz);
2810 rc = E_FAIL;
2811 }
2812 break;
2813 }
2814
2815 case MODIFYVM_FAULT_TOLERANCE_ADDRESS:
2816 {
2817 CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceAddress)(Bstr(ValueUnion.psz).raw()));
2818 break;
2819 }
2820
2821 case MODIFYVM_FAULT_TOLERANCE_PORT:
2822 {
2823 CHECK_ERROR(sessionMachine, COMSETTER(FaultTolerancePort)(ValueUnion.u32));
2824 break;
2825 }
2826
2827 case MODIFYVM_FAULT_TOLERANCE_PASSWORD:
2828 {
2829 CHECK_ERROR(sessionMachine, COMSETTER(FaultTolerancePassword)(Bstr(ValueUnion.psz).raw()));
2830 break;
2831 }
2832
2833 case MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL:
2834 {
2835 CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceSyncInterval)(ValueUnion.u32));
2836 break;
2837 }
2838
2839 case MODIFYVM_HARDWARE_UUID:
2840 {
2841 CHECK_ERROR(sessionMachine, COMSETTER(HardwareUUID)(Bstr(ValueUnion.psz).raw()));
2842 break;
2843 }
2844
2845 case MODIFYVM_HPET:
2846 {
2847 CHECK_ERROR(sessionMachine, COMSETTER(HPETEnabled)(ValueUnion.f));
2848 break;
2849 }
2850
2851 case MODIFYVM_IOCACHE:
2852 {
2853 CHECK_ERROR(sessionMachine, COMSETTER(IOCacheEnabled)(ValueUnion.f));
2854 break;
2855 }
2856
2857 case MODIFYVM_IOCACHESIZE:
2858 {
2859 CHECK_ERROR(sessionMachine, COMSETTER(IOCacheSize)(ValueUnion.u32));
2860 break;
2861 }
2862
2863 case MODIFYVM_CHIPSET:
2864 {
2865 if (!RTStrICmp(ValueUnion.psz, "piix3"))
2866 {
2867 CHECK_ERROR(sessionMachine, COMSETTER(ChipsetType)(ChipsetType_PIIX3));
2868 }
2869 else if (!RTStrICmp(ValueUnion.psz, "ich9"))
2870 {
2871 CHECK_ERROR(sessionMachine, COMSETTER(ChipsetType)(ChipsetType_ICH9));
2872 BOOL fIoApic = FALSE;
2873 CHECK_ERROR(biosSettings, COMGETTER(IOAPICEnabled)(&fIoApic));
2874 if (!fIoApic)
2875 {
2876 RTStrmPrintf(g_pStdErr, "*** I/O APIC must be enabled for ICH9, enabling. ***\n");
2877 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(TRUE));
2878 }
2879 }
2880 else
2881 {
2882 errorArgument("Invalid --chipset argument '%s' (valid: piix3,ich9)", ValueUnion.psz);
2883 rc = E_FAIL;
2884 }
2885 break;
2886 }
2887#ifdef VBOX_WITH_VIDEOREC
2888 case MODIFYVM_VIDEOCAP:
2889 {
2890 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureEnabled)(ValueUnion.f));
2891 break;
2892 }
2893 case MODIFYVM_VIDEOCAP_SCREENS:
2894 {
2895 ULONG cMonitors = 64;
2896 CHECK_ERROR(sessionMachine, COMGETTER(MonitorCount)(&cMonitors));
2897 com::SafeArray<BOOL> screens(cMonitors);
2898 if (parseScreens(ValueUnion.psz, &screens))
2899 {
2900 errorArgument("Invalid list of screens specified\n");
2901 rc = E_FAIL;
2902 break;
2903 }
2904 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureScreens)(ComSafeArrayAsInParam(screens)));
2905 break;
2906 }
2907 case MODIFYVM_VIDEOCAP_FILENAME:
2908 {
2909 Bstr bstr;
2910 /* empty string will fall through, leaving bstr empty */
2911 if (*ValueUnion.psz)
2912 {
2913 char szVCFileAbs[RTPATH_MAX] = "";
2914 int vrc = RTPathAbs(ValueUnion.psz, szVCFileAbs, sizeof(szVCFileAbs));
2915 if (RT_FAILURE(vrc))
2916 {
2917 errorArgument("Cannot convert filename \"%s\" to absolute path\n", ValueUnion.psz);
2918 rc = E_FAIL;
2919 break;
2920 }
2921 bstr = szVCFileAbs;
2922 }
2923 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureFile)(bstr.raw()));
2924 break;
2925 }
2926 case MODIFYVM_VIDEOCAP_WIDTH:
2927 {
2928 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureWidth)(ValueUnion.u32));
2929 break;
2930 }
2931 case MODIFYVM_VIDEOCAP_HEIGHT:
2932 {
2933 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureHeight)(ValueUnion.u32));
2934 break;
2935 }
2936 case MODIFYVM_VIDEOCAP_RES:
2937 {
2938 uint32_t uWidth = 0;
2939 char *pszNext;
2940 int vrc = RTStrToUInt32Ex(ValueUnion.psz, &pszNext, 0, &uWidth);
2941 if (RT_FAILURE(vrc) || vrc != VWRN_TRAILING_CHARS || !pszNext || *pszNext != 'x')
2942 {
2943 errorArgument("Error parsing geomtry '%s' (expected <width>x<height>)", ValueUnion.psz);
2944 rc = E_FAIL;
2945 break;
2946 }
2947 uint32_t uHeight = 0;
2948 vrc = RTStrToUInt32Ex(pszNext+1, NULL, 0, &uHeight);
2949 if (vrc != VINF_SUCCESS)
2950 {
2951 errorArgument("Error parsing geomtry '%s' (expected <width>x<height>)", ValueUnion.psz);
2952 rc = E_FAIL;
2953 break;
2954 }
2955 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureWidth)(uWidth));
2956 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureHeight)(uHeight));
2957 break;
2958 }
2959 case MODIFYVM_VIDEOCAP_RATE:
2960 {
2961 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureRate)(ValueUnion.u32));
2962 break;
2963 }
2964 case MODIFYVM_VIDEOCAP_FPS:
2965 {
2966 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureFPS)(ValueUnion.u32));
2967 break;
2968 }
2969 case MODIFYVM_VIDEOCAP_MAXTIME:
2970 {
2971 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureMaxTime)(ValueUnion.u32));
2972 break;
2973 }
2974 case MODIFYVM_VIDEOCAP_MAXSIZE:
2975 {
2976 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureMaxFileSize)(ValueUnion.u32));
2977 break;
2978 }
2979 case MODIFYVM_VIDEOCAP_OPTIONS:
2980 {
2981 Bstr bstr(ValueUnion.psz);
2982 CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureOptions)(bstr.raw()));
2983 break;
2984 }
2985#endif
2986 case MODIFYVM_AUTOSTART_ENABLED:
2987 {
2988 CHECK_ERROR(sessionMachine, COMSETTER(AutostartEnabled)(ValueUnion.f));
2989 break;
2990 }
2991
2992 case MODIFYVM_AUTOSTART_DELAY:
2993 {
2994 CHECK_ERROR(sessionMachine, COMSETTER(AutostartDelay)(ValueUnion.u32));
2995 break;
2996 }
2997
2998 case MODIFYVM_AUTOSTOP_TYPE:
2999 {
3000 AutostopType_T enmAutostopType = AutostopType_Disabled;
3001
3002 if (!RTStrICmp(ValueUnion.psz, "disabled"))
3003 enmAutostopType = AutostopType_Disabled;
3004 else if (!RTStrICmp(ValueUnion.psz, "savestate"))
3005 enmAutostopType = AutostopType_SaveState;
3006 else if (!RTStrICmp(ValueUnion.psz, "poweroff"))
3007 enmAutostopType = AutostopType_PowerOff;
3008 else if (!RTStrICmp(ValueUnion.psz, "acpishutdown"))
3009 enmAutostopType = AutostopType_AcpiShutdown;
3010 else
3011 {
3012 errorArgument("Invalid --autostop-type argument '%s' (valid: disabled, savestate, poweroff, acpishutdown)", ValueUnion.psz);
3013 rc = E_FAIL;
3014 }
3015
3016 if (SUCCEEDED(rc))
3017 CHECK_ERROR(sessionMachine, COMSETTER(AutostopType)(enmAutostopType));
3018 break;
3019 }
3020#ifdef VBOX_WITH_PCI_PASSTHROUGH
3021 case MODIFYVM_ATTACH_PCI:
3022 {
3023 const char* pAt = strchr(ValueUnion.psz, '@');
3024 int32_t iHostAddr, iGuestAddr;
3025
3026 iHostAddr = parsePci(ValueUnion.psz);
3027 iGuestAddr = pAt != NULL ? parsePci(pAt + 1) : iHostAddr;
3028
3029 if (iHostAddr == -1 || iGuestAddr == -1)
3030 {
3031 errorArgument("Invalid --pciattach argument '%s' (valid: 'HB:HD.HF@GB:GD.GF' or just 'HB:HD.HF')", ValueUnion.psz);
3032 rc = E_FAIL;
3033 }
3034 else
3035 {
3036 CHECK_ERROR(sessionMachine, AttachHostPCIDevice(iHostAddr, iGuestAddr, TRUE));
3037 }
3038
3039 break;
3040 }
3041 case MODIFYVM_DETACH_PCI:
3042 {
3043 int32_t iHostAddr;
3044
3045 iHostAddr = parsePci(ValueUnion.psz);
3046 if (iHostAddr == -1)
3047 {
3048 errorArgument("Invalid --pcidetach argument '%s' (valid: 'HB:HD.HF')", ValueUnion.psz);
3049 rc = E_FAIL;
3050 }
3051 else
3052 {
3053 CHECK_ERROR(sessionMachine, DetachHostPCIDevice(iHostAddr));
3054 }
3055
3056 break;
3057 }
3058#endif
3059
3060#ifdef VBOX_WITH_USB_CARDREADER
3061 case MODIFYVM_USBCARDREADER:
3062 {
3063 CHECK_ERROR(sessionMachine, COMSETTER(EmulatedUSBCardReaderEnabled)(ValueUnion.f));
3064 break;
3065 }
3066#endif /* VBOX_WITH_USB_CARDREADER */
3067
3068 case MODIFYVM_DEFAULTFRONTEND:
3069 {
3070 Bstr bstr(ValueUnion.psz);
3071 if (bstr == "default")
3072 bstr = Bstr::Empty;
3073 CHECK_ERROR(sessionMachine, COMSETTER(DefaultFrontend)(bstr.raw()));
3074 break;
3075 }
3076
3077 default:
3078 {
3079 errorGetOpt(USAGE_MODIFYVM, c, &ValueUnion);
3080 rc = E_FAIL;
3081 break;
3082 }
3083 }
3084 }
3085
3086 /* commit changes */
3087 if (SUCCEEDED(rc))
3088 CHECK_ERROR(sessionMachine, SaveSettings());
3089
3090 /* it's important to always close sessions */
3091 a->session->UnlockMachine();
3092
3093 return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
3094}
3095
3096#endif /* !VBOX_ONLY_DOCS */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette