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