1 | /* $Id: VBoxManageList.cpp 28249 2010-04-13 13:42:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - The 'list' command.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2010 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef VBOX_ONLY_DOCS
|
---|
23 |
|
---|
24 | /*******************************************************************************
|
---|
25 | * Header Files *
|
---|
26 | *******************************************************************************/
|
---|
27 | #include <VBox/com/com.h>
|
---|
28 | #include <VBox/com/string.h>
|
---|
29 | #include <VBox/com/Guid.h>
|
---|
30 | #include <VBox/com/array.h>
|
---|
31 | #include <VBox/com/ErrorInfo.h>
|
---|
32 | #include <VBox/com/errorprint.h>
|
---|
33 |
|
---|
34 | #include <VBox/com/VirtualBox.h>
|
---|
35 |
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <iprt/stream.h>
|
---|
38 | #include <iprt/string.h>
|
---|
39 | #include <iprt/time.h>
|
---|
40 | #include <iprt/getopt.h>
|
---|
41 | #include <iprt/ctype.h>
|
---|
42 |
|
---|
43 | #include "VBoxManage.h"
|
---|
44 | using namespace com;
|
---|
45 |
|
---|
46 | #ifdef VBOX_WITH_HOSTNETIF_API
|
---|
47 | static const char *getHostIfMediumTypeText(HostNetworkInterfaceMediumType_T enmType)
|
---|
48 | {
|
---|
49 | switch (enmType)
|
---|
50 | {
|
---|
51 | case HostNetworkInterfaceMediumType_Ethernet: return "Ethernet";
|
---|
52 | case HostNetworkInterfaceMediumType_PPP: return "PPP";
|
---|
53 | case HostNetworkInterfaceMediumType_SLIP: return "SLIP";
|
---|
54 | }
|
---|
55 | return "Unknown";
|
---|
56 | }
|
---|
57 |
|
---|
58 | static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
|
---|
59 | {
|
---|
60 | switch (enmStatus)
|
---|
61 | {
|
---|
62 | case HostNetworkInterfaceStatus_Up: return "Up";
|
---|
63 | case HostNetworkInterfaceStatus_Down: return "Down";
|
---|
64 | }
|
---|
65 | return "Unknown";
|
---|
66 | }
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | static void listHardDisks(const ComPtr<IVirtualBox> aVirtualBox,
|
---|
70 | const com::SafeIfaceArray<IMedium> &aMedia,
|
---|
71 | const char *pszParentUUIDStr)
|
---|
72 | {
|
---|
73 | HRESULT rc;
|
---|
74 | for (size_t i = 0; i < aMedia.size(); ++i)
|
---|
75 | {
|
---|
76 | ComPtr<IMedium> hdd = aMedia[i];
|
---|
77 | Bstr uuid;
|
---|
78 | hdd->COMGETTER(Id)(uuid.asOutParam());
|
---|
79 | RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
|
---|
80 | RTPrintf("Parent UUID: %s\n", pszParentUUIDStr);
|
---|
81 | Bstr format;
|
---|
82 | hdd->COMGETTER(Format)(format.asOutParam());
|
---|
83 | RTPrintf("Format: %lS\n", format.raw());
|
---|
84 | Bstr filepath;
|
---|
85 | hdd->COMGETTER(Location)(filepath.asOutParam());
|
---|
86 | RTPrintf("Location: %lS\n", filepath.raw());
|
---|
87 |
|
---|
88 | MediumState_T enmState;
|
---|
89 | hdd->RefreshState(&enmState);
|
---|
90 | const char *stateStr = "unknown";
|
---|
91 | switch (enmState)
|
---|
92 | {
|
---|
93 | case MediumState_NotCreated:
|
---|
94 | stateStr = "not created";
|
---|
95 | break;
|
---|
96 | case MediumState_Created:
|
---|
97 | stateStr = "created";
|
---|
98 | break;
|
---|
99 | case MediumState_LockedRead:
|
---|
100 | stateStr = "locked read";
|
---|
101 | break;
|
---|
102 | case MediumState_LockedWrite:
|
---|
103 | stateStr = "locked write";
|
---|
104 | break;
|
---|
105 | case MediumState_Inaccessible:
|
---|
106 | stateStr = "inaccessible";
|
---|
107 | break;
|
---|
108 | case MediumState_Creating:
|
---|
109 | stateStr = "creating";
|
---|
110 | break;
|
---|
111 | case MediumState_Deleting:
|
---|
112 | stateStr = "deleting";
|
---|
113 | break;
|
---|
114 | }
|
---|
115 | RTPrintf("State: %s\n", stateStr);
|
---|
116 |
|
---|
117 | MediumType_T type;
|
---|
118 | hdd->COMGETTER(Type)(&type);
|
---|
119 | const char *typeStr = "unknown";
|
---|
120 | switch (type)
|
---|
121 | {
|
---|
122 | case MediumType_Normal:
|
---|
123 | typeStr = "normal";
|
---|
124 | break;
|
---|
125 | case MediumType_Immutable:
|
---|
126 | typeStr = "immutable";
|
---|
127 | break;
|
---|
128 | case MediumType_Writethrough:
|
---|
129 | typeStr = "writethrough";
|
---|
130 | break;
|
---|
131 | }
|
---|
132 | RTPrintf("Type: %s\n", typeStr);
|
---|
133 |
|
---|
134 | com::SafeArray<BSTR> machineIds;
|
---|
135 | hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds));
|
---|
136 | for (size_t j = 0; j < machineIds.size(); ++j)
|
---|
137 | {
|
---|
138 | ComPtr<IMachine> machine;
|
---|
139 | CHECK_ERROR(aVirtualBox, GetMachine(machineIds[j], machine.asOutParam()));
|
---|
140 | ASSERT(machine);
|
---|
141 | Bstr name;
|
---|
142 | machine->COMGETTER(Name)(name.asOutParam());
|
---|
143 | RTPrintf("%s%lS (UUID: %lS)",
|
---|
144 | j == 0 ? "Usage: " : " ",
|
---|
145 | name.raw(), machineIds[j]);
|
---|
146 | com::SafeArray<BSTR> snapshotIds;
|
---|
147 | hdd->COMGETTER(SnapshotIds)(machineIds[j],
|
---|
148 | ComSafeArrayAsOutParam(snapshotIds));
|
---|
149 | for (size_t k = 0; k < snapshotIds.size(); ++k)
|
---|
150 | {
|
---|
151 | ComPtr<ISnapshot> snapshot;
|
---|
152 | machine->GetSnapshot(snapshotIds[k], snapshot.asOutParam());
|
---|
153 | if (snapshot)
|
---|
154 | {
|
---|
155 | Bstr snapshotName;
|
---|
156 | snapshot->COMGETTER(Name)(snapshotName.asOutParam());
|
---|
157 | RTPrintf(" [%lS (UUID: %lS)]", snapshotName.raw(), snapshotIds[k]);
|
---|
158 | }
|
---|
159 | }
|
---|
160 | RTPrintf("\n");
|
---|
161 | }
|
---|
162 | RTPrintf("\n");
|
---|
163 |
|
---|
164 | com::SafeIfaceArray<IMedium> children;
|
---|
165 | CHECK_ERROR(hdd, COMGETTER(Children)(ComSafeArrayAsOutParam(children)));
|
---|
166 | if (children.size() > 0)
|
---|
167 | {
|
---|
168 | // depth first listing of child media
|
---|
169 | listHardDisks(aVirtualBox, children, Utf8Str(uuid).raw());
|
---|
170 | }
|
---|
171 | }
|
---|
172 | }
|
---|
173 |
|
---|
174 | enum enOptionCodes
|
---|
175 | {
|
---|
176 | LISTVMS = 1000,
|
---|
177 | LISTRUNNINGVMS,
|
---|
178 | LISTOSTYPES,
|
---|
179 | LISTHOSTDVDS,
|
---|
180 | LISTHOSTFLOPPIES,
|
---|
181 | LISTBRIDGEDIFS,
|
---|
182 | #if defined(VBOX_WITH_NETFLT)
|
---|
183 | LISTHOSTONLYIFS,
|
---|
184 | #endif
|
---|
185 | LISTHOSTCPUIDS,
|
---|
186 | LISTHOSTINFO,
|
---|
187 | LISTHDDBACKENDS,
|
---|
188 | LISTHDDS,
|
---|
189 | LISTDVDS,
|
---|
190 | LISTFLOPPIES,
|
---|
191 | LISTUSBHOST,
|
---|
192 | LISTUSBFILTERS,
|
---|
193 | LISTSYSTEMPROPERTIES,
|
---|
194 | LISTDHCPSERVERS,
|
---|
195 | LISTNATPFS
|
---|
196 | };
|
---|
197 |
|
---|
198 | static const RTGETOPTDEF g_aListOptions[]
|
---|
199 | = {
|
---|
200 | { "--long", 'l', RTGETOPT_REQ_NOTHING },
|
---|
201 | { "vms", LISTVMS, RTGETOPT_REQ_NOTHING },
|
---|
202 | { "runningvms", LISTRUNNINGVMS, RTGETOPT_REQ_NOTHING },
|
---|
203 | { "ostypes", LISTOSTYPES, RTGETOPT_REQ_NOTHING },
|
---|
204 | { "hostdvds", LISTHOSTDVDS, RTGETOPT_REQ_NOTHING },
|
---|
205 | { "hostfloppies", LISTHOSTFLOPPIES, RTGETOPT_REQ_NOTHING },
|
---|
206 | { "hostifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
|
---|
207 | { "bridgedifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING },
|
---|
208 | #if defined(VBOX_WITH_NETFLT)
|
---|
209 | { "hostonlyifs", LISTHOSTONLYIFS, RTGETOPT_REQ_NOTHING },
|
---|
210 | #endif
|
---|
211 | { "hostinfo", LISTHOSTINFO, RTGETOPT_REQ_NOTHING },
|
---|
212 | { "hostcpuids", LISTHOSTCPUIDS, RTGETOPT_REQ_NOTHING },
|
---|
213 | { "hddbackends", LISTHDDBACKENDS, RTGETOPT_REQ_NOTHING },
|
---|
214 | { "hdds", LISTHDDS, RTGETOPT_REQ_NOTHING },
|
---|
215 | { "dvds", LISTDVDS, RTGETOPT_REQ_NOTHING },
|
---|
216 | { "floppies", LISTFLOPPIES, RTGETOPT_REQ_NOTHING },
|
---|
217 | { "usbhost", LISTUSBHOST, RTGETOPT_REQ_NOTHING },
|
---|
218 | { "usbfilters", LISTUSBFILTERS, RTGETOPT_REQ_NOTHING },
|
---|
219 | { "systemproperties", LISTSYSTEMPROPERTIES, RTGETOPT_REQ_NOTHING },
|
---|
220 | { "dhcpservers", LISTDHCPSERVERS, RTGETOPT_REQ_NOTHING },
|
---|
221 | { "natrules", LISTNATPFS, RTGETOPT_REQ_STRING|RTGETOPT_FLAG_INDEX }
|
---|
222 | };
|
---|
223 |
|
---|
224 | int handleList(HandlerArg *a)
|
---|
225 | {
|
---|
226 | HRESULT rc = S_OK;
|
---|
227 |
|
---|
228 | bool fOptLong = false;
|
---|
229 |
|
---|
230 | int command = 0;
|
---|
231 | int c;
|
---|
232 |
|
---|
233 | RTGETOPTUNION ValueUnion;
|
---|
234 | RTGETOPTSTATE GetState;
|
---|
235 | RTGetOptInit(&GetState, a->argc, a->argv, g_aListOptions, RT_ELEMENTS(g_aListOptions),
|
---|
236 | 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
|
---|
237 | while ((c = RTGetOpt(&GetState, &ValueUnion)))
|
---|
238 | {
|
---|
239 | switch (c)
|
---|
240 | {
|
---|
241 | case 'l': // --long
|
---|
242 | fOptLong = true;
|
---|
243 | break;
|
---|
244 |
|
---|
245 | case LISTNATPFS:
|
---|
246 | if (a->argc < 2)
|
---|
247 | return errorSyntax(USAGE_LIST, "Missing vm name for \"list\" %S.\n", a->argv[0]);
|
---|
248 |
|
---|
249 | case LISTVMS:
|
---|
250 | case LISTRUNNINGVMS:
|
---|
251 | case LISTOSTYPES:
|
---|
252 | case LISTHOSTDVDS:
|
---|
253 | case LISTHOSTFLOPPIES:
|
---|
254 | case LISTBRIDGEDIFS:
|
---|
255 | #if defined(VBOX_WITH_NETFLT)
|
---|
256 | case LISTHOSTONLYIFS:
|
---|
257 | #endif
|
---|
258 | case LISTHOSTINFO:
|
---|
259 | case LISTHOSTCPUIDS:
|
---|
260 | case LISTHDDBACKENDS:
|
---|
261 | case LISTHDDS:
|
---|
262 | case LISTDVDS:
|
---|
263 | case LISTFLOPPIES:
|
---|
264 | case LISTUSBHOST:
|
---|
265 | case LISTUSBFILTERS:
|
---|
266 | case LISTSYSTEMPROPERTIES:
|
---|
267 | case LISTDHCPSERVERS:
|
---|
268 | if (command)
|
---|
269 | return errorSyntax(USAGE_LIST, "Too many subcommands for \"list\" command.\n");
|
---|
270 |
|
---|
271 | command = c;
|
---|
272 | break;
|
---|
273 |
|
---|
274 | case VINF_GETOPT_NOT_OPTION:
|
---|
275 | return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
|
---|
276 | break;
|
---|
277 |
|
---|
278 | default:
|
---|
279 | if (c > 0)
|
---|
280 | {
|
---|
281 | if (RT_C_IS_GRAPH(c))
|
---|
282 | return errorSyntax(USAGE_LIST, "unhandled option: -%c", c);
|
---|
283 | else
|
---|
284 | return errorSyntax(USAGE_LIST, "unhandled option: %i", c);
|
---|
285 | }
|
---|
286 | else if (c == VERR_GETOPT_UNKNOWN_OPTION)
|
---|
287 | return errorSyntax(USAGE_LIST, "unknown option: %s", ValueUnion.psz);
|
---|
288 | else if (ValueUnion.pDef)
|
---|
289 | return errorSyntax(USAGE_LIST, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
|
---|
290 | else
|
---|
291 | return errorSyntax(USAGE_LIST, "%Rrs", c);
|
---|
292 | }
|
---|
293 | }
|
---|
294 |
|
---|
295 | if (!command)
|
---|
296 | return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
|
---|
297 |
|
---|
298 | /* which object? */
|
---|
299 | switch (command)
|
---|
300 | {
|
---|
301 | case LISTVMS:
|
---|
302 | {
|
---|
303 | /*
|
---|
304 | * Get the list of all registered VMs
|
---|
305 | */
|
---|
306 | com::SafeIfaceArray <IMachine> machines;
|
---|
307 | rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
308 | if (SUCCEEDED(rc))
|
---|
309 | {
|
---|
310 | /*
|
---|
311 | * Iterate through the collection
|
---|
312 | */
|
---|
313 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
314 | {
|
---|
315 | if (machines[i])
|
---|
316 | rc = showVMInfo(a->virtualBox,
|
---|
317 | machines[i],
|
---|
318 | (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
319 | }
|
---|
320 | }
|
---|
321 | }
|
---|
322 | break;
|
---|
323 |
|
---|
324 | case LISTRUNNINGVMS:
|
---|
325 | {
|
---|
326 | /*
|
---|
327 | * Get the list of all _running_ VMs
|
---|
328 | */
|
---|
329 | com::SafeIfaceArray <IMachine> machines;
|
---|
330 | rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
331 | if (SUCCEEDED(rc))
|
---|
332 | {
|
---|
333 | /*
|
---|
334 | * Iterate through the collection
|
---|
335 | */
|
---|
336 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
337 | {
|
---|
338 | if (machines[i])
|
---|
339 | {
|
---|
340 | MachineState_T machineState;
|
---|
341 | rc = machines[i]->COMGETTER(State)(&machineState);
|
---|
342 | if (SUCCEEDED(rc))
|
---|
343 | {
|
---|
344 | switch (machineState)
|
---|
345 | {
|
---|
346 | case MachineState_Running:
|
---|
347 | case MachineState_Teleporting:
|
---|
348 | case MachineState_LiveSnapshotting:
|
---|
349 | case MachineState_Paused:
|
---|
350 | case MachineState_TeleportingPausedVM:
|
---|
351 | rc = showVMInfo(a->virtualBox,
|
---|
352 | machines[i],
|
---|
353 | (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
354 | }
|
---|
355 | }
|
---|
356 | }
|
---|
357 | }
|
---|
358 | }
|
---|
359 | }
|
---|
360 | break;
|
---|
361 |
|
---|
362 | case LISTOSTYPES:
|
---|
363 | {
|
---|
364 | com::SafeIfaceArray <IGuestOSType> coll;
|
---|
365 | rc = a->virtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
|
---|
366 | if (SUCCEEDED(rc))
|
---|
367 | {
|
---|
368 | /*
|
---|
369 | * Iterate through the collection.
|
---|
370 | */
|
---|
371 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
372 | {
|
---|
373 | ComPtr<IGuestOSType> guestOS;
|
---|
374 | guestOS = coll[i];
|
---|
375 | Bstr guestId;
|
---|
376 | guestOS->COMGETTER(Id)(guestId.asOutParam());
|
---|
377 | RTPrintf("ID: %lS\n", guestId.raw());
|
---|
378 | Bstr guestDescription;
|
---|
379 | guestOS->COMGETTER(Description)(guestDescription.asOutParam());
|
---|
380 | RTPrintf("Description: %lS\n\n", guestDescription.raw());
|
---|
381 | }
|
---|
382 | }
|
---|
383 | }
|
---|
384 | break;
|
---|
385 |
|
---|
386 | case LISTHOSTDVDS:
|
---|
387 | {
|
---|
388 | ComPtr<IHost> host;
|
---|
389 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
390 | com::SafeIfaceArray <IMedium> coll;
|
---|
391 | CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
392 | if (SUCCEEDED(rc))
|
---|
393 | {
|
---|
394 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
395 | {
|
---|
396 | ComPtr<IMedium> dvdDrive = coll[i];
|
---|
397 | Bstr uuid;
|
---|
398 | dvdDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
399 | RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
|
---|
400 | Bstr name;
|
---|
401 | dvdDrive->COMGETTER(Name)(name.asOutParam());
|
---|
402 | RTPrintf("Name: %lS\n\n", name.raw());
|
---|
403 | }
|
---|
404 | }
|
---|
405 | }
|
---|
406 | break;
|
---|
407 |
|
---|
408 | case LISTHOSTFLOPPIES:
|
---|
409 | {
|
---|
410 | ComPtr<IHost> host;
|
---|
411 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
412 | com::SafeIfaceArray <IMedium> coll;
|
---|
413 | CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
414 | if (SUCCEEDED(rc))
|
---|
415 | {
|
---|
416 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
417 | {
|
---|
418 | ComPtr<IMedium> floppyDrive = coll[i];
|
---|
419 | Bstr uuid;
|
---|
420 | floppyDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
421 | RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
|
---|
422 | Bstr name;
|
---|
423 | floppyDrive->COMGETTER(Name)(name.asOutParam());
|
---|
424 | RTPrintf("Name: %lS\n\n", name.raw());
|
---|
425 | }
|
---|
426 | }
|
---|
427 | }
|
---|
428 | break;
|
---|
429 |
|
---|
430 | case LISTBRIDGEDIFS:
|
---|
431 | #if defined(VBOX_WITH_NETFLT)
|
---|
432 | case LISTHOSTONLYIFS:
|
---|
433 | #endif
|
---|
434 | {
|
---|
435 | ComPtr<IHost> host;
|
---|
436 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
437 | com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
|
---|
438 | #if defined(VBOX_WITH_NETFLT)
|
---|
439 | if (command == LISTBRIDGEDIFS)
|
---|
440 | CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged,
|
---|
441 | ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
442 | else
|
---|
443 | CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_HostOnly,
|
---|
444 | ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
445 | #else
|
---|
446 | CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
447 | #endif
|
---|
448 | for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
|
---|
449 | {
|
---|
450 | ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
|
---|
451 | #ifndef VBOX_WITH_HOSTNETIF_API
|
---|
452 | Bstr interfaceName;
|
---|
453 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
454 | RTPrintf("Name: %lS\n", interfaceName.raw());
|
---|
455 | Guid interfaceGuid;
|
---|
456 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
457 | RTPrintf("GUID: %lS\n\n", Bstr(interfaceGuid.toString()).raw());
|
---|
458 | #else /* VBOX_WITH_HOSTNETIF_API */
|
---|
459 | Bstr interfaceName;
|
---|
460 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
461 | RTPrintf("Name: %lS\n", interfaceName.raw());
|
---|
462 | Bstr interfaceGuid;
|
---|
463 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
464 | RTPrintf("GUID: %lS\n", interfaceGuid.raw());
|
---|
465 | BOOL bDhcpEnabled;
|
---|
466 | networkInterface->COMGETTER(DhcpEnabled)(&bDhcpEnabled);
|
---|
467 | RTPrintf("Dhcp: %s\n", bDhcpEnabled ? "Enabled" : "Disabled");
|
---|
468 |
|
---|
469 | Bstr IPAddress;
|
---|
470 | networkInterface->COMGETTER(IPAddress)(IPAddress.asOutParam());
|
---|
471 | RTPrintf("IPAddress: %lS\n", IPAddress.raw());
|
---|
472 | Bstr NetworkMask;
|
---|
473 | networkInterface->COMGETTER(NetworkMask)(NetworkMask.asOutParam());
|
---|
474 | RTPrintf("NetworkMask: %lS\n", NetworkMask.raw());
|
---|
475 | Bstr IPV6Address;
|
---|
476 | networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
|
---|
477 | RTPrintf("IPV6Address: %lS\n", IPV6Address.raw());
|
---|
478 | ULONG IPV6NetworkMaskPrefixLength;
|
---|
479 | networkInterface->COMGETTER(IPV6NetworkMaskPrefixLength)(&IPV6NetworkMaskPrefixLength);
|
---|
480 | RTPrintf("IPV6NetworkMaskPrefixLength: %d\n", IPV6NetworkMaskPrefixLength);
|
---|
481 | Bstr HardwareAddress;
|
---|
482 | networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
|
---|
483 | RTPrintf("HardwareAddress: %lS\n", HardwareAddress.raw());
|
---|
484 | HostNetworkInterfaceMediumType_T Type;
|
---|
485 | networkInterface->COMGETTER(MediumType)(&Type);
|
---|
486 | RTPrintf("MediumType: %s\n", getHostIfMediumTypeText(Type));
|
---|
487 | HostNetworkInterfaceStatus_T Status;
|
---|
488 | networkInterface->COMGETTER(Status)(&Status);
|
---|
489 | RTPrintf("Status: %s\n", getHostIfStatusText(Status));
|
---|
490 | Bstr netName;
|
---|
491 | networkInterface->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
492 | RTPrintf("VBoxNetworkName: %lS\n\n", netName.raw());
|
---|
493 |
|
---|
494 | #endif
|
---|
495 | }
|
---|
496 | }
|
---|
497 | break;
|
---|
498 |
|
---|
499 | case LISTHOSTINFO:
|
---|
500 | {
|
---|
501 | ComPtr<IHost> Host;
|
---|
502 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
503 |
|
---|
504 | RTPrintf("Host Information:\n\n");
|
---|
505 |
|
---|
506 | LONG64 uTCTime = 0;
|
---|
507 | CHECK_ERROR(Host, COMGETTER(UTCTime)(&uTCTime));
|
---|
508 | RTTIMESPEC timeSpec;
|
---|
509 | RTTimeSpecSetMilli(&timeSpec, uTCTime);
|
---|
510 | char szTime[32] = {0};
|
---|
511 | RTTimeSpecToString(&timeSpec, szTime, sizeof(szTime));
|
---|
512 | RTPrintf("Host time: %s\n", szTime);
|
---|
513 |
|
---|
514 | ULONG processorOnlineCount = 0;
|
---|
515 | CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
|
---|
516 | RTPrintf("Processor online count: %lu\n", processorOnlineCount);
|
---|
517 | ULONG processorCount = 0;
|
---|
518 | CHECK_ERROR(Host, COMGETTER(ProcessorCount)(&processorCount));
|
---|
519 | RTPrintf("Processor count: %lu\n", processorCount);
|
---|
520 | ULONG processorSpeed = 0;
|
---|
521 | Bstr processorDescription;
|
---|
522 | for (ULONG i = 0; i < processorCount; i++)
|
---|
523 | {
|
---|
524 | CHECK_ERROR(Host, GetProcessorSpeed(i, &processorSpeed));
|
---|
525 | if (processorSpeed)
|
---|
526 | RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
|
---|
527 | else
|
---|
528 | RTPrintf("Processor#%u speed: unknown\n", i, processorSpeed);
|
---|
529 | CHECK_ERROR(Host, GetProcessorDescription(i, processorDescription.asOutParam()));
|
---|
530 | RTPrintf("Processor#%u description: %lS\n", i, processorDescription.raw());
|
---|
531 | }
|
---|
532 |
|
---|
533 | ULONG memorySize = 0;
|
---|
534 | CHECK_ERROR(Host, COMGETTER(MemorySize)(&memorySize));
|
---|
535 | RTPrintf("Memory size: %lu MByte\n", memorySize);
|
---|
536 |
|
---|
537 | ULONG memoryAvailable = 0;
|
---|
538 | CHECK_ERROR(Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
|
---|
539 | RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
|
---|
540 |
|
---|
541 | Bstr operatingSystem;
|
---|
542 | CHECK_ERROR(Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
|
---|
543 | RTPrintf("Operating system: %lS\n", operatingSystem.raw());
|
---|
544 |
|
---|
545 | Bstr oSVersion;
|
---|
546 | CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
|
---|
547 | RTPrintf("Operating system version: %lS\n", oSVersion.raw());
|
---|
548 | }
|
---|
549 | break;
|
---|
550 |
|
---|
551 | case LISTHOSTCPUIDS:
|
---|
552 | {
|
---|
553 | ComPtr<IHost> Host;
|
---|
554 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
555 |
|
---|
556 | RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n");
|
---|
557 | ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
|
---|
558 | static uint32_t const s_auCpuIdRanges[] =
|
---|
559 | {
|
---|
560 | UINT32_C(0x00000000), UINT32_C(0x0000007f),
|
---|
561 | UINT32_C(0x80000000), UINT32_C(0x8000007f),
|
---|
562 | UINT32_C(0xc0000000), UINT32_C(0xc000007f)
|
---|
563 | };
|
---|
564 | for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
|
---|
565 | {
|
---|
566 | ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
|
---|
567 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
|
---|
568 | if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
|
---|
569 | continue;
|
---|
570 | cLeafs++;
|
---|
571 | for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
|
---|
572 | {
|
---|
573 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
|
---|
574 | RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
|
---|
575 | }
|
---|
576 | }
|
---|
577 | }
|
---|
578 | break;
|
---|
579 |
|
---|
580 | case LISTHDDBACKENDS:
|
---|
581 | {
|
---|
582 | ComPtr<ISystemProperties> systemProperties;
|
---|
583 | CHECK_ERROR(a->virtualBox,
|
---|
584 | COMGETTER(SystemProperties)(systemProperties.asOutParam()));
|
---|
585 | com::SafeIfaceArray <IMediumFormat> mediumFormats;
|
---|
586 | CHECK_ERROR(systemProperties,
|
---|
587 | COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
|
---|
588 |
|
---|
589 | RTPrintf("Supported hard disk backends:\n\n");
|
---|
590 | for (size_t i = 0; i < mediumFormats.size(); ++i)
|
---|
591 | {
|
---|
592 | /* General information */
|
---|
593 | Bstr id;
|
---|
594 | CHECK_ERROR(mediumFormats[i], COMGETTER(Id)(id.asOutParam()));
|
---|
595 |
|
---|
596 | Bstr description;
|
---|
597 | CHECK_ERROR(mediumFormats[i],
|
---|
598 | COMGETTER(Id)(description.asOutParam()));
|
---|
599 |
|
---|
600 | ULONG caps;
|
---|
601 | CHECK_ERROR(mediumFormats[i],
|
---|
602 | COMGETTER(Capabilities)(&caps));
|
---|
603 |
|
---|
604 | RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
|
---|
605 | i, id.raw(), description.raw(), caps);
|
---|
606 |
|
---|
607 | /* File extensions */
|
---|
608 | com::SafeArray <BSTR> fileExtensions;
|
---|
609 | CHECK_ERROR(mediumFormats[i],
|
---|
610 | COMGETTER(FileExtensions)(ComSafeArrayAsOutParam(fileExtensions)));
|
---|
611 | for (size_t j = 0; j < fileExtensions.size(); ++j)
|
---|
612 | {
|
---|
613 | RTPrintf("%ls", Bstr(fileExtensions[j]).raw());
|
---|
614 | if (j != fileExtensions.size()-1)
|
---|
615 | RTPrintf(",");
|
---|
616 | }
|
---|
617 | RTPrintf("'");
|
---|
618 |
|
---|
619 | /* Configuration keys */
|
---|
620 | com::SafeArray <BSTR> propertyNames;
|
---|
621 | com::SafeArray <BSTR> propertyDescriptions;
|
---|
622 | com::SafeArray <DataType_T> propertyTypes;
|
---|
623 | com::SafeArray <ULONG> propertyFlags;
|
---|
624 | com::SafeArray <BSTR> propertyDefaults;
|
---|
625 | CHECK_ERROR(mediumFormats[i],
|
---|
626 | DescribeProperties(ComSafeArrayAsOutParam(propertyNames),
|
---|
627 | ComSafeArrayAsOutParam(propertyDescriptions),
|
---|
628 | ComSafeArrayAsOutParam(propertyTypes),
|
---|
629 | ComSafeArrayAsOutParam(propertyFlags),
|
---|
630 | ComSafeArrayAsOutParam(propertyDefaults)));
|
---|
631 |
|
---|
632 | RTPrintf(" properties=(");
|
---|
633 | if (propertyNames.size() > 0)
|
---|
634 | {
|
---|
635 | for (size_t j = 0; j < propertyNames.size(); ++j)
|
---|
636 | {
|
---|
637 | RTPrintf("\n name='%ls' desc='%ls' type=",
|
---|
638 | Bstr(propertyNames[j]).raw(), Bstr(propertyDescriptions[j]).raw());
|
---|
639 | switch (propertyTypes[j])
|
---|
640 | {
|
---|
641 | case DataType_Int32: RTPrintf("int"); break;
|
---|
642 | case DataType_Int8: RTPrintf("byte"); break;
|
---|
643 | case DataType_String: RTPrintf("string"); break;
|
---|
644 | }
|
---|
645 | RTPrintf(" flags=%#04x", propertyFlags[j]);
|
---|
646 | RTPrintf(" default='%ls'", Bstr(propertyDefaults[j]).raw());
|
---|
647 | if (j != propertyNames.size()-1)
|
---|
648 | RTPrintf(", ");
|
---|
649 | }
|
---|
650 | }
|
---|
651 | RTPrintf(")\n");
|
---|
652 | }
|
---|
653 | }
|
---|
654 | break;
|
---|
655 |
|
---|
656 | case LISTHDDS:
|
---|
657 | {
|
---|
658 | com::SafeIfaceArray<IMedium> hdds;
|
---|
659 | CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
|
---|
660 | listHardDisks(a->virtualBox, hdds, "base");
|
---|
661 | }
|
---|
662 | break;
|
---|
663 |
|
---|
664 | case LISTDVDS:
|
---|
665 | {
|
---|
666 | com::SafeIfaceArray<IMedium> dvds;
|
---|
667 | CHECK_ERROR(a->virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
|
---|
668 | for (size_t i = 0; i < dvds.size(); ++i)
|
---|
669 | {
|
---|
670 | ComPtr<IMedium> dvdImage = dvds[i];
|
---|
671 | Bstr uuid;
|
---|
672 | dvdImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
673 | RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
|
---|
674 | Bstr filePath;
|
---|
675 | dvdImage->COMGETTER(Location)(filePath.asOutParam());
|
---|
676 | RTPrintf("Path: %lS\n", filePath.raw());
|
---|
677 | MediumState_T enmState;
|
---|
678 | dvdImage->RefreshState(&enmState);
|
---|
679 | RTPrintf("Accessible: %s\n", enmState != MediumState_Inaccessible ? "yes" : "no");
|
---|
680 |
|
---|
681 | com::SafeArray<BSTR> machineIds;
|
---|
682 | dvdImage->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds));
|
---|
683 | for (size_t j = 0; j < machineIds.size(); ++j)
|
---|
684 | {
|
---|
685 | ComPtr<IMachine> machine;
|
---|
686 | CHECK_ERROR(a->virtualBox, GetMachine(machineIds[j], machine.asOutParam()));
|
---|
687 | ASSERT(machine);
|
---|
688 | Bstr name;
|
---|
689 | machine->COMGETTER(Name)(name.asOutParam());
|
---|
690 | machine->COMGETTER(Id)(uuid.asOutParam());
|
---|
691 | RTPrintf("%s%lS (UUID: %lS)\n",
|
---|
692 | j == 0 ? "Usage: " : " ",
|
---|
693 | name.raw(), machineIds[j]);
|
---|
694 | }
|
---|
695 | RTPrintf("\n");
|
---|
696 | }
|
---|
697 | }
|
---|
698 | break;
|
---|
699 |
|
---|
700 | case LISTFLOPPIES:
|
---|
701 | {
|
---|
702 | com::SafeIfaceArray<IMedium> floppies;
|
---|
703 | CHECK_ERROR(a->virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
|
---|
704 | for (size_t i = 0; i < floppies.size(); ++i)
|
---|
705 | {
|
---|
706 | ComPtr<IMedium> floppyImage = floppies[i];
|
---|
707 | Bstr uuid;
|
---|
708 | floppyImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
709 | RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
|
---|
710 | Bstr filePath;
|
---|
711 | floppyImage->COMGETTER(Location)(filePath.asOutParam());
|
---|
712 | RTPrintf("Path: %lS\n", filePath.raw());
|
---|
713 | MediumState_T enmState;
|
---|
714 | floppyImage->RefreshState(&enmState);
|
---|
715 | RTPrintf("Accessible: %s\n", enmState != MediumState_Inaccessible ? "yes" : "no");
|
---|
716 |
|
---|
717 | com::SafeArray<BSTR> machineIds;
|
---|
718 | floppyImage->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds));
|
---|
719 | for (size_t j = 0; j < machineIds.size(); ++j)
|
---|
720 | {
|
---|
721 | ComPtr<IMachine> machine;
|
---|
722 | CHECK_ERROR(a->virtualBox, GetMachine(machineIds[j], machine.asOutParam()));
|
---|
723 | ASSERT(machine);
|
---|
724 | Bstr name;
|
---|
725 | machine->COMGETTER(Name)(name.asOutParam());
|
---|
726 | machine->COMGETTER(Id)(uuid.asOutParam());
|
---|
727 | RTPrintf("%s%lS (UUID: %lS)\n",
|
---|
728 | j == 0 ? "Usage: " : " ",
|
---|
729 | name.raw(), machineIds[j]);
|
---|
730 | }
|
---|
731 | RTPrintf("\n");
|
---|
732 | }
|
---|
733 | }
|
---|
734 | break;
|
---|
735 |
|
---|
736 | case LISTUSBHOST:
|
---|
737 | {
|
---|
738 | ComPtr<IHost> Host;
|
---|
739 | CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
|
---|
740 |
|
---|
741 | SafeIfaceArray <IHostUSBDevice> CollPtr;
|
---|
742 | CHECK_ERROR_RET(Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1);
|
---|
743 |
|
---|
744 | RTPrintf("Host USB Devices:\n\n");
|
---|
745 |
|
---|
746 | if (CollPtr.size() == 0)
|
---|
747 | {
|
---|
748 | RTPrintf("<none>\n\n");
|
---|
749 | }
|
---|
750 | else
|
---|
751 | {
|
---|
752 | for (size_t i = 0; i < CollPtr.size(); ++i)
|
---|
753 | {
|
---|
754 | ComPtr <IHostUSBDevice> dev = CollPtr[i];
|
---|
755 |
|
---|
756 | /* Query info. */
|
---|
757 | Bstr id;
|
---|
758 | CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), 1);
|
---|
759 | USHORT usVendorId;
|
---|
760 | CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), 1);
|
---|
761 | USHORT usProductId;
|
---|
762 | CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), 1);
|
---|
763 | USHORT bcdRevision;
|
---|
764 | CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), 1);
|
---|
765 |
|
---|
766 | RTPrintf("UUID: %S\n"
|
---|
767 | "VendorId: 0x%04x (%04X)\n"
|
---|
768 | "ProductId: 0x%04x (%04X)\n"
|
---|
769 | "Revision: %u.%u (%02u%02u)\n",
|
---|
770 | Utf8Str(id).raw(),
|
---|
771 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
772 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
773 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
774 |
|
---|
775 | /* optional stuff. */
|
---|
776 | Bstr bstr;
|
---|
777 | CHECK_ERROR_RET(dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
|
---|
778 | if (!bstr.isEmpty())
|
---|
779 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
780 | CHECK_ERROR_RET(dev, COMGETTER(Product)(bstr.asOutParam()), 1);
|
---|
781 | if (!bstr.isEmpty())
|
---|
782 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
783 | CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
784 | if (!bstr.isEmpty())
|
---|
785 | RTPrintf("SerialNumber: %lS\n", bstr.raw());
|
---|
786 | CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), 1);
|
---|
787 | if (!bstr.isEmpty())
|
---|
788 | RTPrintf("Address: %lS\n", bstr.raw());
|
---|
789 |
|
---|
790 | /* current state */
|
---|
791 | USBDeviceState_T state;
|
---|
792 | CHECK_ERROR_RET(dev, COMGETTER(State)(&state), 1);
|
---|
793 | const char *pszState = "?";
|
---|
794 | switch (state)
|
---|
795 | {
|
---|
796 | case USBDeviceState_NotSupported:
|
---|
797 | pszState = "Not supported"; break;
|
---|
798 | case USBDeviceState_Unavailable:
|
---|
799 | pszState = "Unavailable"; break;
|
---|
800 | case USBDeviceState_Busy:
|
---|
801 | pszState = "Busy"; break;
|
---|
802 | case USBDeviceState_Available:
|
---|
803 | pszState = "Available"; break;
|
---|
804 | case USBDeviceState_Held:
|
---|
805 | pszState = "Held"; break;
|
---|
806 | case USBDeviceState_Captured:
|
---|
807 | pszState = "Captured"; break;
|
---|
808 | default:
|
---|
809 | ASSERT(false);
|
---|
810 | break;
|
---|
811 | }
|
---|
812 | RTPrintf("Current State: %s\n\n", pszState);
|
---|
813 | }
|
---|
814 | }
|
---|
815 | }
|
---|
816 | break;
|
---|
817 |
|
---|
818 | case LISTUSBFILTERS:
|
---|
819 | {
|
---|
820 | RTPrintf("Global USB Device Filters:\n\n");
|
---|
821 |
|
---|
822 | ComPtr <IHost> host;
|
---|
823 | CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), 1);
|
---|
824 |
|
---|
825 | SafeIfaceArray <IHostUSBDeviceFilter> coll;
|
---|
826 | CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
|
---|
827 |
|
---|
828 | if (coll.size() == 0)
|
---|
829 | {
|
---|
830 | RTPrintf("<none>\n\n");
|
---|
831 | }
|
---|
832 | else
|
---|
833 | {
|
---|
834 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
835 | {
|
---|
836 | ComPtr<IHostUSBDeviceFilter> flt = coll[index];
|
---|
837 |
|
---|
838 | /* Query info. */
|
---|
839 |
|
---|
840 | RTPrintf("Index: %zu\n", index);
|
---|
841 |
|
---|
842 | BOOL active = FALSE;
|
---|
843 | CHECK_ERROR_RET(flt, COMGETTER(Active)(&active), 1);
|
---|
844 | RTPrintf("Active: %s\n", active ? "yes" : "no");
|
---|
845 |
|
---|
846 | USBDeviceFilterAction_T action;
|
---|
847 | CHECK_ERROR_RET(flt, COMGETTER(Action)(&action), 1);
|
---|
848 | const char *pszAction = "<invalid>";
|
---|
849 | switch (action)
|
---|
850 | {
|
---|
851 | case USBDeviceFilterAction_Ignore:
|
---|
852 | pszAction = "Ignore";
|
---|
853 | break;
|
---|
854 | case USBDeviceFilterAction_Hold:
|
---|
855 | pszAction = "Hold";
|
---|
856 | break;
|
---|
857 | default:
|
---|
858 | break;
|
---|
859 | }
|
---|
860 | RTPrintf("Action: %s\n", pszAction);
|
---|
861 |
|
---|
862 | Bstr bstr;
|
---|
863 | CHECK_ERROR_RET(flt, COMGETTER(Name)(bstr.asOutParam()), 1);
|
---|
864 | RTPrintf("Name: %lS\n", bstr.raw());
|
---|
865 | CHECK_ERROR_RET(flt, COMGETTER(VendorId)(bstr.asOutParam()), 1);
|
---|
866 | RTPrintf("VendorId: %lS\n", bstr.raw());
|
---|
867 | CHECK_ERROR_RET(flt, COMGETTER(ProductId)(bstr.asOutParam()), 1);
|
---|
868 | RTPrintf("ProductId: %lS\n", bstr.raw());
|
---|
869 | CHECK_ERROR_RET(flt, COMGETTER(Revision)(bstr.asOutParam()), 1);
|
---|
870 | RTPrintf("Revision: %lS\n", bstr.raw());
|
---|
871 | CHECK_ERROR_RET(flt, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
|
---|
872 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
873 | CHECK_ERROR_RET(flt, COMGETTER(Product)(bstr.asOutParam()), 1);
|
---|
874 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
875 | CHECK_ERROR_RET(flt, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
876 | RTPrintf("Serial Number: %lS\n\n", bstr.raw());
|
---|
877 | }
|
---|
878 | }
|
---|
879 | }
|
---|
880 | break;
|
---|
881 |
|
---|
882 | case LISTSYSTEMPROPERTIES:
|
---|
883 | {
|
---|
884 | ComPtr<ISystemProperties> systemProperties;
|
---|
885 | a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
|
---|
886 |
|
---|
887 | Bstr str;
|
---|
888 | ULONG ulValue;
|
---|
889 | ULONG64 ul64Value;
|
---|
890 |
|
---|
891 | systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
|
---|
892 | RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
|
---|
893 | systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
|
---|
894 | RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
|
---|
895 | systemProperties->COMGETTER(MinGuestVRAM)(&ulValue);
|
---|
896 | RTPrintf("Minimum video RAM size: %u Megabytes\n", ulValue);
|
---|
897 | systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
|
---|
898 | RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
|
---|
899 | systemProperties->COMGETTER(MinGuestCPUCount)(&ulValue);
|
---|
900 | RTPrintf("Minimum guest CPU count: %u\n", ulValue);
|
---|
901 | systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
|
---|
902 | RTPrintf("Maximum guest CPU count: %u\n", ulValue);
|
---|
903 | systemProperties->COMGETTER(MaxVDISize)(&ul64Value);
|
---|
904 | RTPrintf("Maximum VDI size: %lu Megabytes\n", ul64Value);
|
---|
905 | systemProperties->COMGETTER(NetworkAdapterCount)(&ulValue);
|
---|
906 | RTPrintf("Maximum Network Adapter count: %u\n", ulValue);
|
---|
907 | systemProperties->COMGETTER(SerialPortCount)(&ulValue);
|
---|
908 | RTPrintf("Maximum Serial Port count: %u\n", ulValue);
|
---|
909 | systemProperties->COMGETTER(ParallelPortCount)(&ulValue);
|
---|
910 | RTPrintf("Maximum Parallel Port count: %u\n", ulValue);
|
---|
911 | systemProperties->COMGETTER(MaxBootPosition)(&ulValue);
|
---|
912 | RTPrintf("Maximum Boot Position: %u\n", ulValue);
|
---|
913 | systemProperties->GetMaxInstancesOfStorageBus(StorageBus_IDE, &ulValue);
|
---|
914 | RTPrintf("Maximum IDE Controllers: %u\n", ulValue);
|
---|
915 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_IDE, &ulValue);
|
---|
916 | RTPrintf("Maximum IDE Port count: %u\n", ulValue);
|
---|
917 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_IDE, &ulValue);
|
---|
918 | RTPrintf("Maximum Devices per IDE Port: %u\n", ulValue);
|
---|
919 | systemProperties->GetMaxInstancesOfStorageBus(StorageBus_SATA, &ulValue);
|
---|
920 | RTPrintf("Maximum SATA Controllers: %u\n", ulValue);
|
---|
921 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SATA, &ulValue);
|
---|
922 | RTPrintf("Maximum SATA Port count: %u\n", ulValue);
|
---|
923 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SATA, &ulValue);
|
---|
924 | RTPrintf("Maximum Devices per SATA Port: %u\n", ulValue);
|
---|
925 | systemProperties->GetMaxInstancesOfStorageBus(StorageBus_SCSI, &ulValue);
|
---|
926 | RTPrintf("Maximum SCSI Controllers: %u\n", ulValue);
|
---|
927 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
928 | RTPrintf("Maximum SCSI Port count: %u\n", ulValue);
|
---|
929 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
930 | RTPrintf("Maximum Devices per SCSI Port: %u\n", ulValue);
|
---|
931 | systemProperties->GetMaxInstancesOfStorageBus(StorageBus_Floppy, &ulValue);
|
---|
932 | RTPrintf("Maximum Floppy Controllers: %u\n", ulValue);
|
---|
933 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
934 | RTPrintf("Maximum Floppy Port count: %u\n", ulValue);
|
---|
935 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
936 | RTPrintf("Maximum Devices per Floppy Port: %u\n", ulValue);
|
---|
937 | systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
|
---|
938 | RTPrintf("Default machine folder: %lS\n", str.raw());
|
---|
939 | systemProperties->COMGETTER(DefaultHardDiskFolder)(str.asOutParam());
|
---|
940 | RTPrintf("Default hard disk folder: %lS\n", str.raw());
|
---|
941 | systemProperties->COMGETTER(RemoteDisplayAuthLibrary)(str.asOutParam());
|
---|
942 | RTPrintf("VRDP authentication library: %lS\n", str.raw());
|
---|
943 | systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
|
---|
944 | RTPrintf("Webservice auth. library: %lS\n", str.raw());
|
---|
945 | systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
|
---|
946 | RTPrintf("Log history count: %u\n", ulValue);
|
---|
947 |
|
---|
948 | }
|
---|
949 | break;
|
---|
950 | case LISTDHCPSERVERS:
|
---|
951 | {
|
---|
952 | com::SafeIfaceArray<IDHCPServer> svrs;
|
---|
953 | CHECK_ERROR(a->virtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs)));
|
---|
954 | for (size_t i = 0; i < svrs.size(); ++i)
|
---|
955 | {
|
---|
956 | ComPtr<IDHCPServer> svr = svrs[i];
|
---|
957 | Bstr netName;
|
---|
958 | svr->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
959 | RTPrintf("NetworkName: %lS\n", netName.raw());
|
---|
960 | Bstr ip;
|
---|
961 | svr->COMGETTER(IPAddress)(ip.asOutParam());
|
---|
962 | RTPrintf("IP: %lS\n", ip.raw());
|
---|
963 | Bstr netmask;
|
---|
964 | svr->COMGETTER(NetworkMask)(netmask.asOutParam());
|
---|
965 | RTPrintf("NetworkMask: %lS\n", netmask.raw());
|
---|
966 | Bstr lowerIp;
|
---|
967 | svr->COMGETTER(LowerIP)(lowerIp.asOutParam());
|
---|
968 | RTPrintf("lowerIPAddress: %lS\n", lowerIp.raw());
|
---|
969 | Bstr upperIp;
|
---|
970 | svr->COMGETTER(UpperIP)(upperIp.asOutParam());
|
---|
971 | RTPrintf("upperIPAddress: %lS\n", upperIp.raw());
|
---|
972 | BOOL bEnabled;
|
---|
973 | svr->COMGETTER(Enabled)(&bEnabled);
|
---|
974 | RTPrintf("Enabled: %s\n", bEnabled ? "Yes" : "No");
|
---|
975 | RTPrintf("\n");
|
---|
976 | }
|
---|
977 | }
|
---|
978 | break;
|
---|
979 | case LISTNATPFS:
|
---|
980 | {
|
---|
981 | ComPtr<IMachine> machine;
|
---|
982 | ComPtr<INetworkAdapter> nic;
|
---|
983 | ComPtr<INATEngine> driver;
|
---|
984 | com::SafeArray<BSTR> rules;
|
---|
985 | if (!Guid(Bstr(a->argv[1])).isEmpty())
|
---|
986 | {
|
---|
987 | CHECK_ERROR_RET(a->virtualBox, GetMachine(Bstr(a->argv[1]), machine.asOutParam()), 1);
|
---|
988 | }
|
---|
989 | else
|
---|
990 | {
|
---|
991 | CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(a->argv[1]), machine.asOutParam()), 1);
|
---|
992 | }
|
---|
993 |
|
---|
994 | ASSERT(machine);
|
---|
995 |
|
---|
996 | CHECK_ERROR_BREAK(machine, GetNetworkAdapter(RTStrToUInt32(&a->argv[0][8]) - 1, nic.asOutParam()));
|
---|
997 | ASSERT(nic);
|
---|
998 | CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam()));
|
---|
999 | CHECK_ERROR(driver, COMGETTER(Redirects)(ComSafeArrayAsOutParam(rules)));
|
---|
1000 | for (size_t i = 0; i < rules.size(); ++i)
|
---|
1001 | {
|
---|
1002 | uint16_t port = 0;
|
---|
1003 | BSTR r = rules[i];
|
---|
1004 | Utf8Str utf = Utf8Str(r);
|
---|
1005 | Utf8Str strName;
|
---|
1006 | Utf8Str strProto;
|
---|
1007 | Utf8Str strHostPort;
|
---|
1008 | Utf8Str strHostIP;
|
---|
1009 | Utf8Str strGuestPort;
|
---|
1010 | Utf8Str strGuestIP;
|
---|
1011 | size_t pos, ppos;
|
---|
1012 | pos = ppos = 0;
|
---|
1013 | #define ITERATE_TO_NEXT_TERM(res, str, pos, ppos) \
|
---|
1014 | do { \
|
---|
1015 | pos = str.find(",", ppos); \
|
---|
1016 | if (pos == Utf8Str::npos) \
|
---|
1017 | { \
|
---|
1018 | Log(( #res " extracting from %s is failed\n", str.raw())); \
|
---|
1019 | return E_INVALIDARG; \
|
---|
1020 | } \
|
---|
1021 | res = str.substr(ppos, pos - ppos); \
|
---|
1022 | Log2((#res " %s pos:%d, ppos:%d\n", res.raw(), pos, ppos)); \
|
---|
1023 | ppos = pos + 1; \
|
---|
1024 | } while (0)
|
---|
1025 | ITERATE_TO_NEXT_TERM(strName, utf, pos, ppos);
|
---|
1026 | ITERATE_TO_NEXT_TERM(strProto, utf, pos, ppos);
|
---|
1027 | ITERATE_TO_NEXT_TERM(strHostIP, utf, pos, ppos);
|
---|
1028 | ITERATE_TO_NEXT_TERM(strHostPort, utf, pos, ppos);
|
---|
1029 | ITERATE_TO_NEXT_TERM(strGuestIP, utf, pos, ppos);
|
---|
1030 | strGuestPort = utf.substr(ppos, utf.length() - ppos);
|
---|
1031 | #undef ITERATE_TO_NEXT_TERM
|
---|
1032 | switch (strProto.toUInt32())
|
---|
1033 | {
|
---|
1034 | case NATProtocol_TCP:
|
---|
1035 | strProto = "tcp";
|
---|
1036 | break;
|
---|
1037 | case NATProtocol_UDP:
|
---|
1038 | strProto = "udp";
|
---|
1039 | break;
|
---|
1040 | default:
|
---|
1041 | strProto = "unk";
|
---|
1042 | break;
|
---|
1043 | }
|
---|
1044 | RTPrintf("%s:%s:%s:%s:%s:%s\n", strName.raw(), strProto.raw(),
|
---|
1045 | strHostIP.isEmpty() ? "": strHostIP.raw(), strHostPort.raw(),
|
---|
1046 | strGuestIP.isEmpty() ? "": strGuestIP.raw(), strGuestPort.raw());
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | }
|
---|
1050 | break;
|
---|
1051 | } // end switch
|
---|
1052 |
|
---|
1053 | return SUCCEEDED(rc) ? 0 : 1;
|
---|
1054 | }
|
---|
1055 |
|
---|
1056 | #endif /* !VBOX_ONLY_DOCS */
|
---|
1057 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|