VirtualBox

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

Last change on this file since 33524 was 33524, checked in by vboxsync, 14 years ago

Storage: Implement offical support for other disk types like DVD and floppy images. DMG images can be used now without hacks

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