VirtualBox

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

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

Main/Medium: remaining bits for MediumType_Readonly

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