VirtualBox

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

Last change on this file since 22480 was 21734, checked in by vboxsync, 15 years ago

API: implement IHost::GetProcessorDescription

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 33.0 KB
Line 
1/* $Id: VBoxManageList.cpp 21734 2009-07-21 10:04:46Z vboxsync $ */
2/** @file
3 * VBoxManage - The 'list' command.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef VBOX_ONLY_DOCS
23
24/*******************************************************************************
25* Header Files *
26*******************************************************************************/
27#include <VBox/com/com.h>
28#include <VBox/com/string.h>
29#include <VBox/com/Guid.h>
30#include <VBox/com/array.h>
31#include <VBox/com/ErrorInfo.h>
32#include <VBox/com/errorprint.h>
33
34#include <VBox/com/VirtualBox.h>
35
36#include <VBox/log.h>
37#include <iprt/stream.h>
38#include <iprt/string.h>
39#include <iprt/time.h>
40#include <iprt/getopt.h>
41#include <iprt/ctype.h>
42
43#include "VBoxManage.h"
44using namespace com;
45
46#ifdef VBOX_WITH_HOSTNETIF_API
47static const char *getHostIfMediumTypeText(HostNetworkInterfaceMediumType_T enmType)
48{
49 switch (enmType)
50 {
51 case HostNetworkInterfaceMediumType_Ethernet: return "Ethernet";
52 case HostNetworkInterfaceMediumType_PPP: return "PPP";
53 case HostNetworkInterfaceMediumType_SLIP: return "SLIP";
54 }
55 return "Unknown";
56}
57
58static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
59{
60 switch (enmStatus)
61 {
62 case HostNetworkInterfaceStatus_Up: return "Up";
63 case HostNetworkInterfaceStatus_Down: return "Down";
64 }
65 return "Unknown";
66}
67#endif
68
69enum enOptionCodes
70{
71 LISTVMS = 1000,
72 LISTRUNNINGVMS,
73 LISTOSTYPES,
74 LISTHOSTDVDS,
75 LISTHOSTFLOPPIES,
76 LISTBRIDGEDIFS,
77#if defined(VBOX_WITH_NETFLT)
78 LISTHOSTONLYIFS,
79#endif
80 LISTHOSTINFO,
81 LISTHDDBACKENDS,
82 LISTHDDS,
83 LISTDVDS,
84 LISTFLOPPIES,
85 LISTUSBHOST,
86 LISTUSBFILTERS,
87 LISTSYSTEMPROPERTIES,
88 LISTDHCPSERVERS
89};
90
91static const RTGETOPTDEF g_aListOptions[]
92 = {
93 { "--long", 'l', RTGETOPT_REQ_NOTHING },
94 { "vms", LISTVMS, RTGETOPT_REQ_NOTHING },
95 { "runningvms", LISTRUNNINGVMS, RTGETOPT_REQ_NOTHING },
96 { "ostypes", LISTOSTYPES, RTGETOPT_REQ_NOTHING },
97 { "hostdvds", LISTHOSTDVDS, RTGETOPT_REQ_NOTHING },
98 { "hostfloppies", LISTHOSTFLOPPIES, RTGETOPT_REQ_NOTHING },
99 { "hostifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
100 { "bridgedifs", LISTBRIDGEDIFS, RTGETOPT_REQ_NOTHING },
101#if defined(VBOX_WITH_NETFLT)
102 { "hostonlyifs", LISTHOSTONLYIFS, RTGETOPT_REQ_NOTHING },
103#endif
104 { "hostinfo", LISTHOSTINFO, RTGETOPT_REQ_NOTHING },
105 { "hddbackends", LISTHDDBACKENDS, RTGETOPT_REQ_NOTHING },
106 { "hdds", LISTHDDS, RTGETOPT_REQ_NOTHING },
107 { "dvds", LISTDVDS, RTGETOPT_REQ_NOTHING },
108 { "floppies", LISTFLOPPIES, RTGETOPT_REQ_NOTHING },
109 { "usbhost", LISTUSBHOST, RTGETOPT_REQ_NOTHING },
110 { "usbfilters", LISTUSBFILTERS, RTGETOPT_REQ_NOTHING },
111 { "systemproperties", LISTSYSTEMPROPERTIES, RTGETOPT_REQ_NOTHING },
112 { "dhcpservers", LISTDHCPSERVERS, RTGETOPT_REQ_NOTHING }
113 };
114
115int handleList(HandlerArg *a)
116{
117 HRESULT rc = S_OK;
118
119 bool fOptLong = false;
120
121 int command = 0;
122 int c;
123
124 RTGETOPTUNION ValueUnion;
125 RTGETOPTSTATE GetState;
126 RTGetOptInit(&GetState, a->argc, a->argv, g_aListOptions, RT_ELEMENTS(g_aListOptions), 0, 0 /* fFlags */);
127 while ((c = RTGetOpt(&GetState, &ValueUnion)))
128 {
129 switch (c)
130 {
131 case 'l': // --long
132 fOptLong = true;
133 break;
134
135 case LISTVMS:
136 case LISTRUNNINGVMS:
137 case LISTOSTYPES:
138 case LISTHOSTDVDS:
139 case LISTHOSTFLOPPIES:
140 case LISTBRIDGEDIFS:
141#if defined(VBOX_WITH_NETFLT)
142 case LISTHOSTONLYIFS:
143#endif
144 case LISTHOSTINFO:
145 case LISTHDDBACKENDS:
146 case LISTHDDS:
147 case LISTDVDS:
148 case LISTFLOPPIES:
149 case LISTUSBHOST:
150 case LISTUSBFILTERS:
151 case LISTSYSTEMPROPERTIES:
152 case LISTDHCPSERVERS:
153 if (command)
154 return errorSyntax(USAGE_LIST, "Too many subcommands for \"list\" command.\n");
155
156 command = c;
157 break;
158
159 case VINF_GETOPT_NOT_OPTION:
160 return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
161 break;
162
163 default:
164 if (c > 0)
165 {
166 if (RT_C_IS_GRAPH(c))
167 return errorSyntax(USAGE_LIST, "unhandled option: -%c", c);
168 else
169 return errorSyntax(USAGE_LIST, "unhandled option: %i", c);
170 }
171 else if (c == VERR_GETOPT_UNKNOWN_OPTION)
172 return errorSyntax(USAGE_LIST, "unknown option: %s", ValueUnion.psz);
173 else if (ValueUnion.pDef)
174 return errorSyntax(USAGE_LIST, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
175 else
176 return errorSyntax(USAGE_LIST, "%Rrs", c);
177 }
178 }
179
180 if (!command)
181 return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
182
183 /* which object? */
184 switch (command)
185 {
186 case LISTVMS:
187 {
188 /*
189 * Get the list of all registered VMs
190 */
191 com::SafeIfaceArray <IMachine> machines;
192 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam (machines));
193 if (SUCCEEDED(rc))
194 {
195 /*
196 * Iterate through the collection
197 */
198 for (size_t i = 0; i < machines.size(); ++ i)
199 {
200 if (machines[i])
201 rc = showVMInfo(a->virtualBox,
202 machines[i],
203 (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
204 }
205 }
206 }
207 break;
208
209 case LISTRUNNINGVMS:
210 {
211 /*
212 * Get the list of all _running_ VMs
213 */
214 com::SafeIfaceArray <IMachine> machines;
215 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam (machines));
216 if (SUCCEEDED(rc))
217 {
218 /*
219 * Iterate through the collection
220 */
221 for (size_t i = 0; i < machines.size(); ++ i)
222 {
223 if (machines[i])
224 {
225 MachineState_T machineState;
226 rc = machines [i]->COMGETTER(State)(&machineState);
227 if (SUCCEEDED(rc))
228 {
229 switch (machineState)
230 {
231 case MachineState_Running:
232 case MachineState_Paused:
233 rc = showVMInfo(a->virtualBox,
234 machines[i],
235 (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
236 }
237 }
238 }
239 }
240 }
241 }
242 break;
243
244 case LISTOSTYPES:
245 {
246 com::SafeIfaceArray <IGuestOSType> coll;
247 rc = a->virtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
248 if (SUCCEEDED(rc))
249 {
250 /*
251 * Iterate through the collection.
252 */
253 for (size_t i = 0; i < coll.size(); ++ i)
254 {
255 ComPtr<IGuestOSType> guestOS;
256 guestOS = coll[i];
257 Bstr guestId;
258 guestOS->COMGETTER(Id)(guestId.asOutParam());
259 RTPrintf("ID: %lS\n", guestId.raw());
260 Bstr guestDescription;
261 guestOS->COMGETTER(Description)(guestDescription.asOutParam());
262 RTPrintf("Description: %lS\n\n", guestDescription.raw());
263 }
264 }
265 }
266 break;
267
268 case LISTHOSTDVDS:
269 {
270 ComPtr<IHost> host;
271 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
272 com::SafeIfaceArray <IHostDVDDrive> coll;
273 CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
274 if (SUCCEEDED(rc))
275 {
276 for (size_t i = 0; i < coll.size(); ++ i)
277 {
278 ComPtr<IHostDVDDrive> dvdDrive = coll[i];
279 Bstr name;
280 dvdDrive->COMGETTER(Name)(name.asOutParam());
281 RTPrintf("Name: %lS\n\n", name.raw());
282 }
283 }
284 }
285 break;
286
287 case LISTHOSTFLOPPIES:
288 {
289 ComPtr<IHost> host;
290 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
291 com::SafeIfaceArray <IHostFloppyDrive> coll;
292 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
293 if (SUCCEEDED(rc))
294 {
295 for (size_t i = 0; i < coll.size(); ++i)
296 {
297 ComPtr<IHostFloppyDrive> floppyDrive = coll[i];
298 Bstr name;
299 floppyDrive->COMGETTER(Name)(name.asOutParam());
300 RTPrintf("Name: %lS\n\n", name.raw());
301 }
302 }
303 }
304 break;
305
306 case LISTBRIDGEDIFS:
307#if defined(VBOX_WITH_NETFLT)
308 case LISTHOSTONLYIFS:
309#endif
310 {
311 ComPtr<IHost> host;
312 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
313 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
314#if defined(VBOX_WITH_NETFLT)
315 if (command == LISTBRIDGEDIFS)
316 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged,
317 ComSafeArrayAsOutParam(hostNetworkInterfaces)));
318 else
319 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_HostOnly,
320 ComSafeArrayAsOutParam(hostNetworkInterfaces)));
321#else
322 CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(hostNetworkInterfaces)));
323#endif
324 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
325 {
326 ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
327#ifndef VBOX_WITH_HOSTNETIF_API
328 Bstr interfaceName;
329 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
330 RTPrintf("Name: %lS\n", interfaceName.raw());
331 Guid interfaceGuid;
332 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
333 RTPrintf("GUID: %lS\n\n", Bstr(interfaceGuid.toString()).raw());
334#else /* VBOX_WITH_HOSTNETIF_API */
335 Bstr interfaceName;
336 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
337 RTPrintf("Name: %lS\n", interfaceName.raw());
338 Bstr interfaceGuid;
339 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
340 RTPrintf("GUID: %lS\n", interfaceGuid.raw());
341 BOOL bDhcpEnabled;
342 networkInterface->COMGETTER(DhcpEnabled)(&bDhcpEnabled);
343 RTPrintf("Dhcp: %s\n", bDhcpEnabled ? "Enabled" : "Disabled");
344
345 Bstr IPAddress;
346 networkInterface->COMGETTER(IPAddress)(IPAddress.asOutParam());
347 RTPrintf("IPAddress: %lS\n", IPAddress.raw());
348 Bstr NetworkMask;
349 networkInterface->COMGETTER(NetworkMask)(NetworkMask.asOutParam());
350 RTPrintf("NetworkMask: %lS\n", NetworkMask.raw());
351 Bstr IPV6Address;
352 networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
353 RTPrintf("IPV6Address: %lS\n", IPV6Address.raw());
354 ULONG IPV6NetworkMaskPrefixLength;
355 networkInterface->COMGETTER(IPV6NetworkMaskPrefixLength)(&IPV6NetworkMaskPrefixLength);
356 RTPrintf("IPV6NetworkMaskPrefixLength: %d\n", IPV6NetworkMaskPrefixLength);
357 Bstr HardwareAddress;
358 networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
359 RTPrintf("HardwareAddress: %lS\n", HardwareAddress.raw());
360 HostNetworkInterfaceMediumType_T Type;
361 networkInterface->COMGETTER(MediumType)(&Type);
362 RTPrintf("MediumType: %s\n", getHostIfMediumTypeText(Type));
363 HostNetworkInterfaceStatus_T Status;
364 networkInterface->COMGETTER(Status)(&Status);
365 RTPrintf("Status: %s\n", getHostIfStatusText(Status));
366 Bstr netName;
367 networkInterface->COMGETTER(NetworkName)(netName.asOutParam());
368 RTPrintf("VBoxNetworkName: %lS\n\n", netName.raw());
369
370#endif
371 }
372 }
373 break;
374
375 case LISTHOSTINFO:
376 {
377 ComPtr<IHost> Host;
378 CHECK_ERROR (a->virtualBox, COMGETTER(Host)(Host.asOutParam()));
379
380 RTPrintf("Host Information:\n\n");
381
382 LONG64 uTCTime = 0;
383 CHECK_ERROR (Host, COMGETTER(UTCTime)(&uTCTime));
384 RTTIMESPEC timeSpec;
385 RTTimeSpecSetMilli(&timeSpec, uTCTime);
386 char szTime[32] = {0};
387 RTTimeSpecToString(&timeSpec, szTime, sizeof(szTime));
388 RTPrintf("Host time: %s\n", szTime);
389
390 ULONG processorOnlineCount = 0;
391 CHECK_ERROR (Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
392 RTPrintf("Processor online count: %lu\n", processorOnlineCount);
393 ULONG processorCount = 0;
394 CHECK_ERROR (Host, COMGETTER(ProcessorCount)(&processorCount));
395 RTPrintf("Processor count: %lu\n", processorCount);
396 ULONG processorSpeed = 0;
397 Bstr processorDescription;
398 for (ULONG i = 0; i < processorCount; i++)
399 {
400 CHECK_ERROR (Host, GetProcessorSpeed(i, &processorSpeed));
401 if (processorSpeed)
402 RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
403 else
404 RTPrintf("Processor#%u speed: unknown\n", i, processorSpeed);
405 CHECK_ERROR (Host, GetProcessorDescription(i, processorDescription.asOutParam()));
406 RTPrintf("Processor#%u description: %lS\n", i, processorDescription.raw());
407 }
408
409 ULONG memorySize = 0;
410 CHECK_ERROR (Host, COMGETTER(MemorySize)(&memorySize));
411 RTPrintf("Memory size: %lu MByte\n", memorySize);
412
413 ULONG memoryAvailable = 0;
414 CHECK_ERROR (Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
415 RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
416
417 Bstr operatingSystem;
418 CHECK_ERROR (Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
419 RTPrintf("Operating system: %lS\n", operatingSystem.raw());
420
421 Bstr oSVersion;
422 CHECK_ERROR (Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
423 RTPrintf("Operating system version: %lS\n", oSVersion.raw());
424 }
425 break;
426
427 case LISTHDDBACKENDS:
428 {
429 ComPtr<ISystemProperties> systemProperties;
430 CHECK_ERROR(a->virtualBox,
431 COMGETTER(SystemProperties) (systemProperties.asOutParam()));
432 com::SafeIfaceArray <IHardDiskFormat> hardDiskFormats;
433 CHECK_ERROR(systemProperties,
434 COMGETTER(HardDiskFormats) (ComSafeArrayAsOutParam (hardDiskFormats)));
435
436 RTPrintf("Supported hard disk backends:\n\n");
437 for (size_t i = 0; i < hardDiskFormats.size(); ++ i)
438 {
439 /* General information */
440 Bstr id;
441 CHECK_ERROR(hardDiskFormats [i],
442 COMGETTER(Id) (id.asOutParam()));
443
444 Bstr description;
445 CHECK_ERROR(hardDiskFormats [i],
446 COMGETTER(Id) (description.asOutParam()));
447
448 ULONG caps;
449 CHECK_ERROR(hardDiskFormats [i],
450 COMGETTER(Capabilities) (&caps));
451
452 RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
453 i, id.raw(), description.raw(), caps);
454
455 /* File extensions */
456 com::SafeArray <BSTR> fileExtensions;
457 CHECK_ERROR(hardDiskFormats [i],
458 COMGETTER(FileExtensions) (ComSafeArrayAsOutParam (fileExtensions)));
459 for (size_t a = 0; a < fileExtensions.size(); ++ a)
460 {
461 RTPrintf ("%ls", Bstr (fileExtensions [a]).raw());
462 if (a != fileExtensions.size()-1)
463 RTPrintf (",");
464 }
465 RTPrintf ("'");
466
467 /* Configuration keys */
468 com::SafeArray <BSTR> propertyNames;
469 com::SafeArray <BSTR> propertyDescriptions;
470 com::SafeArray <DataType_T> propertyTypes;
471 com::SafeArray <ULONG> propertyFlags;
472 com::SafeArray <BSTR> propertyDefaults;
473 CHECK_ERROR(hardDiskFormats [i],
474 DescribeProperties (ComSafeArrayAsOutParam (propertyNames),
475 ComSafeArrayAsOutParam (propertyDescriptions),
476 ComSafeArrayAsOutParam (propertyTypes),
477 ComSafeArrayAsOutParam (propertyFlags),
478 ComSafeArrayAsOutParam (propertyDefaults)));
479
480 RTPrintf (" properties=(");
481 if (propertyNames.size() > 0)
482 {
483 for (size_t a = 0; a < propertyNames.size(); ++ a)
484 {
485 RTPrintf ("\n name='%ls' desc='%ls' type=",
486 Bstr (propertyNames [a]).raw(), Bstr (propertyDescriptions [a]).raw());
487 switch (propertyTypes [a])
488 {
489 case DataType_Int32: RTPrintf ("int"); break;
490 case DataType_Int8: RTPrintf ("byte"); break;
491 case DataType_String: RTPrintf ("string"); break;
492 }
493 RTPrintf (" flags=%#04x", propertyFlags [a]);
494 RTPrintf (" default='%ls'", Bstr (propertyDefaults [a]).raw());
495 if (a != propertyNames.size()-1)
496 RTPrintf (", ");
497 }
498 }
499 RTPrintf (")\n");
500 }
501 }
502 break;
503
504 case LISTHDDS:
505 {
506 com::SafeIfaceArray<IHardDisk> hdds;
507 CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam (hdds)));
508 for (size_t i = 0; i < hdds.size(); ++ i)
509 {
510 ComPtr<IHardDisk> hdd = hdds[i];
511 Bstr uuid;
512 hdd->COMGETTER(Id)(uuid.asOutParam());
513 RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
514 Bstr format;
515 hdd->COMGETTER(Format)(format.asOutParam());
516 RTPrintf("Format: %lS\n", format.raw());
517 Bstr filepath;
518 hdd->COMGETTER(Location)(filepath.asOutParam());
519 RTPrintf("Location: %lS\n", filepath.raw());
520 MediaState_T enmState;
521 /// @todo NEWMEDIA check accessibility of all parents
522 /// @todo NEWMEDIA print the full state value
523 hdd->COMGETTER(State)(&enmState);
524 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
525 com::SafeArray<BSTR> machineIds;
526 hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds));
527 for (size_t j = 0; j < machineIds.size(); ++ j)
528 {
529 ComPtr<IMachine> machine;
530 CHECK_ERROR(a->virtualBox, GetMachine(machineIds[j], machine.asOutParam()));
531 ASSERT(machine);
532 Bstr name;
533 machine->COMGETTER(Name)(name.asOutParam());
534 machine->COMGETTER(Id)(uuid.asOutParam());
535 RTPrintf("%s%lS (UUID: %lS)\n",
536 j == 0 ? "Usage: " : " ",
537 name.raw(), machineIds[j]);
538 }
539 /// @todo NEWMEDIA check usage in snapshots too
540 /// @todo NEWMEDIA also list children and say 'differencing' for
541 /// hard disks with the parent or 'base' otherwise.
542 RTPrintf("\n");
543 }
544 }
545 break;
546
547 case LISTDVDS:
548 {
549 com::SafeIfaceArray<IDVDImage> dvds;
550 CHECK_ERROR(a->virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
551 for (size_t i = 0; i < dvds.size(); ++ i)
552 {
553 ComPtr<IDVDImage> dvdImage = dvds[i];
554 Bstr uuid;
555 dvdImage->COMGETTER(Id)(uuid.asOutParam());
556 RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
557 Bstr filePath;
558 dvdImage->COMGETTER(Location)(filePath.asOutParam());
559 RTPrintf("Path: %lS\n", filePath.raw());
560 MediaState_T enmState;
561 dvdImage->COMGETTER(State)(&enmState);
562 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
563 /** @todo usage */
564 RTPrintf("\n");
565 }
566 }
567 break;
568
569 case LISTFLOPPIES:
570 {
571 com::SafeIfaceArray<IFloppyImage> floppies;
572 CHECK_ERROR(a->virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
573 for (size_t i = 0; i < floppies.size(); ++ i)
574 {
575 ComPtr<IFloppyImage> floppyImage = floppies[i];
576 Bstr uuid;
577 floppyImage->COMGETTER(Id)(uuid.asOutParam());
578 RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
579 Bstr filePath;
580 floppyImage->COMGETTER(Location)(filePath.asOutParam());
581 RTPrintf("Path: %lS\n", filePath.raw());
582 MediaState_T enmState;
583 floppyImage->COMGETTER(State)(&enmState);
584 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
585 /** @todo usage */
586 RTPrintf("\n");
587 }
588 }
589 break;
590
591 case LISTUSBHOST:
592 {
593 ComPtr<IHost> Host;
594 CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
595
596 SafeIfaceArray <IHostUSBDevice> CollPtr;
597 CHECK_ERROR_RET (Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1);
598
599 RTPrintf("Host USB Devices:\n\n");
600
601 if (CollPtr.size() == 0)
602 {
603 RTPrintf("<none>\n\n");
604 }
605 else
606 {
607 for (size_t i = 0; i < CollPtr.size(); ++i)
608 {
609 ComPtr <IHostUSBDevice> dev = CollPtr[i];
610
611 /* Query info. */
612 Bstr id;
613 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), 1);
614 USHORT usVendorId;
615 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), 1);
616 USHORT usProductId;
617 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), 1);
618 USHORT bcdRevision;
619 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), 1);
620
621 RTPrintf("UUID: %S\n"
622 "VendorId: 0x%04x (%04X)\n"
623 "ProductId: 0x%04x (%04X)\n"
624 "Revision: %u.%u (%02u%02u)\n",
625 Utf8Str(id).raw(),
626 usVendorId, usVendorId, usProductId, usProductId,
627 bcdRevision >> 8, bcdRevision & 0xff,
628 bcdRevision >> 8, bcdRevision & 0xff);
629
630 /* optional stuff. */
631 Bstr bstr;
632 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
633 if (!bstr.isEmpty())
634 RTPrintf("Manufacturer: %lS\n", bstr.raw());
635 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), 1);
636 if (!bstr.isEmpty())
637 RTPrintf("Product: %lS\n", bstr.raw());
638 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
639 if (!bstr.isEmpty())
640 RTPrintf("SerialNumber: %lS\n", bstr.raw());
641 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), 1);
642 if (!bstr.isEmpty())
643 RTPrintf("Address: %lS\n", bstr.raw());
644
645 /* current state */
646 USBDeviceState_T state;
647 CHECK_ERROR_RET (dev, COMGETTER(State)(&state), 1);
648 const char *pszState = "?";
649 switch (state)
650 {
651 case USBDeviceState_NotSupported:
652 pszState = "Not supported"; break;
653 case USBDeviceState_Unavailable:
654 pszState = "Unavailable"; break;
655 case USBDeviceState_Busy:
656 pszState = "Busy"; break;
657 case USBDeviceState_Available:
658 pszState = "Available"; break;
659 case USBDeviceState_Held:
660 pszState = "Held"; break;
661 case USBDeviceState_Captured:
662 pszState = "Captured"; break;
663 default:
664 ASSERT (false);
665 break;
666 }
667 RTPrintf("Current State: %s\n\n", pszState);
668 }
669 }
670 }
671 break;
672
673 case LISTUSBFILTERS:
674 {
675 RTPrintf("Global USB Device Filters:\n\n");
676
677 ComPtr <IHost> host;
678 CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host) (host.asOutParam()), 1);
679
680 SafeIfaceArray <IHostUSBDeviceFilter> coll;
681 CHECK_ERROR_RET (host, COMGETTER (USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
682
683 if (coll.size() == 0)
684 {
685 RTPrintf("<none>\n\n");
686 }
687 else
688 {
689 for (size_t index = 0; index < coll.size(); ++index)
690 {
691 ComPtr<IHostUSBDeviceFilter> flt = coll[index];
692
693 /* Query info. */
694
695 RTPrintf("Index: %zu\n", index);
696
697 BOOL active = FALSE;
698 CHECK_ERROR_RET (flt, COMGETTER (Active) (&active), 1);
699 RTPrintf("Active: %s\n", active ? "yes" : "no");
700
701 USBDeviceFilterAction_T action;
702 CHECK_ERROR_RET (flt, COMGETTER (Action) (&action), 1);
703 const char *pszAction = "<invalid>";
704 switch (action)
705 {
706 case USBDeviceFilterAction_Ignore:
707 pszAction = "Ignore";
708 break;
709 case USBDeviceFilterAction_Hold:
710 pszAction = "Hold";
711 break;
712 default:
713 break;
714 }
715 RTPrintf("Action: %s\n", pszAction);
716
717 Bstr bstr;
718 CHECK_ERROR_RET (flt, COMGETTER (Name) (bstr.asOutParam()), 1);
719 RTPrintf("Name: %lS\n", bstr.raw());
720 CHECK_ERROR_RET (flt, COMGETTER (VendorId) (bstr.asOutParam()), 1);
721 RTPrintf("VendorId: %lS\n", bstr.raw());
722 CHECK_ERROR_RET (flt, COMGETTER (ProductId) (bstr.asOutParam()), 1);
723 RTPrintf("ProductId: %lS\n", bstr.raw());
724 CHECK_ERROR_RET (flt, COMGETTER (Revision) (bstr.asOutParam()), 1);
725 RTPrintf("Revision: %lS\n", bstr.raw());
726 CHECK_ERROR_RET (flt, COMGETTER (Manufacturer) (bstr.asOutParam()), 1);
727 RTPrintf("Manufacturer: %lS\n", bstr.raw());
728 CHECK_ERROR_RET (flt, COMGETTER (Product) (bstr.asOutParam()), 1);
729 RTPrintf("Product: %lS\n", bstr.raw());
730 CHECK_ERROR_RET (flt, COMGETTER (SerialNumber) (bstr.asOutParam()), 1);
731 RTPrintf("Serial Number: %lS\n\n", bstr.raw());
732 }
733 }
734 }
735 break;
736
737 case LISTSYSTEMPROPERTIES:
738 {
739 ComPtr<ISystemProperties> systemProperties;
740 a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
741
742 Bstr str;
743 ULONG ulValue;
744 ULONG64 ul64Value;
745 BOOL flag;
746
747 systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
748 RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
749 systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
750 RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
751 systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
752 RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
753 systemProperties->COMGETTER(MaxVDISize)(&ul64Value);
754 RTPrintf("Maximum VDI size: %lu Megabytes\n", ul64Value);
755 systemProperties->COMGETTER(DefaultHardDiskFolder)(str.asOutParam());
756 RTPrintf("Default hard disk folder: %lS\n", str.raw());
757 systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
758 RTPrintf("Default machine folder: %lS\n", str.raw());
759 systemProperties->COMGETTER(RemoteDisplayAuthLibrary)(str.asOutParam());
760 RTPrintf("VRDP authentication library: %lS\n", str.raw());
761 systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
762 RTPrintf("Webservice auth. library: %lS\n", str.raw());
763 systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
764 RTPrintf("Log history count: %u\n", ulValue);
765
766 }
767 break;
768 case LISTDHCPSERVERS:
769 {
770 com::SafeIfaceArray<IDHCPServer> svrs;
771 CHECK_ERROR(a->virtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam (svrs)));
772 for (size_t i = 0; i < svrs.size(); ++ i)
773 {
774 ComPtr<IDHCPServer> svr = svrs[i];
775 Bstr netName;
776 svr->COMGETTER(NetworkName)(netName.asOutParam());
777 RTPrintf("NetworkName: %lS\n", netName.raw());
778 Bstr ip;
779 svr->COMGETTER(IPAddress)(ip.asOutParam());
780 RTPrintf("IP: %lS\n", ip.raw());
781 Bstr netmask;
782 svr->COMGETTER(NetworkMask)(netmask.asOutParam());
783 RTPrintf("NetworkMask: %lS\n", netmask.raw());
784 Bstr lowerIp;
785 svr->COMGETTER(LowerIP)(lowerIp.asOutParam());
786 RTPrintf("lowerIPAddress: %lS\n", lowerIp.raw());
787 Bstr upperIp;
788 svr->COMGETTER(UpperIP)(upperIp.asOutParam());
789 RTPrintf("upperIPAddress: %lS\n", upperIp.raw());
790 BOOL bEnabled;
791 svr->COMGETTER(Enabled)(&bEnabled);
792 RTPrintf("Enabled: %s\n", bEnabled ? "Yes" : "No");
793 RTPrintf("\n");
794 }
795 }
796 break;
797 } // end switch
798
799 return SUCCEEDED(rc) ? 0 : 1;
800}
801
802#endif /* !VBOX_ONLY_DOCS */
803/* 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