VirtualBox

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

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

*: scm --update-copyright-year

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