VirtualBox

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

Last change on this file since 47246 was 47246, checked in by vboxsync, 12 years ago

Setings: add multi-touch setting and fix combo mouse somewhat.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 107.0 KB
Line 
1/* $Id: VBoxManageModifyVM.cpp 47246 2013-07-19 09:43:01Z 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 ComPtr<IUSBController> UsbCtl;
1775 rc = machine->COMGETTER(USBController)(UsbCtl.asOutParam());
1776 if (SUCCEEDED(rc))
1777 {
1778 BOOL fEnabled;
1779 rc = UsbCtl->COMGETTER(Enabled)(&fEnabled);
1780 if (FAILED(rc))
1781 fEnabled = false;
1782 if (!fEnabled)
1783 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(true));
1784 }
1785 }
1786 break;
1787 }
1788
1789 case MODIFYVM_HIDKBD:
1790 {
1791 bool fEnableUsb = false;
1792 if (!RTStrICmp(ValueUnion.psz, "ps2"))
1793 {
1794 CHECK_ERROR(machine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_PS2Keyboard));
1795 }
1796 else if (!RTStrICmp(ValueUnion.psz, "usb"))
1797 {
1798 CHECK_ERROR(machine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_USBKeyboard));
1799 if (SUCCEEDED(rc))
1800 fEnableUsb = true;
1801 }
1802 else
1803 {
1804 errorArgument("Invalid type '%s' specfied for keyboard", ValueUnion.psz);
1805 rc = E_FAIL;
1806 }
1807 if (fEnableUsb)
1808 {
1809 /* Make sure the OHCI controller is enabled. */
1810 ComPtr<IUSBController> UsbCtl;
1811 rc = machine->COMGETTER(USBController)(UsbCtl.asOutParam());
1812 if (SUCCEEDED(rc))
1813 {
1814 BOOL fEnabled;
1815 rc = UsbCtl->COMGETTER(Enabled)(&fEnabled);
1816 if (FAILED(rc))
1817 fEnabled = false;
1818 if (!fEnabled)
1819 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(true));
1820 }
1821 }
1822 break;
1823 }
1824
1825 case MODIFYVM_UARTMODE:
1826 {
1827 ComPtr<ISerialPort> uart;
1828 char *pszIRQ = NULL;
1829
1830 CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
1831 ASSERT(uart);
1832
1833 if (!RTStrICmp(ValueUnion.psz, "disconnected"))
1834 {
1835 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_Disconnected));
1836 }
1837 else if ( !RTStrICmp(ValueUnion.psz, "server")
1838 || !RTStrICmp(ValueUnion.psz, "client")
1839 || !RTStrICmp(ValueUnion.psz, "file"))
1840 {
1841 const char *pszMode = ValueUnion.psz;
1842
1843 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
1844 if (RT_FAILURE(vrc))
1845 return errorSyntax(USAGE_MODIFYVM,
1846 "Missing or Invalid argument to '%s'",
1847 GetOptState.pDef->pszLong);
1848
1849 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
1850
1851 if (!RTStrICmp(pszMode, "server"))
1852 {
1853 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
1854 CHECK_ERROR(uart, COMSETTER(Server)(TRUE));
1855 }
1856 else if (!RTStrICmp(pszMode, "client"))
1857 {
1858 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
1859 CHECK_ERROR(uart, COMSETTER(Server)(FALSE));
1860 }
1861 else if (!RTStrICmp(pszMode, "file"))
1862 {
1863 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_RawFile));
1864 }
1865 }
1866 else
1867 {
1868 CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
1869 CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostDevice));
1870 }
1871 break;
1872 }
1873
1874 case MODIFYVM_UART:
1875 {
1876 ComPtr<ISerialPort> uart;
1877
1878 CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
1879 ASSERT(uart);
1880
1881 if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
1882 CHECK_ERROR(uart, COMSETTER(Enabled)(FALSE));
1883 else
1884 {
1885 const char *pszIOBase = ValueUnion.psz;
1886 uint32_t uVal = 0;
1887
1888 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_UART;
1889 if (RT_FAILURE(vrc))
1890 return errorSyntax(USAGE_MODIFYVM,
1891 "Missing or Invalid argument to '%s'",
1892 GetOptState.pDef->pszLong);
1893
1894 CHECK_ERROR(uart, COMSETTER(IRQ)(ValueUnion.u32));
1895
1896 vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
1897 if (vrc != VINF_SUCCESS || uVal == 0)
1898 return errorArgument("Error parsing UART I/O base '%s'", pszIOBase);
1899 CHECK_ERROR(uart, COMSETTER(IOBase)(uVal));
1900
1901 CHECK_ERROR(uart, COMSETTER(Enabled)(TRUE));
1902 }
1903 break;
1904 }
1905
1906#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
1907 case MODIFYVM_LPTMODE:
1908 {
1909 ComPtr<IParallelPort> lpt;
1910 char *pszIRQ = NULL;
1911
1912 CHECK_ERROR_BREAK(machine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
1913 ASSERT(lpt);
1914
1915 CHECK_ERROR(lpt, COMSETTER(Path)(Bstr(ValueUnion.psz).raw()));
1916 break;
1917 }
1918
1919 case MODIFYVM_LPT:
1920 {
1921 ComPtr<IParallelPort> lpt;
1922
1923 CHECK_ERROR_BREAK(machine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
1924 ASSERT(lpt);
1925
1926 if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
1927 CHECK_ERROR(lpt, COMSETTER(Enabled)(FALSE));
1928 else
1929 {
1930 const char *pszIOBase = ValueUnion.psz;
1931 uint32_t uVal = 0;
1932
1933 int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_LPT;
1934 if (RT_FAILURE(vrc))
1935 return errorSyntax(USAGE_MODIFYVM,
1936 "Missing or Invalid argument to '%s'",
1937 GetOptState.pDef->pszLong);
1938
1939 CHECK_ERROR(lpt, COMSETTER(IRQ)(ValueUnion.u32));
1940
1941 vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
1942 if (vrc != VINF_SUCCESS || uVal == 0)
1943 return errorArgument("Error parsing LPT I/O base '%s'", pszIOBase);
1944 CHECK_ERROR(lpt, COMSETTER(IOBase)(uVal));
1945
1946 CHECK_ERROR(lpt, COMSETTER(Enabled)(TRUE));
1947 }
1948 break;
1949 }
1950#endif
1951
1952 case MODIFYVM_GUESTMEMORYBALLOON:
1953 {
1954 CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(ValueUnion.u32));
1955 break;
1956 }
1957
1958 case MODIFYVM_AUDIOCONTROLLER:
1959 {
1960 ComPtr<IAudioAdapter> audioAdapter;
1961 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
1962 ASSERT(audioAdapter);
1963
1964 if (!RTStrICmp(ValueUnion.psz, "sb16"))
1965 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));
1966 else if (!RTStrICmp(ValueUnion.psz, "ac97"))
1967 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));
1968 else if (!RTStrICmp(ValueUnion.psz, "hda"))
1969 CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_HDA));
1970 else
1971 {
1972 errorArgument("Invalid --audiocontroller argument '%s'", ValueUnion.psz);
1973 rc = E_FAIL;
1974 }
1975 break;
1976 }
1977
1978 case MODIFYVM_AUDIO:
1979 {
1980 ComPtr<IAudioAdapter> audioAdapter;
1981 machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
1982 ASSERT(audioAdapter);
1983
1984 /* disable? */
1985 if (!RTStrICmp(ValueUnion.psz, "none"))
1986 {
1987 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
1988 }
1989 else if (!RTStrICmp(ValueUnion.psz, "null"))
1990 {
1991 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));
1992 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
1993 }
1994#ifdef RT_OS_WINDOWS
1995#ifdef VBOX_WITH_WINMM
1996 else if (!RTStrICmp(ValueUnion.psz, "winmm"))
1997 {
1998 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));
1999 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2000 }
2001#endif
2002 else if (!RTStrICmp(ValueUnion.psz, "dsound"))
2003 {
2004 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
2005 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2006 }
2007#endif /* RT_OS_WINDOWS */
2008#ifdef RT_OS_LINUX
2009# ifdef VBOX_WITH_ALSA
2010 else if (!RTStrICmp(ValueUnion.psz, "alsa"))
2011 {
2012 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));
2013 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2014 }
2015# endif
2016# ifdef VBOX_WITH_PULSE
2017 else if (!RTStrICmp(ValueUnion.psz, "pulse"))
2018 {
2019 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
2020 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2021 }
2022# endif
2023#endif /* !RT_OS_LINUX */
2024#ifdef RT_OS_SOLARIS
2025 else if (!RTStrICmp(ValueUnion.psz, "solaudio"))
2026 {
2027 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio));
2028 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2029 }
2030#endif /* !RT_OS_SOLARIS */
2031#ifdef RT_OS_FREEBSD
2032 else if (!RTStrICmp(ValueUnion.psz, "oss"))
2033 {
2034 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
2035 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2036 }
2037# ifdef VBOX_WITH_PULSE
2038 else if (!RTStrICmp(ValueUnion.psz, "pulse"))
2039 {
2040 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
2041 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2042 }
2043# endif
2044#endif /* !RT_OS_FREEBSD */
2045#ifdef RT_OS_DARWIN
2046 else if (!RTStrICmp(ValueUnion.psz, "coreaudio"))
2047 {
2048 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));
2049 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2050 }
2051
2052#endif /* !RT_OS_DARWIN */
2053# if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(VBOX_WITH_SOLARIS_OSS)
2054 else if (!RTStrICmp(ValueUnion.psz, "oss"))
2055 {
2056 CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
2057 CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
2058 }
2059# endif
2060 else
2061 {
2062 errorArgument("Invalid --audio argument '%s'", ValueUnion.psz);
2063 rc = E_FAIL;
2064 }
2065 break;
2066 }
2067
2068 case MODIFYVM_CLIPBOARD:
2069 {
2070 ClipboardMode_T mode;
2071 if (!RTStrICmp(ValueUnion.psz, "disabled"))
2072 mode = ClipboardMode_Disabled;
2073 else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
2074 mode = ClipboardMode_HostToGuest;
2075 else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
2076 mode = ClipboardMode_GuestToHost;
2077 else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
2078 mode = ClipboardMode_Bidirectional;
2079 else
2080 {
2081 errorArgument("Invalid --clipboard argument '%s'", ValueUnion.psz);
2082 rc = E_FAIL;
2083 }
2084 if (SUCCEEDED(rc))
2085 {
2086 CHECK_ERROR(machine, COMSETTER(ClipboardMode)(mode));
2087 }
2088 break;
2089 }
2090
2091 case MODIFYVM_DRAGANDDROP:
2092 {
2093 DragAndDropMode_T mode;
2094 if (!RTStrICmp(ValueUnion.psz, "disabled"))
2095 mode = DragAndDropMode_Disabled;
2096 else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
2097 mode = DragAndDropMode_HostToGuest;
2098 else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
2099 mode = DragAndDropMode_GuestToHost;
2100 else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
2101 mode = DragAndDropMode_Bidirectional;
2102 else
2103 {
2104 errorArgument("Invalid --draganddrop argument '%s'", ValueUnion.psz);
2105 rc = E_FAIL;
2106 }
2107 if (SUCCEEDED(rc))
2108 {
2109 CHECK_ERROR(machine, COMSETTER(DragAndDropMode)(mode));
2110 }
2111 break;
2112 }
2113
2114 case MODIFYVM_VRDE_EXTPACK:
2115 {
2116 ComPtr<IVRDEServer> vrdeServer;
2117 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2118 ASSERT(vrdeServer);
2119
2120 if (vrdeServer)
2121 {
2122 if (RTStrICmp(ValueUnion.psz, "default") != 0)
2123 {
2124 Bstr bstr(ValueUnion.psz);
2125 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(bstr.raw()));
2126 }
2127 else
2128 CHECK_ERROR(vrdeServer, COMSETTER(VRDEExtPack)(Bstr().raw()));
2129 }
2130 break;
2131 }
2132
2133 case MODIFYVM_VRDEPROPERTY:
2134 {
2135 ComPtr<IVRDEServer> vrdeServer;
2136 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2137 ASSERT(vrdeServer);
2138
2139 if (vrdeServer)
2140 {
2141 /* Parse 'name=value' */
2142 char *pszProperty = RTStrDup(ValueUnion.psz);
2143 if (pszProperty)
2144 {
2145 char *pDelimiter = strchr(pszProperty, '=');
2146 if (pDelimiter)
2147 {
2148 *pDelimiter = '\0';
2149
2150 Bstr bstrName = pszProperty;
2151 Bstr bstrValue = &pDelimiter[1];
2152 CHECK_ERROR(vrdeServer, SetVRDEProperty(bstrName.raw(), bstrValue.raw()));
2153 }
2154 else
2155 {
2156 RTStrFree(pszProperty);
2157
2158 errorArgument("Invalid --vrdeproperty argument '%s'", ValueUnion.psz);
2159 rc = E_FAIL;
2160 break;
2161 }
2162 RTStrFree(pszProperty);
2163 }
2164 else
2165 {
2166 RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for VRDE property '%s'\n", ValueUnion.psz);
2167 rc = E_FAIL;
2168 }
2169 }
2170 break;
2171 }
2172
2173 case MODIFYVM_VRDPPORT:
2174 vrdeWarningDeprecatedOption("port");
2175
2176 case MODIFYVM_VRDEPORT:
2177 {
2178 ComPtr<IVRDEServer> vrdeServer;
2179 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2180 ASSERT(vrdeServer);
2181
2182 if (!RTStrICmp(ValueUnion.psz, "default"))
2183 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr("0").raw()));
2184 else
2185 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), Bstr(ValueUnion.psz).raw()));
2186 break;
2187 }
2188
2189 case MODIFYVM_VRDPADDRESS:
2190 vrdeWarningDeprecatedOption("address");
2191
2192 case MODIFYVM_VRDEADDRESS:
2193 {
2194 ComPtr<IVRDEServer> vrdeServer;
2195 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2196 ASSERT(vrdeServer);
2197
2198 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("TCP/Address").raw(), Bstr(ValueUnion.psz).raw()));
2199 break;
2200 }
2201
2202 case MODIFYVM_VRDPAUTHTYPE:
2203 vrdeWarningDeprecatedOption("authtype");
2204 case MODIFYVM_VRDEAUTHTYPE:
2205 {
2206 ComPtr<IVRDEServer> vrdeServer;
2207 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2208 ASSERT(vrdeServer);
2209
2210 if (!RTStrICmp(ValueUnion.psz, "null"))
2211 {
2212 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Null));
2213 }
2214 else if (!RTStrICmp(ValueUnion.psz, "external"))
2215 {
2216 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_External));
2217 }
2218 else if (!RTStrICmp(ValueUnion.psz, "guest"))
2219 {
2220 CHECK_ERROR(vrdeServer, COMSETTER(AuthType)(AuthType_Guest));
2221 }
2222 else
2223 {
2224 errorArgument("Invalid --vrdeauthtype argument '%s'", ValueUnion.psz);
2225 rc = E_FAIL;
2226 }
2227 break;
2228 }
2229
2230 case MODIFYVM_VRDEAUTHLIBRARY:
2231 {
2232 ComPtr<IVRDEServer> vrdeServer;
2233 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2234 ASSERT(vrdeServer);
2235
2236 if (vrdeServer)
2237 {
2238 if (RTStrICmp(ValueUnion.psz, "default") != 0)
2239 {
2240 Bstr bstr(ValueUnion.psz);
2241 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(bstr.raw()));
2242 }
2243 else
2244 CHECK_ERROR(vrdeServer, COMSETTER(AuthLibrary)(Bstr().raw()));
2245 }
2246 break;
2247 }
2248
2249 case MODIFYVM_VRDPMULTICON:
2250 vrdeWarningDeprecatedOption("multicon");
2251 case MODIFYVM_VRDEMULTICON:
2252 {
2253 ComPtr<IVRDEServer> vrdeServer;
2254 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2255 ASSERT(vrdeServer);
2256
2257 CHECK_ERROR(vrdeServer, COMSETTER(AllowMultiConnection)(ValueUnion.f));
2258 break;
2259 }
2260
2261 case MODIFYVM_VRDPREUSECON:
2262 vrdeWarningDeprecatedOption("reusecon");
2263 case MODIFYVM_VRDEREUSECON:
2264 {
2265 ComPtr<IVRDEServer> vrdeServer;
2266 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2267 ASSERT(vrdeServer);
2268
2269 CHECK_ERROR(vrdeServer, COMSETTER(ReuseSingleConnection)(ValueUnion.f));
2270 break;
2271 }
2272
2273 case MODIFYVM_VRDPVIDEOCHANNEL:
2274 vrdeWarningDeprecatedOption("videochannel");
2275 case MODIFYVM_VRDEVIDEOCHANNEL:
2276 {
2277 ComPtr<IVRDEServer> vrdeServer;
2278 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2279 ASSERT(vrdeServer);
2280
2281 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("VideoChannel/Enabled").raw(),
2282 ValueUnion.f? Bstr("true").raw(): Bstr("false").raw()));
2283 break;
2284 }
2285
2286 case MODIFYVM_VRDPVIDEOCHANNELQUALITY:
2287 vrdeWarningDeprecatedOption("videochannelquality");
2288 case MODIFYVM_VRDEVIDEOCHANNELQUALITY:
2289 {
2290 ComPtr<IVRDEServer> vrdeServer;
2291 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2292 ASSERT(vrdeServer);
2293
2294 CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("VideoChannel/Quality").raw(),
2295 Bstr(ValueUnion.psz).raw()));
2296 break;
2297 }
2298
2299 case MODIFYVM_VRDP:
2300 vrdeWarningDeprecatedOption("");
2301 case MODIFYVM_VRDE:
2302 {
2303 ComPtr<IVRDEServer> vrdeServer;
2304 machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
2305 ASSERT(vrdeServer);
2306
2307 CHECK_ERROR(vrdeServer, COMSETTER(Enabled)(ValueUnion.f));
2308 break;
2309 }
2310
2311 case MODIFYVM_USBEHCI:
2312 {
2313 ComPtr<IUSBController> UsbCtl;
2314 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
2315 if (SUCCEEDED(rc))
2316 CHECK_ERROR(UsbCtl, COMSETTER(EnabledEHCI)(ValueUnion.f));
2317 break;
2318 }
2319
2320 case MODIFYVM_USB:
2321 {
2322 ComPtr<IUSBController> UsbCtl;
2323 CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
2324 if (SUCCEEDED(rc))
2325 CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(ValueUnion.f));
2326 break;
2327 }
2328
2329 case MODIFYVM_SNAPSHOTFOLDER:
2330 {
2331 if (!RTStrICmp(ValueUnion.psz, "default"))
2332 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr().raw()));
2333 else
2334 CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz).raw()));
2335 break;
2336 }
2337
2338 case MODIFYVM_TELEPORTER_ENABLED:
2339 {
2340 CHECK_ERROR(machine, COMSETTER(TeleporterEnabled)(ValueUnion.f));
2341 break;
2342 }
2343
2344 case MODIFYVM_TELEPORTER_PORT:
2345 {
2346 CHECK_ERROR(machine, COMSETTER(TeleporterPort)(ValueUnion.u32));
2347 break;
2348 }
2349
2350 case MODIFYVM_TELEPORTER_ADDRESS:
2351 {
2352 CHECK_ERROR(machine, COMSETTER(TeleporterAddress)(Bstr(ValueUnion.psz).raw()));
2353 break;
2354 }
2355
2356 case MODIFYVM_TELEPORTER_PASSWORD:
2357 {
2358 CHECK_ERROR(machine, COMSETTER(TeleporterPassword)(Bstr(ValueUnion.psz).raw()));
2359 break;
2360 }
2361
2362 case MODIFYVM_TELEPORTER_PASSWORD_FILE:
2363 {
2364 Utf8Str password;
2365 RTEXITCODE rcExit = readPasswordFile(ValueUnion.psz, &password);
2366 if (rcExit != RTEXITCODE_SUCCESS)
2367 rc = E_FAIL;
2368 else
2369 CHECK_ERROR(machine, COMSETTER(TeleporterPassword)(Bstr(password).raw()));
2370 break;
2371 }
2372
2373 case MODIFYVM_TRACING_ENABLED:
2374 {
2375 CHECK_ERROR(machine, COMSETTER(TracingEnabled)(ValueUnion.f));
2376 break;
2377 }
2378
2379 case MODIFYVM_TRACING_CONFIG:
2380 {
2381 CHECK_ERROR(machine, COMSETTER(TracingConfig)(Bstr(ValueUnion.psz).raw()));
2382 break;
2383 }
2384
2385 case MODIFYVM_TRACING_ALLOW_VM_ACCESS:
2386 {
2387 CHECK_ERROR(machine, COMSETTER(AllowTracingToAccessVM)(ValueUnion.f));
2388 break;
2389 }
2390
2391 case MODIFYVM_FAULT_TOLERANCE:
2392 {
2393 if (!RTStrICmp(ValueUnion.psz, "master"))
2394 {
2395 CHECK_ERROR(machine, COMSETTER(FaultToleranceState(FaultToleranceState_Master)));
2396 }
2397 else
2398 if (!RTStrICmp(ValueUnion.psz, "standby"))
2399 {
2400 CHECK_ERROR(machine, COMSETTER(FaultToleranceState(FaultToleranceState_Standby)));
2401 }
2402 else
2403 {
2404 errorArgument("Invalid --faulttolerance argument '%s'", ValueUnion.psz);
2405 rc = E_FAIL;
2406 }
2407 break;
2408 }
2409
2410 case MODIFYVM_FAULT_TOLERANCE_ADDRESS:
2411 {
2412 CHECK_ERROR(machine, COMSETTER(FaultToleranceAddress)(Bstr(ValueUnion.psz).raw()));
2413 break;
2414 }
2415
2416 case MODIFYVM_FAULT_TOLERANCE_PORT:
2417 {
2418 CHECK_ERROR(machine, COMSETTER(FaultTolerancePort)(ValueUnion.u32));
2419 break;
2420 }
2421
2422 case MODIFYVM_FAULT_TOLERANCE_PASSWORD:
2423 {
2424 CHECK_ERROR(machine, COMSETTER(FaultTolerancePassword)(Bstr(ValueUnion.psz).raw()));
2425 break;
2426 }
2427
2428 case MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL:
2429 {
2430 CHECK_ERROR(machine, COMSETTER(FaultToleranceSyncInterval)(ValueUnion.u32));
2431 break;
2432 }
2433
2434 case MODIFYVM_HARDWARE_UUID:
2435 {
2436 CHECK_ERROR(machine, COMSETTER(HardwareUUID)(Bstr(ValueUnion.psz).raw()));
2437 break;
2438 }
2439
2440 case MODIFYVM_HPET:
2441 {
2442 CHECK_ERROR(machine, COMSETTER(HPETEnabled)(ValueUnion.f));
2443 break;
2444 }
2445
2446 case MODIFYVM_IOCACHE:
2447 {
2448 CHECK_ERROR(machine, COMSETTER(IOCacheEnabled)(ValueUnion.f));
2449 break;
2450 }
2451
2452 case MODIFYVM_IOCACHESIZE:
2453 {
2454 CHECK_ERROR(machine, COMSETTER(IOCacheSize)(ValueUnion.u32));
2455 break;
2456 }
2457
2458 case MODIFYVM_CHIPSET:
2459 {
2460 if (!RTStrICmp(ValueUnion.psz, "piix3"))
2461 {
2462 CHECK_ERROR(machine, COMSETTER(ChipsetType)(ChipsetType_PIIX3));
2463 }
2464 else if (!RTStrICmp(ValueUnion.psz, "ich9"))
2465 {
2466 CHECK_ERROR(machine, COMSETTER(ChipsetType)(ChipsetType_ICH9));
2467 BOOL fIoApic = FALSE;
2468 CHECK_ERROR(biosSettings, COMGETTER(IOAPICEnabled)(&fIoApic));
2469 if (!fIoApic)
2470 {
2471 RTStrmPrintf(g_pStdErr, "*** I/O APIC must be enabled for ICH9, enabling. ***\n");
2472 CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(TRUE));
2473 }
2474 }
2475 else
2476 {
2477 errorArgument("Invalid --chipset argument '%s' (valid: piix3,ich9)", ValueUnion.psz);
2478 rc = E_FAIL;
2479 }
2480 break;
2481 }
2482#ifdef VBOX_WITH_VPX
2483 case MODIFYVM_VCP:
2484 {
2485 CHECK_ERROR(machine, COMSETTER(VideoCaptureEnabled)(ValueUnion.f));
2486 break;
2487 }
2488 case MODIFYVM_VCP_SCREENS:
2489 {
2490 ULONG cMonitors = 64;
2491 CHECK_ERROR(machine, COMGETTER(MonitorCount)(&cMonitors));
2492 com::SafeArray<BOOL> screens(cMonitors);
2493 if (parseScreens(ValueUnion.psz, &screens))
2494 {
2495 errorArgument("Invalid list of screens specified\n");
2496 rc = E_FAIL;
2497 break;
2498 }
2499 CHECK_ERROR(machine, COMSETTER(VideoCaptureScreens)(ComSafeArrayAsInParam(screens)));
2500 break;
2501 }
2502 case MODIFYVM_VCP_FILENAME:
2503 {
2504 Bstr bstr;
2505 /* empty string will fall through, leaving bstr empty */
2506 if (*ValueUnion.psz)
2507 {
2508 char szVCFileAbs[RTPATH_MAX] = "";
2509 int vrc = RTPathAbs(ValueUnion.psz, szVCFileAbs, sizeof(szVCFileAbs));
2510 if (RT_FAILURE(vrc))
2511 {
2512 errorArgument("Cannot convert filename \"%s\" to absolute path\n", ValueUnion.psz);
2513 rc = E_FAIL;
2514 break;
2515 }
2516 bstr = szVCFileAbs;
2517 }
2518 CHECK_ERROR(machine, COMSETTER(VideoCaptureFile)(bstr.raw()));
2519 break;
2520 }
2521 case MODIFYVM_VCP_WIDTH:
2522 {
2523 CHECK_ERROR(machine, COMSETTER(VideoCaptureWidth)(ValueUnion.u32));
2524 break;
2525 }
2526 case MODIFYVM_VCP_HEIGHT:
2527 {
2528 CHECK_ERROR(machine, COMSETTER(VideoCaptureHeight)(ValueUnion.u32));
2529 break;
2530 }
2531 case MODIFYVM_VCP_RATE:
2532 {
2533 CHECK_ERROR(machine, COMSETTER(VideoCaptureRate)(ValueUnion.u32));
2534 break;
2535 }
2536 case MODIFYVM_VCP_FPS:
2537 {
2538 CHECK_ERROR(machine, COMSETTER(VideoCaptureFPS)(ValueUnion.u32));
2539 break;
2540 }
2541#endif
2542 case MODIFYVM_AUTOSTART_ENABLED:
2543 {
2544 CHECK_ERROR(machine, COMSETTER(AutostartEnabled)(ValueUnion.f));
2545 break;
2546 }
2547
2548 case MODIFYVM_AUTOSTART_DELAY:
2549 {
2550 CHECK_ERROR(machine, COMSETTER(AutostartDelay)(ValueUnion.u32));
2551 break;
2552 }
2553
2554 case MODIFYVM_AUTOSTOP_TYPE:
2555 {
2556 AutostopType_T enmAutostopType = AutostopType_Disabled;
2557
2558 if (!RTStrICmp(ValueUnion.psz, "disabled"))
2559 enmAutostopType = AutostopType_Disabled;
2560 else if (!RTStrICmp(ValueUnion.psz, "savestate"))
2561 enmAutostopType = AutostopType_SaveState;
2562 else if (!RTStrICmp(ValueUnion.psz, "poweroff"))
2563 enmAutostopType = AutostopType_PowerOff;
2564 else if (!RTStrICmp(ValueUnion.psz, "acpishutdown"))
2565 enmAutostopType = AutostopType_AcpiShutdown;
2566 else
2567 {
2568 errorArgument("Invalid --autostop-type argument '%s' (valid: disabled, savestate, poweroff, acpishutdown)", ValueUnion.psz);
2569 rc = E_FAIL;
2570 }
2571
2572 if (SUCCEEDED(rc))
2573 CHECK_ERROR(machine, COMSETTER(AutostopType)(enmAutostopType));
2574 break;
2575 }
2576#ifdef VBOX_WITH_PCI_PASSTHROUGH
2577 case MODIFYVM_ATTACH_PCI:
2578 {
2579 const char* pAt = strchr(ValueUnion.psz, '@');
2580 int32_t iHostAddr, iGuestAddr;
2581
2582 iHostAddr = parsePci(ValueUnion.psz);
2583 iGuestAddr = pAt != NULL ? parsePci(pAt + 1) : iHostAddr;
2584
2585 if (iHostAddr == -1 || iGuestAddr == -1)
2586 {
2587 errorArgument("Invalid --pciattach argument '%s' (valid: 'HB:HD.HF@GB:GD.GF' or just 'HB:HD.HF')", ValueUnion.psz);
2588 rc = E_FAIL;
2589 }
2590 else
2591 {
2592 CHECK_ERROR(machine, AttachHostPCIDevice(iHostAddr, iGuestAddr, TRUE));
2593 }
2594
2595 break;
2596 }
2597 case MODIFYVM_DETACH_PCI:
2598 {
2599 int32_t iHostAddr;
2600
2601 iHostAddr = parsePci(ValueUnion.psz);
2602 if (iHostAddr == -1)
2603 {
2604 errorArgument("Invalid --pcidetach argument '%s' (valid: 'HB:HD.HF')", ValueUnion.psz);
2605 rc = E_FAIL;
2606 }
2607 else
2608 {
2609 CHECK_ERROR(machine, DetachHostPCIDevice(iHostAddr));
2610 }
2611
2612 break;
2613 }
2614#endif
2615
2616#ifdef VBOX_WITH_USB_VIDEO
2617 case MODIFYVM_USBWEBCAM:
2618 {
2619 CHECK_ERROR(machine, COMSETTER(EmulatedUSBWebcameraEnabled)(ValueUnion.f));
2620 break;
2621 }
2622#endif /* VBOX_WITH_USB_VIDEO */
2623
2624#ifdef VBOX_WITH_USB_CARDREADER
2625 case MODIFYVM_USBCARDREADER:
2626 {
2627 CHECK_ERROR(machine, COMSETTER(EmulatedUSBCardReaderEnabled)(ValueUnion.f));
2628 break;
2629 }
2630#endif /* VBOX_WITH_USB_CARDREADER */
2631
2632 case MODIFYVM_DEFAULTFRONTEND:
2633 {
2634 Bstr bstr(ValueUnion.psz);
2635 if (bstr == "default")
2636 bstr = Bstr::Empty;
2637 CHECK_ERROR(machine, COMSETTER(DefaultFrontend)(bstr.raw()));
2638 break;
2639 }
2640
2641 default:
2642 {
2643 errorGetOpt(USAGE_MODIFYVM, c, &ValueUnion);
2644 rc = E_FAIL;
2645 break;
2646 }
2647 }
2648 }
2649
2650 /* commit changes */
2651 if (SUCCEEDED(rc))
2652 CHECK_ERROR(machine, SaveSettings());
2653
2654 /* it's important to always close sessions */
2655 a->session->UnlockMachine();
2656
2657 return SUCCEEDED(rc) ? 0 : 1;
2658}
2659
2660#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