VirtualBox

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

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

Main: Added paravirt. provider APIs.

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