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