1 | /* $Id: VBoxManageModifyVM.cpp 28588 2010-04-22 12:05:20Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - Implementation of modifyvm command.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2009 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*******************************************************************************
|
---|
23 | * Header Files *
|
---|
24 | *******************************************************************************/
|
---|
25 | #ifndef VBOX_ONLY_DOCS
|
---|
26 | #include <VBox/com/com.h>
|
---|
27 | #include <VBox/com/array.h>
|
---|
28 | #include <VBox/com/ErrorInfo.h>
|
---|
29 | #include <VBox/com/errorprint.h>
|
---|
30 | #include <VBox/com/EventQueue.h>
|
---|
31 |
|
---|
32 | #include <VBox/com/VirtualBox.h>
|
---|
33 |
|
---|
34 | #include <vector>
|
---|
35 | #include <list>
|
---|
36 | #endif /* !VBOX_ONLY_DOCS */
|
---|
37 |
|
---|
38 | #include <iprt/cidr.h>
|
---|
39 | #include <iprt/param.h>
|
---|
40 | #include <iprt/path.h>
|
---|
41 | #include <iprt/stream.h>
|
---|
42 | #include <iprt/string.h>
|
---|
43 | #include <iprt/getopt.h>
|
---|
44 | #include <VBox/log.h>
|
---|
45 |
|
---|
46 | #include "VBoxManage.h"
|
---|
47 |
|
---|
48 | #ifndef VBOX_ONLY_DOCS
|
---|
49 | using namespace com;
|
---|
50 |
|
---|
51 |
|
---|
52 | /** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */
|
---|
53 | #if defined(_MSC_VER)
|
---|
54 | # pragma optimize("g", off)
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | enum
|
---|
58 | {
|
---|
59 | MODIFYVM_NAME = 1000,
|
---|
60 | MODIFYVM_OSTYPE,
|
---|
61 | MODIFYVM_MEMORY,
|
---|
62 | MODIFYVM_VRAM,
|
---|
63 | MODIFYVM_FIRMWARE,
|
---|
64 | MODIFYVM_ACPI,
|
---|
65 | MODIFYVM_IOAPIC,
|
---|
66 | MODIFYVM_PAE,
|
---|
67 | MODIFYVM_SYNTHCPU,
|
---|
68 | MODIFYVM_HWVIRTEX,
|
---|
69 | MODIFYVM_HWVIRTEXEXCLUSIVE,
|
---|
70 | MODIFYVM_NESTEDPAGING,
|
---|
71 | MODIFYVM_LARGEPAGES,
|
---|
72 | MODIFYVM_VTXVPID,
|
---|
73 | MODIFYVM_CPUS,
|
---|
74 | MODIFYVM_CPUHOTPLUG,
|
---|
75 | MODIFYVM_PLUGCPU,
|
---|
76 | MODIFYVM_UNPLUGCPU,
|
---|
77 | MODIFYVM_SETCPUID,
|
---|
78 | MODIFYVM_DELCPUID,
|
---|
79 | MODIFYVM_DELALLCPUID,
|
---|
80 | MODIFYVM_MONITORCOUNT,
|
---|
81 | MODIFYVM_ACCELERATE3D,
|
---|
82 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
83 | MODIFYVM_ACCELERATE2DVIDEO,
|
---|
84 | #endif
|
---|
85 | MODIFYVM_BIOSLOGOFADEIN,
|
---|
86 | MODIFYVM_BIOSLOGOFADEOUT,
|
---|
87 | MODIFYVM_BIOSLOGODISPLAYTIME,
|
---|
88 | MODIFYVM_BIOSLOGOIMAGEPATH,
|
---|
89 | MODIFYVM_BIOSBOOTMENU,
|
---|
90 | MODIFYVM_BIOSSYSTEMTIMEOFFSET,
|
---|
91 | MODIFYVM_BIOSPXEDEBUG,
|
---|
92 | MODIFYVM_BOOT,
|
---|
93 | MODIFYVM_HDA, // deprecated
|
---|
94 | MODIFYVM_HDB, // deprecated
|
---|
95 | MODIFYVM_HDD, // deprecated
|
---|
96 | MODIFYVM_IDECONTROLLER, // deprecated
|
---|
97 | MODIFYVM_SATAIDEEMULATION, // deprecated
|
---|
98 | MODIFYVM_SATAPORTCOUNT, // deprecated
|
---|
99 | MODIFYVM_SATAPORT, // deprecated
|
---|
100 | MODIFYVM_SATA, // deprecated
|
---|
101 | MODIFYVM_SCSIPORT, // deprecated
|
---|
102 | MODIFYVM_SCSITYPE, // deprecated
|
---|
103 | MODIFYVM_SCSI, // deprecated
|
---|
104 | MODIFYVM_DVDPASSTHROUGH, // deprecated
|
---|
105 | MODIFYVM_DVD, // deprecated
|
---|
106 | MODIFYVM_FLOPPY, // deprecated
|
---|
107 | MODIFYVM_NICTRACEFILE,
|
---|
108 | MODIFYVM_NICTRACE,
|
---|
109 | MODIFYVM_NICTYPE,
|
---|
110 | MODIFYVM_NICSPEED,
|
---|
111 | MODIFYVM_NICBOOTPRIO,
|
---|
112 | MODIFYVM_NIC,
|
---|
113 | MODIFYVM_CABLECONNECTED,
|
---|
114 | MODIFYVM_BRIDGEADAPTER,
|
---|
115 | MODIFYVM_HOSTONLYADAPTER,
|
---|
116 | MODIFYVM_INTNET,
|
---|
117 | MODIFYVM_NATNET,
|
---|
118 | MODIFYVM_NATBINDIP,
|
---|
119 | MODIFYVM_NATSETTINGS,
|
---|
120 | MODIFYVM_NATPF,
|
---|
121 | MODIFYVM_NATTFTPPREFIX,
|
---|
122 | MODIFYVM_NATTFTPFILE,
|
---|
123 | MODIFYVM_NATTFTPSERVER,
|
---|
124 | MODIFYVM_NATDNSPASSDOMAIN,
|
---|
125 | MODIFYVM_NATDNSPROXY,
|
---|
126 | MODIFYVM_NATDNSHOSTRESOLVER,
|
---|
127 | MODIFYVM_MACADDRESS,
|
---|
128 | MODIFYVM_HIDPTR,
|
---|
129 | MODIFYVM_HIDKBD,
|
---|
130 | MODIFYVM_UARTMODE,
|
---|
131 | MODIFYVM_UART,
|
---|
132 | MODIFYVM_GUESTMEMORYBALLOON,
|
---|
133 | MODIFYVM_AUDIOCONTROLLER,
|
---|
134 | MODIFYVM_AUDIO,
|
---|
135 | MODIFYVM_CLIPBOARD,
|
---|
136 | #ifdef VBOX_WITH_VRDP
|
---|
137 | MODIFYVM_VRDPPORT,
|
---|
138 | MODIFYVM_VRDPADDRESS,
|
---|
139 | MODIFYVM_VRDPAUTHTYPE,
|
---|
140 | MODIFYVM_VRDPMULTICON,
|
---|
141 | MODIFYVM_VRDPREUSECON,
|
---|
142 | MODIFYVM_VRDP,
|
---|
143 | #endif
|
---|
144 | MODIFYVM_RTCUSEUTC,
|
---|
145 | MODIFYVM_USBEHCI,
|
---|
146 | MODIFYVM_USB,
|
---|
147 | MODIFYVM_SNAPSHOTFOLDER,
|
---|
148 | MODIFYVM_TELEPORTER_ENABLED,
|
---|
149 | MODIFYVM_TELEPORTER_PORT,
|
---|
150 | MODIFYVM_TELEPORTER_ADDRESS,
|
---|
151 | MODIFYVM_TELEPORTER_PASSWORD,
|
---|
152 | MODIFYVM_HARDWARE_UUID,
|
---|
153 | MODIFYVM_HPET,
|
---|
154 | MODIFYVM_IOMGR,
|
---|
155 | MODIFYVM_IOBACKEND,
|
---|
156 | MODIFYVM_IOCACHE,
|
---|
157 | MODIFYVM_IOCACHESIZE,
|
---|
158 | MODIFYVM_IOBANDWIDTHMAX
|
---|
159 | };
|
---|
160 |
|
---|
161 | static const RTGETOPTDEF g_aModifyVMOptions[] =
|
---|
162 | {
|
---|
163 | { "--name", MODIFYVM_NAME, RTGETOPT_REQ_STRING },
|
---|
164 | { "--ostype", MODIFYVM_OSTYPE, RTGETOPT_REQ_STRING },
|
---|
165 | { "--memory", MODIFYVM_MEMORY, RTGETOPT_REQ_UINT32 },
|
---|
166 | { "--vram", MODIFYVM_VRAM, RTGETOPT_REQ_UINT32 },
|
---|
167 | { "--firmware", MODIFYVM_FIRMWARE, RTGETOPT_REQ_STRING },
|
---|
168 | { "--acpi", MODIFYVM_ACPI, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
169 | { "--ioapic", MODIFYVM_IOAPIC, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
170 | { "--pae", MODIFYVM_PAE, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
171 | { "--synthcpu", MODIFYVM_SYNTHCPU, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
172 | { "--hwvirtex", MODIFYVM_HWVIRTEX, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
173 | { "--hwvirtexexcl", MODIFYVM_HWVIRTEXEXCLUSIVE, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
174 | { "--nestedpaging", MODIFYVM_NESTEDPAGING, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
175 | { "--largepages", MODIFYVM_LARGEPAGES, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
176 | { "--vtxvpid", MODIFYVM_VTXVPID, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
177 | { "--cpuidset", MODIFYVM_SETCPUID, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX},
|
---|
178 | { "--cpuidremove", MODIFYVM_DELCPUID, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX},
|
---|
179 | { "--cpuidremoveall", MODIFYVM_DELALLCPUID, RTGETOPT_REQ_NOTHING},
|
---|
180 | { "--cpus", MODIFYVM_CPUS, RTGETOPT_REQ_UINT32 },
|
---|
181 | { "--cpuhotplug", MODIFYVM_CPUHOTPLUG, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
182 | { "--plugcpu", MODIFYVM_PLUGCPU, RTGETOPT_REQ_UINT32 },
|
---|
183 | { "--unplugcpu", MODIFYVM_UNPLUGCPU, RTGETOPT_REQ_UINT32 },
|
---|
184 | { "--rtcuseutc", MODIFYVM_RTCUSEUTC, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
185 | { "--monitorcount", MODIFYVM_MONITORCOUNT, RTGETOPT_REQ_UINT32 },
|
---|
186 | { "--accelerate3d", MODIFYVM_ACCELERATE3D, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
187 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
188 | { "--accelerate2dvideo", MODIFYVM_ACCELERATE2DVIDEO, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
189 | #endif
|
---|
190 | { "--bioslogofadein", MODIFYVM_BIOSLOGOFADEIN, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
191 | { "--bioslogofadeout", MODIFYVM_BIOSLOGOFADEOUT, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
192 | { "--bioslogodisplaytime", MODIFYVM_BIOSLOGODISPLAYTIME, RTGETOPT_REQ_UINT32 },
|
---|
193 | { "--bioslogoimagepath", MODIFYVM_BIOSLOGOIMAGEPATH, RTGETOPT_REQ_STRING },
|
---|
194 | { "--biosbootmenu", MODIFYVM_BIOSBOOTMENU, RTGETOPT_REQ_STRING },
|
---|
195 | { "--biossystemtimeoffset", MODIFYVM_BIOSSYSTEMTIMEOFFSET, RTGETOPT_REQ_INT64 },
|
---|
196 | { "--biospxedebug", MODIFYVM_BIOSPXEDEBUG, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
197 | { "--boot", MODIFYVM_BOOT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
198 | { "--hda", MODIFYVM_HDA, RTGETOPT_REQ_STRING },
|
---|
199 | { "--hdb", MODIFYVM_HDB, RTGETOPT_REQ_STRING },
|
---|
200 | { "--hdd", MODIFYVM_HDD, RTGETOPT_REQ_STRING },
|
---|
201 | { "--idecontroller", MODIFYVM_IDECONTROLLER, RTGETOPT_REQ_STRING },
|
---|
202 | { "--sataideemulation", MODIFYVM_SATAIDEEMULATION, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
|
---|
203 | { "--sataportcount", MODIFYVM_SATAPORTCOUNT, RTGETOPT_REQ_UINT32 },
|
---|
204 | { "--sataport", MODIFYVM_SATAPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
205 | { "--sata", MODIFYVM_SATA, RTGETOPT_REQ_STRING },
|
---|
206 | { "--scsiport", MODIFYVM_SCSIPORT, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
207 | { "--scsitype", MODIFYVM_SCSITYPE, RTGETOPT_REQ_STRING },
|
---|
208 | { "--scsi", MODIFYVM_SCSI, RTGETOPT_REQ_STRING },
|
---|
209 | { "--dvdpassthrough", MODIFYVM_DVDPASSTHROUGH, RTGETOPT_REQ_STRING },
|
---|
210 | { "--dvd", MODIFYVM_DVD, RTGETOPT_REQ_STRING },
|
---|
211 | { "--floppy", MODIFYVM_FLOPPY, RTGETOPT_REQ_STRING },
|
---|
212 | { "--nictracefile", MODIFYVM_NICTRACEFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
213 | { "--nictrace", MODIFYVM_NICTRACE, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
|
---|
214 | { "--nictype", MODIFYVM_NICTYPE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
215 | { "--nicspeed", MODIFYVM_NICSPEED, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
|
---|
216 | { "--nicbootprio", MODIFYVM_NICBOOTPRIO, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX },
|
---|
217 | { "--nic", MODIFYVM_NIC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
218 | { "--cableconnected", MODIFYVM_CABLECONNECTED, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
|
---|
219 | { "--bridgeadapter", MODIFYVM_BRIDGEADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
220 | { "--hostonlyadapter", MODIFYVM_HOSTONLYADAPTER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
221 | { "--intnet", MODIFYVM_INTNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
222 | { "--natnet", MODIFYVM_NATNET, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
223 | { "--natbindip", MODIFYVM_NATBINDIP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
224 | { "--natsettings", MODIFYVM_NATSETTINGS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
225 | { "--natpf", MODIFYVM_NATPF, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
226 | { "--nattftpprefix", MODIFYVM_NATTFTPPREFIX, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
227 | { "--nattftpfile", MODIFYVM_NATTFTPFILE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
228 | { "--nattftpserver", MODIFYVM_NATTFTPSERVER, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
229 | { "--natdnspassdomain", MODIFYVM_NATDNSPASSDOMAIN, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
|
---|
230 | { "--natdnsproxy", MODIFYVM_NATDNSPROXY, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
|
---|
231 | { "--natdnshostresolver", MODIFYVM_NATDNSHOSTRESOLVER, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
|
---|
232 | { "--macaddress", MODIFYVM_MACADDRESS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
233 | { "--mouse", MODIFYVM_HIDPTR, RTGETOPT_REQ_STRING },
|
---|
234 | { "--keyboard", MODIFYVM_HIDKBD, RTGETOPT_REQ_STRING },
|
---|
235 | { "--uartmode", MODIFYVM_UARTMODE, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
236 | { "--uart", MODIFYVM_UART, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
|
---|
237 | { "--guestmemoryballoon", MODIFYVM_GUESTMEMORYBALLOON, RTGETOPT_REQ_UINT32 },
|
---|
238 | { "--audiocontroller", MODIFYVM_AUDIOCONTROLLER, RTGETOPT_REQ_STRING },
|
---|
239 | { "--audio", MODIFYVM_AUDIO, RTGETOPT_REQ_STRING },
|
---|
240 | { "--clipboard", MODIFYVM_CLIPBOARD, RTGETOPT_REQ_STRING },
|
---|
241 | #ifdef VBOX_WITH_VRDP
|
---|
242 | { "--vrdpport", MODIFYVM_VRDPPORT, RTGETOPT_REQ_STRING },
|
---|
243 | { "--vrdpaddress", MODIFYVM_VRDPADDRESS, RTGETOPT_REQ_STRING },
|
---|
244 | { "--vrdpauthtype", MODIFYVM_VRDPAUTHTYPE, RTGETOPT_REQ_STRING },
|
---|
245 | { "--vrdpmulticon", MODIFYVM_VRDPMULTICON, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
246 | { "--vrdpreusecon", MODIFYVM_VRDPREUSECON, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
247 | { "--vrdp", MODIFYVM_VRDP, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
248 | #endif
|
---|
249 | { "--usbehci", MODIFYVM_USBEHCI, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
250 | { "--usb", MODIFYVM_USB, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
251 | { "--snapshotfolder", MODIFYVM_SNAPSHOTFOLDER, RTGETOPT_REQ_STRING },
|
---|
252 | { "--teleporter", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
253 | { "--teleporterenabled", MODIFYVM_TELEPORTER_ENABLED, RTGETOPT_REQ_BOOL_ONOFF }, /* deprecated */
|
---|
254 | { "--teleporterport", MODIFYVM_TELEPORTER_PORT, RTGETOPT_REQ_UINT32 },
|
---|
255 | { "--teleporteraddress", MODIFYVM_TELEPORTER_ADDRESS, RTGETOPT_REQ_STRING },
|
---|
256 | { "--teleporterpassword", MODIFYVM_TELEPORTER_PASSWORD, RTGETOPT_REQ_STRING },
|
---|
257 | { "--hardwareuuid", MODIFYVM_HARDWARE_UUID, RTGETOPT_REQ_STRING },
|
---|
258 | { "--hpet", MODIFYVM_HPET, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
259 | { "--iomgr", MODIFYVM_IOMGR, RTGETOPT_REQ_STRING },
|
---|
260 | { "--iobackend", MODIFYVM_IOBACKEND, RTGETOPT_REQ_STRING },
|
---|
261 | { "--iocache", MODIFYVM_IOCACHE, RTGETOPT_REQ_BOOL_ONOFF },
|
---|
262 | { "--iocachesize", MODIFYVM_IOCACHESIZE, RTGETOPT_REQ_UINT32 },
|
---|
263 | { "--iobandwidthmax", MODIFYVM_IOBANDWIDTHMAX, RTGETOPT_REQ_UINT32 },
|
---|
264 | };
|
---|
265 |
|
---|
266 | int handleModifyVM(HandlerArg *a)
|
---|
267 | {
|
---|
268 | int c;
|
---|
269 | HRESULT rc;
|
---|
270 | Bstr name;
|
---|
271 | Bstr machineuuid (a->argv[0]);
|
---|
272 | RTGETOPTUNION ValueUnion;
|
---|
273 | RTGETOPTSTATE GetOptState;
|
---|
274 | ComPtr <IMachine> machine;
|
---|
275 | ComPtr <IBIOSSettings> biosSettings;
|
---|
276 |
|
---|
277 | /* VM ID + at least one parameter. Parameter arguments are checked
|
---|
278 | * individually. */
|
---|
279 | if (a->argc < 2)
|
---|
280 | return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
|
---|
281 |
|
---|
282 | /* Get the number of network adapters */
|
---|
283 | ULONG NetworkAdapterCount = 0;
|
---|
284 | {
|
---|
285 | ComPtr <ISystemProperties> info;
|
---|
286 | CHECK_ERROR_RET(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()), 1);
|
---|
287 | CHECK_ERROR_RET(info, COMGETTER(NetworkAdapterCount)(&NetworkAdapterCount), 1);
|
---|
288 | }
|
---|
289 | ULONG SerialPortCount = 0;
|
---|
290 | {
|
---|
291 | ComPtr <ISystemProperties> info;
|
---|
292 | CHECK_ERROR_RET(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()), 1);
|
---|
293 | CHECK_ERROR_RET(info, COMGETTER(SerialPortCount)(&SerialPortCount), 1);
|
---|
294 | }
|
---|
295 |
|
---|
296 | /* try to find the given machine */
|
---|
297 | if (!Guid(machineuuid).isEmpty())
|
---|
298 | {
|
---|
299 | CHECK_ERROR_RET(a->virtualBox, GetMachine(machineuuid, machine.asOutParam()), 1);
|
---|
300 | }
|
---|
301 | else
|
---|
302 | {
|
---|
303 | CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()), 1);
|
---|
304 | machine->COMGETTER(Id)(machineuuid.asOutParam());
|
---|
305 | }
|
---|
306 |
|
---|
307 | /* open a session for the VM */
|
---|
308 | CHECK_ERROR_RET(a->virtualBox, OpenSession(a->session, machineuuid), 1);
|
---|
309 |
|
---|
310 | /* get the mutable session machine */
|
---|
311 | a->session->COMGETTER(Machine)(machine.asOutParam());
|
---|
312 | machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
|
---|
313 |
|
---|
314 | RTGetOptInit(&GetOptState, a->argc, a->argv, g_aModifyVMOptions,
|
---|
315 | RT_ELEMENTS(g_aModifyVMOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
|
---|
316 |
|
---|
317 | while ( SUCCEEDED (rc)
|
---|
318 | && (c = RTGetOpt(&GetOptState, &ValueUnion)))
|
---|
319 | {
|
---|
320 | switch (c)
|
---|
321 | {
|
---|
322 | case MODIFYVM_NAME:
|
---|
323 | {
|
---|
324 | CHECK_ERROR(machine, COMSETTER(Name)(Bstr(ValueUnion.psz)));
|
---|
325 | break;
|
---|
326 | }
|
---|
327 | case MODIFYVM_OSTYPE:
|
---|
328 | {
|
---|
329 | ComPtr<IGuestOSType> guestOSType;
|
---|
330 | CHECK_ERROR(a->virtualBox, GetGuestOSType(Bstr(ValueUnion.psz), guestOSType.asOutParam()));
|
---|
331 | if (SUCCEEDED(rc) && guestOSType)
|
---|
332 | {
|
---|
333 | CHECK_ERROR(machine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz)));
|
---|
334 | }
|
---|
335 | else
|
---|
336 | {
|
---|
337 | errorArgument("Invalid guest OS type '%s'", Utf8Str(ValueUnion.psz).raw());
|
---|
338 | rc = E_FAIL;
|
---|
339 | }
|
---|
340 | break;
|
---|
341 | }
|
---|
342 |
|
---|
343 | case MODIFYVM_MEMORY:
|
---|
344 | {
|
---|
345 | CHECK_ERROR(machine, COMSETTER(MemorySize)(ValueUnion.u32));
|
---|
346 | break;
|
---|
347 | }
|
---|
348 |
|
---|
349 | case MODIFYVM_VRAM:
|
---|
350 | {
|
---|
351 | CHECK_ERROR(machine, COMSETTER(VRAMSize)(ValueUnion.u32));
|
---|
352 | break;
|
---|
353 | }
|
---|
354 |
|
---|
355 | case MODIFYVM_FIRMWARE:
|
---|
356 | {
|
---|
357 | if (!strcmp(ValueUnion.psz, "efi"))
|
---|
358 | {
|
---|
359 | CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI));
|
---|
360 | }
|
---|
361 | else if (!strcmp(ValueUnion.psz, "efi32"))
|
---|
362 | {
|
---|
363 | CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI32));
|
---|
364 | }
|
---|
365 | else if (!strcmp(ValueUnion.psz, "efi64"))
|
---|
366 | {
|
---|
367 | CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI64));
|
---|
368 | }
|
---|
369 | else if (!strcmp(ValueUnion.psz, "efidual"))
|
---|
370 | {
|
---|
371 | CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFIDUAL));
|
---|
372 | }
|
---|
373 | else if (!strcmp(ValueUnion.psz, "bios"))
|
---|
374 | {
|
---|
375 | CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_BIOS));
|
---|
376 | }
|
---|
377 | else
|
---|
378 | {
|
---|
379 | errorArgument("Invalid --firmware argument '%s'", ValueUnion.psz);
|
---|
380 | rc = E_FAIL;
|
---|
381 | }
|
---|
382 | break;
|
---|
383 | }
|
---|
384 |
|
---|
385 | case MODIFYVM_ACPI:
|
---|
386 | {
|
---|
387 | CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(ValueUnion.f));
|
---|
388 | break;
|
---|
389 | }
|
---|
390 |
|
---|
391 | case MODIFYVM_IOAPIC:
|
---|
392 | {
|
---|
393 | CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(ValueUnion.f));
|
---|
394 | break;
|
---|
395 | }
|
---|
396 |
|
---|
397 | case MODIFYVM_PAE:
|
---|
398 | {
|
---|
399 | CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_PAE, ValueUnion.f));
|
---|
400 | break;
|
---|
401 | }
|
---|
402 |
|
---|
403 | case MODIFYVM_SYNTHCPU:
|
---|
404 | {
|
---|
405 | CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_Synthetic, ValueUnion.f));
|
---|
406 | break;
|
---|
407 | }
|
---|
408 |
|
---|
409 | case MODIFYVM_HWVIRTEX:
|
---|
410 | {
|
---|
411 | CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_Enabled, ValueUnion.f));
|
---|
412 | break;
|
---|
413 | }
|
---|
414 |
|
---|
415 | case MODIFYVM_HWVIRTEXEXCLUSIVE:
|
---|
416 | {
|
---|
417 | CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_Exclusive, ValueUnion.f));
|
---|
418 | break;
|
---|
419 | }
|
---|
420 |
|
---|
421 | case MODIFYVM_SETCPUID:
|
---|
422 | {
|
---|
423 | uint32_t id = ValueUnion.u32;
|
---|
424 | uint32_t aValue[4];
|
---|
425 |
|
---|
426 | for (unsigned i = 0 ; i < 4 ; i++)
|
---|
427 | {
|
---|
428 | int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_HEX);
|
---|
429 | if (RT_FAILURE(vrc))
|
---|
430 | return errorSyntax(USAGE_MODIFYVM,
|
---|
431 | "Missing or Invalid argument to '%s'",
|
---|
432 | GetOptState.pDef->pszLong);
|
---|
433 | aValue[i] = ValueUnion.u32;
|
---|
434 | }
|
---|
435 | CHECK_ERROR(machine, SetCPUIDLeaf(id, aValue[0], aValue[1], aValue[2], aValue[3]));
|
---|
436 | break;
|
---|
437 | }
|
---|
438 |
|
---|
439 | case MODIFYVM_DELCPUID:
|
---|
440 | {
|
---|
441 | CHECK_ERROR(machine, RemoveCPUIDLeaf(ValueUnion.u32));
|
---|
442 | break;
|
---|
443 | }
|
---|
444 |
|
---|
445 | case MODIFYVM_DELALLCPUID:
|
---|
446 | {
|
---|
447 | CHECK_ERROR(machine, RemoveAllCPUIDLeaves());
|
---|
448 | break;
|
---|
449 | }
|
---|
450 |
|
---|
451 | case MODIFYVM_NESTEDPAGING:
|
---|
452 | {
|
---|
453 | CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, ValueUnion.f));
|
---|
454 | break;
|
---|
455 | }
|
---|
456 |
|
---|
457 | case MODIFYVM_LARGEPAGES:
|
---|
458 | {
|
---|
459 | CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_LargePages, ValueUnion.f));
|
---|
460 | break;
|
---|
461 | }
|
---|
462 |
|
---|
463 | case MODIFYVM_VTXVPID:
|
---|
464 | {
|
---|
465 | CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_VPID, ValueUnion.f));
|
---|
466 | break;
|
---|
467 | }
|
---|
468 |
|
---|
469 | case MODIFYVM_CPUS:
|
---|
470 | {
|
---|
471 | CHECK_ERROR(machine, COMSETTER(CPUCount)(ValueUnion.u32));
|
---|
472 | break;
|
---|
473 | }
|
---|
474 |
|
---|
475 | case MODIFYVM_RTCUSEUTC:
|
---|
476 | {
|
---|
477 | CHECK_ERROR(machine, COMSETTER(RTCUseUTC)(ValueUnion.f));
|
---|
478 | break;
|
---|
479 | }
|
---|
480 |
|
---|
481 | case MODIFYVM_CPUHOTPLUG:
|
---|
482 | {
|
---|
483 | CHECK_ERROR(machine, COMSETTER(CPUHotPlugEnabled)(ValueUnion.f));
|
---|
484 | break;
|
---|
485 | }
|
---|
486 |
|
---|
487 | case MODIFYVM_PLUGCPU:
|
---|
488 | {
|
---|
489 | CHECK_ERROR(machine, HotPlugCPU(ValueUnion.u32));
|
---|
490 | break;
|
---|
491 | }
|
---|
492 |
|
---|
493 | case MODIFYVM_UNPLUGCPU:
|
---|
494 | {
|
---|
495 | CHECK_ERROR(machine, HotUnplugCPU(ValueUnion.u32));
|
---|
496 | break;
|
---|
497 | }
|
---|
498 |
|
---|
499 | case MODIFYVM_MONITORCOUNT:
|
---|
500 | {
|
---|
501 | CHECK_ERROR(machine, COMSETTER(MonitorCount)(ValueUnion.u32));
|
---|
502 | break;
|
---|
503 | }
|
---|
504 |
|
---|
505 | case MODIFYVM_ACCELERATE3D:
|
---|
506 | {
|
---|
507 | CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(ValueUnion.f));
|
---|
508 | break;
|
---|
509 | }
|
---|
510 |
|
---|
511 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
512 | case MODIFYVM_ACCELERATE2DVIDEO:
|
---|
513 | {
|
---|
514 | CHECK_ERROR(machine, COMSETTER(Accelerate2DVideoEnabled)(ValueUnion.f));
|
---|
515 | break;
|
---|
516 | }
|
---|
517 | #endif
|
---|
518 |
|
---|
519 | case MODIFYVM_BIOSLOGOFADEIN:
|
---|
520 | {
|
---|
521 | CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(ValueUnion.f));
|
---|
522 | break;
|
---|
523 | }
|
---|
524 |
|
---|
525 | case MODIFYVM_BIOSLOGOFADEOUT:
|
---|
526 | {
|
---|
527 | CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(ValueUnion.f));
|
---|
528 | break;
|
---|
529 | }
|
---|
530 |
|
---|
531 | case MODIFYVM_BIOSLOGODISPLAYTIME:
|
---|
532 | {
|
---|
533 | CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(ValueUnion.u32));
|
---|
534 | break;
|
---|
535 | }
|
---|
536 |
|
---|
537 | case MODIFYVM_BIOSLOGOIMAGEPATH:
|
---|
538 | {
|
---|
539 | CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(ValueUnion.psz)));
|
---|
540 | break;
|
---|
541 | }
|
---|
542 |
|
---|
543 | case MODIFYVM_BIOSBOOTMENU:
|
---|
544 | {
|
---|
545 | if (!strcmp(ValueUnion.psz, "disabled"))
|
---|
546 | {
|
---|
547 | CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled));
|
---|
548 | }
|
---|
549 | else if (!strcmp(ValueUnion.psz, "menuonly"))
|
---|
550 | {
|
---|
551 | CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly));
|
---|
552 | }
|
---|
553 | else if (!strcmp(ValueUnion.psz, "messageandmenu"))
|
---|
554 | {
|
---|
555 | CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu));
|
---|
556 | }
|
---|
557 | else
|
---|
558 | {
|
---|
559 | errorArgument("Invalid --biosbootmenu argument '%s'", ValueUnion.psz);
|
---|
560 | rc = E_FAIL;
|
---|
561 | }
|
---|
562 | break;
|
---|
563 | }
|
---|
564 |
|
---|
565 | case MODIFYVM_BIOSSYSTEMTIMEOFFSET:
|
---|
566 | {
|
---|
567 | CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(ValueUnion.i64));
|
---|
568 | break;
|
---|
569 | }
|
---|
570 |
|
---|
571 | case MODIFYVM_BIOSPXEDEBUG:
|
---|
572 | {
|
---|
573 | CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(ValueUnion.f));
|
---|
574 | break;
|
---|
575 | }
|
---|
576 |
|
---|
577 | case MODIFYVM_BOOT:
|
---|
578 | {
|
---|
579 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
580 | {
|
---|
581 | CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Null));
|
---|
582 | }
|
---|
583 | else if (!strcmp(ValueUnion.psz, "floppy"))
|
---|
584 | {
|
---|
585 | CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Floppy));
|
---|
586 | }
|
---|
587 | else if (!strcmp(ValueUnion.psz, "dvd"))
|
---|
588 | {
|
---|
589 | CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_DVD));
|
---|
590 | }
|
---|
591 | else if (!strcmp(ValueUnion.psz, "disk"))
|
---|
592 | {
|
---|
593 | CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_HardDisk));
|
---|
594 | }
|
---|
595 | else if (!strcmp(ValueUnion.psz, "net"))
|
---|
596 | {
|
---|
597 | CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Network));
|
---|
598 | }
|
---|
599 | else
|
---|
600 | return errorArgument("Invalid boot device '%s'", ValueUnion.psz);
|
---|
601 | break;
|
---|
602 | }
|
---|
603 |
|
---|
604 | case MODIFYVM_HDA: // deprecated
|
---|
605 | {
|
---|
606 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
607 | {
|
---|
608 | machine->DetachDevice(Bstr("IDE Controller"), 0, 0);
|
---|
609 | }
|
---|
610 | else
|
---|
611 | {
|
---|
612 | /* first guess is that it's a UUID */
|
---|
613 | Bstr uuid(ValueUnion.psz);
|
---|
614 | ComPtr<IMedium> hardDisk;
|
---|
615 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
616 | /* not successful? Then it must be a filename */
|
---|
617 | if (!hardDisk)
|
---|
618 | {
|
---|
619 | rc = a->virtualBox->FindHardDisk(Bstr(ValueUnion.psz), hardDisk.asOutParam());
|
---|
620 | if (FAILED(rc))
|
---|
621 | {
|
---|
622 | /* open the new hard disk object */
|
---|
623 | CHECK_ERROR(a->virtualBox,
|
---|
624 | OpenHardDisk(Bstr(ValueUnion.psz),
|
---|
625 | AccessMode_ReadWrite, false, Bstr(""),
|
---|
626 | false, Bstr(""), hardDisk.asOutParam()));
|
---|
627 | }
|
---|
628 | }
|
---|
629 | if (hardDisk)
|
---|
630 | {
|
---|
631 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
632 | CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 0, 0, DeviceType_HardDisk, uuid));
|
---|
633 | }
|
---|
634 | else
|
---|
635 | rc = E_FAIL;
|
---|
636 | }
|
---|
637 | break;
|
---|
638 | }
|
---|
639 |
|
---|
640 | case MODIFYVM_HDB: // deprecated
|
---|
641 | {
|
---|
642 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
643 | {
|
---|
644 | machine->DetachDevice(Bstr("IDE Controller"), 0, 1);
|
---|
645 | }
|
---|
646 | else
|
---|
647 | {
|
---|
648 | /* first guess is that it's a UUID */
|
---|
649 | Bstr uuid(ValueUnion.psz);
|
---|
650 | ComPtr<IMedium> hardDisk;
|
---|
651 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
652 | /* not successful? Then it must be a filename */
|
---|
653 | if (!hardDisk)
|
---|
654 | {
|
---|
655 | rc = a->virtualBox->FindHardDisk(Bstr(ValueUnion.psz), hardDisk.asOutParam());
|
---|
656 | if (FAILED(rc))
|
---|
657 | {
|
---|
658 | /* open the new hard disk object */
|
---|
659 | CHECK_ERROR(a->virtualBox,
|
---|
660 | OpenHardDisk(Bstr(ValueUnion.psz),
|
---|
661 | AccessMode_ReadWrite, false, Bstr(""),
|
---|
662 | false, Bstr(""), hardDisk.asOutParam()));
|
---|
663 | }
|
---|
664 | }
|
---|
665 | if (hardDisk)
|
---|
666 | {
|
---|
667 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
668 | CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 0, 1, DeviceType_HardDisk, uuid));
|
---|
669 | }
|
---|
670 | else
|
---|
671 | rc = E_FAIL;
|
---|
672 | }
|
---|
673 | break;
|
---|
674 | }
|
---|
675 |
|
---|
676 | case MODIFYVM_HDD: // deprecated
|
---|
677 | {
|
---|
678 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
679 | {
|
---|
680 | machine->DetachDevice(Bstr("IDE Controller"), 1, 1);
|
---|
681 | }
|
---|
682 | else
|
---|
683 | {
|
---|
684 | /* first guess is that it's a UUID */
|
---|
685 | Bstr uuid(ValueUnion.psz);
|
---|
686 | ComPtr<IMedium> hardDisk;
|
---|
687 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
688 | /* not successful? Then it must be a filename */
|
---|
689 | if (!hardDisk)
|
---|
690 | {
|
---|
691 | rc = a->virtualBox->FindHardDisk(Bstr(ValueUnion.psz), hardDisk.asOutParam());
|
---|
692 | if (FAILED(rc))
|
---|
693 | {
|
---|
694 | /* open the new hard disk object */
|
---|
695 | CHECK_ERROR(a->virtualBox,
|
---|
696 | OpenHardDisk(Bstr(ValueUnion.psz),
|
---|
697 | AccessMode_ReadWrite, false, Bstr(""),
|
---|
698 | false, Bstr(""), hardDisk.asOutParam()));
|
---|
699 | }
|
---|
700 | }
|
---|
701 | if (hardDisk)
|
---|
702 | {
|
---|
703 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
704 | CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 1, 1, DeviceType_HardDisk, uuid));
|
---|
705 | }
|
---|
706 | else
|
---|
707 | rc = E_FAIL;
|
---|
708 | }
|
---|
709 | break;
|
---|
710 | }
|
---|
711 |
|
---|
712 | case MODIFYVM_IDECONTROLLER: // deprecated
|
---|
713 | {
|
---|
714 | ComPtr<IStorageController> storageController;
|
---|
715 | CHECK_ERROR(machine, GetStorageControllerByName(Bstr("IDE Controller"),
|
---|
716 | storageController.asOutParam()));
|
---|
717 |
|
---|
718 | if (!RTStrICmp(ValueUnion.psz, "PIIX3"))
|
---|
719 | {
|
---|
720 | CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX3));
|
---|
721 | }
|
---|
722 | else if (!RTStrICmp(ValueUnion.psz, "PIIX4"))
|
---|
723 | {
|
---|
724 | CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_PIIX4));
|
---|
725 | }
|
---|
726 | else if (!RTStrICmp(ValueUnion.psz, "ICH6"))
|
---|
727 | {
|
---|
728 | CHECK_ERROR(storageController, COMSETTER(ControllerType)(StorageControllerType_ICH6));
|
---|
729 | }
|
---|
730 | else
|
---|
731 | {
|
---|
732 | errorArgument("Invalid --idecontroller argument '%s'", ValueUnion.psz);
|
---|
733 | rc = E_FAIL;
|
---|
734 | }
|
---|
735 | break;
|
---|
736 | }
|
---|
737 |
|
---|
738 | case MODIFYVM_SATAIDEEMULATION: // deprecated
|
---|
739 | {
|
---|
740 | ComPtr<IStorageController> SataCtl;
|
---|
741 | CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam()));
|
---|
742 |
|
---|
743 | if (SUCCEEDED(rc))
|
---|
744 | CHECK_ERROR(SataCtl, SetIDEEmulationPort(GetOptState.uIndex, ValueUnion.u32));
|
---|
745 | break;
|
---|
746 | }
|
---|
747 |
|
---|
748 | case MODIFYVM_SATAPORTCOUNT: // deprecated
|
---|
749 | {
|
---|
750 | ComPtr<IStorageController> SataCtl;
|
---|
751 | CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam()));
|
---|
752 |
|
---|
753 | if (SUCCEEDED(rc) && ValueUnion.u32 > 0)
|
---|
754 | CHECK_ERROR(SataCtl, COMSETTER(PortCount)(ValueUnion.u32));
|
---|
755 | break;
|
---|
756 | }
|
---|
757 |
|
---|
758 | case MODIFYVM_SATAPORT: // deprecated
|
---|
759 | {
|
---|
760 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
761 | {
|
---|
762 | machine->DetachDevice(Bstr("SATA"), GetOptState.uIndex, 0);
|
---|
763 | }
|
---|
764 | else
|
---|
765 | {
|
---|
766 | /* first guess is that it's a UUID */
|
---|
767 | Bstr uuid(ValueUnion.psz);
|
---|
768 | ComPtr<IMedium> hardDisk;
|
---|
769 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
770 | /* not successful? Then it must be a filename */
|
---|
771 | if (!hardDisk)
|
---|
772 | {
|
---|
773 | rc = a->virtualBox->FindHardDisk(Bstr(ValueUnion.psz), hardDisk.asOutParam());
|
---|
774 | if (FAILED(rc))
|
---|
775 | {
|
---|
776 | /* open the new hard disk object */
|
---|
777 | CHECK_ERROR(a->virtualBox,
|
---|
778 | OpenHardDisk(Bstr(ValueUnion.psz), AccessMode_ReadWrite,
|
---|
779 | false, Bstr(""), false,
|
---|
780 | Bstr(""), hardDisk.asOutParam()));
|
---|
781 | }
|
---|
782 | }
|
---|
783 | if (hardDisk)
|
---|
784 | {
|
---|
785 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
786 | CHECK_ERROR(machine,
|
---|
787 | AttachDevice(Bstr("SATA"), GetOptState.uIndex,
|
---|
788 | 0, DeviceType_HardDisk, uuid));
|
---|
789 | }
|
---|
790 | else
|
---|
791 | rc = E_FAIL;
|
---|
792 | }
|
---|
793 | break;
|
---|
794 | }
|
---|
795 |
|
---|
796 | case MODIFYVM_SATA: // deprecated
|
---|
797 | {
|
---|
798 | if (!strcmp(ValueUnion.psz, "on") || !strcmp(ValueUnion.psz, "enable"))
|
---|
799 | {
|
---|
800 | ComPtr<IStorageController> ctl;
|
---|
801 | CHECK_ERROR(machine, AddStorageController(Bstr("SATA"), StorageBus_SATA, ctl.asOutParam()));
|
---|
802 | CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_IntelAhci));
|
---|
803 | }
|
---|
804 | else if (!strcmp(ValueUnion.psz, "off") || !strcmp(ValueUnion.psz, "disable"))
|
---|
805 | CHECK_ERROR(machine, RemoveStorageController(Bstr("SATA")));
|
---|
806 | else
|
---|
807 | return errorArgument("Invalid --usb argument '%s'", ValueUnion.psz);
|
---|
808 | break;
|
---|
809 | }
|
---|
810 |
|
---|
811 | case MODIFYVM_SCSIPORT: // deprecated
|
---|
812 | {
|
---|
813 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
814 | {
|
---|
815 | rc = machine->DetachDevice(Bstr("LsiLogic"), GetOptState.uIndex, 0);
|
---|
816 | if (FAILED(rc))
|
---|
817 | CHECK_ERROR(machine, DetachDevice(Bstr("BusLogic"), GetOptState.uIndex, 0));
|
---|
818 | }
|
---|
819 | else
|
---|
820 | {
|
---|
821 | /* first guess is that it's a UUID */
|
---|
822 | Bstr uuid(ValueUnion.psz);
|
---|
823 | ComPtr<IMedium> hardDisk;
|
---|
824 | rc = a->virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
|
---|
825 | /* not successful? Then it must be a filename */
|
---|
826 | if (!hardDisk)
|
---|
827 | {
|
---|
828 | rc = a->virtualBox->FindHardDisk(Bstr(ValueUnion.psz), hardDisk.asOutParam());
|
---|
829 | if (FAILED(rc))
|
---|
830 | {
|
---|
831 | /* open the new hard disk object */
|
---|
832 | CHECK_ERROR(a->virtualBox,
|
---|
833 | OpenHardDisk(Bstr(ValueUnion.psz),
|
---|
834 | AccessMode_ReadWrite, false, Bstr(""),
|
---|
835 | false, Bstr(""), hardDisk.asOutParam()));
|
---|
836 | }
|
---|
837 | }
|
---|
838 | if (hardDisk)
|
---|
839 | {
|
---|
840 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
841 | rc = machine->AttachDevice(Bstr("LsiLogic"), GetOptState.uIndex, 0, DeviceType_HardDisk, uuid);
|
---|
842 | if (FAILED(rc))
|
---|
843 | CHECK_ERROR(machine,
|
---|
844 | AttachDevice(Bstr("BusLogic"),
|
---|
845 | GetOptState.uIndex, 0,
|
---|
846 | DeviceType_HardDisk, uuid));
|
---|
847 | }
|
---|
848 | else
|
---|
849 | rc = E_FAIL;
|
---|
850 | }
|
---|
851 | break;
|
---|
852 | }
|
---|
853 |
|
---|
854 | case MODIFYVM_SCSITYPE: // deprecated
|
---|
855 | {
|
---|
856 | ComPtr<IStorageController> ctl;
|
---|
857 |
|
---|
858 | if (!RTStrICmp(ValueUnion.psz, "LsiLogic"))
|
---|
859 | {
|
---|
860 | rc = machine->RemoveStorageController(Bstr("BusLogic"));
|
---|
861 | if (FAILED(rc))
|
---|
862 | CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic")));
|
---|
863 |
|
---|
864 | CHECK_ERROR(machine,
|
---|
865 | AddStorageController(Bstr("LsiLogic"),
|
---|
866 | StorageBus_SCSI,
|
---|
867 | ctl.asOutParam()));
|
---|
868 |
|
---|
869 | if (SUCCEEDED(rc))
|
---|
870 | CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_LsiLogic));
|
---|
871 | }
|
---|
872 | else if (!RTStrICmp(ValueUnion.psz, "BusLogic"))
|
---|
873 | {
|
---|
874 | rc = machine->RemoveStorageController(Bstr("LsiLogic"));
|
---|
875 | if (FAILED(rc))
|
---|
876 | CHECK_ERROR(machine, RemoveStorageController(Bstr("BusLogic")));
|
---|
877 |
|
---|
878 | CHECK_ERROR(machine,
|
---|
879 | AddStorageController(Bstr("BusLogic"),
|
---|
880 | StorageBus_SCSI,
|
---|
881 | ctl.asOutParam()));
|
---|
882 |
|
---|
883 | if (SUCCEEDED(rc))
|
---|
884 | CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
|
---|
885 | }
|
---|
886 | else
|
---|
887 | return errorArgument("Invalid --scsitype argument '%s'", ValueUnion.psz);
|
---|
888 | break;
|
---|
889 | }
|
---|
890 |
|
---|
891 | case MODIFYVM_SCSI: // deprecated
|
---|
892 | {
|
---|
893 | if (!strcmp(ValueUnion.psz, "on") || !strcmp(ValueUnion.psz, "enable"))
|
---|
894 | {
|
---|
895 | ComPtr<IStorageController> ctl;
|
---|
896 |
|
---|
897 | CHECK_ERROR(machine, AddStorageController(Bstr("BusLogic"), StorageBus_SCSI, ctl.asOutParam()));
|
---|
898 | if (SUCCEEDED(rc))
|
---|
899 | CHECK_ERROR(ctl, COMSETTER(ControllerType)(StorageControllerType_BusLogic));
|
---|
900 | }
|
---|
901 | else if (!strcmp(ValueUnion.psz, "off") || !strcmp(ValueUnion.psz, "disable"))
|
---|
902 | {
|
---|
903 | rc = machine->RemoveStorageController(Bstr("BusLogic"));
|
---|
904 | if (FAILED(rc))
|
---|
905 | CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic")));
|
---|
906 | }
|
---|
907 | break;
|
---|
908 | }
|
---|
909 |
|
---|
910 | case MODIFYVM_DVDPASSTHROUGH: // deprecated
|
---|
911 | {
|
---|
912 | CHECK_ERROR(machine, PassthroughDevice(Bstr("IDE Controller"), 1, 0, !strcmp(ValueUnion.psz, "on")));
|
---|
913 | break;
|
---|
914 | }
|
---|
915 |
|
---|
916 | case MODIFYVM_DVD: // deprecated
|
---|
917 | {
|
---|
918 | ComPtr<IMedium> dvdMedium;
|
---|
919 | Bstr uuid(ValueUnion.psz);
|
---|
920 |
|
---|
921 | /* unmount? */
|
---|
922 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
923 | {
|
---|
924 | /* nothing to do, NULL object will cause unmount */
|
---|
925 | }
|
---|
926 | /* host drive? */
|
---|
927 | else if (!strncmp(ValueUnion.psz, "host:", 5))
|
---|
928 | {
|
---|
929 | ComPtr<IHost> host;
|
---|
930 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
931 | rc = host->FindHostDVDDrive(Bstr(ValueUnion.psz + 5), dvdMedium.asOutParam());
|
---|
932 | if (!dvdMedium)
|
---|
933 | {
|
---|
934 | /* 2nd try: try with the real name, important on Linux+libhal */
|
---|
935 | char szPathReal[RTPATH_MAX];
|
---|
936 | if (RT_FAILURE(RTPathReal(ValueUnion.psz + 5, szPathReal, sizeof(szPathReal))))
|
---|
937 | {
|
---|
938 | errorArgument("Invalid host DVD drive name \"%s\"", ValueUnion.psz + 5);
|
---|
939 | rc = E_FAIL;
|
---|
940 | break;
|
---|
941 | }
|
---|
942 | rc = host->FindHostDVDDrive(Bstr(szPathReal), dvdMedium.asOutParam());
|
---|
943 | if (!dvdMedium)
|
---|
944 | {
|
---|
945 | errorArgument("Invalid host DVD drive name \"%s\"", ValueUnion.psz + 5);
|
---|
946 | rc = E_FAIL;
|
---|
947 | break;
|
---|
948 | }
|
---|
949 | }
|
---|
950 | }
|
---|
951 | else
|
---|
952 | {
|
---|
953 | /* first assume it's a UUID */
|
---|
954 | rc = a->virtualBox->GetDVDImage(uuid, dvdMedium.asOutParam());
|
---|
955 | if (FAILED(rc) || !dvdMedium)
|
---|
956 | {
|
---|
957 | /* must be a filename, check if it's in the collection */
|
---|
958 | rc = a->virtualBox->FindDVDImage(Bstr(ValueUnion.psz), dvdMedium.asOutParam());
|
---|
959 | /* not registered, do that on the fly */
|
---|
960 | if (!dvdMedium)
|
---|
961 | {
|
---|
962 | Bstr emptyUUID;
|
---|
963 | CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(ValueUnion.psz),
|
---|
964 | emptyUUID, dvdMedium.asOutParam()));
|
---|
965 | }
|
---|
966 | }
|
---|
967 | if (!dvdMedium)
|
---|
968 | {
|
---|
969 | rc = E_FAIL;
|
---|
970 | break;
|
---|
971 | }
|
---|
972 | }
|
---|
973 |
|
---|
974 | /** @todo generalize this, allow arbitrary number of DVD drives
|
---|
975 | * and as a consequence multiple attachments and different
|
---|
976 | * storage controllers. */
|
---|
977 | if (dvdMedium)
|
---|
978 | dvdMedium->COMGETTER(Id)(uuid.asOutParam());
|
---|
979 | CHECK_ERROR(machine, MountMedium(Bstr("IDE Controller"), 1, 0, uuid, FALSE /* aForce */));
|
---|
980 | break;
|
---|
981 | }
|
---|
982 |
|
---|
983 | case MODIFYVM_FLOPPY: // deprecated
|
---|
984 | {
|
---|
985 | Bstr uuid(ValueUnion.psz);
|
---|
986 | ComPtr<IMedium> floppyMedium;
|
---|
987 | ComPtr<IMediumAttachment> floppyAttachment;
|
---|
988 | machine->GetMediumAttachment(Bstr("Floppy Controller"), 0, 0, floppyAttachment.asOutParam());
|
---|
989 |
|
---|
990 | /* disable? */
|
---|
991 | if (!strcmp(ValueUnion.psz, "disabled"))
|
---|
992 | {
|
---|
993 | /* disable the controller */
|
---|
994 | if (floppyAttachment)
|
---|
995 | CHECK_ERROR(machine, DetachDevice(Bstr("Floppy Controller"), 0, 0));
|
---|
996 | }
|
---|
997 | else
|
---|
998 | {
|
---|
999 | /* enable the controller */
|
---|
1000 | if (!floppyAttachment)
|
---|
1001 | CHECK_ERROR(machine, AttachDevice(Bstr("Floppy Controller"), 0, 0, DeviceType_Floppy, NULL));
|
---|
1002 |
|
---|
1003 | /* unmount? */
|
---|
1004 | if ( !strcmp(ValueUnion.psz, "none")
|
---|
1005 | || !strcmp(ValueUnion.psz, "empty")) // deprecated
|
---|
1006 | {
|
---|
1007 | /* nothing to do, NULL object will cause unmount */
|
---|
1008 | }
|
---|
1009 | /* host drive? */
|
---|
1010 | else if (!strncmp(ValueUnion.psz, "host:", 5))
|
---|
1011 | {
|
---|
1012 | ComPtr<IHost> host;
|
---|
1013 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1014 | rc = host->FindHostFloppyDrive(Bstr(ValueUnion.psz + 5), floppyMedium.asOutParam());
|
---|
1015 | if (!floppyMedium)
|
---|
1016 | {
|
---|
1017 | errorArgument("Invalid host floppy drive name \"%s\"", ValueUnion.psz + 5);
|
---|
1018 | rc = E_FAIL;
|
---|
1019 | break;
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 | else
|
---|
1023 | {
|
---|
1024 | /* first assume it's a UUID */
|
---|
1025 | rc = a->virtualBox->GetFloppyImage(uuid, floppyMedium.asOutParam());
|
---|
1026 | if (FAILED(rc) || !floppyMedium)
|
---|
1027 | {
|
---|
1028 | /* must be a filename, check if it's in the collection */
|
---|
1029 | rc = a->virtualBox->FindFloppyImage(Bstr(ValueUnion.psz), floppyMedium.asOutParam());
|
---|
1030 | /* not registered, do that on the fly */
|
---|
1031 | if (!floppyMedium)
|
---|
1032 | {
|
---|
1033 | Bstr emptyUUID;
|
---|
1034 | CHECK_ERROR(a->virtualBox,
|
---|
1035 | OpenFloppyImage(Bstr(ValueUnion.psz),
|
---|
1036 | emptyUUID,
|
---|
1037 | floppyMedium.asOutParam()));
|
---|
1038 | }
|
---|
1039 | }
|
---|
1040 | if (!floppyMedium)
|
---|
1041 | {
|
---|
1042 | rc = E_FAIL;
|
---|
1043 | break;
|
---|
1044 | }
|
---|
1045 | }
|
---|
1046 | floppyMedium->COMGETTER(Id)(uuid.asOutParam());
|
---|
1047 | CHECK_ERROR(machine, MountMedium(Bstr("Floppy Controller"), 0, 0, uuid, FALSE /* aForce */));
|
---|
1048 | }
|
---|
1049 | break;
|
---|
1050 | }
|
---|
1051 |
|
---|
1052 | case MODIFYVM_NICTRACEFILE:
|
---|
1053 | {
|
---|
1054 | ComPtr<INetworkAdapter> nic;
|
---|
1055 |
|
---|
1056 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1057 | ASSERT(nic);
|
---|
1058 |
|
---|
1059 | CHECK_ERROR(nic, COMSETTER(TraceFile)(Bstr(ValueUnion.psz)));
|
---|
1060 | break;
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | case MODIFYVM_NICTRACE:
|
---|
1064 | {
|
---|
1065 | ComPtr<INetworkAdapter> nic;
|
---|
1066 |
|
---|
1067 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1068 | ASSERT(nic);
|
---|
1069 |
|
---|
1070 | CHECK_ERROR(nic, COMSETTER(TraceEnabled)(ValueUnion.f));
|
---|
1071 | break;
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | case MODIFYVM_NICTYPE:
|
---|
1075 | {
|
---|
1076 | ComPtr<INetworkAdapter> nic;
|
---|
1077 |
|
---|
1078 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1079 | ASSERT(nic);
|
---|
1080 |
|
---|
1081 | if (!strcmp(ValueUnion.psz, "Am79C970A"))
|
---|
1082 | {
|
---|
1083 | CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C970A));
|
---|
1084 | }
|
---|
1085 | else if (!strcmp(ValueUnion.psz, "Am79C973"))
|
---|
1086 | {
|
---|
1087 | CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Am79C973));
|
---|
1088 | }
|
---|
1089 | #ifdef VBOX_WITH_E1000
|
---|
1090 | else if (!strcmp(ValueUnion.psz, "82540EM"))
|
---|
1091 | {
|
---|
1092 | CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82540EM));
|
---|
1093 | }
|
---|
1094 | else if (!strcmp(ValueUnion.psz, "82543GC"))
|
---|
1095 | {
|
---|
1096 | CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82543GC));
|
---|
1097 | }
|
---|
1098 | else if (!strcmp(ValueUnion.psz, "82545EM"))
|
---|
1099 | {
|
---|
1100 | CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_I82545EM));
|
---|
1101 | }
|
---|
1102 | #endif
|
---|
1103 | #ifdef VBOX_WITH_VIRTIO
|
---|
1104 | else if (!strcmp(ValueUnion.psz, "virtio"))
|
---|
1105 | {
|
---|
1106 | CHECK_ERROR(nic, COMSETTER(AdapterType)(NetworkAdapterType_Virtio));
|
---|
1107 | }
|
---|
1108 | #endif /* VBOX_WITH_VIRTIO */
|
---|
1109 | else
|
---|
1110 | {
|
---|
1111 | errorArgument("Invalid NIC type '%s' specified for NIC %u", ValueUnion.psz, GetOptState.uIndex);
|
---|
1112 | rc = E_FAIL;
|
---|
1113 | }
|
---|
1114 | break;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | case MODIFYVM_NICSPEED:
|
---|
1118 | {
|
---|
1119 | ComPtr<INetworkAdapter> nic;
|
---|
1120 |
|
---|
1121 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1122 | ASSERT(nic);
|
---|
1123 |
|
---|
1124 | CHECK_ERROR(nic, COMSETTER(LineSpeed)(ValueUnion.u32));
|
---|
1125 | break;
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | case MODIFYVM_NICBOOTPRIO:
|
---|
1129 | {
|
---|
1130 | ComPtr<INetworkAdapter> nic;
|
---|
1131 |
|
---|
1132 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1133 | ASSERT(nic);
|
---|
1134 |
|
---|
1135 | /* Somewhat arbitrary limitation - we can pass a list of up to 4 PCI devices
|
---|
1136 | * to the PXE ROM, hence only boot priorities 1-4 are allowed (in addition to
|
---|
1137 | * 0 for the default lowest priority).
|
---|
1138 | */
|
---|
1139 | if (ValueUnion.u32 > 4)
|
---|
1140 | {
|
---|
1141 | errorArgument("Invalid boot priority '%u' specfied for NIC %u", ValueUnion.u32, GetOptState.uIndex);
|
---|
1142 | rc = E_FAIL;
|
---|
1143 | }
|
---|
1144 | else
|
---|
1145 | {
|
---|
1146 | CHECK_ERROR(nic, COMSETTER(BootPriority)(ValueUnion.u32));
|
---|
1147 | }
|
---|
1148 | break;
|
---|
1149 | }
|
---|
1150 |
|
---|
1151 | case MODIFYVM_NIC:
|
---|
1152 | {
|
---|
1153 | ComPtr<INetworkAdapter> nic;
|
---|
1154 |
|
---|
1155 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1156 | ASSERT(nic);
|
---|
1157 |
|
---|
1158 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
1159 | {
|
---|
1160 | CHECK_ERROR(nic, COMSETTER(Enabled)(FALSE));
|
---|
1161 | }
|
---|
1162 | else if (!strcmp(ValueUnion.psz, "null"))
|
---|
1163 | {
|
---|
1164 | CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
|
---|
1165 | CHECK_ERROR(nic, Detach());
|
---|
1166 | }
|
---|
1167 | else if (!strcmp(ValueUnion.psz, "nat"))
|
---|
1168 | {
|
---|
1169 | CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
|
---|
1170 | CHECK_ERROR(nic, AttachToNAT());
|
---|
1171 | }
|
---|
1172 | else if ( !strcmp(ValueUnion.psz, "bridged")
|
---|
1173 | || !strcmp(ValueUnion.psz, "hostif")) /* backward compatibility */
|
---|
1174 | {
|
---|
1175 | CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
|
---|
1176 | CHECK_ERROR(nic, AttachToBridgedInterface());
|
---|
1177 | }
|
---|
1178 | else if (!strcmp(ValueUnion.psz, "intnet"))
|
---|
1179 | {
|
---|
1180 | CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
|
---|
1181 | CHECK_ERROR(nic, AttachToInternalNetwork());
|
---|
1182 | }
|
---|
1183 | #if defined(VBOX_WITH_NETFLT)
|
---|
1184 | else if (!strcmp(ValueUnion.psz, "hostonly"))
|
---|
1185 | {
|
---|
1186 |
|
---|
1187 | CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
|
---|
1188 | CHECK_ERROR(nic, AttachToHostOnlyInterface());
|
---|
1189 | }
|
---|
1190 | #endif
|
---|
1191 | else
|
---|
1192 | {
|
---|
1193 | errorArgument("Invalid type '%s' specfied for NIC %u", ValueUnion.psz, GetOptState.uIndex);
|
---|
1194 | rc = E_FAIL;
|
---|
1195 | }
|
---|
1196 | break;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | case MODIFYVM_CABLECONNECTED:
|
---|
1200 | {
|
---|
1201 | ComPtr<INetworkAdapter> nic;
|
---|
1202 |
|
---|
1203 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1204 | ASSERT(nic);
|
---|
1205 |
|
---|
1206 | CHECK_ERROR(nic, COMSETTER(CableConnected)(ValueUnion.f));
|
---|
1207 | break;
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | case MODIFYVM_BRIDGEADAPTER:
|
---|
1211 | case MODIFYVM_HOSTONLYADAPTER:
|
---|
1212 | {
|
---|
1213 | ComPtr<INetworkAdapter> nic;
|
---|
1214 |
|
---|
1215 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1216 | ASSERT(nic);
|
---|
1217 |
|
---|
1218 | /* remove it? */
|
---|
1219 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
1220 | {
|
---|
1221 | CHECK_ERROR(nic, COMSETTER(HostInterface)(NULL));
|
---|
1222 | }
|
---|
1223 | else
|
---|
1224 | {
|
---|
1225 | CHECK_ERROR(nic, COMSETTER(HostInterface)(Bstr(ValueUnion.psz)));
|
---|
1226 | }
|
---|
1227 | break;
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | case MODIFYVM_INTNET:
|
---|
1231 | {
|
---|
1232 | ComPtr<INetworkAdapter> nic;
|
---|
1233 |
|
---|
1234 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1235 | ASSERT(nic);
|
---|
1236 |
|
---|
1237 | /* remove it? */
|
---|
1238 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
1239 | {
|
---|
1240 | CHECK_ERROR(nic, COMSETTER(InternalNetwork)(NULL));
|
---|
1241 | }
|
---|
1242 | else
|
---|
1243 | {
|
---|
1244 | CHECK_ERROR(nic, COMSETTER(InternalNetwork)(Bstr(ValueUnion.psz)));
|
---|
1245 | }
|
---|
1246 | break;
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 | case MODIFYVM_NATNET:
|
---|
1250 | {
|
---|
1251 | ComPtr<INetworkAdapter> nic;
|
---|
1252 | ComPtr<INATEngine> driver;
|
---|
1253 |
|
---|
1254 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1255 | ASSERT(nic);
|
---|
1256 |
|
---|
1257 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1258 |
|
---|
1259 | const char *psz = ValueUnion.psz;
|
---|
1260 | if (!strcmp("default", psz))
|
---|
1261 | psz = "";
|
---|
1262 |
|
---|
1263 | CHECK_ERROR(driver, COMSETTER(Network)(Bstr(psz)));
|
---|
1264 | break;
|
---|
1265 | }
|
---|
1266 |
|
---|
1267 | case MODIFYVM_NATBINDIP:
|
---|
1268 | {
|
---|
1269 | ComPtr<INetworkAdapter> nic;
|
---|
1270 | ComPtr<INATEngine> driver;
|
---|
1271 |
|
---|
1272 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1273 | ASSERT(nic);
|
---|
1274 |
|
---|
1275 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1276 | CHECK_ERROR(driver, COMSETTER(HostIP)(Bstr(ValueUnion.psz)));
|
---|
1277 | break;
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 | #define ITERATE_TO_NEXT_TERM(ch) \
|
---|
1281 | do { \
|
---|
1282 | while (*ch != ',') \
|
---|
1283 | { \
|
---|
1284 | if (*ch == 0) \
|
---|
1285 | { \
|
---|
1286 | return errorSyntax(USAGE_MODIFYVM, \
|
---|
1287 | "Missing or Invalid argument to '%s'", \
|
---|
1288 | GetOptState.pDef->pszLong); \
|
---|
1289 | } \
|
---|
1290 | ch++; \
|
---|
1291 | } \
|
---|
1292 | *ch = '\0'; \
|
---|
1293 | ch++; \
|
---|
1294 | } while(0)
|
---|
1295 |
|
---|
1296 | case MODIFYVM_NATSETTINGS:
|
---|
1297 | {
|
---|
1298 | ComPtr<INetworkAdapter> nic;
|
---|
1299 | ComPtr<INATEngine> driver;
|
---|
1300 | char *strMtu;
|
---|
1301 | char *strSockSnd;
|
---|
1302 | char *strSockRcv;
|
---|
1303 | char *strTcpSnd;
|
---|
1304 | char *strTcpRcv;
|
---|
1305 | char *strRaw = RTStrDup(ValueUnion.psz);
|
---|
1306 | char *ch = strRaw;
|
---|
1307 | strMtu = RTStrStrip(ch);
|
---|
1308 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1309 | strSockSnd = RTStrStrip(ch);
|
---|
1310 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1311 | strSockRcv = RTStrStrip(ch);
|
---|
1312 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1313 | strTcpSnd = RTStrStrip(ch);
|
---|
1314 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1315 | strTcpRcv = RTStrStrip(ch);
|
---|
1316 |
|
---|
1317 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1318 | ASSERT(nic);
|
---|
1319 |
|
---|
1320 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1321 | CHECK_ERROR(driver, SetNetworkSettings(RTStrToUInt32(strMtu), RTStrToUInt32(strSockSnd), RTStrToUInt32(strSockRcv),
|
---|
1322 | RTStrToUInt32(strTcpSnd), RTStrToUInt32(strTcpRcv)));
|
---|
1323 | break;
|
---|
1324 | }
|
---|
1325 |
|
---|
1326 |
|
---|
1327 | case MODIFYVM_NATPF:
|
---|
1328 | {
|
---|
1329 | ComPtr<INetworkAdapter> nic;
|
---|
1330 | ComPtr<INATEngine> driver;
|
---|
1331 |
|
---|
1332 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1333 | ASSERT(nic);
|
---|
1334 |
|
---|
1335 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1336 | /* format name:proto:hostip:hostport:guestip:guestport*/
|
---|
1337 | if (RTStrCmp(ValueUnion.psz, "delete") != 0)
|
---|
1338 | {
|
---|
1339 | char *strName;
|
---|
1340 | char *strProto;
|
---|
1341 | char *strHostIp;
|
---|
1342 | char *strHostPort;
|
---|
1343 | char *strGuestIp;
|
---|
1344 | char *strGuestPort;
|
---|
1345 | char *strRaw = RTStrDup(ValueUnion.psz);
|
---|
1346 | char *ch = strRaw;
|
---|
1347 | strName = RTStrStrip(ch);
|
---|
1348 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1349 | strProto = RTStrStrip(ch);
|
---|
1350 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1351 | strHostIp = RTStrStrip(ch);
|
---|
1352 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1353 | strHostPort = RTStrStrip(ch);
|
---|
1354 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1355 | strGuestIp = RTStrStrip(ch);
|
---|
1356 | ITERATE_TO_NEXT_TERM(ch);
|
---|
1357 | strGuestPort = RTStrStrip(ch);
|
---|
1358 | NATProtocol_T proto;
|
---|
1359 | if (RTStrICmp(strProto, "udp") == 0)
|
---|
1360 | proto = NATProtocol_UDP;
|
---|
1361 | else if (RTStrICmp(strProto, "tcp") == 0)
|
---|
1362 | proto = NATProtocol_TCP;
|
---|
1363 | else
|
---|
1364 | {
|
---|
1365 | errorArgument("Invalid proto '%s' specfied for NIC %u", ValueUnion.psz, GetOptState.uIndex);
|
---|
1366 | rc = E_FAIL;
|
---|
1367 | break;
|
---|
1368 | }
|
---|
1369 | CHECK_ERROR(driver, AddRedirect(Bstr(strName), proto, Bstr(strHostIp),
|
---|
1370 | RTStrToUInt16(strHostPort), Bstr(strGuestIp), RTStrToUInt16(strGuestPort)));
|
---|
1371 | }
|
---|
1372 | else
|
---|
1373 | {
|
---|
1374 | /* delete NAT Rule operation */
|
---|
1375 | int vrc;
|
---|
1376 | vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
|
---|
1377 | if (RT_FAILURE(vrc))
|
---|
1378 | return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
|
---|
1379 | CHECK_ERROR(driver, RemoveRedirect(Bstr(ValueUnion.psz)));
|
---|
1380 | }
|
---|
1381 | break;
|
---|
1382 | }
|
---|
1383 | #undef ITERATE_TO_NEXT_TERM
|
---|
1384 |
|
---|
1385 | case MODIFYVM_NATTFTPPREFIX:
|
---|
1386 | {
|
---|
1387 | ComPtr<INetworkAdapter> nic;
|
---|
1388 | ComPtr<INATEngine> driver;
|
---|
1389 |
|
---|
1390 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1391 | ASSERT(nic);
|
---|
1392 |
|
---|
1393 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1394 | CHECK_ERROR(driver, COMSETTER(TftpPrefix)(Bstr(ValueUnion.psz)));
|
---|
1395 | break;
|
---|
1396 | }
|
---|
1397 |
|
---|
1398 | case MODIFYVM_NATTFTPFILE:
|
---|
1399 | {
|
---|
1400 | ComPtr<INetworkAdapter> nic;
|
---|
1401 | ComPtr<INATEngine> driver;
|
---|
1402 |
|
---|
1403 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1404 | ASSERT(nic);
|
---|
1405 |
|
---|
1406 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1407 | CHECK_ERROR(driver, COMSETTER(TftpBootFile)(Bstr(ValueUnion.psz)));
|
---|
1408 | break;
|
---|
1409 | }
|
---|
1410 |
|
---|
1411 | case MODIFYVM_NATTFTPSERVER:
|
---|
1412 | {
|
---|
1413 | ComPtr<INetworkAdapter> nic;
|
---|
1414 | ComPtr<INATEngine> driver;
|
---|
1415 |
|
---|
1416 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1417 | ASSERT(nic);
|
---|
1418 |
|
---|
1419 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1420 | CHECK_ERROR(driver, COMSETTER(TftpNextServer)(Bstr(ValueUnion.psz)));
|
---|
1421 | break;
|
---|
1422 | }
|
---|
1423 | case MODIFYVM_NATDNSPASSDOMAIN:
|
---|
1424 | {
|
---|
1425 | ComPtr<INetworkAdapter> nic;
|
---|
1426 | ComPtr<INATEngine> driver;
|
---|
1427 |
|
---|
1428 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1429 | ASSERT(nic);
|
---|
1430 |
|
---|
1431 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1432 | CHECK_ERROR(driver, COMSETTER(DnsPassDomain)(ValueUnion.f));
|
---|
1433 | break;
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | case MODIFYVM_NATDNSPROXY:
|
---|
1437 | {
|
---|
1438 | ComPtr<INetworkAdapter> nic;
|
---|
1439 | ComPtr<INATEngine> driver;
|
---|
1440 |
|
---|
1441 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1442 | ASSERT(nic);
|
---|
1443 |
|
---|
1444 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1445 | CHECK_ERROR(driver, COMSETTER(DnsProxy)(ValueUnion.f));
|
---|
1446 | break;
|
---|
1447 | }
|
---|
1448 |
|
---|
1449 | case MODIFYVM_NATDNSHOSTRESOLVER:
|
---|
1450 | {
|
---|
1451 | ComPtr<INetworkAdapter> nic;
|
---|
1452 | ComPtr<INATEngine> driver;
|
---|
1453 |
|
---|
1454 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1455 | ASSERT(nic);
|
---|
1456 |
|
---|
1457 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
1458 | CHECK_ERROR(driver, COMSETTER(DnsUseHostResolver)(ValueUnion.f));
|
---|
1459 | break;
|
---|
1460 | }
|
---|
1461 | case MODIFYVM_MACADDRESS:
|
---|
1462 | {
|
---|
1463 | ComPtr<INetworkAdapter> nic;
|
---|
1464 |
|
---|
1465 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
|
---|
1466 | ASSERT(nic);
|
---|
1467 |
|
---|
1468 | /* generate one? */
|
---|
1469 | if (!strcmp(ValueUnion.psz, "auto"))
|
---|
1470 | {
|
---|
1471 | CHECK_ERROR(nic, COMSETTER(MACAddress)(NULL));
|
---|
1472 | }
|
---|
1473 | else
|
---|
1474 | {
|
---|
1475 | CHECK_ERROR(nic, COMSETTER(MACAddress)(Bstr(ValueUnion.psz)));
|
---|
1476 | }
|
---|
1477 | break;
|
---|
1478 | }
|
---|
1479 |
|
---|
1480 | case MODIFYVM_HIDPTR:
|
---|
1481 | {
|
---|
1482 | bool fEnableUsb = false;
|
---|
1483 | if (!strcmp(ValueUnion.psz, "ps2"))
|
---|
1484 | {
|
---|
1485 | CHECK_ERROR(machine, COMSETTER(PointingHidType)(PointingHidType_PS2Mouse));
|
---|
1486 | }
|
---|
1487 | else if (!strcmp(ValueUnion.psz, "usb"))
|
---|
1488 | {
|
---|
1489 | CHECK_ERROR(machine, COMSETTER(PointingHidType)(PointingHidType_USBMouse));
|
---|
1490 | if (SUCCEEDED(rc))
|
---|
1491 | fEnableUsb = true;
|
---|
1492 | }
|
---|
1493 | else if (!strcmp(ValueUnion.psz, "usbtablet"))
|
---|
1494 | {
|
---|
1495 | CHECK_ERROR(machine, COMSETTER(PointingHidType)(PointingHidType_USBTablet));
|
---|
1496 | if (SUCCEEDED(rc))
|
---|
1497 | fEnableUsb = true;
|
---|
1498 | }
|
---|
1499 | else
|
---|
1500 | {
|
---|
1501 | errorArgument("Invalid type '%s' specfied for pointing device", ValueUnion.psz);
|
---|
1502 | rc = E_FAIL;
|
---|
1503 | }
|
---|
1504 | if (fEnableUsb)
|
---|
1505 | {
|
---|
1506 | /* Make sure the OHCI controller is enabled. */
|
---|
1507 | ComPtr<IUSBController> UsbCtl;
|
---|
1508 | rc = machine->COMGETTER(USBController)(UsbCtl.asOutParam());
|
---|
1509 | if (SUCCEEDED(rc))
|
---|
1510 | {
|
---|
1511 | BOOL fEnabled;
|
---|
1512 | rc = UsbCtl->COMGETTER(Enabled)(&fEnabled);
|
---|
1513 | if (FAILED(rc))
|
---|
1514 | fEnabled = false;
|
---|
1515 | if (!fEnabled)
|
---|
1516 | CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(true));
|
---|
1517 | }
|
---|
1518 | }
|
---|
1519 | break;
|
---|
1520 | }
|
---|
1521 |
|
---|
1522 | case MODIFYVM_HIDKBD:
|
---|
1523 | {
|
---|
1524 | bool fEnableUsb = false;
|
---|
1525 | if (!strcmp(ValueUnion.psz, "ps2"))
|
---|
1526 | {
|
---|
1527 | CHECK_ERROR(machine, COMSETTER(KeyboardHidType)(KeyboardHidType_PS2Keyboard));
|
---|
1528 | }
|
---|
1529 | else if (!strcmp(ValueUnion.psz, "usb"))
|
---|
1530 | {
|
---|
1531 | CHECK_ERROR(machine, COMSETTER(KeyboardHidType)(KeyboardHidType_USBKeyboard));
|
---|
1532 | if (SUCCEEDED(rc))
|
---|
1533 | fEnableUsb = true;
|
---|
1534 | }
|
---|
1535 | else
|
---|
1536 | {
|
---|
1537 | errorArgument("Invalid type '%s' specfied for keyboard", ValueUnion.psz);
|
---|
1538 | rc = E_FAIL;
|
---|
1539 | }
|
---|
1540 | if (fEnableUsb)
|
---|
1541 | {
|
---|
1542 | /* Make sure the OHCI controller is enabled. */
|
---|
1543 | ComPtr<IUSBController> UsbCtl;
|
---|
1544 | rc = machine->COMGETTER(USBController)(UsbCtl.asOutParam());
|
---|
1545 | if (SUCCEEDED(rc))
|
---|
1546 | {
|
---|
1547 | BOOL fEnabled;
|
---|
1548 | rc = UsbCtl->COMGETTER(Enabled)(&fEnabled);
|
---|
1549 | if (FAILED(rc))
|
---|
1550 | fEnabled = false;
|
---|
1551 | if (!fEnabled)
|
---|
1552 | CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(true));
|
---|
1553 | }
|
---|
1554 | }
|
---|
1555 | break;
|
---|
1556 | }
|
---|
1557 |
|
---|
1558 | case MODIFYVM_UARTMODE:
|
---|
1559 | {
|
---|
1560 | ComPtr<ISerialPort> uart;
|
---|
1561 | char *pszIRQ = NULL;
|
---|
1562 |
|
---|
1563 | CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
|
---|
1564 | ASSERT(uart);
|
---|
1565 |
|
---|
1566 | if (!strcmp(ValueUnion.psz, "disconnected"))
|
---|
1567 | {
|
---|
1568 | CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_Disconnected));
|
---|
1569 | }
|
---|
1570 | else if ( !strcmp(ValueUnion.psz, "server")
|
---|
1571 | || !strcmp(ValueUnion.psz, "client")
|
---|
1572 | || !strcmp(ValueUnion.psz, "file"))
|
---|
1573 | {
|
---|
1574 | const char *pszMode = ValueUnion.psz;
|
---|
1575 |
|
---|
1576 | int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_STRING);
|
---|
1577 | if (RT_FAILURE(vrc))
|
---|
1578 | return errorSyntax(USAGE_MODIFYVM,
|
---|
1579 | "Missing or Invalid argument to '%s'",
|
---|
1580 | GetOptState.pDef->pszLong);
|
---|
1581 |
|
---|
1582 | CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz)));
|
---|
1583 |
|
---|
1584 | if (!strcmp(pszMode, "server"))
|
---|
1585 | {
|
---|
1586 | CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
|
---|
1587 | CHECK_ERROR(uart, COMSETTER(Server)(TRUE));
|
---|
1588 | }
|
---|
1589 | else if (!strcmp(pszMode, "client"))
|
---|
1590 | {
|
---|
1591 | CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostPipe));
|
---|
1592 | CHECK_ERROR(uart, COMSETTER(Server)(FALSE));
|
---|
1593 | }
|
---|
1594 | else if (!strcmp(pszMode, "file"))
|
---|
1595 | {
|
---|
1596 | CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_RawFile));
|
---|
1597 | }
|
---|
1598 | }
|
---|
1599 | else
|
---|
1600 | {
|
---|
1601 | CHECK_ERROR(uart, COMSETTER(Path)(Bstr(ValueUnion.psz)));
|
---|
1602 | CHECK_ERROR(uart, COMSETTER(HostMode)(PortMode_HostDevice));
|
---|
1603 | }
|
---|
1604 | break;
|
---|
1605 | }
|
---|
1606 |
|
---|
1607 | case MODIFYVM_UART:
|
---|
1608 | {
|
---|
1609 | ComPtr<ISerialPort> uart;
|
---|
1610 |
|
---|
1611 | CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
|
---|
1612 | ASSERT(uart);
|
---|
1613 |
|
---|
1614 | if (!strcmp(ValueUnion.psz, "off") || !strcmp(ValueUnion.psz, "disable"))
|
---|
1615 | CHECK_ERROR(uart, COMSETTER(Enabled)(FALSE));
|
---|
1616 | else
|
---|
1617 | {
|
---|
1618 | const char *pszIOBase = ValueUnion.psz;
|
---|
1619 | uint32_t uVal = 0;
|
---|
1620 |
|
---|
1621 | int vrc = RTGetOptFetchValue(&GetOptState, &ValueUnion, RTGETOPT_REQ_UINT32) != MODIFYVM_UART;
|
---|
1622 | if (RT_FAILURE(vrc))
|
---|
1623 | return errorSyntax(USAGE_MODIFYVM,
|
---|
1624 | "Missing or Invalid argument to '%s'",
|
---|
1625 | GetOptState.pDef->pszLong);
|
---|
1626 |
|
---|
1627 | CHECK_ERROR(uart, COMSETTER(IRQ)(ValueUnion.u32));
|
---|
1628 |
|
---|
1629 | vrc = RTStrToUInt32Ex(pszIOBase, NULL, 0, &uVal);
|
---|
1630 | if (vrc != VINF_SUCCESS || uVal == 0)
|
---|
1631 | return errorArgument("Error parsing UART I/O base '%s'", pszIOBase);
|
---|
1632 | CHECK_ERROR(uart, COMSETTER(IOBase)(uVal));
|
---|
1633 |
|
---|
1634 | CHECK_ERROR(uart, COMSETTER(Enabled)(TRUE));
|
---|
1635 | }
|
---|
1636 | break;
|
---|
1637 | }
|
---|
1638 |
|
---|
1639 | case MODIFYVM_GUESTMEMORYBALLOON:
|
---|
1640 | {
|
---|
1641 | CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(ValueUnion.u32));
|
---|
1642 | break;
|
---|
1643 | }
|
---|
1644 |
|
---|
1645 | case MODIFYVM_AUDIOCONTROLLER:
|
---|
1646 | {
|
---|
1647 | ComPtr<IAudioAdapter> audioAdapter;
|
---|
1648 | machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
|
---|
1649 | ASSERT(audioAdapter);
|
---|
1650 |
|
---|
1651 | if (!strcmp(ValueUnion.psz, "sb16"))
|
---|
1652 | CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_SB16));
|
---|
1653 | else if (!strcmp(ValueUnion.psz, "ac97"))
|
---|
1654 | CHECK_ERROR(audioAdapter, COMSETTER(AudioController)(AudioControllerType_AC97));
|
---|
1655 | else
|
---|
1656 | {
|
---|
1657 | errorArgument("Invalid --audiocontroller argument '%s'", ValueUnion.psz);
|
---|
1658 | rc = E_FAIL;
|
---|
1659 | }
|
---|
1660 | break;
|
---|
1661 | }
|
---|
1662 |
|
---|
1663 | case MODIFYVM_AUDIO:
|
---|
1664 | {
|
---|
1665 | ComPtr<IAudioAdapter> audioAdapter;
|
---|
1666 | machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
|
---|
1667 | ASSERT(audioAdapter);
|
---|
1668 |
|
---|
1669 | /* disable? */
|
---|
1670 | if (!strcmp(ValueUnion.psz, "none"))
|
---|
1671 | {
|
---|
1672 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
|
---|
1673 | }
|
---|
1674 | else if (!strcmp(ValueUnion.psz, "null"))
|
---|
1675 | {
|
---|
1676 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Null));
|
---|
1677 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1678 | }
|
---|
1679 | #ifdef RT_OS_WINDOWS
|
---|
1680 | #ifdef VBOX_WITH_WINMM
|
---|
1681 | else if (!strcmp(ValueUnion.psz, "winmm"))
|
---|
1682 | {
|
---|
1683 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WinMM));
|
---|
1684 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1685 | }
|
---|
1686 | #endif
|
---|
1687 | else if (!strcmp(ValueUnion.psz, "dsound"))
|
---|
1688 | {
|
---|
1689 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
|
---|
1690 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1691 | }
|
---|
1692 | #endif /* RT_OS_WINDOWS */
|
---|
1693 | #ifdef RT_OS_LINUX
|
---|
1694 | # ifdef VBOX_WITH_ALSA
|
---|
1695 | else if (!strcmp(ValueUnion.psz, "alsa"))
|
---|
1696 | {
|
---|
1697 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSA));
|
---|
1698 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1699 | }
|
---|
1700 | # endif
|
---|
1701 | # ifdef VBOX_WITH_PULSE
|
---|
1702 | else if (!strcmp(ValueUnion.psz, "pulse"))
|
---|
1703 | {
|
---|
1704 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
|
---|
1705 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1706 | }
|
---|
1707 | # endif
|
---|
1708 | #endif /* !RT_OS_LINUX */
|
---|
1709 | #ifdef RT_OS_SOLARIS
|
---|
1710 | else if (!strcmp(ValueUnion.psz, "solaudio"))
|
---|
1711 | {
|
---|
1712 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio));
|
---|
1713 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1714 | }
|
---|
1715 | #endif /* !RT_OS_SOLARIS */
|
---|
1716 | #ifdef RT_OS_FREEBSD
|
---|
1717 | else if (!strcmp(ValueUnion.psz, "oss"))
|
---|
1718 | {
|
---|
1719 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
|
---|
1720 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1721 | }
|
---|
1722 | # ifdef VBOX_WITH_PULSE
|
---|
1723 | else if (!strcmp(ValueUnion.psz, "pulse"))
|
---|
1724 | {
|
---|
1725 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Pulse));
|
---|
1726 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1727 | }
|
---|
1728 | # endif
|
---|
1729 | #endif /* !RT_OS_FREEBSD */
|
---|
1730 | #ifdef RT_OS_DARWIN
|
---|
1731 | else if (!strcmp(ValueUnion.psz, "coreaudio"))
|
---|
1732 | {
|
---|
1733 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudio));
|
---|
1734 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1735 | }
|
---|
1736 |
|
---|
1737 | #endif /* !RT_OS_DARWIN */
|
---|
1738 | # if defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(VBOX_WITH_SOLARIS_OSS)
|
---|
1739 | else if (!strcmp(ValueUnion.psz, "oss"))
|
---|
1740 | {
|
---|
1741 | CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSS));
|
---|
1742 | CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
|
---|
1743 | }
|
---|
1744 | # endif
|
---|
1745 | else
|
---|
1746 | {
|
---|
1747 | errorArgument("Invalid --audio argument '%s'", ValueUnion.psz);
|
---|
1748 | rc = E_FAIL;
|
---|
1749 | }
|
---|
1750 | break;
|
---|
1751 | }
|
---|
1752 |
|
---|
1753 | case MODIFYVM_CLIPBOARD:
|
---|
1754 | {
|
---|
1755 | if (!strcmp(ValueUnion.psz, "disabled"))
|
---|
1756 | {
|
---|
1757 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled));
|
---|
1758 | }
|
---|
1759 | else if (!strcmp(ValueUnion.psz, "hosttoguest"))
|
---|
1760 | {
|
---|
1761 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest));
|
---|
1762 | }
|
---|
1763 | else if (!strcmp(ValueUnion.psz, "guesttohost"))
|
---|
1764 | {
|
---|
1765 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost));
|
---|
1766 | }
|
---|
1767 | else if (!strcmp(ValueUnion.psz, "bidirectional"))
|
---|
1768 | {
|
---|
1769 | CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional));
|
---|
1770 | }
|
---|
1771 | else
|
---|
1772 | {
|
---|
1773 | errorArgument("Invalid --clipboard argument '%s'", ValueUnion.psz);
|
---|
1774 | rc = E_FAIL;
|
---|
1775 | }
|
---|
1776 | break;
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | #ifdef VBOX_WITH_VRDP
|
---|
1780 | case MODIFYVM_VRDPPORT:
|
---|
1781 | {
|
---|
1782 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1783 | machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1784 | ASSERT(vrdpServer);
|
---|
1785 |
|
---|
1786 | if (!strcmp(ValueUnion.psz, "default"))
|
---|
1787 | CHECK_ERROR(vrdpServer, COMSETTER(Ports)(Bstr("0")));
|
---|
1788 | else
|
---|
1789 | CHECK_ERROR(vrdpServer, COMSETTER(Ports)(Bstr(ValueUnion.psz)));
|
---|
1790 | break;
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | case MODIFYVM_VRDPADDRESS:
|
---|
1794 | {
|
---|
1795 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1796 | machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1797 | ASSERT(vrdpServer);
|
---|
1798 |
|
---|
1799 | CHECK_ERROR(vrdpServer, COMSETTER(NetAddress)(Bstr(ValueUnion.psz)));
|
---|
1800 | break;
|
---|
1801 | }
|
---|
1802 |
|
---|
1803 | case MODIFYVM_VRDPAUTHTYPE:
|
---|
1804 | {
|
---|
1805 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1806 | machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1807 | ASSERT(vrdpServer);
|
---|
1808 |
|
---|
1809 | if (!strcmp(ValueUnion.psz, "null"))
|
---|
1810 | {
|
---|
1811 | CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Null));
|
---|
1812 | }
|
---|
1813 | else if (!strcmp(ValueUnion.psz, "external"))
|
---|
1814 | {
|
---|
1815 | CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_External));
|
---|
1816 | }
|
---|
1817 | else if (!strcmp(ValueUnion.psz, "guest"))
|
---|
1818 | {
|
---|
1819 | CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_Guest));
|
---|
1820 | }
|
---|
1821 | else
|
---|
1822 | {
|
---|
1823 | errorArgument("Invalid --vrdpauthtype argument '%s'", ValueUnion.psz);
|
---|
1824 | rc = E_FAIL;
|
---|
1825 | }
|
---|
1826 | break;
|
---|
1827 | }
|
---|
1828 |
|
---|
1829 | case MODIFYVM_VRDPMULTICON:
|
---|
1830 | {
|
---|
1831 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1832 | machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1833 | ASSERT(vrdpServer);
|
---|
1834 |
|
---|
1835 | CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(ValueUnion.f));
|
---|
1836 | break;
|
---|
1837 | }
|
---|
1838 |
|
---|
1839 | case MODIFYVM_VRDPREUSECON:
|
---|
1840 | {
|
---|
1841 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1842 | machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1843 | ASSERT(vrdpServer);
|
---|
1844 |
|
---|
1845 | CHECK_ERROR(vrdpServer, COMSETTER(ReuseSingleConnection)(ValueUnion.f));
|
---|
1846 | break;
|
---|
1847 | }
|
---|
1848 |
|
---|
1849 | case MODIFYVM_VRDP:
|
---|
1850 | {
|
---|
1851 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1852 | machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1853 | ASSERT(vrdpServer);
|
---|
1854 |
|
---|
1855 | CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(ValueUnion.f));
|
---|
1856 | break;
|
---|
1857 | }
|
---|
1858 | #endif /* VBOX_WITH_VRDP */
|
---|
1859 |
|
---|
1860 | case MODIFYVM_USBEHCI:
|
---|
1861 | {
|
---|
1862 | ComPtr<IUSBController> UsbCtl;
|
---|
1863 | CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
|
---|
1864 | if (SUCCEEDED(rc))
|
---|
1865 | CHECK_ERROR(UsbCtl, COMSETTER(EnabledEhci)(ValueUnion.f));
|
---|
1866 | break;
|
---|
1867 | }
|
---|
1868 |
|
---|
1869 | case MODIFYVM_USB:
|
---|
1870 | {
|
---|
1871 | ComPtr<IUSBController> UsbCtl;
|
---|
1872 | CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
|
---|
1873 | if (SUCCEEDED(rc))
|
---|
1874 | CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(ValueUnion.f));
|
---|
1875 | break;
|
---|
1876 | }
|
---|
1877 |
|
---|
1878 | case MODIFYVM_SNAPSHOTFOLDER:
|
---|
1879 | {
|
---|
1880 | if (!strcmp(ValueUnion.psz, "default"))
|
---|
1881 | CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(NULL));
|
---|
1882 | else
|
---|
1883 | CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz)));
|
---|
1884 | break;
|
---|
1885 | }
|
---|
1886 |
|
---|
1887 | case MODIFYVM_TELEPORTER_ENABLED:
|
---|
1888 | {
|
---|
1889 | CHECK_ERROR(machine, COMSETTER(TeleporterEnabled)(ValueUnion.f));
|
---|
1890 | break;
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 | case MODIFYVM_TELEPORTER_PORT:
|
---|
1894 | {
|
---|
1895 | CHECK_ERROR(machine, COMSETTER(TeleporterPort)(ValueUnion.u32));
|
---|
1896 | break;
|
---|
1897 | }
|
---|
1898 |
|
---|
1899 | case MODIFYVM_TELEPORTER_ADDRESS:
|
---|
1900 | {
|
---|
1901 | CHECK_ERROR(machine, COMSETTER(TeleporterAddress)(Bstr(ValueUnion.psz)));
|
---|
1902 | break;
|
---|
1903 | }
|
---|
1904 |
|
---|
1905 | case MODIFYVM_TELEPORTER_PASSWORD:
|
---|
1906 | {
|
---|
1907 | CHECK_ERROR(machine, COMSETTER(TeleporterPassword)(Bstr(ValueUnion.psz)));
|
---|
1908 | break;
|
---|
1909 | }
|
---|
1910 |
|
---|
1911 | case MODIFYVM_HARDWARE_UUID:
|
---|
1912 | {
|
---|
1913 | CHECK_ERROR(machine, COMSETTER(HardwareUUID)(Bstr(ValueUnion.psz)));
|
---|
1914 | break;
|
---|
1915 | }
|
---|
1916 |
|
---|
1917 | case MODIFYVM_HPET:
|
---|
1918 | {
|
---|
1919 | CHECK_ERROR(machine, COMSETTER(HpetEnabled)(ValueUnion.f));
|
---|
1920 | break;
|
---|
1921 | }
|
---|
1922 |
|
---|
1923 | case MODIFYVM_IOMGR:
|
---|
1924 | {
|
---|
1925 | if (!strcmp(ValueUnion.psz, "simple"))
|
---|
1926 | CHECK_ERROR(machine, COMSETTER(IoMgr)(IoMgrType_Simple));
|
---|
1927 | else if (!strcmp(ValueUnion.psz, "async"))
|
---|
1928 | CHECK_ERROR(machine, COMSETTER(IoMgr)(IoMgrType_Async));
|
---|
1929 | else
|
---|
1930 | {
|
---|
1931 | errorArgument("Invalid --iomgr argument '%s'", ValueUnion.psz);
|
---|
1932 | rc = E_FAIL;
|
---|
1933 | }
|
---|
1934 | break;
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 | case MODIFYVM_IOBACKEND:
|
---|
1938 | {
|
---|
1939 | if (!strcmp(ValueUnion.psz, "buffered"))
|
---|
1940 | CHECK_ERROR(machine, COMSETTER(IoBackend)(IoBackendType_Buffered));
|
---|
1941 | else if (!strcmp(ValueUnion.psz, "unbuffered"))
|
---|
1942 | CHECK_ERROR(machine, COMSETTER(IoBackend)(IoBackendType_Unbuffered));
|
---|
1943 | else
|
---|
1944 | {
|
---|
1945 | errorArgument("Invalid --iobackend argument '%s'", ValueUnion.psz);
|
---|
1946 | rc = E_FAIL;
|
---|
1947 | }
|
---|
1948 | break;
|
---|
1949 | }
|
---|
1950 |
|
---|
1951 | case MODIFYVM_IOCACHE:
|
---|
1952 | {
|
---|
1953 | CHECK_ERROR(machine, COMSETTER(IoCacheEnabled)(ValueUnion.f));
|
---|
1954 | break;
|
---|
1955 | }
|
---|
1956 |
|
---|
1957 | case MODIFYVM_IOCACHESIZE:
|
---|
1958 | {
|
---|
1959 | CHECK_ERROR(machine, COMSETTER(IoCacheSize)(ValueUnion.u32));
|
---|
1960 | break;
|
---|
1961 | }
|
---|
1962 |
|
---|
1963 | case MODIFYVM_IOBANDWIDTHMAX:
|
---|
1964 | {
|
---|
1965 | CHECK_ERROR(machine, COMSETTER(IoBandwidthMax)(ValueUnion.u32));
|
---|
1966 | break;
|
---|
1967 | }
|
---|
1968 |
|
---|
1969 | default:
|
---|
1970 | {
|
---|
1971 | errorGetOpt(USAGE_MODIFYVM, c, &ValueUnion);
|
---|
1972 | rc = E_FAIL;
|
---|
1973 | break;
|
---|
1974 | }
|
---|
1975 | }
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | /* commit changes */
|
---|
1979 | if (SUCCEEDED(rc))
|
---|
1980 | CHECK_ERROR(machine, SaveSettings());
|
---|
1981 |
|
---|
1982 | /* it's important to always close sessions */
|
---|
1983 | a->session->Close();
|
---|
1984 |
|
---|
1985 | return SUCCEEDED(rc) ? 0 : 1;
|
---|
1986 | }
|
---|
1987 |
|
---|
1988 | #endif /* !VBOX_ONLY_DOCS */
|
---|