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