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