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