VirtualBox

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

Last change on this file since 47428 was 47403, checked in by vboxsync, 11 years ago

build fix

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