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