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