VirtualBox

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

Last change on this file since 15246 was 15235, checked in by vboxsync, 16 years ago

#3282: API, RT generic part, updated VBoxManage list hostif.

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