VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp@ 30125

Last change on this file since 30125 was 29356, checked in by vboxsync, 15 years ago

Frontends/VBoxManage: When listing floppies and DVDs now use the same function as for hard disks. This provides more detailed information and reduces the code size.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette