VirtualBox

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

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

DnD: API overhaul; now using IDnDTarget + IDnDSource. Renamed DragAndDrop* enumerations to DnD*. Also rewrote some internal code.

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