VirtualBox

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

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

Main: Made the exclusive HW virtualization use setting global rather than per-VM.

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