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