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