VirtualBox

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

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

Frontends/VBoxManage: automatically convert the video capture filename to an absolute path

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