VirtualBox

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

最後變更 在這個檔案從76366是 76366,由 vboxsync 提交於 6 年 前

include/VBox/com/Guid.h: Don't include iprt/err.h for no good reason. bugref:9344

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 62.9 KB
 
1/* $Id: VBoxManageList.cpp 76366 2018-12-22 02:16:26Z vboxsync $ */
2/** @file
3 * VBoxManage - The 'list' command.
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.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/*********************************************************************************************************************************
22* Header Files *
23*********************************************************************************************************************************/
24#include <VBox/com/com.h>
25#include <VBox/com/string.h>
26#include <VBox/com/Guid.h>
27#include <VBox/com/array.h>
28#include <VBox/com/ErrorInfo.h>
29#include <VBox/com/errorprint.h>
30
31#include <VBox/com/VirtualBox.h>
32
33#include <VBox/log.h>
34#include <iprt/err.h>
35#include <iprt/stream.h>
36#include <iprt/string.h>
37#include <iprt/time.h>
38#include <iprt/getopt.h>
39#include <iprt/ctype.h>
40
41#include <vector>
42#include <algorithm>
43
44#include "VBoxManage.h"
45using namespace com;
46
47#ifdef VBOX_WITH_HOSTNETIF_API
48static const char *getHostIfMediumTypeText(HostNetworkInterfaceMediumType_T enmType)
49{
50 switch (enmType)
51 {
52 case HostNetworkInterfaceMediumType_Ethernet: return "Ethernet";
53 case HostNetworkInterfaceMediumType_PPP: return "PPP";
54 case HostNetworkInterfaceMediumType_SLIP: return "SLIP";
55 case HostNetworkInterfaceMediumType_Unknown: return "Unknown";
56#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
57 case HostNetworkInterfaceMediumType_32BitHack: break; /* Shut up compiler warnings. */
58#endif
59 }
60 return "unknown";
61}
62
63static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
64{
65 switch (enmStatus)
66 {
67 case HostNetworkInterfaceStatus_Up: return "Up";
68 case HostNetworkInterfaceStatus_Down: return "Down";
69 case HostNetworkInterfaceStatus_Unknown: return "Unknown";
70#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
71 case HostNetworkInterfaceStatus_32BitHack: break; /* Shut up compiler warnings. */
72#endif
73 }
74 return "unknown";
75}
76#endif /* VBOX_WITH_HOSTNETIF_API */
77
78static const char*getDeviceTypeText(DeviceType_T enmType)
79{
80 switch (enmType)
81 {
82 case DeviceType_HardDisk: return "HardDisk";
83 case DeviceType_DVD: return "DVD";
84 case DeviceType_Floppy: return "Floppy";
85 /* Make MSC happy */
86 case DeviceType_Null: return "Null";
87 case DeviceType_Network: return "Network";
88 case DeviceType_USB: return "USB";
89 case DeviceType_SharedFolder: return "SharedFolder";
90 case DeviceType_Graphics3D: return "Graphics3D";
91#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
92 case DeviceType_32BitHack: break; /* Shut up compiler warnings. */
93#endif
94 }
95 return "Unknown";
96}
97
98
99/**
100 * List internal networks.
101 *
102 * @returns See produceList.
103 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
104 */
105static HRESULT listInternalNetworks(const ComPtr<IVirtualBox> pVirtualBox)
106{
107 HRESULT rc;
108 com::SafeArray<BSTR> internalNetworks;
109 CHECK_ERROR(pVirtualBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks)));
110 for (size_t i = 0; i < internalNetworks.size(); ++i)
111 {
112 RTPrintf("Name: %ls\n", internalNetworks[i]);
113 }
114 return rc;
115}
116
117
118/**
119 * List network interfaces information (bridged/host only).
120 *
121 * @returns See produceList.
122 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
123 * @param fIsBridged Selects between listing host interfaces (for
124 * use with bridging) or host only interfaces.
125 */
126static HRESULT listNetworkInterfaces(const ComPtr<IVirtualBox> pVirtualBox,
127 bool fIsBridged)
128{
129 HRESULT rc;
130 ComPtr<IHost> host;
131 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
132 com::SafeIfaceArray<IHostNetworkInterface> hostNetworkInterfaces;
133#if defined(VBOX_WITH_NETFLT)
134 if (fIsBridged)
135 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged,
136 ComSafeArrayAsOutParam(hostNetworkInterfaces)));
137 else
138 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_HostOnly,
139 ComSafeArrayAsOutParam(hostNetworkInterfaces)));
140#else
141 RT_NOREF(fIsBridged);
142 CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(hostNetworkInterfaces)));
143#endif
144 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
145 {
146 ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
147#ifndef VBOX_WITH_HOSTNETIF_API
148 Bstr interfaceName;
149 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
150 RTPrintf("Name: %ls\n", interfaceName.raw());
151 Guid interfaceGuid;
152 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
153 RTPrintf("GUID: %ls\n\n", Bstr(interfaceGuid.toString()).raw());
154#else /* VBOX_WITH_HOSTNETIF_API */
155 Bstr interfaceName;
156 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
157 RTPrintf("Name: %ls\n", interfaceName.raw());
158 Bstr interfaceGuid;
159 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
160 RTPrintf("GUID: %ls\n", interfaceGuid.raw());
161 BOOL bDHCPEnabled;
162 networkInterface->COMGETTER(DHCPEnabled)(&bDHCPEnabled);
163 RTPrintf("DHCP: %s\n", bDHCPEnabled ? "Enabled" : "Disabled");
164
165 Bstr IPAddress;
166 networkInterface->COMGETTER(IPAddress)(IPAddress.asOutParam());
167 RTPrintf("IPAddress: %ls\n", IPAddress.raw());
168 Bstr NetworkMask;
169 networkInterface->COMGETTER(NetworkMask)(NetworkMask.asOutParam());
170 RTPrintf("NetworkMask: %ls\n", NetworkMask.raw());
171 Bstr IPV6Address;
172 networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
173 RTPrintf("IPV6Address: %ls\n", IPV6Address.raw());
174 ULONG IPV6NetworkMaskPrefixLength;
175 networkInterface->COMGETTER(IPV6NetworkMaskPrefixLength)(&IPV6NetworkMaskPrefixLength);
176 RTPrintf("IPV6NetworkMaskPrefixLength: %d\n", IPV6NetworkMaskPrefixLength);
177 Bstr HardwareAddress;
178 networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
179 RTPrintf("HardwareAddress: %ls\n", HardwareAddress.raw());
180 HostNetworkInterfaceMediumType_T Type;
181 networkInterface->COMGETTER(MediumType)(&Type);
182 RTPrintf("MediumType: %s\n", getHostIfMediumTypeText(Type));
183 BOOL fWireless;
184 networkInterface->COMGETTER(Wireless)(&fWireless);
185 RTPrintf("Wireless: %s\n", fWireless ? "Yes" : "No");
186 HostNetworkInterfaceStatus_T Status;
187 networkInterface->COMGETTER(Status)(&Status);
188 RTPrintf("Status: %s\n", getHostIfStatusText(Status));
189 Bstr netName;
190 networkInterface->COMGETTER(NetworkName)(netName.asOutParam());
191 RTPrintf("VBoxNetworkName: %ls\n\n", netName.raw());
192#endif
193 }
194 return rc;
195}
196
197
198/**
199 * List host information.
200 *
201 * @returns See produceList.
202 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
203 */
204static HRESULT listHostInfo(const ComPtr<IVirtualBox> pVirtualBox)
205{
206 static struct
207 {
208 ProcessorFeature_T feature;
209 const char *pszName;
210 } features[]
211 =
212 {
213 { ProcessorFeature_HWVirtEx, "HW virtualization" },
214 { ProcessorFeature_PAE, "PAE" },
215 { ProcessorFeature_LongMode, "long mode" },
216 { ProcessorFeature_NestedPaging, "nested paging" },
217 };
218 HRESULT rc;
219 ComPtr<IHost> Host;
220 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
221
222 RTPrintf("Host Information:\n\n");
223
224 LONG64 u64UtcTime = 0;
225 CHECK_ERROR(Host, COMGETTER(UTCTime)(&u64UtcTime));
226 RTTIMESPEC timeSpec;
227 char szTime[32];
228 RTPrintf("Host time: %s\n", RTTimeSpecToString(RTTimeSpecSetMilli(&timeSpec, u64UtcTime), szTime, sizeof(szTime)));
229
230 ULONG processorOnlineCount = 0;
231 CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
232 RTPrintf("Processor online count: %lu\n", processorOnlineCount);
233 ULONG processorCount = 0;
234 CHECK_ERROR(Host, COMGETTER(ProcessorCount)(&processorCount));
235 RTPrintf("Processor count: %lu\n", processorCount);
236 ULONG processorOnlineCoreCount = 0;
237 CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCoreCount)(&processorOnlineCoreCount));
238 RTPrintf("Processor online core count: %lu\n", processorOnlineCoreCount);
239 ULONG processorCoreCount = 0;
240 CHECK_ERROR(Host, COMGETTER(ProcessorCoreCount)(&processorCoreCount));
241 RTPrintf("Processor core count: %lu\n", processorCoreCount);
242 for (unsigned i = 0; i < RT_ELEMENTS(features); i++)
243 {
244 BOOL supported;
245 CHECK_ERROR(Host, GetProcessorFeature(features[i].feature, &supported));
246 RTPrintf("Processor supports %s: %s\n", features[i].pszName, supported ? "yes" : "no");
247 }
248 for (ULONG i = 0; i < processorCount; i++)
249 {
250 ULONG processorSpeed = 0;
251 CHECK_ERROR(Host, GetProcessorSpeed(i, &processorSpeed));
252 if (processorSpeed)
253 RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
254 else
255 RTPrintf("Processor#%u speed: unknown\n", i);
256 Bstr processorDescription;
257 CHECK_ERROR(Host, GetProcessorDescription(i, processorDescription.asOutParam()));
258 RTPrintf("Processor#%u description: %ls\n", i, processorDescription.raw());
259 }
260
261 ULONG memorySize = 0;
262 CHECK_ERROR(Host, COMGETTER(MemorySize)(&memorySize));
263 RTPrintf("Memory size: %lu MByte\n", memorySize);
264
265 ULONG memoryAvailable = 0;
266 CHECK_ERROR(Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
267 RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
268
269 Bstr operatingSystem;
270 CHECK_ERROR(Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
271 RTPrintf("Operating system: %ls\n", operatingSystem.raw());
272
273 Bstr oSVersion;
274 CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
275 RTPrintf("Operating system version: %ls\n", oSVersion.raw());
276 return rc;
277}
278
279
280/**
281 * List media information.
282 *
283 * @returns See produceList.
284 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
285 * @param aMedia Medium objects to list information for.
286 * @param pszParentUUIDStr String with the parent UUID string (or "base").
287 * @param fOptLong Long (@c true) or short list format.
288 */
289static HRESULT listMedia(const ComPtr<IVirtualBox> pVirtualBox,
290 const com::SafeIfaceArray<IMedium> &aMedia,
291 const char *pszParentUUIDStr,
292 bool fOptLong)
293{
294 HRESULT rc = S_OK;
295 for (size_t i = 0; i < aMedia.size(); ++i)
296 {
297 ComPtr<IMedium> pMedium = aMedia[i];
298
299 rc = showMediumInfo(pVirtualBox, pMedium, pszParentUUIDStr, fOptLong);
300
301 RTPrintf("\n");
302
303 com::SafeIfaceArray<IMedium> children;
304 CHECK_ERROR(pMedium, COMGETTER(Children)(ComSafeArrayAsOutParam(children)));
305 if (children.size() > 0)
306 {
307 Bstr uuid;
308 pMedium->COMGETTER(Id)(uuid.asOutParam());
309
310 // depth first listing of child media
311 rc = listMedia(pVirtualBox, children, Utf8Str(uuid).c_str(), fOptLong);
312 }
313 }
314
315 return rc;
316}
317
318
319/**
320 * List virtual image backends.
321 *
322 * @returns See produceList.
323 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
324 */
325static HRESULT listHddBackends(const ComPtr<IVirtualBox> pVirtualBox)
326{
327 HRESULT rc;
328 ComPtr<ISystemProperties> systemProperties;
329 CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
330 com::SafeIfaceArray<IMediumFormat> mediumFormats;
331 CHECK_ERROR(systemProperties, COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
332
333 RTPrintf("Supported hard disk backends:\n\n");
334 for (size_t i = 0; i < mediumFormats.size(); ++i)
335 {
336 /* General information */
337 Bstr id;
338 CHECK_ERROR(mediumFormats[i], COMGETTER(Id)(id.asOutParam()));
339
340 Bstr description;
341 CHECK_ERROR(mediumFormats[i],
342 COMGETTER(Name)(description.asOutParam()));
343
344 ULONG caps = 0;
345 com::SafeArray <MediumFormatCapabilities_T> mediumFormatCap;
346 CHECK_ERROR(mediumFormats[i],
347 COMGETTER(Capabilities)(ComSafeArrayAsOutParam(mediumFormatCap)));
348 for (ULONG j = 0; j < mediumFormatCap.size(); j++)
349 caps |= mediumFormatCap[j];
350
351
352 RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
353 i, id.raw(), description.raw(), caps);
354
355 /* File extensions */
356 com::SafeArray<BSTR> fileExtensions;
357 com::SafeArray<DeviceType_T> deviceTypes;
358 CHECK_ERROR(mediumFormats[i],
359 DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes)));
360 for (size_t j = 0; j < fileExtensions.size(); ++j)
361 {
362 RTPrintf("%ls (%s)", Bstr(fileExtensions[j]).raw(), getDeviceTypeText(deviceTypes[j]));
363 if (j != fileExtensions.size()-1)
364 RTPrintf(",");
365 }
366 RTPrintf("'");
367
368 /* Configuration keys */
369 com::SafeArray<BSTR> propertyNames;
370 com::SafeArray<BSTR> propertyDescriptions;
371 com::SafeArray<DataType_T> propertyTypes;
372 com::SafeArray<ULONG> propertyFlags;
373 com::SafeArray<BSTR> propertyDefaults;
374 CHECK_ERROR(mediumFormats[i],
375 DescribeProperties(ComSafeArrayAsOutParam(propertyNames),
376 ComSafeArrayAsOutParam(propertyDescriptions),
377 ComSafeArrayAsOutParam(propertyTypes),
378 ComSafeArrayAsOutParam(propertyFlags),
379 ComSafeArrayAsOutParam(propertyDefaults)));
380
381 RTPrintf(" properties=(");
382 if (propertyNames.size() > 0)
383 {
384 for (size_t j = 0; j < propertyNames.size(); ++j)
385 {
386 RTPrintf("\n name='%ls' desc='%ls' type=",
387 Bstr(propertyNames[j]).raw(), Bstr(propertyDescriptions[j]).raw());
388 switch (propertyTypes[j])
389 {
390 case DataType_Int32: RTPrintf("int"); break;
391 case DataType_Int8: RTPrintf("byte"); break;
392 case DataType_String: RTPrintf("string"); break;
393#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
394 case DataType_32BitHack: break; /* Shut up compiler warnings. */
395#endif
396 }
397 RTPrintf(" flags=%#04x", propertyFlags[j]);
398 RTPrintf(" default='%ls'", Bstr(propertyDefaults[j]).raw());
399 if (j != propertyNames.size()-1)
400 RTPrintf(", ");
401 }
402 }
403 RTPrintf(")\n");
404 }
405 return rc;
406}
407
408
409/**
410 * List USB devices attached to the host.
411 *
412 * @returns See produceList.
413 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
414 */
415static HRESULT listUsbHost(const ComPtr<IVirtualBox> &pVirtualBox)
416{
417 HRESULT rc;
418 ComPtr<IHost> Host;
419 CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
420
421 SafeIfaceArray<IHostUSBDevice> CollPtr;
422 CHECK_ERROR_RET(Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1);
423
424 RTPrintf("Host USB Devices:\n\n");
425
426 if (CollPtr.size() == 0)
427 {
428 RTPrintf("<none>\n\n");
429 }
430 else
431 {
432 for (size_t i = 0; i < CollPtr.size(); ++i)
433 {
434 ComPtr<IHostUSBDevice> dev = CollPtr[i];
435
436 /* Query info. */
437 Bstr id;
438 CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), 1);
439 USHORT usVendorId;
440 CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), 1);
441 USHORT usProductId;
442 CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), 1);
443 USHORT bcdRevision;
444 CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), 1);
445 USHORT usPort;
446 CHECK_ERROR_RET(dev, COMGETTER(Port)(&usPort), 1);
447 USHORT usVersion;
448 CHECK_ERROR_RET(dev, COMGETTER(Version)(&usVersion), 1);
449 USHORT usPortVersion;
450 CHECK_ERROR_RET(dev, COMGETTER(PortVersion)(&usPortVersion), 1);
451 USBConnectionSpeed_T enmSpeed;
452 CHECK_ERROR_RET(dev, COMGETTER(Speed)(&enmSpeed), 1);
453
454 RTPrintf("UUID: %s\n"
455 "VendorId: %#06x (%04X)\n"
456 "ProductId: %#06x (%04X)\n"
457 "Revision: %u.%u (%02u%02u)\n"
458 "Port: %u\n",
459 Utf8Str(id).c_str(),
460 usVendorId, usVendorId, usProductId, usProductId,
461 bcdRevision >> 8, bcdRevision & 0xff,
462 bcdRevision >> 8, bcdRevision & 0xff,
463 usPort);
464
465 const char *pszSpeed = "?";
466 switch (enmSpeed)
467 {
468 case USBConnectionSpeed_Low:
469 pszSpeed = "Low";
470 break;
471 case USBConnectionSpeed_Full:
472 pszSpeed = "Full";
473 break;
474 case USBConnectionSpeed_High:
475 pszSpeed = "High";
476 break;
477 case USBConnectionSpeed_Super:
478 pszSpeed = "Super";
479 break;
480 case USBConnectionSpeed_SuperPlus:
481 pszSpeed = "SuperPlus";
482 break;
483 default:
484 ASSERT(false);
485 break;
486 }
487
488 RTPrintf("USB version/speed: %u/%s\n", usVersion, pszSpeed);
489
490 /* optional stuff. */
491 SafeArray<BSTR> CollDevInfo;
492 Bstr bstr;
493 CHECK_ERROR_RET(dev, COMGETTER(DeviceInfo)(ComSafeArrayAsOutParam(CollDevInfo)), 1);
494 if (CollDevInfo.size() >= 1)
495 bstr = Bstr(CollDevInfo[0]);
496 if (!bstr.isEmpty())
497 RTPrintf("Manufacturer: %ls\n", bstr.raw());
498 if (CollDevInfo.size() >= 2)
499 bstr = Bstr(CollDevInfo[1]);
500 if (!bstr.isEmpty())
501 RTPrintf("Product: %ls\n", bstr.raw());
502 CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
503 if (!bstr.isEmpty())
504 RTPrintf("SerialNumber: %ls\n", bstr.raw());
505 CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), 1);
506 if (!bstr.isEmpty())
507 RTPrintf("Address: %ls\n", bstr.raw());
508
509 /* current state */
510 USBDeviceState_T state;
511 CHECK_ERROR_RET(dev, COMGETTER(State)(&state), 1);
512 const char *pszState = "?";
513 switch (state)
514 {
515 case USBDeviceState_NotSupported:
516 pszState = "Not supported";
517 break;
518 case USBDeviceState_Unavailable:
519 pszState = "Unavailable";
520 break;
521 case USBDeviceState_Busy:
522 pszState = "Busy";
523 break;
524 case USBDeviceState_Available:
525 pszState = "Available";
526 break;
527 case USBDeviceState_Held:
528 pszState = "Held";
529 break;
530 case USBDeviceState_Captured:
531 pszState = "Captured";
532 break;
533 default:
534 ASSERT(false);
535 break;
536 }
537 RTPrintf("Current State: %s\n\n", pszState);
538 }
539 }
540 return rc;
541}
542
543
544/**
545 * List USB filters.
546 *
547 * @returns See produceList.
548 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
549 */
550static HRESULT listUsbFilters(const ComPtr<IVirtualBox> &pVirtualBox)
551{
552 HRESULT rc;
553
554 RTPrintf("Global USB Device Filters:\n\n");
555
556 ComPtr<IHost> host;
557 CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(host.asOutParam()), 1);
558
559 SafeIfaceArray<IHostUSBDeviceFilter> coll;
560 CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
561
562 if (coll.size() == 0)
563 {
564 RTPrintf("<none>\n\n");
565 }
566 else
567 {
568 for (size_t index = 0; index < coll.size(); ++index)
569 {
570 ComPtr<IHostUSBDeviceFilter> flt = coll[index];
571
572 /* Query info. */
573
574 RTPrintf("Index: %zu\n", index);
575
576 BOOL active = FALSE;
577 CHECK_ERROR_RET(flt, COMGETTER(Active)(&active), 1);
578 RTPrintf("Active: %s\n", active ? "yes" : "no");
579
580 USBDeviceFilterAction_T action;
581 CHECK_ERROR_RET(flt, COMGETTER(Action)(&action), 1);
582 const char *pszAction = "<invalid>";
583 switch (action)
584 {
585 case USBDeviceFilterAction_Ignore:
586 pszAction = "Ignore";
587 break;
588 case USBDeviceFilterAction_Hold:
589 pszAction = "Hold";
590 break;
591 default:
592 break;
593 }
594 RTPrintf("Action: %s\n", pszAction);
595
596 Bstr bstr;
597 CHECK_ERROR_RET(flt, COMGETTER(Name)(bstr.asOutParam()), 1);
598 RTPrintf("Name: %ls\n", bstr.raw());
599 CHECK_ERROR_RET(flt, COMGETTER(VendorId)(bstr.asOutParam()), 1);
600 RTPrintf("VendorId: %ls\n", bstr.raw());
601 CHECK_ERROR_RET(flt, COMGETTER(ProductId)(bstr.asOutParam()), 1);
602 RTPrintf("ProductId: %ls\n", bstr.raw());
603 CHECK_ERROR_RET(flt, COMGETTER(Revision)(bstr.asOutParam()), 1);
604 RTPrintf("Revision: %ls\n", bstr.raw());
605 CHECK_ERROR_RET(flt, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
606 RTPrintf("Manufacturer: %ls\n", bstr.raw());
607 CHECK_ERROR_RET(flt, COMGETTER(Product)(bstr.asOutParam()), 1);
608 RTPrintf("Product: %ls\n", bstr.raw());
609 CHECK_ERROR_RET(flt, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
610 RTPrintf("Serial Number: %ls\n\n", bstr.raw());
611 }
612 }
613 return rc;
614}
615
616
617/**
618 * List system properties.
619 *
620 * @returns See produceList.
621 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
622 */
623static HRESULT listSystemProperties(const ComPtr<IVirtualBox> &pVirtualBox)
624{
625 ComPtr<ISystemProperties> systemProperties;
626 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), hrcCheck);
627
628 Bstr str;
629 ULONG ulValue;
630 LONG64 i64Value;
631 BOOL fValue;
632 const char *psz;
633
634 pVirtualBox->COMGETTER(APIVersion)(str.asOutParam());
635 RTPrintf("API version: %ls\n", str.raw());
636
637 systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
638 RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
639 systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
640 RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
641 systemProperties->COMGETTER(MinGuestVRAM)(&ulValue);
642 RTPrintf("Minimum video RAM size: %u Megabytes\n", ulValue);
643 systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
644 RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
645 systemProperties->COMGETTER(MaxGuestMonitors)(&ulValue);
646 RTPrintf("Maximum guest monitor count: %u\n", ulValue);
647 systemProperties->COMGETTER(MinGuestCPUCount)(&ulValue);
648 RTPrintf("Minimum guest CPU count: %u\n", ulValue);
649 systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
650 RTPrintf("Maximum guest CPU count: %u\n", ulValue);
651 systemProperties->COMGETTER(InfoVDSize)(&i64Value);
652 RTPrintf("Virtual disk limit (info): %lld Bytes\n", i64Value);
653 systemProperties->COMGETTER(SerialPortCount)(&ulValue);
654 RTPrintf("Maximum Serial Port count: %u\n", ulValue);
655 systemProperties->COMGETTER(ParallelPortCount)(&ulValue);
656 RTPrintf("Maximum Parallel Port count: %u\n", ulValue);
657 systemProperties->COMGETTER(MaxBootPosition)(&ulValue);
658 RTPrintf("Maximum Boot Position: %u\n", ulValue);
659 systemProperties->GetMaxNetworkAdapters(ChipsetType_PIIX3, &ulValue);
660 RTPrintf("Maximum PIIX3 Network Adapter count: %u\n", ulValue);
661 systemProperties->GetMaxNetworkAdapters(ChipsetType_ICH9, &ulValue);
662 RTPrintf("Maximum ICH9 Network Adapter count: %u\n", ulValue);
663 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_IDE, &ulValue);
664 RTPrintf("Maximum PIIX3 IDE Controllers: %u\n", ulValue);
665 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_IDE, &ulValue);
666 RTPrintf("Maximum ICH9 IDE Controllers: %u\n", ulValue);
667 systemProperties->GetMaxPortCountForStorageBus(StorageBus_IDE, &ulValue);
668 RTPrintf("Maximum IDE Port count: %u\n", ulValue);
669 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_IDE, &ulValue);
670 RTPrintf("Maximum Devices per IDE Port: %u\n", ulValue);
671 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SATA, &ulValue);
672 RTPrintf("Maximum PIIX3 SATA Controllers: %u\n", ulValue);
673 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SATA, &ulValue);
674 RTPrintf("Maximum ICH9 SATA Controllers: %u\n", ulValue);
675 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SATA, &ulValue);
676 RTPrintf("Maximum SATA Port count: %u\n", ulValue);
677 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SATA, &ulValue);
678 RTPrintf("Maximum Devices per SATA Port: %u\n", ulValue);
679 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SCSI, &ulValue);
680 RTPrintf("Maximum PIIX3 SCSI Controllers: %u\n", ulValue);
681 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SCSI, &ulValue);
682 RTPrintf("Maximum ICH9 SCSI Controllers: %u\n", ulValue);
683 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SCSI, &ulValue);
684 RTPrintf("Maximum SCSI Port count: %u\n", ulValue);
685 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SCSI, &ulValue);
686 RTPrintf("Maximum Devices per SCSI Port: %u\n", ulValue);
687 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SAS, &ulValue);
688 RTPrintf("Maximum SAS PIIX3 Controllers: %u\n", ulValue);
689 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SAS, &ulValue);
690 RTPrintf("Maximum SAS ICH9 Controllers: %u\n", ulValue);
691 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SAS, &ulValue);
692 RTPrintf("Maximum SAS Port count: %u\n", ulValue);
693 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SAS, &ulValue);
694 RTPrintf("Maximum Devices per SAS Port: %u\n", ulValue);
695 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_PCIe, &ulValue);
696 RTPrintf("Maximum NVMe PIIX3 Controllers: %u\n", ulValue);
697 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_PCIe, &ulValue);
698 RTPrintf("Maximum NVMe ICH9 Controllers: %u\n", ulValue);
699 systemProperties->GetMaxPortCountForStorageBus(StorageBus_PCIe, &ulValue);
700 RTPrintf("Maximum NVMe Port count: %u\n", ulValue);
701 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_PCIe, &ulValue);
702 RTPrintf("Maximum Devices per NVMe Port: %u\n", ulValue);
703 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_Floppy, &ulValue);
704 RTPrintf("Maximum PIIX3 Floppy Controllers:%u\n", ulValue);
705 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_Floppy, &ulValue);
706 RTPrintf("Maximum ICH9 Floppy Controllers: %u\n", ulValue);
707 systemProperties->GetMaxPortCountForStorageBus(StorageBus_Floppy, &ulValue);
708 RTPrintf("Maximum Floppy Port count: %u\n", ulValue);
709 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_Floppy, &ulValue);
710 RTPrintf("Maximum Devices per Floppy Port: %u\n", ulValue);
711#if 0
712 systemProperties->GetFreeDiskSpaceWarning(&i64Value);
713 RTPrintf("Free disk space warning at: %u Bytes\n", i64Value);
714 systemProperties->GetFreeDiskSpacePercentWarning(&ulValue);
715 RTPrintf("Free disk space warning at: %u %%\n", ulValue);
716 systemProperties->GetFreeDiskSpaceError(&i64Value);
717 RTPrintf("Free disk space error at: %u Bytes\n", i64Value);
718 systemProperties->GetFreeDiskSpacePercentError(&ulValue);
719 RTPrintf("Free disk space error at: %u %%\n", ulValue);
720#endif
721 systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
722 RTPrintf("Default machine folder: %ls\n", str.raw());
723 systemProperties->COMGETTER(RawModeSupported)(&fValue);
724 RTPrintf("Raw-mode Supported: %s\n", fValue ? "yes" : "no");
725 systemProperties->COMGETTER(ExclusiveHwVirt)(&fValue);
726 RTPrintf("Exclusive HW virtualization use: %s\n", fValue ? "on" : "off");
727 systemProperties->COMGETTER(DefaultHardDiskFormat)(str.asOutParam());
728 RTPrintf("Default hard disk format: %ls\n", str.raw());
729 systemProperties->COMGETTER(VRDEAuthLibrary)(str.asOutParam());
730 RTPrintf("VRDE auth library: %ls\n", str.raw());
731 systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
732 RTPrintf("Webservice auth. library: %ls\n", str.raw());
733 systemProperties->COMGETTER(DefaultVRDEExtPack)(str.asOutParam());
734 RTPrintf("Remote desktop ExtPack: %ls\n", str.raw());
735 systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
736 RTPrintf("Log history count: %u\n", ulValue);
737 systemProperties->COMGETTER(DefaultFrontend)(str.asOutParam());
738 RTPrintf("Default frontend: %ls\n", str.raw());
739 AudioDriverType_T enmAudio;
740 systemProperties->COMGETTER(DefaultAudioDriver)(&enmAudio);
741 switch (enmAudio)
742 {
743 case AudioDriverType_Null: psz = "Null"; break;
744 case AudioDriverType_WinMM: psz = "WinMM"; break;
745 case AudioDriverType_OSS: psz = "OSS"; break;
746 case AudioDriverType_ALSA: psz = "ALSA"; break;
747 case AudioDriverType_DirectSound: psz = "DirectSound"; break;
748 case AudioDriverType_CoreAudio: psz = "CoreAudio"; break;
749 case AudioDriverType_MMPM: psz = "MMPM"; break;
750 case AudioDriverType_Pulse: psz = "Pulse"; break;
751 case AudioDriverType_SolAudio: psz = "SolAudio"; break;
752 default: psz = "Unknown";
753 }
754 RTPrintf("Default audio driver: %s\n", psz);
755 systemProperties->COMGETTER(AutostartDatabasePath)(str.asOutParam());
756 RTPrintf("Autostart database path: %ls\n", str.raw());
757 systemProperties->COMGETTER(DefaultAdditionsISO)(str.asOutParam());
758 RTPrintf("Default Guest Additions ISO: %ls\n", str.raw());
759 systemProperties->COMGETTER(LoggingLevel)(str.asOutParam());
760 RTPrintf("Logging Level: %ls\n", str.raw());
761 ProxyMode_T enmProxyMode = (ProxyMode_T)42;
762 systemProperties->COMGETTER(ProxyMode)(&enmProxyMode);
763 psz = "Unknown";
764 switch (enmProxyMode)
765 {
766 case ProxyMode_System: psz = "System"; break;
767 case ProxyMode_NoProxy: psz = "NoProxy"; break;
768 case ProxyMode_Manual: psz = "Manual"; break;
769#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
770 case ProxyMode_32BitHack: break; /* Shut up compiler warnings. */
771#endif
772 }
773 RTPrintf("Proxy Mode: %s\n", psz);
774 systemProperties->COMGETTER(ProxyURL)(str.asOutParam());
775 RTPrintf("Proxy URL: %ls\n", str.raw());
776 return S_OK;
777}
778
779
780/**
781 * Helper function for querying and displaying DHCP option for an adapter.
782 *
783 * @returns See produceList.
784 * @param pSrv Smart pointer to IDHCPServer.
785 * @param vmSlot String identifying the adapter, like '[vmname]:slot'
786 */
787static HRESULT listVmSlotDhcpOptions(const ComPtr<IDHCPServer> pSrv, const Utf8Str& vmSlot)
788{
789 RTCList<RTCString> lstParts = vmSlot.split(":");
790 if (lstParts.size() < 2)
791 return E_INVALIDARG;
792 if (lstParts[0].length() < 2 || !lstParts[0].startsWith("[") || !lstParts[0].endsWith("]"))
793 return E_INVALIDARG;
794 Bstr vmName(lstParts[0].substr(1, lstParts[0].length()-2));
795 ULONG uSlot = lstParts[1].toUInt32();
796 com::SafeArray<BSTR> options;
797 CHECK_ERROR2I_RET(pSrv, GetVmSlotOptions(vmName.raw(), uSlot, ComSafeArrayAsOutParam(options)), hrcCheck);
798 if (options.size())
799 RTPrintf("Options for NIC %d of '%ls':\n", uSlot + 1, vmName.raw());
800 for (size_t i = 0; i < options.size(); ++i)
801 RTPrintf(" %ls\n", options[i]);
802
803 return S_OK;
804}
805
806
807/**
808 * List DHCP servers.
809 *
810 * @returns See produceList.
811 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
812 */
813static HRESULT listDhcpServers(const ComPtr<IVirtualBox> &pVirtualBox)
814{
815 HRESULT rc = S_OK;
816 com::SafeIfaceArray<IDHCPServer> svrs;
817 CHECK_ERROR_RET(pVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs)), rc);
818 for (size_t i = 0; i < svrs.size(); ++i)
819 {
820 ComPtr<IDHCPServer> svr = svrs[i];
821 Bstr netName;
822 svr->COMGETTER(NetworkName)(netName.asOutParam());
823 RTPrintf("NetworkName: %ls\n", netName.raw());
824 Bstr ip;
825 svr->COMGETTER(IPAddress)(ip.asOutParam());
826 RTPrintf("IP: %ls\n", ip.raw());
827 Bstr netmask;
828 svr->COMGETTER(NetworkMask)(netmask.asOutParam());
829 RTPrintf("NetworkMask: %ls\n", netmask.raw());
830 Bstr lowerIp;
831 svr->COMGETTER(LowerIP)(lowerIp.asOutParam());
832 RTPrintf("lowerIPAddress: %ls\n", lowerIp.raw());
833 Bstr upperIp;
834 svr->COMGETTER(UpperIP)(upperIp.asOutParam());
835 RTPrintf("upperIPAddress: %ls\n", upperIp.raw());
836 BOOL fEnabled;
837 svr->COMGETTER(Enabled)(&fEnabled);
838 RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
839 com::SafeArray<BSTR> globalOptions;
840 CHECK_ERROR_BREAK(svr, COMGETTER(GlobalOptions)(ComSafeArrayAsOutParam(globalOptions)));
841 if (globalOptions.size())
842 {
843 RTPrintf("Global options:\n");
844 for (size_t j = 0; j < globalOptions.size(); ++j)
845 RTPrintf(" %ls\n", globalOptions[j]);
846 }
847 com::SafeArray<BSTR> vmConfigs;
848 CHECK_ERROR_BREAK(svr, COMGETTER(VmConfigs)(ComSafeArrayAsOutParam(vmConfigs)));
849 for (size_t j = 0; j < vmConfigs.size(); ++j)
850 {
851 rc = listVmSlotDhcpOptions(svr, vmConfigs[j]);
852 if (FAILED(rc))
853 break;
854 }
855 RTPrintf("\n");
856 }
857
858 return rc;
859}
860
861/**
862 * List extension packs.
863 *
864 * @returns See produceList.
865 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
866 */
867static HRESULT listExtensionPacks(const ComPtr<IVirtualBox> &pVirtualBox)
868{
869 ComObjPtr<IExtPackManager> ptrExtPackMgr;
870 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
871
872 SafeIfaceArray<IExtPack> extPacks;
873 CHECK_ERROR2I_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
874 RTPrintf("Extension Packs: %u\n", extPacks.size());
875
876 HRESULT hrc = S_OK;
877 for (size_t i = 0; i < extPacks.size(); i++)
878 {
879 /* Read all the properties. */
880 Bstr bstrName;
881 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
882 Bstr bstrDesc;
883 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
884 Bstr bstrVersion;
885 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
886 ULONG uRevision;
887 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Revision)(&uRevision), hrc = hrcCheck; uRevision = 0);
888 Bstr bstrEdition;
889 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
890 Bstr bstrVrdeModule;
891 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.setNull());
892 BOOL fUsable;
893 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Usable)(&fUsable), hrc = hrcCheck; fUsable = FALSE);
894 Bstr bstrWhy;
895 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
896
897 /* Display them. */
898 if (i)
899 RTPrintf("\n");
900 RTPrintf("Pack no.%2zu: %ls\n"
901 "Version: %ls\n"
902 "Revision: %u\n"
903 "Edition: %ls\n"
904 "Description: %ls\n"
905 "VRDE Module: %ls\n"
906 "Usable: %RTbool\n"
907 "Why unusable: %ls\n",
908 i, bstrName.raw(),
909 bstrVersion.raw(),
910 uRevision,
911 bstrEdition.raw(),
912 bstrDesc.raw(),
913 bstrVrdeModule.raw(),
914 fUsable != FALSE,
915 bstrWhy.raw());
916
917 /* Query plugins and display them. */
918 }
919 return hrc;
920}
921
922
923/**
924 * List machine groups.
925 *
926 * @returns See produceList.
927 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
928 */
929static HRESULT listGroups(const ComPtr<IVirtualBox> &pVirtualBox)
930{
931 SafeArray<BSTR> groups;
932 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(MachineGroups)(ComSafeArrayAsOutParam(groups)), hrcCheck);
933
934 for (size_t i = 0; i < groups.size(); i++)
935 {
936 RTPrintf("\"%ls\"\n", groups[i]);
937 }
938 return S_OK;
939}
940
941
942/**
943 * List video capture devices.
944 *
945 * @returns See produceList.
946 * @param pVirtualBox Reference to the IVirtualBox pointer.
947 */
948static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> pVirtualBox)
949{
950 HRESULT rc;
951 ComPtr<IHost> host;
952 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
953 com::SafeIfaceArray<IHostVideoInputDevice> hostVideoInputDevices;
954 CHECK_ERROR(host, COMGETTER(VideoInputDevices)(ComSafeArrayAsOutParam(hostVideoInputDevices)));
955 RTPrintf("Video Input Devices: %u\n", hostVideoInputDevices.size());
956 for (size_t i = 0; i < hostVideoInputDevices.size(); ++i)
957 {
958 ComPtr<IHostVideoInputDevice> p = hostVideoInputDevices[i];
959 Bstr name;
960 p->COMGETTER(Name)(name.asOutParam());
961 Bstr path;
962 p->COMGETTER(Path)(path.asOutParam());
963 Bstr alias;
964 p->COMGETTER(Alias)(alias.asOutParam());
965 RTPrintf("%ls \"%ls\"\n%ls\n", alias.raw(), name.raw(), path.raw());
966 }
967 return rc;
968}
969
970/**
971 * List supported screen shot formats.
972 *
973 * @returns See produceList.
974 * @param pVirtualBox Reference to the IVirtualBox pointer.
975 */
976static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> pVirtualBox)
977{
978 HRESULT rc = S_OK;
979 ComPtr<ISystemProperties> systemProperties;
980 CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
981 com::SafeArray<BitmapFormat_T> formats;
982 CHECK_ERROR(systemProperties, COMGETTER(ScreenShotFormats)(ComSafeArrayAsOutParam(formats)));
983
984 RTPrintf("Supported %d screen shot formats:\n", formats.size());
985 for (size_t i = 0; i < formats.size(); ++i)
986 {
987 uint32_t u32Format = (uint32_t)formats[i];
988 char szFormat[5];
989 szFormat[0] = RT_BYTE1(u32Format);
990 szFormat[1] = RT_BYTE2(u32Format);
991 szFormat[2] = RT_BYTE3(u32Format);
992 szFormat[3] = RT_BYTE4(u32Format);
993 szFormat[4] = 0;
994 RTPrintf(" BitmapFormat_%s (0x%08X)\n", szFormat, u32Format);
995 }
996 return rc;
997}
998
999/**
1000 * List available cloud providers.
1001 *
1002 * @returns See produceList.
1003 * @param pVirtualBox Reference to the IVirtualBox pointer.
1004 */
1005static HRESULT listCloudProviders(const ComPtr<IVirtualBox> pVirtualBox)
1006{
1007 HRESULT rc = S_OK;
1008 ComPtr<ICloudProviderManager> pCloudProviderManager;
1009 CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
1010 com::SafeIfaceArray<ICloudProvider> apCloudProviders;
1011 CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
1012
1013 RTPrintf("Supported %d cloud providers:\n", apCloudProviders.size());
1014 for (size_t i = 0; i < apCloudProviders.size(); ++i)
1015 {
1016 ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
1017 Bstr bstrProviderName;
1018 pCloudProvider->COMGETTER(Name)(bstrProviderName.asOutParam());
1019 RTPrintf("Name: %ls\n", bstrProviderName.raw());
1020 pCloudProvider->COMGETTER(ShortName)(bstrProviderName.asOutParam());
1021 RTPrintf("Short Name: %ls\n", bstrProviderName.raw());
1022 Bstr bstrProviderID;
1023 pCloudProvider->COMGETTER(Id)(bstrProviderID.asOutParam());
1024 RTPrintf("GUID: %ls\n", bstrProviderID.raw());
1025
1026 RTPrintf("\n");
1027 }
1028 return rc;
1029}
1030
1031
1032/**
1033 * List all available cloud profiles (by iterating over the cloud providers).
1034 *
1035 * @returns See produceList.
1036 * @param pVirtualBox Reference to the IVirtualBox pointer.
1037 * @param fOptLong If true, list all profile properties.
1038 */
1039static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> pVirtualBox, bool fOptLong)
1040{
1041 HRESULT rc = S_OK;
1042 ComPtr<ICloudProviderManager> pCloudProviderManager;
1043 CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
1044 com::SafeIfaceArray<ICloudProvider> apCloudProviders;
1045 CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
1046
1047 for (size_t i = 0; i < apCloudProviders.size(); ++i)
1048 {
1049 ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
1050 com::SafeIfaceArray<ICloudProfile> apCloudProfiles;
1051 CHECK_ERROR(pCloudProvider, COMGETTER(Profiles)(ComSafeArrayAsOutParam(apCloudProfiles)));
1052 for (size_t j = 0; j < apCloudProfiles.size(); ++j)
1053 {
1054 ComPtr<ICloudProfile> pCloudProfile = apCloudProfiles[j];
1055 Bstr bstrProfileName;
1056 pCloudProfile->COMGETTER(Name)(bstrProfileName.asOutParam());
1057 RTPrintf("Name: %ls\n", bstrProfileName.raw());
1058 Bstr bstrProviderID;
1059 pCloudProfile->COMGETTER(ProviderId)(bstrProviderID.asOutParam());
1060 RTPrintf("Provider GUID: %ls\n", bstrProviderID.raw());
1061
1062 if (fOptLong)
1063 {
1064 com::SafeArray<BSTR> names;
1065 com::SafeArray<BSTR> values;
1066 pCloudProfile->GetProperties(Bstr().raw(), ComSafeArrayAsOutParam(names), ComSafeArrayAsOutParam(values));
1067 size_t cNames = names.size();
1068 size_t cValues = values.size();
1069 bool fFirst = true;
1070 for (size_t k = 0; k < cNames; k++)
1071 {
1072 Bstr value;
1073 if (k < cValues)
1074 value = values[k];
1075 RTPrintf("%s%ls=%ls\n",
1076 fFirst ? "Property: " : " ",
1077 names[k], value.raw());
1078 fFirst = false;
1079 }
1080 }
1081
1082 RTPrintf("\n");
1083 }
1084 }
1085 return rc;
1086}
1087
1088
1089/**
1090 * The type of lists we can produce.
1091 */
1092enum enmListType
1093{
1094 kListNotSpecified = 1000,
1095 kListVMs,
1096 kListRunningVMs,
1097 kListOsTypes,
1098 kListHostDvds,
1099 kListHostFloppies,
1100 kListInternalNetworks,
1101 kListBridgedInterfaces,
1102#if defined(VBOX_WITH_NETFLT)
1103 kListHostOnlyInterfaces,
1104#endif
1105 kListHostCpuIDs,
1106 kListHostInfo,
1107 kListHddBackends,
1108 kListHdds,
1109 kListDvds,
1110 kListFloppies,
1111 kListUsbHost,
1112 kListUsbFilters,
1113 kListSystemProperties,
1114 kListDhcpServers,
1115 kListExtPacks,
1116 kListGroups,
1117 kListNatNetworks,
1118 kListVideoInputDevices,
1119 kListScreenShotFormats,
1120 kListCloudProviders,
1121 kListCloudProfiles,
1122};
1123
1124
1125/**
1126 * Produces the specified listing.
1127 *
1128 * @returns S_OK or some COM error code that has been reported in full.
1129 * @param enmList The list to produce.
1130 * @param fOptLong Long (@c true) or short list format.
1131 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1132 */
1133static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, bool fOptSorted, const ComPtr<IVirtualBox> &pVirtualBox)
1134{
1135 HRESULT rc = S_OK;
1136 switch (enmCommand)
1137 {
1138 case kListNotSpecified:
1139 AssertFailed();
1140 return E_FAIL;
1141
1142 case kListVMs:
1143 {
1144 /*
1145 * Get the list of all registered VMs
1146 */
1147 com::SafeIfaceArray<IMachine> machines;
1148 rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
1149 if (SUCCEEDED(rc))
1150 {
1151 /*
1152 * Display it.
1153 */
1154 if (!fOptSorted)
1155 {
1156 for (size_t i = 0; i < machines.size(); ++i)
1157 if (machines[i])
1158 rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
1159 }
1160 else
1161 {
1162 /*
1163 * Sort the list by name before displaying it.
1164 */
1165 std::vector<std::pair<com::Bstr, IMachine *> > sortedMachines;
1166 for (size_t i = 0; i < machines.size(); ++i)
1167 {
1168 IMachine *pMachine = machines[i];
1169 if (pMachine) /* no idea why we need to do this... */
1170 {
1171 Bstr bstrName;
1172 pMachine->COMGETTER(Name)(bstrName.asOutParam());
1173 sortedMachines.push_back(std::pair<com::Bstr, IMachine *>(bstrName, pMachine));
1174 }
1175 }
1176
1177 std::sort(sortedMachines.begin(), sortedMachines.end());
1178
1179 for (size_t i = 0; i < sortedMachines.size(); ++i)
1180 rc = showVMInfo(pVirtualBox, sortedMachines[i].second, NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
1181 }
1182 }
1183 break;
1184 }
1185
1186 case kListRunningVMs:
1187 {
1188 /*
1189 * Get the list of all _running_ VMs
1190 */
1191 com::SafeIfaceArray<IMachine> machines;
1192 rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
1193 com::SafeArray<MachineState_T> states;
1194 if (SUCCEEDED(rc))
1195 rc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
1196 if (SUCCEEDED(rc))
1197 {
1198 /*
1199 * Iterate through the collection
1200 */
1201 for (size_t i = 0; i < machines.size(); ++i)
1202 {
1203 if (machines[i])
1204 {
1205 MachineState_T machineState = states[i];
1206 switch (machineState)
1207 {
1208 case MachineState_Running:
1209 case MachineState_Teleporting:
1210 case MachineState_LiveSnapshotting:
1211 case MachineState_Paused:
1212 case MachineState_TeleportingPausedVM:
1213 rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
1214 break;
1215 default: break; /* Shut up MSC */
1216 }
1217 }
1218 }
1219 }
1220 break;
1221 }
1222
1223 case kListOsTypes:
1224 {
1225 com::SafeIfaceArray<IGuestOSType> coll;
1226 rc = pVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
1227 if (SUCCEEDED(rc))
1228 {
1229 /*
1230 * Iterate through the collection.
1231 */
1232 for (size_t i = 0; i < coll.size(); ++i)
1233 {
1234 ComPtr<IGuestOSType> guestOS;
1235 guestOS = coll[i];
1236 Bstr guestId;
1237 guestOS->COMGETTER(Id)(guestId.asOutParam());
1238 RTPrintf("ID: %ls\n", guestId.raw());
1239 Bstr guestDescription;
1240 guestOS->COMGETTER(Description)(guestDescription.asOutParam());
1241 RTPrintf("Description: %ls\n", guestDescription.raw());
1242 Bstr familyId;
1243 guestOS->COMGETTER(FamilyId)(familyId.asOutParam());
1244 RTPrintf("Family ID: %ls\n", familyId.raw());
1245 Bstr familyDescription;
1246 guestOS->COMGETTER(FamilyDescription)(familyDescription.asOutParam());
1247 RTPrintf("Family Desc: %ls\n", familyDescription.raw());
1248 BOOL is64Bit;
1249 guestOS->COMGETTER(Is64Bit)(&is64Bit);
1250 RTPrintf("64 bit: %RTbool\n", is64Bit);
1251 RTPrintf("\n");
1252 }
1253 }
1254 break;
1255 }
1256
1257 case kListHostDvds:
1258 {
1259 ComPtr<IHost> host;
1260 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
1261 com::SafeIfaceArray<IMedium> coll;
1262 CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
1263 if (SUCCEEDED(rc))
1264 {
1265 for (size_t i = 0; i < coll.size(); ++i)
1266 {
1267 ComPtr<IMedium> dvdDrive = coll[i];
1268 Bstr uuid;
1269 dvdDrive->COMGETTER(Id)(uuid.asOutParam());
1270 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
1271 Bstr location;
1272 dvdDrive->COMGETTER(Location)(location.asOutParam());
1273 RTPrintf("Name: %ls\n\n", location.raw());
1274 }
1275 }
1276 break;
1277 }
1278
1279 case kListHostFloppies:
1280 {
1281 ComPtr<IHost> host;
1282 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
1283 com::SafeIfaceArray<IMedium> coll;
1284 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
1285 if (SUCCEEDED(rc))
1286 {
1287 for (size_t i = 0; i < coll.size(); ++i)
1288 {
1289 ComPtr<IMedium> floppyDrive = coll[i];
1290 Bstr uuid;
1291 floppyDrive->COMGETTER(Id)(uuid.asOutParam());
1292 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
1293 Bstr location;
1294 floppyDrive->COMGETTER(Location)(location.asOutParam());
1295 RTPrintf("Name: %ls\n\n", location.raw());
1296 }
1297 }
1298 break;
1299 }
1300
1301 case kListInternalNetworks:
1302 rc = listInternalNetworks(pVirtualBox);
1303 break;
1304
1305 case kListBridgedInterfaces:
1306#if defined(VBOX_WITH_NETFLT)
1307 case kListHostOnlyInterfaces:
1308#endif
1309 rc = listNetworkInterfaces(pVirtualBox, enmCommand == kListBridgedInterfaces);
1310 break;
1311
1312 case kListHostInfo:
1313 rc = listHostInfo(pVirtualBox);
1314 break;
1315
1316 case kListHostCpuIDs:
1317 {
1318 ComPtr<IHost> Host;
1319 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
1320
1321 RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n");
1322 ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
1323 static uint32_t const s_auCpuIdRanges[] =
1324 {
1325 UINT32_C(0x00000000), UINT32_C(0x0000007f),
1326 UINT32_C(0x80000000), UINT32_C(0x8000007f),
1327 UINT32_C(0xc0000000), UINT32_C(0xc000007f)
1328 };
1329 for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
1330 {
1331 ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
1332 CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
1333 if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
1334 continue;
1335 cLeafs++;
1336 for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
1337 {
1338 CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
1339 RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
1340 }
1341 }
1342 break;
1343 }
1344
1345 case kListHddBackends:
1346 rc = listHddBackends(pVirtualBox);
1347 break;
1348
1349 case kListHdds:
1350 {
1351 com::SafeIfaceArray<IMedium> hdds;
1352 CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
1353 rc = listMedia(pVirtualBox, hdds, "base", fOptLong);
1354 break;
1355 }
1356
1357 case kListDvds:
1358 {
1359 com::SafeIfaceArray<IMedium> dvds;
1360 CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
1361 rc = listMedia(pVirtualBox, dvds, NULL, fOptLong);
1362 break;
1363 }
1364
1365 case kListFloppies:
1366 {
1367 com::SafeIfaceArray<IMedium> floppies;
1368 CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
1369 rc = listMedia(pVirtualBox, floppies, NULL, fOptLong);
1370 break;
1371 }
1372
1373 case kListUsbHost:
1374 rc = listUsbHost(pVirtualBox);
1375 break;
1376
1377 case kListUsbFilters:
1378 rc = listUsbFilters(pVirtualBox);
1379 break;
1380
1381 case kListSystemProperties:
1382 rc = listSystemProperties(pVirtualBox);
1383 break;
1384
1385 case kListDhcpServers:
1386 rc = listDhcpServers(pVirtualBox);
1387 break;
1388
1389 case kListExtPacks:
1390 rc = listExtensionPacks(pVirtualBox);
1391 break;
1392
1393 case kListGroups:
1394 rc = listGroups(pVirtualBox);
1395 break;
1396
1397 case kListNatNetworks:
1398 {
1399 com::SafeIfaceArray<INATNetwork> nets;
1400 CHECK_ERROR(pVirtualBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(nets)));
1401 for (size_t i = 0; i < nets.size(); ++i)
1402 {
1403 ComPtr<INATNetwork> net = nets[i];
1404 Bstr netName;
1405 net->COMGETTER(NetworkName)(netName.asOutParam());
1406 RTPrintf("NetworkName: %ls\n", netName.raw());
1407 Bstr gateway;
1408 net->COMGETTER(Gateway)(gateway.asOutParam());
1409 RTPrintf("IP: %ls\n", gateway.raw());
1410 Bstr network;
1411 net->COMGETTER(Network)(network.asOutParam());
1412 RTPrintf("Network: %ls\n", network.raw());
1413 BOOL fEnabled;
1414 net->COMGETTER(IPv6Enabled)(&fEnabled);
1415 RTPrintf("IPv6 Enabled: %s\n", fEnabled ? "Yes" : "No");
1416 Bstr ipv6prefix;
1417 net->COMGETTER(IPv6Prefix)(ipv6prefix.asOutParam());
1418 RTPrintf("IPv6 Prefix: %ls\n", ipv6prefix.raw());
1419 net->COMGETTER(NeedDhcpServer)(&fEnabled);
1420 RTPrintf("DHCP Enabled: %s\n", fEnabled ? "Yes" : "No");
1421 net->COMGETTER(Enabled)(&fEnabled);
1422 RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
1423
1424#define PRINT_STRING_ARRAY(title) \
1425 if (strs.size() > 0) \
1426 { \
1427 RTPrintf(title); \
1428 size_t j = 0; \
1429 for (;j < strs.size(); ++j) \
1430 RTPrintf(" %s\n", Utf8Str(strs[j]).c_str()); \
1431 }
1432
1433 com::SafeArray<BSTR> strs;
1434
1435 CHECK_ERROR(nets[i], COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(strs)));
1436 PRINT_STRING_ARRAY("Port-forwarding (ipv4)\n");
1437 strs.setNull();
1438
1439 CHECK_ERROR(nets[i], COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(strs)));
1440 PRINT_STRING_ARRAY("Port-forwarding (ipv6)\n");
1441 strs.setNull();
1442
1443 CHECK_ERROR(nets[i], COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs)));
1444 PRINT_STRING_ARRAY("loopback mappings (ipv4)\n");
1445 strs.setNull();
1446
1447#undef PRINT_STRING_ARRAY
1448 RTPrintf("\n");
1449 }
1450 break;
1451 }
1452
1453 case kListVideoInputDevices:
1454 rc = listVideoInputDevices(pVirtualBox);
1455 break;
1456
1457 case kListScreenShotFormats:
1458 rc = listScreenShotFormats(pVirtualBox);
1459 break;
1460
1461 case kListCloudProviders:
1462 rc = listCloudProviders(pVirtualBox);
1463 break;
1464
1465 case kListCloudProfiles:
1466 rc = listCloudProfiles(pVirtualBox, fOptLong);
1467 break;
1468
1469 /* No default here, want gcc warnings. */
1470
1471 } /* end switch */
1472
1473 return rc;
1474}
1475
1476/**
1477 * Handles the 'list' command.
1478 *
1479 * @returns Appropriate exit code.
1480 * @param a Handler argument.
1481 */
1482RTEXITCODE handleList(HandlerArg *a)
1483{
1484 bool fOptLong = false;
1485 bool fOptMultiple = false;
1486 bool fOptSorted = false;
1487 enum enmListType enmOptCommand = kListNotSpecified;
1488
1489 static const RTGETOPTDEF s_aListOptions[] =
1490 {
1491 { "--long", 'l', RTGETOPT_REQ_NOTHING },
1492 { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */
1493 { "--sorted", 's', RTGETOPT_REQ_NOTHING },
1494 { "vms", kListVMs, RTGETOPT_REQ_NOTHING },
1495 { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING },
1496 { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING },
1497 { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING },
1498 { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING },
1499 { "intnets", kListInternalNetworks, RTGETOPT_REQ_NOTHING },
1500 { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
1501 { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING },
1502#if defined(VBOX_WITH_NETFLT)
1503 { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
1504#endif
1505 { "natnetworks", kListNatNetworks, RTGETOPT_REQ_NOTHING },
1506 { "natnets", kListNatNetworks, RTGETOPT_REQ_NOTHING },
1507 { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING },
1508 { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING },
1509 { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING },
1510 { "hdds", kListHdds, RTGETOPT_REQ_NOTHING },
1511 { "dvds", kListDvds, RTGETOPT_REQ_NOTHING },
1512 { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING },
1513 { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING },
1514 { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING },
1515 { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING },
1516 { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING },
1517 { "extpacks", kListExtPacks, RTGETOPT_REQ_NOTHING },
1518 { "groups", kListGroups, RTGETOPT_REQ_NOTHING },
1519 { "webcams", kListVideoInputDevices, RTGETOPT_REQ_NOTHING },
1520 { "screenshotformats", kListScreenShotFormats, RTGETOPT_REQ_NOTHING },
1521 { "cloudproviders", kListCloudProviders, RTGETOPT_REQ_NOTHING },
1522 { "cloudprofiles", kListCloudProfiles, RTGETOPT_REQ_NOTHING },
1523 };
1524
1525 int ch;
1526 RTGETOPTUNION ValueUnion;
1527 RTGETOPTSTATE GetState;
1528 RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
1529 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
1530 while ((ch = RTGetOpt(&GetState, &ValueUnion)))
1531 {
1532 switch (ch)
1533 {
1534 case 'l': /* --long */
1535 fOptLong = true;
1536 break;
1537
1538 case 's':
1539 fOptSorted = true;
1540 break;
1541
1542 case 'm':
1543 fOptMultiple = true;
1544 if (enmOptCommand == kListNotSpecified)
1545 break;
1546 ch = enmOptCommand;
1547 RT_FALL_THRU();
1548
1549 case kListVMs:
1550 case kListRunningVMs:
1551 case kListOsTypes:
1552 case kListHostDvds:
1553 case kListHostFloppies:
1554 case kListInternalNetworks:
1555 case kListBridgedInterfaces:
1556#if defined(VBOX_WITH_NETFLT)
1557 case kListHostOnlyInterfaces:
1558#endif
1559 case kListHostInfo:
1560 case kListHostCpuIDs:
1561 case kListHddBackends:
1562 case kListHdds:
1563 case kListDvds:
1564 case kListFloppies:
1565 case kListUsbHost:
1566 case kListUsbFilters:
1567 case kListSystemProperties:
1568 case kListDhcpServers:
1569 case kListExtPacks:
1570 case kListGroups:
1571 case kListNatNetworks:
1572 case kListVideoInputDevices:
1573 case kListScreenShotFormats:
1574 case kListCloudProviders:
1575 case kListCloudProfiles:
1576 enmOptCommand = (enum enmListType)ch;
1577 if (fOptMultiple)
1578 {
1579 HRESULT hrc = produceList((enum enmListType)ch, fOptLong, fOptSorted, a->virtualBox);
1580 if (FAILED(hrc))
1581 return RTEXITCODE_FAILURE;
1582 }
1583 break;
1584
1585 case VINF_GETOPT_NOT_OPTION:
1586 return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
1587
1588 default:
1589 return errorGetOpt(USAGE_LIST, ch, &ValueUnion);
1590 }
1591 }
1592
1593 /*
1594 * If not in multiple list mode, we have to produce the list now.
1595 */
1596 if (enmOptCommand == kListNotSpecified)
1597 return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
1598 if (!fOptMultiple)
1599 {
1600 HRESULT hrc = produceList(enmOptCommand, fOptLong, fOptSorted, a->virtualBox);
1601 if (FAILED(hrc))
1602 return RTEXITCODE_FAILURE;
1603 }
1604
1605 return RTEXITCODE_SUCCESS;
1606}
1607
1608#endif /* !VBOX_ONLY_DOCS */
1609/* vi: set tabstop=4 shiftwidth=4 expandtab: */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette