VirtualBox

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

Last change on this file since 16840 was 16530, checked in by vboxsync, 16 years ago

Main: rework error macros everywhere; make error messages much more readable (esp. with VBoxManage); use shared function to actually print message; reduces size of VBoxManage debug build from 3.4 to 2.3 MB

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.0 KB
Line 
1/* $Id: VBoxManageList.cpp 16530 2009-02-05 16:08:49Z vboxsync $ */
2/** @file
3 * VBoxManage - The 'list' command.
4 */
5
6/*
7 * Copyright (C) 2006-2007 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/errorprint2.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
41#include "VBoxManage.h"
42using namespace com;
43
44#ifdef VBOX_WITH_HOSTNETIF_API
45static const char *getHostIfTypeText(HostNetworkInterfaceType_T enmType)
46{
47 switch (enmType)
48 {
49 case HostNetworkInterfaceType_Ethernet: return "Ethernet";
50 case HostNetworkInterfaceType_PPP: return "PPP";
51 case HostNetworkInterfaceType_SLIP: return "SLIP";
52 }
53 return "Unknown";
54}
55
56static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
57{
58 switch (enmStatus)
59 {
60 case HostNetworkInterfaceStatus_Up: return "Up";
61 case HostNetworkInterfaceStatus_Down: return "Down";
62 }
63 return "Unknown";
64}
65#endif
66
67int handleList(HandlerArg *a)
68{
69 HRESULT rc = S_OK;
70
71 /* exactly one option: the object */
72 if (a->argc != 1)
73 return errorSyntax(USAGE_LIST, "Incorrect number of parameters");
74
75 /* which object? */
76 if (strcmp(a->argv[0], "vms") == 0)
77 {
78 /*
79 * Get the list of all registered VMs
80 */
81 com::SafeIfaceArray <IMachine> machines;
82 rc = a->virtualBox->COMGETTER(Machines2)(ComSafeArrayAsOutParam (machines));
83 if (SUCCEEDED(rc))
84 {
85 /*
86 * Iterate through the collection
87 */
88 for (size_t i = 0; i < machines.size(); ++ i)
89 {
90 if (machines [i])
91 rc = showVMInfo(a->virtualBox, machines [i]);
92 }
93 }
94 }
95 else
96 if (strcmp(a->argv[0], "runningvms") == 0)
97 {
98 /*
99 * Get the list of all _running_ VMs
100 */
101 com::SafeIfaceArray <IMachine> machines;
102 rc = a->virtualBox->COMGETTER(Machines2)(ComSafeArrayAsOutParam (machines));
103 if (SUCCEEDED(rc))
104 {
105 /*
106 * Iterate through the collection
107 */
108 for (size_t i = 0; i < machines.size(); ++ i)
109 {
110 if (machines [i])
111 {
112 MachineState_T machineState;
113 rc = machines [i]->COMGETTER(State)(&machineState);
114 if (SUCCEEDED(rc))
115 {
116 switch (machineState)
117 {
118 case MachineState_Running:
119 case MachineState_Paused:
120 {
121 Guid uuid;
122 rc = machines [i]->COMGETTER(Id) (uuid.asOutParam());
123 if (SUCCEEDED(rc))
124 RTPrintf ("%s\n", uuid.toString().raw());
125 break;
126 }
127 }
128 }
129 }
130 }
131 }
132 }
133 else
134 if (strcmp(a->argv[0], "ostypes") == 0)
135 {
136 ComPtr<IGuestOSTypeCollection> coll;
137 ComPtr<IGuestOSTypeEnumerator> enumerator;
138 CHECK_ERROR(a->virtualBox, COMGETTER(GuestOSTypes)(coll.asOutParam()));
139 if (SUCCEEDED(rc) && coll)
140 {
141 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
142 BOOL hasMore;
143 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
144 {
145 ComPtr<IGuestOSType> guestOS;
146 CHECK_ERROR_BREAK(enumerator, GetNext(guestOS.asOutParam()));
147 Bstr guestId;
148 guestOS->COMGETTER(Id)(guestId.asOutParam());
149 RTPrintf("ID: %lS\n", guestId.raw());
150 Bstr guestDescription;
151 guestOS->COMGETTER(Description)(guestDescription.asOutParam());
152 RTPrintf("Description: %lS\n\n", guestDescription.raw());
153 }
154 }
155 }
156 else
157 if (strcmp(a->argv[0], "hostdvds") == 0)
158 {
159 ComPtr<IHost> host;
160 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
161 ComPtr<IHostDVDDriveCollection> coll;
162 ComPtr<IHostDVDDriveEnumerator> enumerator;
163 CHECK_ERROR(host, COMGETTER(DVDDrives)(coll.asOutParam()));
164 if (SUCCEEDED(rc) && coll)
165 {
166 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
167 BOOL hasMore;
168 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
169 {
170 ComPtr<IHostDVDDrive> dvdDrive;
171 CHECK_ERROR_BREAK(enumerator, GetNext(dvdDrive.asOutParam()));
172 Bstr name;
173 dvdDrive->COMGETTER(Name)(name.asOutParam());
174 RTPrintf("Name: %lS\n\n", name.raw());
175 }
176 }
177 }
178 else
179 if (strcmp(a->argv[0], "hostfloppies") == 0)
180 {
181 ComPtr<IHost> host;
182 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
183 ComPtr<IHostFloppyDriveCollection> coll;
184 ComPtr<IHostFloppyDriveEnumerator> enumerator;
185 CHECK_ERROR(host, COMGETTER(FloppyDrives)(coll.asOutParam()));
186 if (SUCCEEDED(rc) && coll)
187 {
188 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
189 BOOL hasMore;
190 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
191 {
192 ComPtr<IHostFloppyDrive> floppyDrive;
193 CHECK_ERROR_BREAK(enumerator, GetNext(floppyDrive.asOutParam()));
194 Bstr name;
195 floppyDrive->COMGETTER(Name)(name.asOutParam());
196 RTPrintf("Name: %lS\n\n", name.raw());
197 }
198 }
199 }
200 else
201 if (strcmp(a->argv[0], "hostifs") == 0)
202 {
203 ComPtr<IHost> host;
204 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
205 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
206 CHECK_ERROR(host,
207 COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces)));
208 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
209 {
210 ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
211#ifndef VBOX_WITH_HOSTNETIF_API
212 Bstr interfaceName;
213 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
214 RTPrintf("Name: %lS\n", interfaceName.raw());
215 Guid interfaceGuid;
216 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
217 RTPrintf("GUID: %lS\n\n", Bstr(interfaceGuid.toString()).raw());
218#else /* VBOX_WITH_HOSTNETIF_API */
219 Bstr interfaceName;
220 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
221 RTPrintf("Name: %lS\n", interfaceName.raw());
222 Guid interfaceGuid;
223 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
224 RTPrintf("GUID: %lS\n", Bstr(interfaceGuid.toString()).raw());
225 ULONG IPAddress;
226 networkInterface->COMGETTER(IPAddress)(&IPAddress);
227 RTPrintf("IPAddress: %d.%d.%d.%d\n",
228 ((uint8_t*)&IPAddress)[0],
229 ((uint8_t*)&IPAddress)[1],
230 ((uint8_t*)&IPAddress)[2],
231 ((uint8_t*)&IPAddress)[3]);
232 ULONG NetworkMask;
233 networkInterface->COMGETTER(NetworkMask)(&NetworkMask);
234 RTPrintf("NetworkMask: %d.%d.%d.%d\n",
235 ((uint8_t*)&NetworkMask)[0],
236 ((uint8_t*)&NetworkMask)[1],
237 ((uint8_t*)&NetworkMask)[2],
238 ((uint8_t*)&NetworkMask)[3]);
239 Bstr IPV6Address;
240 networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
241 RTPrintf("IPV6Address: %lS\n", IPV6Address.raw());
242 Bstr IPV6NetworkMask;
243 networkInterface->COMGETTER(IPV6NetworkMask)(IPV6NetworkMask.asOutParam());
244 RTPrintf("IPV6NetworkMask: %lS\n", IPV6NetworkMask.raw());
245 Bstr HardwareAddress;
246 networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
247 RTPrintf("HardwareAddress: %lS\n", HardwareAddress.raw());
248 HostNetworkInterfaceType_T Type;
249 networkInterface->COMGETTER(Type)(&Type);
250 RTPrintf("Type: %s\n", getHostIfTypeText(Type));
251 HostNetworkInterfaceStatus_T Status;
252 networkInterface->COMGETTER(Status)(&Status);
253 RTPrintf("Status: %s\n\n", getHostIfStatusText(Status));
254#endif
255 }
256 }
257 else
258 if (strcmp(a->argv[0], "hostinfo") == 0)
259 {
260 ComPtr<IHost> Host;
261 CHECK_ERROR (a->virtualBox, COMGETTER(Host)(Host.asOutParam()));
262
263 RTPrintf("Host Information:\n\n");
264
265 LONG64 uTCTime = 0;
266 CHECK_ERROR (Host, COMGETTER(UTCTime)(&uTCTime));
267 RTTIMESPEC timeSpec;
268 RTTimeSpecSetMilli(&timeSpec, uTCTime);
269 char pszTime[30] = {0};
270 RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
271 RTPrintf("Host time: %s\n", pszTime);
272
273 ULONG processorOnlineCount = 0;
274 CHECK_ERROR (Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
275 RTPrintf("Processor online count: %lu\n", processorOnlineCount);
276 ULONG processorCount = 0;
277 CHECK_ERROR (Host, COMGETTER(ProcessorCount)(&processorCount));
278 RTPrintf("Processor count: %lu\n", processorCount);
279 ULONG processorSpeed = 0;
280 Bstr processorDescription;
281 for (ULONG i = 0; i < processorCount; i++)
282 {
283 CHECK_ERROR (Host, GetProcessorSpeed(i, &processorSpeed));
284 if (processorSpeed)
285 RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
286 else
287 RTPrintf("Processor#%u speed: unknown\n", i, processorSpeed);
288 #if 0 /* not yet implemented in Main */
289 CHECK_ERROR (Host, GetProcessorDescription(i, processorDescription.asOutParam()));
290 RTPrintf("Processor#%u description: %lS\n", i, processorDescription.raw());
291 #endif
292 }
293
294 #if 0 /* not yet implemented in Main */
295 ULONG memorySize = 0;
296 CHECK_ERROR (Host, COMGETTER(MemorySize)(&memorySize));
297 RTPrintf("Memory size: %lu MByte\n", memorySize);
298
299 ULONG memoryAvailable = 0;
300 CHECK_ERROR (Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
301 RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
302
303 Bstr operatingSystem;
304 CHECK_ERROR (Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
305 RTPrintf("Operating system: %lS\n", operatingSystem.raw());
306
307 Bstr oSVersion;
308 CHECK_ERROR (Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
309 RTPrintf("Operating system version: %lS\n", oSVersion.raw());
310 #endif
311 }
312 else
313 if (strcmp(a->argv[0], "hddbackends") == 0)
314 {
315 ComPtr<ISystemProperties> systemProperties;
316 CHECK_ERROR(a->virtualBox,
317 COMGETTER(SystemProperties) (systemProperties.asOutParam()));
318 com::SafeIfaceArray <IHardDiskFormat> hardDiskFormats;
319 CHECK_ERROR(systemProperties,
320 COMGETTER(HardDiskFormats) (ComSafeArrayAsOutParam (hardDiskFormats)));
321
322 RTPrintf("Supported hard disk backends:\n\n");
323 for (size_t i = 0; i < hardDiskFormats.size(); ++ i)
324 {
325 /* General information */
326 Bstr id;
327 CHECK_ERROR(hardDiskFormats [i],
328 COMGETTER(Id) (id.asOutParam()));
329
330 Bstr description;
331 CHECK_ERROR(hardDiskFormats [i],
332 COMGETTER(Id) (description.asOutParam()));
333
334 ULONG caps;
335 CHECK_ERROR(hardDiskFormats [i],
336 COMGETTER(Capabilities) (&caps));
337
338 RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
339 i, id.raw(), description.raw(), caps);
340
341 /* File extensions */
342 com::SafeArray <BSTR> fileExtensions;
343 CHECK_ERROR(hardDiskFormats [i],
344 COMGETTER(FileExtensions) (ComSafeArrayAsOutParam (fileExtensions)));
345 for (size_t a = 0; a < fileExtensions.size(); ++ a)
346 {
347 RTPrintf ("%ls", Bstr (fileExtensions [a]).raw());
348 if (a != fileExtensions.size()-1)
349 RTPrintf (",");
350 }
351 RTPrintf ("'");
352
353 /* Configuration keys */
354 com::SafeArray <BSTR> propertyNames;
355 com::SafeArray <BSTR> propertyDescriptions;
356 com::SafeArray <DataType_T> propertyTypes;
357 com::SafeArray <ULONG> propertyFlags;
358 com::SafeArray <BSTR> propertyDefaults;
359 CHECK_ERROR(hardDiskFormats [i],
360 DescribeProperties (ComSafeArrayAsOutParam (propertyNames),
361 ComSafeArrayAsOutParam (propertyDescriptions),
362 ComSafeArrayAsOutParam (propertyTypes),
363 ComSafeArrayAsOutParam (propertyFlags),
364 ComSafeArrayAsOutParam (propertyDefaults)));
365
366 RTPrintf (" properties=(");
367 if (propertyNames.size() > 0)
368 {
369 for (size_t a = 0; a < propertyNames.size(); ++ a)
370 {
371 RTPrintf ("\n name='%ls' desc='%ls' type=",
372 Bstr (propertyNames [a]).raw(), Bstr (propertyDescriptions [a]).raw());
373 switch (propertyTypes [a])
374 {
375 case DataType_Int32: RTPrintf ("int"); break;
376 case DataType_Int8: RTPrintf ("byte"); break;
377 case DataType_String: RTPrintf ("string"); break;
378 }
379 RTPrintf (" flags=%#04x", propertyFlags [a]);
380 RTPrintf (" default='%ls'", Bstr (propertyDefaults [a]).raw());
381 if (a != propertyNames.size()-1)
382 RTPrintf (", ");
383 }
384 }
385 RTPrintf (")\n");
386 }
387 }
388 else
389 if (strcmp(a->argv[0], "hdds") == 0)
390 {
391 com::SafeIfaceArray <IHardDisk2> hdds;
392 CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks2)(ComSafeArrayAsOutParam (hdds)));
393 for (size_t i = 0; i < hdds.size(); ++ i)
394 {
395 ComPtr<IHardDisk2> hdd = hdds[i];
396 Guid uuid;
397 hdd->COMGETTER(Id)(uuid.asOutParam());
398 RTPrintf("UUID: %s\n", uuid.toString().raw());
399 Bstr format;
400 hdd->COMGETTER(Format)(format.asOutParam());
401 RTPrintf("Format: %lS\n", format.raw());
402 Bstr filepath;
403 hdd->COMGETTER(Location)(filepath.asOutParam());
404 RTPrintf("Location: %lS\n", filepath.raw());
405 MediaState_T enmState;
406 /// @todo NEWMEDIA check accessibility of all parents
407 /// @todo NEWMEDIA print the full state value
408 hdd->COMGETTER(State)(&enmState);
409 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
410 com::SafeGUIDArray machineIds;
411 hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds));
412 for (size_t j = 0; j < machineIds.size(); ++ j)
413 {
414 ComPtr<IMachine> machine;
415 CHECK_ERROR(a->virtualBox, GetMachine(machineIds[j], machine.asOutParam()));
416 ASSERT(machine);
417 Bstr name;
418 machine->COMGETTER(Name)(name.asOutParam());
419 machine->COMGETTER(Id)(uuid.asOutParam());
420 RTPrintf("%s%lS (UUID: %RTuuid)\n",
421 j == 0 ? "Usage: " : " ",
422 name.raw(), &machineIds[j]);
423 }
424 /// @todo NEWMEDIA check usage in snapshots too
425 /// @todo NEWMEDIA also list children and say 'differencing' for
426 /// hard disks with the parent or 'base' otherwise.
427 RTPrintf("\n");
428 }
429 }
430 else
431 if (strcmp(a->argv[0], "dvds") == 0)
432 {
433 com::SafeIfaceArray<IDVDImage2> dvds;
434 CHECK_ERROR(a->virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
435 for (size_t i = 0; i < dvds.size(); ++ i)
436 {
437 ComPtr<IDVDImage2> dvdImage = dvds[i];
438 Guid uuid;
439 dvdImage->COMGETTER(Id)(uuid.asOutParam());
440 RTPrintf("UUID: %s\n", uuid.toString().raw());
441 Bstr filePath;
442 dvdImage->COMGETTER(Location)(filePath.asOutParam());
443 RTPrintf("Path: %lS\n", filePath.raw());
444 MediaState_T enmState;
445 dvdImage->COMGETTER(State)(&enmState);
446 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
447 /** @todo usage */
448 RTPrintf("\n");
449 }
450 }
451 else
452 if (strcmp(a->argv[0], "floppies") == 0)
453 {
454 com::SafeIfaceArray<IFloppyImage2> floppies;
455 CHECK_ERROR(a->virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
456 for (size_t i = 0; i < floppies.size(); ++ i)
457 {
458 ComPtr<IFloppyImage2> floppyImage = floppies[i];
459 Guid uuid;
460 floppyImage->COMGETTER(Id)(uuid.asOutParam());
461 RTPrintf("UUID: %s\n", uuid.toString().raw());
462 Bstr filePath;
463 floppyImage->COMGETTER(Location)(filePath.asOutParam());
464 RTPrintf("Path: %lS\n", filePath.raw());
465 MediaState_T enmState;
466 floppyImage->COMGETTER(State)(&enmState);
467 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
468 /** @todo usage */
469 RTPrintf("\n");
470 }
471 }
472 else
473 if (strcmp(a->argv[0], "usbhost") == 0)
474 {
475 ComPtr<IHost> Host;
476 CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
477
478 ComPtr<IHostUSBDeviceCollection> CollPtr;
479 CHECK_ERROR_RET (Host, COMGETTER(USBDevices)(CollPtr.asOutParam()), 1);
480
481 ComPtr<IHostUSBDeviceEnumerator> EnumPtr;
482 CHECK_ERROR_RET (CollPtr, Enumerate(EnumPtr.asOutParam()), 1);
483
484 RTPrintf("Host USB Devices:\n\n");
485
486 BOOL fMore = FALSE;
487 ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
488 if (FAILED(rc))
489 return rc;
490
491 if (!fMore)
492 {
493 RTPrintf("<none>\n\n");
494 }
495 else
496 while (fMore)
497 {
498 ComPtr <IHostUSBDevice> dev;
499 ASSERT(SUCCEEDED(rc = EnumPtr->GetNext (dev.asOutParam())));
500 if (FAILED(rc))
501 return rc;
502
503 /* Query info. */
504 Guid id;
505 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), 1);
506 USHORT usVendorId;
507 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), 1);
508 USHORT usProductId;
509 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), 1);
510 USHORT bcdRevision;
511 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), 1);
512
513 RTPrintf("UUID: %S\n"
514 "VendorId: 0x%04x (%04X)\n"
515 "ProductId: 0x%04x (%04X)\n"
516 "Revision: %u.%u (%02u%02u)\n",
517 id.toString().raw(),
518 usVendorId, usVendorId, usProductId, usProductId,
519 bcdRevision >> 8, bcdRevision & 0xff,
520 bcdRevision >> 8, bcdRevision & 0xff);
521
522 /* optional stuff. */
523 Bstr bstr;
524 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
525 if (!bstr.isEmpty())
526 RTPrintf("Manufacturer: %lS\n", bstr.raw());
527 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), 1);
528 if (!bstr.isEmpty())
529 RTPrintf("Product: %lS\n", bstr.raw());
530 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
531 if (!bstr.isEmpty())
532 RTPrintf("SerialNumber: %lS\n", bstr.raw());
533 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), 1);
534 if (!bstr.isEmpty())
535 RTPrintf("Address: %lS\n", bstr.raw());
536
537 /* current state */
538 USBDeviceState_T state;
539 CHECK_ERROR_RET (dev, COMGETTER(State)(&state), 1);
540 const char *pszState = "?";
541 switch (state)
542 {
543 case USBDeviceState_NotSupported:
544 pszState = "Not supported"; break;
545 case USBDeviceState_Unavailable:
546 pszState = "Unavailable"; break;
547 case USBDeviceState_Busy:
548 pszState = "Busy"; break;
549 case USBDeviceState_Available:
550 pszState = "Available"; break;
551 case USBDeviceState_Held:
552 pszState = "Held"; break;
553 case USBDeviceState_Captured:
554 pszState = "Captured"; break;
555 default:
556 ASSERT (false);
557 break;
558 }
559 RTPrintf("Current State: %s\n\n", pszState);
560
561 ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
562 if (FAILED(rc))
563 return rc;
564 }
565 }
566 else
567 if (strcmp(a->argv[0], "usbfilters") == 0)
568 {
569 RTPrintf("Global USB Device Filters:\n\n");
570
571 ComPtr <IHost> host;
572 CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host) (host.asOutParam()), 1);
573
574 ComPtr<IHostUSBDeviceFilterCollection> coll;
575 CHECK_ERROR_RET (host, COMGETTER (USBDeviceFilters)(coll.asOutParam()), 1);
576
577 ComPtr<IHostUSBDeviceFilterEnumerator> en;
578 CHECK_ERROR_RET (coll, Enumerate(en.asOutParam()), 1);
579
580 ULONG index = 0;
581 BOOL more = FALSE;
582 ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
583 if (FAILED(rc))
584 return rc;
585
586 if (!more)
587 {
588 RTPrintf("<none>\n\n");
589 }
590 else
591 while (more)
592 {
593 ComPtr<IHostUSBDeviceFilter> flt;
594 ASSERT(SUCCEEDED(rc = en->GetNext (flt.asOutParam())));
595 if (FAILED(rc))
596 return rc;
597
598 /* Query info. */
599
600 RTPrintf("Index: %lu\n", index);
601
602 BOOL active = FALSE;
603 CHECK_ERROR_RET (flt, COMGETTER (Active) (&active), 1);
604 RTPrintf("Active: %s\n", active ? "yes" : "no");
605
606 USBDeviceFilterAction_T action;
607 CHECK_ERROR_RET (flt, COMGETTER (Action) (&action), 1);
608 const char *pszAction = "<invalid>";
609 switch (action)
610 {
611 case USBDeviceFilterAction_Ignore:
612 pszAction = "Ignore";
613 break;
614 case USBDeviceFilterAction_Hold:
615 pszAction = "Hold";
616 break;
617 default:
618 break;
619 }
620 RTPrintf("Action: %s\n", pszAction);
621
622 Bstr bstr;
623 CHECK_ERROR_RET (flt, COMGETTER (Name) (bstr.asOutParam()), 1);
624 RTPrintf("Name: %lS\n", bstr.raw());
625 CHECK_ERROR_RET (flt, COMGETTER (VendorId) (bstr.asOutParam()), 1);
626 RTPrintf("VendorId: %lS\n", bstr.raw());
627 CHECK_ERROR_RET (flt, COMGETTER (ProductId) (bstr.asOutParam()), 1);
628 RTPrintf("ProductId: %lS\n", bstr.raw());
629 CHECK_ERROR_RET (flt, COMGETTER (Revision) (bstr.asOutParam()), 1);
630 RTPrintf("Revision: %lS\n", bstr.raw());
631 CHECK_ERROR_RET (flt, COMGETTER (Manufacturer) (bstr.asOutParam()), 1);
632 RTPrintf("Manufacturer: %lS\n", bstr.raw());
633 CHECK_ERROR_RET (flt, COMGETTER (Product) (bstr.asOutParam()), 1);
634 RTPrintf("Product: %lS\n", bstr.raw());
635 CHECK_ERROR_RET (flt, COMGETTER (SerialNumber) (bstr.asOutParam()), 1);
636 RTPrintf("Serial Number: %lS\n\n", bstr.raw());
637
638 ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
639 if (FAILED(rc))
640 return rc;
641
642 index ++;
643 }
644 }
645 else if (strcmp(a->argv[0], "systemproperties") == 0)
646 {
647 ComPtr<ISystemProperties> systemProperties;
648 a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
649
650 Bstr str;
651 ULONG ulValue;
652 ULONG64 ul64Value;
653 BOOL flag;
654
655 systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
656 RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
657 systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
658 RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
659 systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
660 RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
661 systemProperties->COMGETTER(MaxVDISize)(&ul64Value);
662 RTPrintf("Maximum VDI size: %lu Megabytes\n", ul64Value);
663 systemProperties->COMGETTER(DefaultHardDiskFolder)(str.asOutParam());
664 RTPrintf("Default hard disk folder: %lS\n", str.raw());
665 systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
666 RTPrintf("Default machine folder: %lS\n", str.raw());
667 systemProperties->COMGETTER(RemoteDisplayAuthLibrary)(str.asOutParam());
668 RTPrintf("VRDP authentication library: %lS\n", str.raw());
669 systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
670 RTPrintf("Webservice auth. library: %lS\n", str.raw());
671 systemProperties->COMGETTER(HWVirtExEnabled)(&flag);
672 RTPrintf("Hardware virt. extensions: %s\n", flag ? "yes" : "no");
673 systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
674 RTPrintf("Log history count: %u\n", ulValue);
675
676 }
677 else
678 return errorSyntax(USAGE_LIST, "Invalid parameter '%s'", Utf8Str(a->argv[0]).raw());
679
680 return SUCCEEDED(rc) ? 0 : 1;
681}
682
683#endif /* !VBOX_ONLY_DOCS */
684
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