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