VirtualBox

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

Last change on this file since 92710 was 92594, checked in by vboxsync, 3 years ago

Main: bugref:1909: Added translation into VBoxManage excluding built-in docbook help. Fixed translation marks in the VBoxManage

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 99.9 KB
Line 
1/* $Id: VBoxManageList.cpp 92594 2021-11-25 09:05:48Z vboxsync $ */
2/** @file
3 * VBoxManage - The 'list' command.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_ONLY_DOCS
19
20
21/*********************************************************************************************************************************
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/stream.h>
35#include <iprt/string.h>
36#include <iprt/time.h>
37#include <iprt/getopt.h>
38#include <iprt/ctype.h>
39
40#include <vector>
41#include <algorithm>
42
43#include "VBoxManage.h"
44using namespace com;
45
46DECLARE_TRANSLATION_CONTEXT(List);
47
48#ifdef VBOX_WITH_HOSTNETIF_API
49static const char *getHostIfMediumTypeText(HostNetworkInterfaceMediumType_T enmType)
50{
51 switch (enmType)
52 {
53 case HostNetworkInterfaceMediumType_Ethernet: return "Ethernet";
54 case HostNetworkInterfaceMediumType_PPP: return "PPP";
55 case HostNetworkInterfaceMediumType_SLIP: return "SLIP";
56 case HostNetworkInterfaceMediumType_Unknown: return List::tr("Unknown");
57#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
58 case HostNetworkInterfaceMediumType_32BitHack: break; /* Shut up compiler warnings. */
59#endif
60 }
61 return List::tr("unknown");
62}
63
64static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
65{
66 switch (enmStatus)
67 {
68 case HostNetworkInterfaceStatus_Up: return List::tr("Up");
69 case HostNetworkInterfaceStatus_Down: return List::tr("Down");
70 case HostNetworkInterfaceStatus_Unknown: return List::tr("Unknown");
71#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
72 case HostNetworkInterfaceStatus_32BitHack: break; /* Shut up compiler warnings. */
73#endif
74 }
75 return List::tr("unknown");
76}
77#endif /* VBOX_WITH_HOSTNETIF_API */
78
79static const char*getDeviceTypeText(DeviceType_T enmType)
80{
81 switch (enmType)
82 {
83 case DeviceType_HardDisk: return List::tr("HardDisk");
84 case DeviceType_DVD: return "DVD";
85 case DeviceType_Floppy: return List::tr("Floppy");
86 /* Make MSC happy */
87 case DeviceType_Null: return "Null";
88 case DeviceType_Network: return List::tr("Network");
89 case DeviceType_USB: return "USB";
90 case DeviceType_SharedFolder: return List::tr("SharedFolder");
91 case DeviceType_Graphics3D: return List::tr("Graphics3D");
92#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
93 case DeviceType_32BitHack: break; /* Shut up compiler warnings. */
94#endif
95 }
96 return List::tr("Unknown");
97}
98
99
100/**
101 * List internal networks.
102 *
103 * @returns See produceList.
104 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
105 */
106static HRESULT listInternalNetworks(const ComPtr<IVirtualBox> pVirtualBox)
107{
108 HRESULT rc;
109 com::SafeArray<BSTR> internalNetworks;
110 CHECK_ERROR(pVirtualBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks)));
111 for (size_t i = 0; i < internalNetworks.size(); ++i)
112 {
113 RTPrintf(List::tr("Name: %ls\n"), internalNetworks[i]);
114 }
115 return rc;
116}
117
118
119/**
120 * List network interfaces information (bridged/host only).
121 *
122 * @returns See produceList.
123 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
124 * @param fIsBridged Selects between listing host interfaces (for
125 * use with bridging) or host only interfaces.
126 */
127static HRESULT listNetworkInterfaces(const ComPtr<IVirtualBox> pVirtualBox,
128 bool fIsBridged)
129{
130 HRESULT rc;
131 ComPtr<IHost> host;
132 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
133 com::SafeIfaceArray<IHostNetworkInterface> hostNetworkInterfaces;
134#if defined(VBOX_WITH_NETFLT)
135 if (fIsBridged)
136 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged,
137 ComSafeArrayAsOutParam(hostNetworkInterfaces)));
138 else
139 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_HostOnly,
140 ComSafeArrayAsOutParam(hostNetworkInterfaces)));
141#else
142 RT_NOREF(fIsBridged);
143 CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(hostNetworkInterfaces)));
144#endif
145 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
146 {
147 ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
148#ifndef VBOX_WITH_HOSTNETIF_API
149 Bstr interfaceName;
150 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
151 RTPrintf(List::tr("Name: %ls\n"), interfaceName.raw());
152 Guid interfaceGuid;
153 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
154 RTPrintf("GUID: %ls\n\n", Bstr(interfaceGuid.toString()).raw());
155#else /* VBOX_WITH_HOSTNETIF_API */
156 Bstr interfaceName;
157 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
158 RTPrintf(List::tr("Name: %ls\n"), interfaceName.raw());
159 Bstr interfaceGuid;
160 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
161 RTPrintf("GUID: %ls\n", interfaceGuid.raw());
162 BOOL fDHCPEnabled = FALSE;
163 networkInterface->COMGETTER(DHCPEnabled)(&fDHCPEnabled);
164 RTPrintf("DHCP: %s\n", fDHCPEnabled ? List::tr("Enabled") : List::tr("Disabled"));
165
166 Bstr IPAddress;
167 networkInterface->COMGETTER(IPAddress)(IPAddress.asOutParam());
168 RTPrintf(List::tr("IPAddress: %ls\n"), IPAddress.raw());
169 Bstr NetworkMask;
170 networkInterface->COMGETTER(NetworkMask)(NetworkMask.asOutParam());
171 RTPrintf(List::tr("NetworkMask: %ls\n"), NetworkMask.raw());
172 Bstr IPV6Address;
173 networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
174 RTPrintf(List::tr("IPV6Address: %ls\n"), IPV6Address.raw());
175 ULONG IPV6NetworkMaskPrefixLength;
176 networkInterface->COMGETTER(IPV6NetworkMaskPrefixLength)(&IPV6NetworkMaskPrefixLength);
177 RTPrintf(List::tr("IPV6NetworkMaskPrefixLength: %d\n"), IPV6NetworkMaskPrefixLength);
178 Bstr HardwareAddress;
179 networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
180 RTPrintf(List::tr("HardwareAddress: %ls\n"), HardwareAddress.raw());
181 HostNetworkInterfaceMediumType_T Type;
182 networkInterface->COMGETTER(MediumType)(&Type);
183 RTPrintf(List::tr("MediumType: %s\n"), getHostIfMediumTypeText(Type));
184 BOOL fWireless = FALSE;
185 networkInterface->COMGETTER(Wireless)(&fWireless);
186 RTPrintf(List::tr("Wireless: %s\n"), fWireless ? List::tr("Yes") : List::tr("No"));
187 HostNetworkInterfaceStatus_T Status;
188 networkInterface->COMGETTER(Status)(&Status);
189 RTPrintf(List::tr("Status: %s\n"), getHostIfStatusText(Status));
190 Bstr netName;
191 networkInterface->COMGETTER(NetworkName)(netName.asOutParam());
192 RTPrintf(List::tr("VBoxNetworkName: %ls\n\n"), netName.raw());
193#endif
194 }
195 return rc;
196}
197
198
199#ifdef VBOX_WITH_VMNET
200/**
201 * List configured host-only networks.
202 *
203 * @returns See produceList.
204 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
205 * @param Reserved Placeholder!
206 */
207static HRESULT listHostOnlyNetworks(const ComPtr<IVirtualBox> pVirtualBox)
208{
209 HRESULT rc;
210 com::SafeIfaceArray<IHostOnlyNetwork> hostOnlyNetworks;
211 CHECK_ERROR(pVirtualBox, COMGETTER(HostOnlyNetworks)(ComSafeArrayAsOutParam(hostOnlyNetworks)));
212 for (size_t i = 0; i < hostOnlyNetworks.size(); ++i)
213 {
214 ComPtr<IHostOnlyNetwork> hostOnlyNetwork = hostOnlyNetworks[i];
215 Bstr networkName;
216 hostOnlyNetwork->COMGETTER(NetworkName)(networkName.asOutParam());
217 RTPrintf(List::tr("Name: %ls\n"), networkName.raw());
218 Bstr networkGuid;
219 hostOnlyNetwork->COMGETTER(Id)(networkGuid.asOutParam());
220 RTPrintf("GUID: %ls\n\n", networkGuid.raw());
221 BOOL fEnabled = FALSE;
222 hostOnlyNetwork->COMGETTER(Enabled)(&fEnabled);
223 RTPrintf(List::tr("State: %s\n"), fEnabled ? List::tr("Enabled") : List::tr("Disabled"));
224
225 Bstr networkMask;
226 hostOnlyNetwork->COMGETTER(NetworkMask)(networkMask.asOutParam());
227 RTPrintf(List::tr("NetworkMask: %ls\n"), networkMask.raw());
228 Bstr lowerIP;
229 hostOnlyNetwork->COMGETTER(LowerIP)(lowerIP.asOutParam());
230 RTPrintf(List::tr("LowerIP: %ls\n"), lowerIP.raw());
231 Bstr upperIP;
232 hostOnlyNetwork->COMGETTER(UpperIP)(upperIP.asOutParam());
233 RTPrintf(List::tr("UpperIP: %ls\n"), upperIP.raw());
234 // Bstr NetworkId;
235 // hostOnlyNetwork->COMGETTER(Id)(NetworkId.asOutParam());
236 // RTPrintf("NetworkId: %ls\n", NetworkId.raw());
237 Bstr netName = BstrFmt("hostonly-%ls", networkName.raw());
238 RTPrintf(List::tr("VBoxNetworkName: %ls\n\n"), netName.raw());
239 }
240 return rc;
241}
242#endif /* VBOX_WITH_VMNET */
243
244
245#ifdef VBOX_WITH_CLOUD_NET
246/**
247 * List configured cloud network attachments.
248 *
249 * @returns See produceList.
250 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
251 * @param Reserved Placeholder!
252 */
253static HRESULT listCloudNetworks(const ComPtr<IVirtualBox> pVirtualBox)
254{
255 HRESULT rc;
256 com::SafeIfaceArray<ICloudNetwork> cloudNetworks;
257 CHECK_ERROR(pVirtualBox, COMGETTER(CloudNetworks)(ComSafeArrayAsOutParam(cloudNetworks)));
258 for (size_t i = 0; i < cloudNetworks.size(); ++i)
259 {
260 ComPtr<ICloudNetwork> cloudNetwork = cloudNetworks[i];
261 Bstr networkName;
262 cloudNetwork->COMGETTER(NetworkName)(networkName.asOutParam());
263 RTPrintf(List::tr("Name: %ls\n"), networkName.raw());
264 // Guid interfaceGuid;
265 // cloudNetwork->COMGETTER(Id)(interfaceGuid.asOutParam());
266 // RTPrintf("GUID: %ls\n\n", Bstr(interfaceGuid.toString()).raw());
267 BOOL fEnabled = FALSE;
268 cloudNetwork->COMGETTER(Enabled)(&fEnabled);
269 RTPrintf(List::tr("State: %s\n"), fEnabled ? List::tr("Enabled") : List::tr("Disabled"));
270
271 Bstr Provider;
272 cloudNetwork->COMGETTER(Provider)(Provider.asOutParam());
273 RTPrintf(List::tr("CloudProvider: %ls\n"), Provider.raw());
274 Bstr Profile;
275 cloudNetwork->COMGETTER(Profile)(Profile.asOutParam());
276 RTPrintf(List::tr("CloudProfile: %ls\n"), Profile.raw());
277 Bstr NetworkId;
278 cloudNetwork->COMGETTER(NetworkId)(NetworkId.asOutParam());
279 RTPrintf(List::tr("CloudNetworkId: %ls\n"), NetworkId.raw());
280 Bstr netName = BstrFmt("cloud-%ls", networkName.raw());
281 RTPrintf(List::tr("VBoxNetworkName: %ls\n\n"), netName.raw());
282 }
283 return rc;
284}
285#endif /* VBOX_WITH_CLOUD_NET */
286
287
288/**
289 * List host information.
290 *
291 * @returns See produceList.
292 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
293 */
294static HRESULT listHostInfo(const ComPtr<IVirtualBox> pVirtualBox)
295{
296 static struct
297 {
298 ProcessorFeature_T feature;
299 const char *pszName;
300 } features[]
301 =
302 {
303 { ProcessorFeature_HWVirtEx, List::tr("HW virtualization") },
304 { ProcessorFeature_PAE, "PAE" },
305 { ProcessorFeature_LongMode, List::tr("long mode") },
306 { ProcessorFeature_NestedPaging, List::tr("nested paging") },
307 { ProcessorFeature_UnrestrictedGuest, List::tr("unrestricted guest") },
308 { ProcessorFeature_NestedHWVirt, List::tr("nested HW virtualization") },
309 { ProcessorFeature_VirtVmsaveVmload, List::tr("virt. vmsave/vmload") },
310 };
311 HRESULT rc;
312 ComPtr<IHost> Host;
313 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
314
315 RTPrintf(List::tr("Host Information:\n\n"));
316
317 LONG64 u64UtcTime = 0;
318 CHECK_ERROR(Host, COMGETTER(UTCTime)(&u64UtcTime));
319 RTTIMESPEC timeSpec;
320 char szTime[32];
321 RTPrintf(List::tr("Host time: %s\n"), RTTimeSpecToString(RTTimeSpecSetMilli(&timeSpec, u64UtcTime), szTime, sizeof(szTime)));
322
323 ULONG processorOnlineCount = 0;
324 CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
325 RTPrintf(List::tr("Processor online count: %lu\n"), processorOnlineCount);
326 ULONG processorCount = 0;
327 CHECK_ERROR(Host, COMGETTER(ProcessorCount)(&processorCount));
328 RTPrintf(List::tr("Processor count: %lu\n"), processorCount);
329 ULONG processorOnlineCoreCount = 0;
330 CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCoreCount)(&processorOnlineCoreCount));
331 RTPrintf(List::tr("Processor online core count: %lu\n"), processorOnlineCoreCount);
332 ULONG processorCoreCount = 0;
333 CHECK_ERROR(Host, COMGETTER(ProcessorCoreCount)(&processorCoreCount));
334 RTPrintf(List::tr("Processor core count: %lu\n"), processorCoreCount);
335 for (unsigned i = 0; i < RT_ELEMENTS(features); i++)
336 {
337 BOOL supported;
338 CHECK_ERROR(Host, GetProcessorFeature(features[i].feature, &supported));
339 RTPrintf(List::tr("Processor supports %s: %s\n"), features[i].pszName, supported ? List::tr("yes") : List::tr("no"));
340 }
341 for (ULONG i = 0; i < processorCount; i++)
342 {
343 ULONG processorSpeed = 0;
344 CHECK_ERROR(Host, GetProcessorSpeed(i, &processorSpeed));
345 if (processorSpeed)
346 RTPrintf(List::tr("Processor#%u speed: %lu MHz\n"), i, processorSpeed);
347 else
348 RTPrintf(List::tr("Processor#%u speed: unknown\n"), i);
349 Bstr processorDescription;
350 CHECK_ERROR(Host, GetProcessorDescription(i, processorDescription.asOutParam()));
351 RTPrintf(List::tr("Processor#%u description: %ls\n"), i, processorDescription.raw());
352 }
353
354 ULONG memorySize = 0;
355 CHECK_ERROR(Host, COMGETTER(MemorySize)(&memorySize));
356 RTPrintf(List::tr("Memory size: %lu MByte\n", "", memorySize), memorySize);
357
358 ULONG memoryAvailable = 0;
359 CHECK_ERROR(Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
360 RTPrintf(List::tr("Memory available: %lu MByte\n", "", memoryAvailable), memoryAvailable);
361
362 Bstr operatingSystem;
363 CHECK_ERROR(Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
364 RTPrintf(List::tr("Operating system: %ls\n"), operatingSystem.raw());
365
366 Bstr oSVersion;
367 CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
368 RTPrintf(List::tr("Operating system version: %ls\n"), oSVersion.raw());
369 return rc;
370}
371
372
373/**
374 * List media information.
375 *
376 * @returns See produceList.
377 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
378 * @param aMedia Medium objects to list information for.
379 * @param pszParentUUIDStr String with the parent UUID string (or "base").
380 * @param fOptLong Long (@c true) or short list format.
381 */
382static HRESULT listMedia(const ComPtr<IVirtualBox> pVirtualBox,
383 const com::SafeIfaceArray<IMedium> &aMedia,
384 const char *pszParentUUIDStr,
385 bool fOptLong)
386{
387 HRESULT rc = S_OK;
388 for (size_t i = 0; i < aMedia.size(); ++i)
389 {
390 ComPtr<IMedium> pMedium = aMedia[i];
391
392 rc = showMediumInfo(pVirtualBox, pMedium, pszParentUUIDStr, fOptLong);
393
394 RTPrintf("\n");
395
396 com::SafeIfaceArray<IMedium> children;
397 CHECK_ERROR(pMedium, COMGETTER(Children)(ComSafeArrayAsOutParam(children)));
398 if (children.size() > 0)
399 {
400 Bstr uuid;
401 pMedium->COMGETTER(Id)(uuid.asOutParam());
402
403 // depth first listing of child media
404 rc = listMedia(pVirtualBox, children, Utf8Str(uuid).c_str(), fOptLong);
405 }
406 }
407
408 return rc;
409}
410
411
412/**
413 * List virtual image backends.
414 *
415 * @returns See produceList.
416 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
417 */
418static HRESULT listHddBackends(const ComPtr<IVirtualBox> pVirtualBox)
419{
420 HRESULT rc;
421 ComPtr<ISystemProperties> systemProperties;
422 CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
423 com::SafeIfaceArray<IMediumFormat> mediumFormats;
424 CHECK_ERROR(systemProperties, COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
425
426 RTPrintf(List::tr("Supported hard disk backends:\n\n"));
427 for (size_t i = 0; i < mediumFormats.size(); ++i)
428 {
429 /* General information */
430 Bstr id;
431 CHECK_ERROR(mediumFormats[i], COMGETTER(Id)(id.asOutParam()));
432
433 Bstr description;
434 CHECK_ERROR(mediumFormats[i],
435 COMGETTER(Name)(description.asOutParam()));
436
437 ULONG caps = 0;
438 com::SafeArray <MediumFormatCapabilities_T> mediumFormatCap;
439 CHECK_ERROR(mediumFormats[i],
440 COMGETTER(Capabilities)(ComSafeArrayAsOutParam(mediumFormatCap)));
441 for (ULONG j = 0; j < mediumFormatCap.size(); j++)
442 caps |= mediumFormatCap[j];
443
444
445 RTPrintf(List::tr("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='"),
446 i, id.raw(), description.raw(), caps);
447
448 /* File extensions */
449 com::SafeArray<BSTR> fileExtensions;
450 com::SafeArray<DeviceType_T> deviceTypes;
451 CHECK_ERROR(mediumFormats[i],
452 DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes)));
453 for (size_t j = 0; j < fileExtensions.size(); ++j)
454 {
455 RTPrintf("%ls (%s)", Bstr(fileExtensions[j]).raw(), getDeviceTypeText(deviceTypes[j]));
456 if (j != fileExtensions.size()-1)
457 RTPrintf(",");
458 }
459 RTPrintf("'");
460
461 /* Configuration keys */
462 com::SafeArray<BSTR> propertyNames;
463 com::SafeArray<BSTR> propertyDescriptions;
464 com::SafeArray<DataType_T> propertyTypes;
465 com::SafeArray<ULONG> propertyFlags;
466 com::SafeArray<BSTR> propertyDefaults;
467 CHECK_ERROR(mediumFormats[i],
468 DescribeProperties(ComSafeArrayAsOutParam(propertyNames),
469 ComSafeArrayAsOutParam(propertyDescriptions),
470 ComSafeArrayAsOutParam(propertyTypes),
471 ComSafeArrayAsOutParam(propertyFlags),
472 ComSafeArrayAsOutParam(propertyDefaults)));
473
474 RTPrintf(List::tr(" properties=("));
475 if (propertyNames.size() > 0)
476 {
477 for (size_t j = 0; j < propertyNames.size(); ++j)
478 {
479 RTPrintf(List::tr("\n name='%ls' desc='%ls' type="),
480 Bstr(propertyNames[j]).raw(), Bstr(propertyDescriptions[j]).raw());
481 switch (propertyTypes[j])
482 {
483 case DataType_Int32: RTPrintf(List::tr("int")); break;
484 case DataType_Int8: RTPrintf(List::tr("byte")); break;
485 case DataType_String: RTPrintf(List::tr("string")); break;
486#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
487 case DataType_32BitHack: break; /* Shut up compiler warnings. */
488#endif
489 }
490 RTPrintf(List::tr(" flags=%#04x"), propertyFlags[j]);
491 RTPrintf(List::tr(" default='%ls'"), Bstr(propertyDefaults[j]).raw());
492 if (j != propertyNames.size()-1)
493 RTPrintf(", ");
494 }
495 }
496 RTPrintf(")\n");
497 }
498 return rc;
499}
500
501
502/**
503 * List USB devices attached to the host.
504 *
505 * @returns See produceList.
506 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
507 */
508static HRESULT listUsbHost(const ComPtr<IVirtualBox> &pVirtualBox)
509{
510 HRESULT rc;
511 ComPtr<IHost> Host;
512 CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
513
514 SafeIfaceArray<IHostUSBDevice> CollPtr;
515 CHECK_ERROR_RET(Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1);
516
517 RTPrintf(List::tr("Host USB Devices:\n\n"));
518
519 if (CollPtr.size() == 0)
520 {
521 RTPrintf(List::tr("<none>\n\n"));
522 }
523 else
524 {
525 for (size_t i = 0; i < CollPtr.size(); ++i)
526 {
527 ComPtr<IHostUSBDevice> dev = CollPtr[i];
528
529 /* Query info. */
530 Bstr id;
531 CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), 1);
532 USHORT usVendorId;
533 CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), 1);
534 USHORT usProductId;
535 CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), 1);
536 USHORT bcdRevision;
537 CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), 1);
538 USHORT usPort;
539 CHECK_ERROR_RET(dev, COMGETTER(Port)(&usPort), 1);
540 USHORT usVersion;
541 CHECK_ERROR_RET(dev, COMGETTER(Version)(&usVersion), 1);
542 USBConnectionSpeed_T enmSpeed;
543 CHECK_ERROR_RET(dev, COMGETTER(Speed)(&enmSpeed), 1);
544
545 RTPrintf(List::tr(
546 "UUID: %s\n"
547 "VendorId: %#06x (%04X)\n"
548 "ProductId: %#06x (%04X)\n"
549 "Revision: %u.%u (%02u%02u)\n"
550 "Port: %u\n"),
551 Utf8Str(id).c_str(),
552 usVendorId, usVendorId, usProductId, usProductId,
553 bcdRevision >> 8, bcdRevision & 0xff,
554 bcdRevision >> 8, bcdRevision & 0xff,
555 usPort);
556
557 const char *pszSpeed = "?";
558 switch (enmSpeed)
559 {
560 case USBConnectionSpeed_Low:
561 pszSpeed = List::tr("Low");
562 break;
563 case USBConnectionSpeed_Full:
564 pszSpeed = List::tr("Full");
565 break;
566 case USBConnectionSpeed_High:
567 pszSpeed = List::tr("High");
568 break;
569 case USBConnectionSpeed_Super:
570 pszSpeed = List::tr("Super");
571 break;
572 case USBConnectionSpeed_SuperPlus:
573 pszSpeed = List::tr("SuperPlus");
574 break;
575 default:
576 ASSERT(false);
577 break;
578 }
579
580 RTPrintf(List::tr("USB version/speed: %u/%s\n"), usVersion, pszSpeed);
581
582 /* optional stuff. */
583 SafeArray<BSTR> CollDevInfo;
584 Bstr bstr;
585 CHECK_ERROR_RET(dev, COMGETTER(DeviceInfo)(ComSafeArrayAsOutParam(CollDevInfo)), 1);
586 if (CollDevInfo.size() >= 1)
587 bstr = Bstr(CollDevInfo[0]);
588 if (!bstr.isEmpty())
589 RTPrintf(List::tr("Manufacturer: %ls\n"), bstr.raw());
590 if (CollDevInfo.size() >= 2)
591 bstr = Bstr(CollDevInfo[1]);
592 if (!bstr.isEmpty())
593 RTPrintf(List::tr("Product: %ls\n"), bstr.raw());
594 CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
595 if (!bstr.isEmpty())
596 RTPrintf(List::tr("SerialNumber: %ls\n"), bstr.raw());
597 CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), 1);
598 if (!bstr.isEmpty())
599 RTPrintf(List::tr("Address: %ls\n"), bstr.raw());
600 CHECK_ERROR_RET(dev, COMGETTER(PortPath)(bstr.asOutParam()), 1);
601 if (!bstr.isEmpty())
602 RTPrintf(List::tr("Port path: %ls\n"), bstr.raw());
603
604 /* current state */
605 USBDeviceState_T state;
606 CHECK_ERROR_RET(dev, COMGETTER(State)(&state), 1);
607 const char *pszState = "?";
608 switch (state)
609 {
610 case USBDeviceState_NotSupported:
611 pszState = List::tr("Not supported");
612 break;
613 case USBDeviceState_Unavailable:
614 pszState = List::tr("Unavailable");
615 break;
616 case USBDeviceState_Busy:
617 pszState = List::tr("Busy");
618 break;
619 case USBDeviceState_Available:
620 pszState = List::tr("Available");
621 break;
622 case USBDeviceState_Held:
623 pszState = List::tr("Held");
624 break;
625 case USBDeviceState_Captured:
626 pszState = List::tr("Captured");
627 break;
628 default:
629 ASSERT(false);
630 break;
631 }
632 RTPrintf(List::tr("Current State: %s\n\n"), pszState);
633 }
634 }
635 return rc;
636}
637
638
639/**
640 * List USB filters.
641 *
642 * @returns See produceList.
643 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
644 */
645static HRESULT listUsbFilters(const ComPtr<IVirtualBox> &pVirtualBox)
646{
647 HRESULT rc;
648
649 RTPrintf(List::tr("Global USB Device Filters:\n\n"));
650
651 ComPtr<IHost> host;
652 CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(host.asOutParam()), 1);
653
654 SafeIfaceArray<IHostUSBDeviceFilter> coll;
655 CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
656
657 if (coll.size() == 0)
658 {
659 RTPrintf(List::tr("<none>\n\n"));
660 }
661 else
662 {
663 for (size_t index = 0; index < coll.size(); ++index)
664 {
665 ComPtr<IHostUSBDeviceFilter> flt = coll[index];
666
667 /* Query info. */
668
669 RTPrintf(List::tr("Index: %zu\n"), index);
670
671 BOOL active = FALSE;
672 CHECK_ERROR_RET(flt, COMGETTER(Active)(&active), 1);
673 RTPrintf(List::tr("Active: %s\n"), active ? List::tr("yes") : List::tr("no"));
674
675 USBDeviceFilterAction_T action;
676 CHECK_ERROR_RET(flt, COMGETTER(Action)(&action), 1);
677 const char *pszAction = List::tr("<invalid>");
678 switch (action)
679 {
680 case USBDeviceFilterAction_Ignore:
681 pszAction = List::tr("Ignore");
682 break;
683 case USBDeviceFilterAction_Hold:
684 pszAction = List::tr("Hold");
685 break;
686 default:
687 break;
688 }
689 RTPrintf(List::tr("Action: %s\n"), pszAction);
690
691 Bstr bstr;
692 CHECK_ERROR_RET(flt, COMGETTER(Name)(bstr.asOutParam()), 1);
693 RTPrintf(List::tr("Name: %ls\n"), bstr.raw());
694 CHECK_ERROR_RET(flt, COMGETTER(VendorId)(bstr.asOutParam()), 1);
695 RTPrintf(List::tr("VendorId: %ls\n"), bstr.raw());
696 CHECK_ERROR_RET(flt, COMGETTER(ProductId)(bstr.asOutParam()), 1);
697 RTPrintf(List::tr("ProductId: %ls\n"), bstr.raw());
698 CHECK_ERROR_RET(flt, COMGETTER(Revision)(bstr.asOutParam()), 1);
699 RTPrintf(List::tr("Revision: %ls\n"), bstr.raw());
700 CHECK_ERROR_RET(flt, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
701 RTPrintf(List::tr("Manufacturer: %ls\n"), bstr.raw());
702 CHECK_ERROR_RET(flt, COMGETTER(Product)(bstr.asOutParam()), 1);
703 RTPrintf(List::tr("Product: %ls\n"), bstr.raw());
704 CHECK_ERROR_RET(flt, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
705 RTPrintf(List::tr("Serial Number: %ls\n\n"), bstr.raw());
706 }
707 }
708 return rc;
709}
710
711
712/**
713 * List system properties.
714 *
715 * @returns See produceList.
716 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
717 */
718static HRESULT listSystemProperties(const ComPtr<IVirtualBox> &pVirtualBox)
719{
720 ComPtr<ISystemProperties> systemProperties;
721 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), hrcCheck);
722
723 Bstr str;
724 ULONG ulValue;
725 LONG64 i64Value;
726 BOOL fValue;
727 const char *psz;
728
729 pVirtualBox->COMGETTER(APIVersion)(str.asOutParam());
730 RTPrintf(List::tr("API version: %ls\n"), str.raw());
731
732 systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
733 RTPrintf(List::tr("Minimum guest RAM size: %u Megabytes\n", "", ulValue), ulValue);
734 systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
735 RTPrintf(List::tr("Maximum guest RAM size: %u Megabytes\n", "", ulValue), ulValue);
736 systemProperties->COMGETTER(MinGuestVRAM)(&ulValue);
737 RTPrintf(List::tr("Minimum video RAM size: %u Megabytes\n", "", ulValue), ulValue);
738 systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
739 RTPrintf(List::tr("Maximum video RAM size: %u Megabytes\n", "", ulValue), ulValue);
740 systemProperties->COMGETTER(MaxGuestMonitors)(&ulValue);
741 RTPrintf(List::tr("Maximum guest monitor count: %u\n"), ulValue);
742 systemProperties->COMGETTER(MinGuestCPUCount)(&ulValue);
743 RTPrintf(List::tr("Minimum guest CPU count: %u\n"), ulValue);
744 systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
745 RTPrintf(List::tr("Maximum guest CPU count: %u\n"), ulValue);
746 systemProperties->COMGETTER(InfoVDSize)(&i64Value);
747 RTPrintf(List::tr("Virtual disk limit (info): %lld Bytes\n", "" , i64Value), i64Value);
748 systemProperties->COMGETTER(SerialPortCount)(&ulValue);
749 RTPrintf(List::tr("Maximum Serial Port count: %u\n"), ulValue);
750 systemProperties->COMGETTER(ParallelPortCount)(&ulValue);
751 RTPrintf(List::tr("Maximum Parallel Port count: %u\n"), ulValue);
752 systemProperties->COMGETTER(MaxBootPosition)(&ulValue);
753 RTPrintf(List::tr("Maximum Boot Position: %u\n"), ulValue);
754 systemProperties->GetMaxNetworkAdapters(ChipsetType_PIIX3, &ulValue);
755 RTPrintf(List::tr("Maximum PIIX3 Network Adapter count: %u\n"), ulValue);
756 systemProperties->GetMaxNetworkAdapters(ChipsetType_ICH9, &ulValue);
757 RTPrintf(List::tr("Maximum ICH9 Network Adapter count: %u\n"), ulValue);
758 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_IDE, &ulValue);
759 RTPrintf(List::tr("Maximum PIIX3 IDE Controllers: %u\n"), ulValue);
760 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_IDE, &ulValue);
761 RTPrintf(List::tr("Maximum ICH9 IDE Controllers: %u\n"), ulValue);
762 systemProperties->GetMaxPortCountForStorageBus(StorageBus_IDE, &ulValue);
763 RTPrintf(List::tr("Maximum IDE Port count: %u\n"), ulValue);
764 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_IDE, &ulValue);
765 RTPrintf(List::tr("Maximum Devices per IDE Port: %u\n"), ulValue);
766 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SATA, &ulValue);
767 RTPrintf(List::tr("Maximum PIIX3 SATA Controllers: %u\n"), ulValue);
768 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SATA, &ulValue);
769 RTPrintf(List::tr("Maximum ICH9 SATA Controllers: %u\n"), ulValue);
770 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SATA, &ulValue);
771 RTPrintf(List::tr("Maximum SATA Port count: %u\n"), ulValue);
772 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SATA, &ulValue);
773 RTPrintf(List::tr("Maximum Devices per SATA Port: %u\n"), ulValue);
774 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SCSI, &ulValue);
775 RTPrintf(List::tr("Maximum PIIX3 SCSI Controllers: %u\n"), ulValue);
776 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SCSI, &ulValue);
777 RTPrintf(List::tr("Maximum ICH9 SCSI Controllers: %u\n"), ulValue);
778 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SCSI, &ulValue);
779 RTPrintf(List::tr("Maximum SCSI Port count: %u\n"), ulValue);
780 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SCSI, &ulValue);
781 RTPrintf(List::tr("Maximum Devices per SCSI Port: %u\n"), ulValue);
782 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SAS, &ulValue);
783 RTPrintf(List::tr("Maximum SAS PIIX3 Controllers: %u\n"), ulValue);
784 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SAS, &ulValue);
785 RTPrintf(List::tr("Maximum SAS ICH9 Controllers: %u\n"), ulValue);
786 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SAS, &ulValue);
787 RTPrintf(List::tr("Maximum SAS Port count: %u\n"), ulValue);
788 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SAS, &ulValue);
789 RTPrintf(List::tr("Maximum Devices per SAS Port: %u\n"), ulValue);
790 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_PCIe, &ulValue);
791 RTPrintf(List::tr("Maximum NVMe PIIX3 Controllers: %u\n"), ulValue);
792 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_PCIe, &ulValue);
793 RTPrintf(List::tr("Maximum NVMe ICH9 Controllers: %u\n"), ulValue);
794 systemProperties->GetMaxPortCountForStorageBus(StorageBus_PCIe, &ulValue);
795 RTPrintf(List::tr("Maximum NVMe Port count: %u\n"), ulValue);
796 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_PCIe, &ulValue);
797 RTPrintf(List::tr("Maximum Devices per NVMe Port: %u\n"), ulValue);
798 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_VirtioSCSI, &ulValue);
799 RTPrintf(List::tr("Maximum virtio-scsi PIIX3 Controllers: %u\n"), ulValue);
800 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_VirtioSCSI, &ulValue);
801 RTPrintf(List::tr("Maximum virtio-scsi ICH9 Controllers: %u\n"), ulValue);
802 systemProperties->GetMaxPortCountForStorageBus(StorageBus_VirtioSCSI, &ulValue);
803 RTPrintf(List::tr("Maximum virtio-scsi Port count: %u\n"), ulValue);
804 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_VirtioSCSI, &ulValue);
805 RTPrintf(List::tr("Maximum Devices per virtio-scsi Port: %u\n"), ulValue);
806 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_Floppy, &ulValue);
807 RTPrintf(List::tr("Maximum PIIX3 Floppy Controllers:%u\n"), ulValue);
808 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_Floppy, &ulValue);
809 RTPrintf(List::tr("Maximum ICH9 Floppy Controllers: %u\n"), ulValue);
810 systemProperties->GetMaxPortCountForStorageBus(StorageBus_Floppy, &ulValue);
811 RTPrintf(List::tr("Maximum Floppy Port count: %u\n"), ulValue);
812 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_Floppy, &ulValue);
813 RTPrintf(List::tr("Maximum Devices per Floppy Port: %u\n"), ulValue);
814#if 0
815 systemProperties->GetFreeDiskSpaceWarning(&i64Value);
816 RTPrintf(List::tr("Free disk space warning at: %u Bytes\n", "", i64Value), i64Value);
817 systemProperties->GetFreeDiskSpacePercentWarning(&ulValue);
818 RTPrintf(List::tr("Free disk space warning at: %u %%\n"), ulValue);
819 systemProperties->GetFreeDiskSpaceError(&i64Value);
820 RTPrintf(List::tr("Free disk space error at: %u Bytes\n", "", i64Value), i64Value);
821 systemProperties->GetFreeDiskSpacePercentError(&ulValue);
822 RTPrintf(List::tr("Free disk space error at: %u %%\n"), ulValue);
823#endif
824 systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
825 RTPrintf(List::tr("Default machine folder: %ls\n"), str.raw());
826 systemProperties->COMGETTER(RawModeSupported)(&fValue);
827 RTPrintf(List::tr("Raw-mode Supported: %s\n"), fValue ? List::tr("yes") : List::tr("no"));
828 systemProperties->COMGETTER(ExclusiveHwVirt)(&fValue);
829 RTPrintf(List::tr("Exclusive HW virtualization use: %s\n"), fValue ? List::tr("on") : List::tr("off"));
830 systemProperties->COMGETTER(DefaultHardDiskFormat)(str.asOutParam());
831 RTPrintf(List::tr("Default hard disk format: %ls\n"), str.raw());
832 systemProperties->COMGETTER(VRDEAuthLibrary)(str.asOutParam());
833 RTPrintf(List::tr("VRDE auth library: %ls\n"), str.raw());
834 systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
835 RTPrintf(List::tr("Webservice auth. library: %ls\n"), str.raw());
836 systemProperties->COMGETTER(DefaultVRDEExtPack)(str.asOutParam());
837 RTPrintf(List::tr("Remote desktop ExtPack: %ls\n"), str.raw());
838 systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
839 RTPrintf(List::tr("Log history count: %u\n"), ulValue);
840 systemProperties->COMGETTER(DefaultFrontend)(str.asOutParam());
841 RTPrintf(List::tr("Default frontend: %ls\n"), str.raw());
842 AudioDriverType_T enmAudio;
843 systemProperties->COMGETTER(DefaultAudioDriver)(&enmAudio);
844 switch (enmAudio)
845 {
846 case AudioDriverType_Null: psz = List::tr("Null"); break;
847 case AudioDriverType_WinMM: psz = "WinMM"; break;
848 case AudioDriverType_OSS: psz = "OSS"; break;
849 case AudioDriverType_ALSA: psz = "ALSA"; break;
850 case AudioDriverType_DirectSound: psz = "DirectSound"; break;
851 case AudioDriverType_CoreAudio: psz = "CoreAudio"; break;
852 case AudioDriverType_MMPM: psz = "MMPM"; break;
853 case AudioDriverType_Pulse: psz = "Pulse"; break;
854 case AudioDriverType_SolAudio: psz = "SolAudio"; break;
855 default: psz = List::tr("Unknown");
856 }
857 RTPrintf(List::tr("Default audio driver: %s\n"), psz);
858 systemProperties->COMGETTER(AutostartDatabasePath)(str.asOutParam());
859 RTPrintf(List::tr("Autostart database path: %ls\n"), str.raw());
860 systemProperties->COMGETTER(DefaultAdditionsISO)(str.asOutParam());
861 RTPrintf(List::tr("Default Guest Additions ISO: %ls\n"), str.raw());
862 systemProperties->COMGETTER(LoggingLevel)(str.asOutParam());
863 RTPrintf(List::tr("Logging Level: %ls\n"), str.raw());
864 ProxyMode_T enmProxyMode = (ProxyMode_T)42;
865 systemProperties->COMGETTER(ProxyMode)(&enmProxyMode);
866 psz = List::tr("Unknown");
867 switch (enmProxyMode)
868 {
869 case ProxyMode_System: psz = List::tr("System"); break;
870 case ProxyMode_NoProxy: psz = List::tr("NoProxy"); break;
871 case ProxyMode_Manual: psz = List::tr("Manual"); break;
872#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
873 case ProxyMode_32BitHack: break; /* Shut up compiler warnings. */
874#endif
875 }
876 RTPrintf(List::tr("Proxy Mode: %s\n"), psz);
877 systemProperties->COMGETTER(ProxyURL)(str.asOutParam());
878 RTPrintf(List::tr("Proxy URL: %ls\n"), str.raw());
879 systemProperties->COMGETTER(VBoxUpdateEnabled)(&fValue);
880 RTPrintf(List::tr("Update check enabled: %s\n"), fValue ? List::tr("yes") : List::tr("no"));
881 systemProperties->COMGETTER(VBoxUpdateCount)(&ulValue);
882 RTPrintf(List::tr("Update check count: %u\n"), ulValue);
883 systemProperties->COMGETTER(VBoxUpdateFrequency)(&ulValue);
884 if (ulValue == 0)
885 RTPrintf(List::tr("Update check frequency: never\n"));
886 else if (ulValue == 1)
887 RTPrintf(List::tr("Update check frequency: every day\n"));
888 else
889 RTPrintf(List::tr("Update check frequency: every %u days\n", "", ulValue), ulValue);
890 VBoxUpdateTarget_T enmVBoxUpdateTarget;
891 systemProperties->COMGETTER(VBoxUpdateTarget)(&enmVBoxUpdateTarget);
892 switch (enmVBoxUpdateTarget)
893 {
894 case VBoxUpdateTarget_Stable:
895 psz = List::tr("Stable: new minor and maintenance releases");
896 break;
897 case VBoxUpdateTarget_AllReleases:
898 psz = List::tr("All releases: new minor, maintenance, and major releases");
899 break;
900 case VBoxUpdateTarget_WithBetas:
901 psz = List::tr("With Betas: new minor, maintenance, major, and beta releases");
902 break;
903 default:
904 psz = List::tr("Unset");
905 break;
906 }
907 RTPrintf(List::tr("Update check target: %s\n"), psz);
908 systemProperties->COMGETTER(VBoxUpdateLastCheckDate)(str.asOutParam());
909 RTPrintf(List::tr("Last check date: %ls\n"), str.raw());
910#ifdef VBOX_WITH_MAIN_NLS
911 systemProperties->COMGETTER(LanguageId)(str.asOutParam());
912 RTPrintf(List::tr("User language: %ls\n"), str.raw());
913#endif
914 return S_OK;
915}
916
917
918/**
919 * Helper for listDhcpServers() that shows a DHCP configuration.
920 */
921static HRESULT showDhcpConfig(ComPtr<IDHCPConfig> ptrConfig)
922{
923 HRESULT hrcRet = S_OK;
924
925 ULONG secs = 0;
926 CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MinLeaseTime)(&secs), hrcRet = hrcCheck);
927 if (secs == 0)
928 RTPrintf(List::tr(" minLeaseTime: default\n"));
929 else
930 RTPrintf(List::tr(" minLeaseTime: %u sec\n"), secs);
931
932 secs = 0;
933 CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(DefaultLeaseTime)(&secs), hrcRet = hrcCheck);
934 if (secs == 0)
935 RTPrintf(List::tr(" defaultLeaseTime: default\n"));
936 else
937 RTPrintf(List::tr(" defaultLeaseTime: %u sec\n"), secs);
938
939 secs = 0;
940 CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MaxLeaseTime)(&secs), hrcRet = hrcCheck);
941 if (secs == 0)
942 RTPrintf(List::tr(" maxLeaseTime: default\n"));
943 else
944 RTPrintf(List::tr(" maxLeaseTime: %u sec\n"), secs);
945
946 com::SafeArray<DHCPOption_T> Options;
947 HRESULT hrc;
948 CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(ForcedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
949 if (FAILED(hrc))
950 RTPrintf(List::tr(" Forced options: %Rhrc\n"), hrc);
951 else if (Options.size() == 0)
952 RTPrintf(List::tr(" Forced options: None\n"));
953 else
954 {
955 RTPrintf(List::tr(" Forced options: "));
956 for (size_t i = 0; i < Options.size(); i++)
957 RTPrintf(i ? ", %u" : "%u", Options[i]);
958 RTPrintf("\n");
959 }
960
961 CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(SuppressedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
962 if (FAILED(hrc))
963 RTPrintf(List::tr(" Suppressed opt.s: %Rhrc\n"), hrc);
964 else if (Options.size() == 0)
965 RTPrintf(List::tr(" Suppressed opts.: None\n"));
966 else
967 {
968 RTPrintf(List::tr(" Suppressed opts.: "));
969 for (size_t i = 0; i < Options.size(); i++)
970 RTPrintf(i ? ", %u" : "%u", Options[i]);
971 RTPrintf("\n");
972 }
973
974 com::SafeArray<DHCPOptionEncoding_T> Encodings;
975 com::SafeArray<BSTR> Values;
976 CHECK_ERROR2_STMT(hrc, ptrConfig, GetAllOptions(ComSafeArrayAsOutParam(Options),
977 ComSafeArrayAsOutParam(Encodings),
978 ComSafeArrayAsOutParam(Values)), hrcRet = hrc);
979 if (FAILED(hrc))
980 RTPrintf(List::tr(" DHCP options: %Rhrc\n"), hrc);
981 else if (Options.size() != Encodings.size() || Options.size() != Values.size())
982 {
983 RTPrintf(List::tr(" DHCP options: Return count mismatch: %zu, %zu, %zu\n"),
984 Options.size(), Encodings.size(), Values.size());
985 hrcRet = E_FAIL;
986 }
987 else if (Options.size() == 0)
988 RTPrintf(List::tr(" DHCP options: None\n"));
989 else
990 for (size_t i = 0; i < Options.size(); i++)
991 {
992 switch (Encodings[i])
993 {
994 case DHCPOptionEncoding_Normal:
995 RTPrintf(List::tr(" %3d/legacy: %ls\n"), Options[i], Values[i]);
996 break;
997 case DHCPOptionEncoding_Hex:
998 RTPrintf(" %3d/hex: %ls\n", Options[i], Values[i]);
999 break;
1000 default:
1001 RTPrintf(" %3d/%u?: %ls\n", Options[i], Encodings[i], Values[i]);
1002 break;
1003 }
1004 }
1005
1006 return S_OK;
1007}
1008
1009
1010/**
1011 * List DHCP servers.
1012 *
1013 * @returns See produceList.
1014 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1015 */
1016static HRESULT listDhcpServers(const ComPtr<IVirtualBox> &pVirtualBox)
1017{
1018 HRESULT hrcRet = S_OK;
1019 com::SafeIfaceArray<IDHCPServer> DHCPServers;
1020 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers)), hrcCheck);
1021 for (size_t i = 0; i < DHCPServers.size(); ++i)
1022 {
1023 if (i > 0)
1024 RTPrintf("\n");
1025
1026 ComPtr<IDHCPServer> ptrDHCPServer = DHCPServers[i];
1027 Bstr bstr;
1028 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkName)(bstr.asOutParam()), hrcRet = hrcCheck);
1029 RTPrintf(List::tr("NetworkName: %ls\n"), bstr.raw());
1030
1031 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(IPAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
1032 RTPrintf("Dhcpd IP: %ls\n", bstr.raw());
1033
1034 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(LowerIP)(bstr.asOutParam()), hrcRet = hrcCheck);
1035 RTPrintf(List::tr("LowerIPAddress: %ls\n"), bstr.raw());
1036
1037 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(UpperIP)(bstr.asOutParam()), hrcRet = hrcCheck);
1038 RTPrintf(List::tr("UpperIPAddress: %ls\n"), bstr.raw());
1039
1040 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkMask)(bstr.asOutParam()), hrcRet = hrcCheck);
1041 RTPrintf(List::tr("NetworkMask: %ls\n"), bstr.raw());
1042
1043 BOOL fEnabled = FALSE;
1044 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(Enabled)(&fEnabled), hrcRet = hrcCheck);
1045 RTPrintf(List::tr("Enabled: %s\n"), fEnabled ? List::tr("Yes") : List::tr("No"));
1046
1047 /* Global configuration: */
1048 RTPrintf(List::tr("Global Configuration:\n"));
1049 HRESULT hrc;
1050 ComPtr<IDHCPGlobalConfig> ptrGlobal;
1051 CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GlobalConfig)(ptrGlobal.asOutParam()), hrcRet = hrc);
1052 if (SUCCEEDED(hrc))
1053 {
1054 hrc = showDhcpConfig(ptrGlobal);
1055 if (FAILED(hrc))
1056 hrcRet = hrc;
1057 }
1058
1059 /* Group configurations: */
1060 com::SafeIfaceArray<IDHCPGroupConfig> Groups;
1061 CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GroupConfigs)(ComSafeArrayAsOutParam(Groups)), hrcRet = hrc);
1062 if (FAILED(hrc))
1063 RTPrintf(List::tr("Groups: %Rrc\n"), hrc);
1064 else if (Groups.size() == 0)
1065 RTPrintf(List::tr("Groups: None\n"));
1066 else
1067 {
1068 for (size_t iGrp = 0; iGrp < Groups.size(); iGrp++)
1069 {
1070 CHECK_ERROR2I_STMT(Groups[iGrp], COMGETTER(Name)(bstr.asOutParam()), hrcRet = hrcCheck);
1071 RTPrintf(List::tr("Group: %ls\n"), bstr.raw());
1072
1073 com::SafeIfaceArray<IDHCPGroupCondition> Conditions;
1074 CHECK_ERROR2_STMT(hrc, Groups[iGrp], COMGETTER(Conditions)(ComSafeArrayAsOutParam(Conditions)), hrcRet = hrc);
1075 if (FAILED(hrc))
1076 RTPrintf(List::tr(" Conditions: %Rhrc\n"), hrc);
1077 else if (Conditions.size() == 0)
1078 RTPrintf(List::tr(" Conditions: None\n"));
1079 else
1080 for (size_t iCond = 0; iCond < Conditions.size(); iCond++)
1081 {
1082 BOOL fInclusive = TRUE;
1083 CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Inclusive)(&fInclusive), hrcRet = hrc);
1084 DHCPGroupConditionType_T enmType = DHCPGroupConditionType_MAC;
1085 CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Type)(&enmType), hrcRet = hrc);
1086 CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Value)(bstr.asOutParam()), hrcRet = hrc);
1087
1088 RTPrintf(List::tr(" Conditions: %s %s %ls\n"),
1089 fInclusive ? List::tr("include") : List::tr("exclude"),
1090 enmType == DHCPGroupConditionType_MAC ? "MAC "
1091 : enmType == DHCPGroupConditionType_MACWildcard ? "MAC* "
1092 : enmType == DHCPGroupConditionType_vendorClassID ? "VendorCID "
1093 : enmType == DHCPGroupConditionType_vendorClassIDWildcard ? "VendorCID*"
1094 : enmType == DHCPGroupConditionType_userClassID ? "UserCID "
1095 : enmType == DHCPGroupConditionType_userClassIDWildcard ? "UserCID* "
1096 : "!UNKNOWN! ",
1097 bstr.raw());
1098 }
1099
1100 hrc = showDhcpConfig(Groups[iGrp]);
1101 if (FAILED(hrc))
1102 hrcRet = hrc;
1103 }
1104 Groups.setNull();
1105 }
1106
1107 /* Individual host / NIC configurations: */
1108 com::SafeIfaceArray<IDHCPIndividualConfig> Hosts;
1109 CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(IndividualConfigs)(ComSafeArrayAsOutParam(Hosts)), hrcRet = hrc);
1110 if (FAILED(hrc))
1111 RTPrintf(List::tr("Individual Configs: %Rrc\n"), hrc);
1112 else if (Hosts.size() == 0)
1113 RTPrintf(List::tr("Individual Configs: None\n"));
1114 else
1115 {
1116 for (size_t iHost = 0; iHost < Hosts.size(); iHost++)
1117 {
1118 DHCPConfigScope_T enmScope = DHCPConfigScope_MAC;
1119 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Scope)(&enmScope), hrcRet = hrcCheck);
1120
1121 if (enmScope == DHCPConfigScope_MAC)
1122 {
1123 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MACAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
1124 RTPrintf(List::tr("Individual Config: MAC %ls\n"), bstr.raw());
1125 }
1126 else
1127 {
1128 ULONG uSlot = 0;
1129 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Slot)(&uSlot), hrcRet = hrcCheck);
1130 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MachineId)(bstr.asOutParam()), hrcRet = hrcCheck);
1131 Bstr bstrMACAddress;
1132 hrc = Hosts[iHost]->COMGETTER(MACAddress)(bstrMACAddress.asOutParam()); /* No CHECK_ERROR2 stuff! */
1133 if (SUCCEEDED(hrc))
1134 RTPrintf(List::tr("Individual Config: VM NIC: %ls slot %u, MAC %ls\n"), bstr.raw(), uSlot,
1135 bstrMACAddress.raw());
1136 else
1137 RTPrintf(List::tr("Individual Config: VM NIC: %ls slot %u, MAC %Rhrc\n"), bstr.raw(), uSlot, hrc);
1138 }
1139
1140 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(FixedAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
1141 if (bstr.isNotEmpty())
1142 RTPrintf(List::tr(" Fixed Address: %ls\n"), bstr.raw());
1143 else
1144 RTPrintf(List::tr(" Fixed Address: dynamic\n"));
1145
1146 hrc = showDhcpConfig(Hosts[iHost]);
1147 if (FAILED(hrc))
1148 hrcRet = hrc;
1149 }
1150 Hosts.setNull();
1151 }
1152 }
1153
1154 return hrcRet;
1155}
1156
1157/**
1158 * List extension packs.
1159 *
1160 * @returns See produceList.
1161 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1162 */
1163static HRESULT listExtensionPacks(const ComPtr<IVirtualBox> &pVirtualBox)
1164{
1165 ComObjPtr<IExtPackManager> ptrExtPackMgr;
1166 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
1167
1168 SafeIfaceArray<IExtPack> extPacks;
1169 CHECK_ERROR2I_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
1170 RTPrintf(List::tr("Extension Packs: %u\n"), extPacks.size());
1171
1172 HRESULT hrc = S_OK;
1173 for (size_t i = 0; i < extPacks.size(); i++)
1174 {
1175 /* Read all the properties. */
1176 Bstr bstrName;
1177 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
1178 Bstr bstrDesc;
1179 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
1180 Bstr bstrVersion;
1181 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
1182 ULONG uRevision;
1183 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Revision)(&uRevision), hrc = hrcCheck; uRevision = 0);
1184 Bstr bstrEdition;
1185 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
1186 Bstr bstrVrdeModule;
1187 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.setNull());
1188 BOOL fUsable;
1189 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Usable)(&fUsable), hrc = hrcCheck; fUsable = FALSE);
1190 Bstr bstrWhy;
1191 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
1192
1193 /* Display them. */
1194 if (i)
1195 RTPrintf("\n");
1196 RTPrintf(List::tr(
1197 "Pack no.%2zu: %ls\n"
1198 "Version: %ls\n"
1199 "Revision: %u\n"
1200 "Edition: %ls\n"
1201 "Description: %ls\n"
1202 "VRDE Module: %ls\n"
1203 "Usable: %RTbool\n"
1204 "Why unusable: %ls\n"),
1205 i, bstrName.raw(),
1206 bstrVersion.raw(),
1207 uRevision,
1208 bstrEdition.raw(),
1209 bstrDesc.raw(),
1210 bstrVrdeModule.raw(),
1211 fUsable != FALSE,
1212 bstrWhy.raw());
1213
1214 /* Query plugins and display them. */
1215 }
1216 return hrc;
1217}
1218
1219
1220/**
1221 * List machine groups.
1222 *
1223 * @returns See produceList.
1224 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1225 */
1226static HRESULT listGroups(const ComPtr<IVirtualBox> &pVirtualBox)
1227{
1228 SafeArray<BSTR> groups;
1229 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(MachineGroups)(ComSafeArrayAsOutParam(groups)), hrcCheck);
1230
1231 for (size_t i = 0; i < groups.size(); i++)
1232 {
1233 RTPrintf("\"%ls\"\n", groups[i]);
1234 }
1235 return S_OK;
1236}
1237
1238
1239/**
1240 * List video capture devices.
1241 *
1242 * @returns See produceList.
1243 * @param pVirtualBox Reference to the IVirtualBox pointer.
1244 */
1245static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> &pVirtualBox)
1246{
1247 HRESULT rc;
1248 ComPtr<IHost> host;
1249 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
1250 com::SafeIfaceArray<IHostVideoInputDevice> hostVideoInputDevices;
1251 CHECK_ERROR(host, COMGETTER(VideoInputDevices)(ComSafeArrayAsOutParam(hostVideoInputDevices)));
1252 RTPrintf(List::tr("Video Input Devices: %u\n"), hostVideoInputDevices.size());
1253 for (size_t i = 0; i < hostVideoInputDevices.size(); ++i)
1254 {
1255 ComPtr<IHostVideoInputDevice> p = hostVideoInputDevices[i];
1256 Bstr name;
1257 p->COMGETTER(Name)(name.asOutParam());
1258 Bstr path;
1259 p->COMGETTER(Path)(path.asOutParam());
1260 Bstr alias;
1261 p->COMGETTER(Alias)(alias.asOutParam());
1262 RTPrintf("%ls \"%ls\"\n%ls\n", alias.raw(), name.raw(), path.raw());
1263 }
1264 return rc;
1265}
1266
1267/**
1268 * List supported screen shot formats.
1269 *
1270 * @returns See produceList.
1271 * @param pVirtualBox Reference to the IVirtualBox pointer.
1272 */
1273static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> &pVirtualBox)
1274{
1275 HRESULT rc = S_OK;
1276 ComPtr<ISystemProperties> systemProperties;
1277 CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
1278 com::SafeArray<BitmapFormat_T> formats;
1279 CHECK_ERROR(systemProperties, COMGETTER(ScreenShotFormats)(ComSafeArrayAsOutParam(formats)));
1280
1281 RTPrintf(List::tr("Supported %d screen shot formats:\n", "", formats.size()), formats.size());
1282 for (size_t i = 0; i < formats.size(); ++i)
1283 {
1284 uint32_t u32Format = (uint32_t)formats[i];
1285 char szFormat[5];
1286 szFormat[0] = RT_BYTE1(u32Format);
1287 szFormat[1] = RT_BYTE2(u32Format);
1288 szFormat[2] = RT_BYTE3(u32Format);
1289 szFormat[3] = RT_BYTE4(u32Format);
1290 szFormat[4] = 0;
1291 RTPrintf(" BitmapFormat_%s (0x%08X)\n", szFormat, u32Format);
1292 }
1293 return rc;
1294}
1295
1296/**
1297 * List available cloud providers.
1298 *
1299 * @returns See produceList.
1300 * @param pVirtualBox Reference to the IVirtualBox pointer.
1301 */
1302static HRESULT listCloudProviders(const ComPtr<IVirtualBox> &pVirtualBox)
1303{
1304 HRESULT rc = S_OK;
1305 ComPtr<ICloudProviderManager> pCloudProviderManager;
1306 CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
1307 com::SafeIfaceArray<ICloudProvider> apCloudProviders;
1308 CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
1309
1310 RTPrintf(List::tr("Supported %d cloud providers:\n", "", apCloudProviders.size()), apCloudProviders.size());
1311 for (size_t i = 0; i < apCloudProviders.size(); ++i)
1312 {
1313 ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
1314 Bstr bstrProviderName;
1315 pCloudProvider->COMGETTER(Name)(bstrProviderName.asOutParam());
1316 RTPrintf(List::tr("Name: %ls\n"), bstrProviderName.raw());
1317 pCloudProvider->COMGETTER(ShortName)(bstrProviderName.asOutParam());
1318 RTPrintf(List::tr("Short Name: %ls\n"), bstrProviderName.raw());
1319 Bstr bstrProviderID;
1320 pCloudProvider->COMGETTER(Id)(bstrProviderID.asOutParam());
1321 RTPrintf("GUID: %ls\n", bstrProviderID.raw());
1322
1323 RTPrintf("\n");
1324 }
1325 return rc;
1326}
1327
1328
1329/**
1330 * List all available cloud profiles (by iterating over the cloud providers).
1331 *
1332 * @returns See produceList.
1333 * @param pVirtualBox Reference to the IVirtualBox pointer.
1334 * @param fOptLong If true, list all profile properties.
1335 */
1336static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> &pVirtualBox, bool fOptLong)
1337{
1338 HRESULT rc = S_OK;
1339 ComPtr<ICloudProviderManager> pCloudProviderManager;
1340 CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
1341 com::SafeIfaceArray<ICloudProvider> apCloudProviders;
1342 CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
1343
1344 for (size_t i = 0; i < apCloudProviders.size(); ++i)
1345 {
1346 ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
1347 com::SafeIfaceArray<ICloudProfile> apCloudProfiles;
1348 CHECK_ERROR(pCloudProvider, COMGETTER(Profiles)(ComSafeArrayAsOutParam(apCloudProfiles)));
1349 for (size_t j = 0; j < apCloudProfiles.size(); ++j)
1350 {
1351 ComPtr<ICloudProfile> pCloudProfile = apCloudProfiles[j];
1352 Bstr bstrProfileName;
1353 pCloudProfile->COMGETTER(Name)(bstrProfileName.asOutParam());
1354 RTPrintf(List::tr("Name: %ls\n"), bstrProfileName.raw());
1355 Bstr bstrProviderID;
1356 pCloudProfile->COMGETTER(ProviderId)(bstrProviderID.asOutParam());
1357 RTPrintf(List::tr("Provider GUID: %ls\n"), bstrProviderID.raw());
1358
1359 if (fOptLong)
1360 {
1361 com::SafeArray<BSTR> names;
1362 com::SafeArray<BSTR> values;
1363 pCloudProfile->GetProperties(Bstr().raw(), ComSafeArrayAsOutParam(names), ComSafeArrayAsOutParam(values));
1364 size_t cNames = names.size();
1365 size_t cValues = values.size();
1366 bool fFirst = true;
1367 for (size_t k = 0; k < cNames; k++)
1368 {
1369 Bstr value;
1370 if (k < cValues)
1371 value = values[k];
1372 RTPrintf("%s%ls=%ls\n",
1373 fFirst ? List::tr("Property: ") : " ",
1374 names[k], value.raw());
1375 fFirst = false;
1376 }
1377 }
1378
1379 RTPrintf("\n");
1380 }
1381 }
1382 return rc;
1383}
1384
1385static HRESULT displayCPUProfile(ICPUProfile *pProfile, size_t idx, int cchIdx, bool fOptLong, HRESULT hrc)
1386{
1387 /* Retrieve the attributes needed for both long and short display. */
1388 Bstr bstrName;
1389 CHECK_ERROR2I_RET(pProfile, COMGETTER(Name)(bstrName.asOutParam()), hrcCheck);
1390
1391 CPUArchitecture_T enmArchitecture = CPUArchitecture_Any;
1392 CHECK_ERROR2I_RET(pProfile, COMGETTER(Architecture)(&enmArchitecture), hrcCheck);
1393 const char *pszArchitecture = "???";
1394 switch (enmArchitecture)
1395 {
1396 case CPUArchitecture_x86: pszArchitecture = "x86"; break;
1397 case CPUArchitecture_AMD64: pszArchitecture = "AMD64"; break;
1398
1399#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
1400 case CPUArchitecture_32BitHack:
1401#endif
1402 case CPUArchitecture_Any:
1403 break;
1404 }
1405
1406 /* Print what we've got. */
1407 if (!fOptLong)
1408 RTPrintf("#%0*zu: %ls [%s]\n", cchIdx, idx, bstrName.raw(), pszArchitecture);
1409 else
1410 {
1411 RTPrintf(List::tr("CPU Profile #%02zu:\n"), idx);
1412 RTPrintf(List::tr(" Architecture: %s\n"), pszArchitecture);
1413 RTPrintf(List::tr(" Name: %ls\n"), bstrName.raw());
1414 CHECK_ERROR2I_RET(pProfile, COMGETTER(FullName)(bstrName.asOutParam()), hrcCheck);
1415 RTPrintf(List::tr(" Full Name: %ls\n"), bstrName.raw());
1416 }
1417 return hrc;
1418}
1419
1420
1421/**
1422 * List all CPU profiles.
1423 *
1424 * @returns See produceList.
1425 * @param ptrVirtualBox Reference to the smart IVirtualBox pointer.
1426 * @param fOptLong If true, list all profile properties.
1427 * @param fOptSorted Sort the output if true, otherwise display in
1428 * system order.
1429 */
1430static HRESULT listCPUProfiles(const ComPtr<IVirtualBox> &ptrVirtualBox, bool fOptLong, bool fOptSorted)
1431{
1432 ComPtr<ISystemProperties> ptrSysProps;
1433 CHECK_ERROR2I_RET(ptrVirtualBox, COMGETTER(SystemProperties)(ptrSysProps.asOutParam()), hrcCheck);
1434 com::SafeIfaceArray<ICPUProfile> aCPUProfiles;
1435 CHECK_ERROR2I_RET(ptrSysProps, GetCPUProfiles(CPUArchitecture_Any, Bstr().raw(),
1436 ComSafeArrayAsOutParam(aCPUProfiles)), hrcCheck);
1437
1438 int const cchIdx = 1 + (aCPUProfiles.size() >= 10) + (aCPUProfiles.size() >= 100);
1439
1440 HRESULT hrc = S_OK;
1441 if (!fOptSorted)
1442 for (size_t i = 0; i < aCPUProfiles.size(); i++)
1443 hrc = displayCPUProfile(aCPUProfiles[i], i, cchIdx, fOptLong, hrc);
1444 else
1445 {
1446 std::vector<std::pair<com::Bstr, ICPUProfile *> > vecSortedProfiles;
1447 for (size_t i = 0; i < aCPUProfiles.size(); ++i)
1448 {
1449 Bstr bstrName;
1450 CHECK_ERROR2I_RET(aCPUProfiles[i], COMGETTER(Name)(bstrName.asOutParam()), hrcCheck);
1451 try
1452 {
1453 vecSortedProfiles.push_back(std::pair<com::Bstr, ICPUProfile *>(bstrName, aCPUProfiles[i]));
1454 }
1455 catch (std::bad_alloc &)
1456 {
1457 return E_OUTOFMEMORY;
1458 }
1459 }
1460
1461 std::sort(vecSortedProfiles.begin(), vecSortedProfiles.end());
1462
1463 for (size_t i = 0; i < vecSortedProfiles.size(); i++)
1464 hrc = displayCPUProfile(vecSortedProfiles[i].second, i, cchIdx, fOptLong, hrc);
1465 }
1466
1467 return hrc;
1468}
1469
1470
1471/**
1472 * Translates PartitionType_T to a string if possible.
1473 * @returns read-only string if known value, @a pszUnknown if not.
1474 */
1475static const char *PartitionTypeToString(PartitionType_T enmType, const char *pszUnknown)
1476{
1477#define MY_CASE_STR(a_Type) case RT_CONCAT(PartitionType_,a_Type): return #a_Type
1478 switch (enmType)
1479 {
1480 MY_CASE_STR(Empty);
1481 MY_CASE_STR(FAT12);
1482 MY_CASE_STR(FAT16);
1483 MY_CASE_STR(FAT);
1484 MY_CASE_STR(IFS);
1485 MY_CASE_STR(FAT32CHS);
1486 MY_CASE_STR(FAT32LBA);
1487 MY_CASE_STR(FAT16B);
1488 MY_CASE_STR(Extended);
1489 MY_CASE_STR(WindowsRE);
1490 MY_CASE_STR(LinuxSwapOld);
1491 MY_CASE_STR(LinuxOld);
1492 MY_CASE_STR(DragonFlyBSDSlice);
1493 MY_CASE_STR(LinuxSwap);
1494 MY_CASE_STR(Linux);
1495 MY_CASE_STR(LinuxExtended);
1496 MY_CASE_STR(LinuxLVM);
1497 MY_CASE_STR(BSDSlice);
1498 MY_CASE_STR(AppleUFS);
1499 MY_CASE_STR(AppleHFS);
1500 MY_CASE_STR(Solaris);
1501 MY_CASE_STR(GPT);
1502 MY_CASE_STR(EFI);
1503 MY_CASE_STR(Unknown);
1504 MY_CASE_STR(MBR);
1505 MY_CASE_STR(iFFS);
1506 MY_CASE_STR(SonyBoot);
1507 MY_CASE_STR(LenovoBoot);
1508 MY_CASE_STR(WindowsMSR);
1509 MY_CASE_STR(WindowsBasicData);
1510 MY_CASE_STR(WindowsLDMMeta);
1511 MY_CASE_STR(WindowsLDMData);
1512 MY_CASE_STR(WindowsRecovery);
1513 MY_CASE_STR(WindowsStorageSpaces);
1514 MY_CASE_STR(WindowsStorageReplica);
1515 MY_CASE_STR(IBMGPFS);
1516 MY_CASE_STR(LinuxData);
1517 MY_CASE_STR(LinuxRAID);
1518 MY_CASE_STR(LinuxRootX86);
1519 MY_CASE_STR(LinuxRootAMD64);
1520 MY_CASE_STR(LinuxRootARM32);
1521 MY_CASE_STR(LinuxRootARM64);
1522 MY_CASE_STR(LinuxHome);
1523 MY_CASE_STR(LinuxSrv);
1524 MY_CASE_STR(LinuxPlainDmCrypt);
1525 MY_CASE_STR(LinuxLUKS);
1526 MY_CASE_STR(LinuxReserved);
1527 MY_CASE_STR(FreeBSDBoot);
1528 MY_CASE_STR(FreeBSDData);
1529 MY_CASE_STR(FreeBSDSwap);
1530 MY_CASE_STR(FreeBSDUFS);
1531 MY_CASE_STR(FreeBSDVinum);
1532 MY_CASE_STR(FreeBSDZFS);
1533 MY_CASE_STR(FreeBSDUnknown);
1534 MY_CASE_STR(AppleHFSPlus);
1535 MY_CASE_STR(AppleAPFS);
1536 MY_CASE_STR(AppleRAID);
1537 MY_CASE_STR(AppleRAIDOffline);
1538 MY_CASE_STR(AppleBoot);
1539 MY_CASE_STR(AppleLabel);
1540 MY_CASE_STR(AppleTvRecovery);
1541 MY_CASE_STR(AppleCoreStorage);
1542 MY_CASE_STR(SoftRAIDStatus);
1543 MY_CASE_STR(SoftRAIDScratch);
1544 MY_CASE_STR(SoftRAIDVolume);
1545 MY_CASE_STR(SoftRAIDCache);
1546 MY_CASE_STR(AppleUnknown);
1547 MY_CASE_STR(SolarisBoot);
1548 MY_CASE_STR(SolarisRoot);
1549 MY_CASE_STR(SolarisSwap);
1550 MY_CASE_STR(SolarisBackup);
1551 MY_CASE_STR(SolarisUsr);
1552 MY_CASE_STR(SolarisVar);
1553 MY_CASE_STR(SolarisHome);
1554 MY_CASE_STR(SolarisAltSector);
1555 MY_CASE_STR(SolarisReserved);
1556 MY_CASE_STR(SolarisUnknown);
1557 MY_CASE_STR(NetBSDSwap);
1558 MY_CASE_STR(NetBSDFFS);
1559 MY_CASE_STR(NetBSDLFS);
1560 MY_CASE_STR(NetBSDRAID);
1561 MY_CASE_STR(NetBSDConcatenated);
1562 MY_CASE_STR(NetBSDEncrypted);
1563 MY_CASE_STR(NetBSDUnknown);
1564 MY_CASE_STR(ChromeOSKernel);
1565 MY_CASE_STR(ChromeOSRootFS);
1566 MY_CASE_STR(ChromeOSFuture);
1567 MY_CASE_STR(ContLnxUsr);
1568 MY_CASE_STR(ContLnxRoot);
1569 MY_CASE_STR(ContLnxReserved);
1570 MY_CASE_STR(ContLnxRootRAID);
1571 MY_CASE_STR(HaikuBFS);
1572 MY_CASE_STR(MidntBSDBoot);
1573 MY_CASE_STR(MidntBSDData);
1574 MY_CASE_STR(MidntBSDSwap);
1575 MY_CASE_STR(MidntBSDUFS);
1576 MY_CASE_STR(MidntBSDVium);
1577 MY_CASE_STR(MidntBSDZFS);
1578 MY_CASE_STR(MidntBSDUnknown);
1579 MY_CASE_STR(OpenBSDData);
1580 MY_CASE_STR(QNXPowerSafeFS);
1581 MY_CASE_STR(Plan9);
1582 MY_CASE_STR(VMWareVMKCore);
1583 MY_CASE_STR(VMWareVMFS);
1584 MY_CASE_STR(VMWareReserved);
1585 MY_CASE_STR(VMWareUnknown);
1586 MY_CASE_STR(AndroidX86Bootloader);
1587 MY_CASE_STR(AndroidX86Bootloader2);
1588 MY_CASE_STR(AndroidX86Boot);
1589 MY_CASE_STR(AndroidX86Recovery);
1590 MY_CASE_STR(AndroidX86Misc);
1591 MY_CASE_STR(AndroidX86Metadata);
1592 MY_CASE_STR(AndroidX86System);
1593 MY_CASE_STR(AndroidX86Cache);
1594 MY_CASE_STR(AndroidX86Data);
1595 MY_CASE_STR(AndroidX86Persistent);
1596 MY_CASE_STR(AndroidX86Vendor);
1597 MY_CASE_STR(AndroidX86Config);
1598 MY_CASE_STR(AndroidX86Factory);
1599 MY_CASE_STR(AndroidX86FactoryAlt);
1600 MY_CASE_STR(AndroidX86Fastboot);
1601 MY_CASE_STR(AndroidX86OEM);
1602 MY_CASE_STR(AndroidARMMeta);
1603 MY_CASE_STR(AndroidARMExt);
1604 MY_CASE_STR(ONIEBoot);
1605 MY_CASE_STR(ONIEConfig);
1606 MY_CASE_STR(PowerPCPrep);
1607 MY_CASE_STR(XDGShrBootConfig);
1608 MY_CASE_STR(CephBlock);
1609 MY_CASE_STR(CephBlockDB);
1610 MY_CASE_STR(CephBlockDBDmc);
1611 MY_CASE_STR(CephBlockDBDmcLUKS);
1612 MY_CASE_STR(CephBlockDmc);
1613 MY_CASE_STR(CephBlockDmcLUKS);
1614 MY_CASE_STR(CephBlockWALog);
1615 MY_CASE_STR(CephBlockWALogDmc);
1616 MY_CASE_STR(CephBlockWALogDmcLUKS);
1617 MY_CASE_STR(CephDisk);
1618 MY_CASE_STR(CephDiskDmc);
1619 MY_CASE_STR(CephJournal);
1620 MY_CASE_STR(CephJournalDmc);
1621 MY_CASE_STR(CephJournalDmcLUKS);
1622 MY_CASE_STR(CephLockbox);
1623 MY_CASE_STR(CephMultipathBlock1);
1624 MY_CASE_STR(CephMultipathBlock2);
1625 MY_CASE_STR(CephMultipathBlockDB);
1626 MY_CASE_STR(CephMultipathBLockWALog);
1627 MY_CASE_STR(CephMultipathJournal);
1628 MY_CASE_STR(CephMultipathOSD);
1629 MY_CASE_STR(CephOSD);
1630 MY_CASE_STR(CephOSDDmc);
1631 MY_CASE_STR(CephOSDDmcLUKS);
1632#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
1633 case PartitionType_32BitHack: break;
1634#endif
1635 /* no default! */
1636 }
1637#undef MY_CASE_STR
1638 return pszUnknown;
1639}
1640
1641
1642/**
1643 * List all available host drives with their partitions.
1644 *
1645 * @returns See produceList.
1646 * @param pVirtualBox Reference to the IVirtualBox pointer.
1647 * @param fOptLong Long listing or human readable.
1648 */
1649static HRESULT listHostDrives(const ComPtr<IVirtualBox> pVirtualBox, bool fOptLong)
1650{
1651 HRESULT rc = S_OK;
1652 ComPtr<IHost> pHost;
1653 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(Host)(pHost.asOutParam()), hrcCheck);
1654 com::SafeIfaceArray<IHostDrive> apHostDrives;
1655 CHECK_ERROR2I_RET(pHost, COMGETTER(HostDrives)(ComSafeArrayAsOutParam(apHostDrives)), hrcCheck);
1656 for (size_t i = 0; i < apHostDrives.size(); ++i)
1657 {
1658 ComPtr<IHostDrive> pHostDrive = apHostDrives[i];
1659
1660 /* The drivePath and model attributes are accessible even when the object
1661 is in 'limited' mode. */
1662 com::Bstr bstrDrivePath;
1663 CHECK_ERROR(pHostDrive,COMGETTER(DrivePath)(bstrDrivePath.asOutParam()));
1664 if (SUCCEEDED(rc))
1665 RTPrintf(List::tr("%sDrive: %ls\n"), i > 0 ? "\n" : "", bstrDrivePath.raw());
1666 else
1667 RTPrintf(List::tr("%sDrive: %Rhrc\n"), i > 0 ? "\n" : "", rc);
1668
1669 com::Bstr bstrModel;
1670 CHECK_ERROR(pHostDrive,COMGETTER(Model)(bstrModel.asOutParam()));
1671 if (FAILED(rc))
1672 RTPrintf(List::tr("Model: %Rhrc\n"), rc);
1673 else if (bstrModel.isNotEmpty())
1674 RTPrintf(List::tr("Model: \"%ls\"\n"), bstrModel.raw());
1675 else
1676 RTPrintf(List::tr("Model: unknown/inaccessible\n"));
1677
1678 /* The other attributes are not accessible in limited mode and will fail
1679 with E_ACCESSDENIED. Typically means the user cannot read the drive. */
1680 com::Bstr bstrUuidDisk;
1681 rc = pHostDrive->COMGETTER(Uuid)(bstrUuidDisk.asOutParam());
1682 if (SUCCEEDED(rc) && !com::Guid(bstrUuidDisk).isZero())
1683 RTPrintf("UUID: %ls\n", bstrUuidDisk.raw());
1684 else if (rc == E_ACCESSDENIED)
1685 {
1686 RTPrintf(List::tr("Further disk and partitioning information is not available for drive \"%ls\". (E_ACCESSDENIED)\n"),
1687 bstrDrivePath.raw());
1688 continue;
1689 }
1690 else if (FAILED(rc))
1691 {
1692 RTPrintf("UUID: %Rhrc\n", rc);
1693 com::GlueHandleComErrorNoCtx(pHostDrive, rc);
1694 }
1695
1696 LONG64 cbSize = 0;
1697 rc = pHostDrive->COMGETTER(Size)(&cbSize);
1698 if (SUCCEEDED(rc) && fOptLong)
1699 RTPrintf(List::tr("Size: %llu bytes (%Rhcb)\n", "", cbSize), cbSize, cbSize);
1700 else if (SUCCEEDED(rc))
1701 RTPrintf(List::tr("Size: %Rhcb\n"), cbSize);
1702 else
1703 {
1704 RTPrintf(List::tr("Size: %Rhrc\n"), rc);
1705 com::GlueHandleComErrorNoCtx(pHostDrive, rc);
1706 }
1707
1708 ULONG cbSectorSize = 0;
1709 rc = pHostDrive->COMGETTER(SectorSize)(&cbSectorSize);
1710 if (SUCCEEDED(rc))
1711 RTPrintf(List::tr("Sector Size: %u bytes\n", "", cbSectorSize), cbSectorSize);
1712 else
1713 {
1714 RTPrintf(List::tr("Sector Size: %Rhrc\n"), rc);
1715 com::GlueHandleComErrorNoCtx(pHostDrive, rc);
1716 }
1717
1718 PartitioningType_T partitioningType = (PartitioningType_T)9999;
1719 rc = pHostDrive->COMGETTER(PartitioningType)(&partitioningType);
1720 if (SUCCEEDED(rc))
1721 RTPrintf(List::tr("Scheme: %s\n"), partitioningType == PartitioningType_MBR ? "MBR" : "GPT");
1722 else
1723 {
1724 RTPrintf(List::tr("Scheme: %Rhrc\n"), rc);
1725 com::GlueHandleComErrorNoCtx(pHostDrive, rc);
1726 }
1727
1728 com::SafeIfaceArray<IHostDrivePartition> apHostDrivesPartitions;
1729 rc = pHostDrive->COMGETTER(Partitions)(ComSafeArrayAsOutParam(apHostDrivesPartitions));
1730 if (FAILED(rc))
1731 {
1732 RTPrintf(List::tr("Partitions: %Rhrc\n"), rc);
1733 com::GlueHandleComErrorNoCtx(pHostDrive, rc);
1734 }
1735 else if (apHostDrivesPartitions.size() == 0)
1736 RTPrintf(List::tr("Partitions: None (or not able to grok them).\n"));
1737 else if (partitioningType == PartitioningType_MBR)
1738 {
1739 if (fOptLong)
1740 RTPrintf(List::tr("Partitions: First Last\n"
1741 "## Type Byte Size Byte Offset Cyl/Head/Sec Cyl/Head/Sec Active\n"));
1742 else
1743 RTPrintf(List::tr("Partitions: First Last\n"
1744 "## Type Size Start Cyl/Head/Sec Cyl/Head/Sec Active\n"));
1745 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j)
1746 {
1747 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j];
1748
1749 ULONG idx = 0;
1750 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx));
1751 ULONG uType = 0;
1752 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeMBR)(&uType));
1753 ULONG uStartCylinder = 0;
1754 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartCylinder)(&uStartCylinder));
1755 ULONG uStartHead = 0;
1756 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartHead)(&uStartHead));
1757 ULONG uStartSector = 0;
1758 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartSector)(&uStartSector));
1759 ULONG uEndCylinder = 0;
1760 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndCylinder)(&uEndCylinder));
1761 ULONG uEndHead = 0;
1762 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndHead)(&uEndHead));
1763 ULONG uEndSector = 0;
1764 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndSector)(&uEndSector));
1765 cbSize = 0;
1766 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize));
1767 LONG64 offStart = 0;
1768 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart));
1769 BOOL fActive = 0;
1770 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive));
1771 PartitionType_T enmType = PartitionType_Unknown;
1772 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType));
1773
1774 /* Max size & offset here is around 16TiB with 4KiB sectors. */
1775 if (fOptLong) /* cb/off: max 16TiB; idx: max 64. */
1776 RTPrintf("%2u %02x %14llu %14llu %4u/%3u/%2u %4u/%3u/%2u %s %s\n",
1777 idx, uType, cbSize, offStart,
1778 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector,
1779 fActive ? List::tr("yes") : List::tr("no"), PartitionTypeToString(enmType, ""));
1780 else
1781 RTPrintf("%2u %02x %8Rhcb %8Rhcb %4u/%3u/%2u %4u/%3u/%2u %s %s\n",
1782 idx, uType, (uint64_t)cbSize, (uint64_t)offStart,
1783 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector,
1784 fActive ? List::tr("yes") : List::tr("no"), PartitionTypeToString(enmType, ""));
1785 }
1786 }
1787 else /* GPT */
1788 {
1789 /* Determin the max partition type length to try reduce the table width: */
1790 size_t cchMaxType = 0;
1791 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j)
1792 {
1793 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j];
1794 PartitionType_T enmType = PartitionType_Unknown;
1795 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType));
1796 size_t const cchTypeNm = strlen(PartitionTypeToString(enmType, "e530bf6d-2754-4e9d-b260-60a5d0b80457"));
1797 cchMaxType = RT_MAX(cchTypeNm, cchMaxType);
1798 }
1799 cchMaxType = RT_MIN(cchMaxType, RTUUID_STR_LENGTH);
1800
1801 if (fOptLong)
1802 RTPrintf(List::tr(
1803 "Partitions:\n"
1804 "## %-*s Uuid Byte Size Byte Offset Active Name\n"),
1805 (int)cchMaxType, List::tr("Type"));
1806 else
1807 RTPrintf(List::tr(
1808 "Partitions:\n"
1809 "## %-*s Uuid Size Start Active Name\n"),
1810 (int)cchMaxType, List::tr("Type"));
1811
1812 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j)
1813 {
1814 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j];
1815
1816 ULONG idx = 0;
1817 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx));
1818 com::Bstr bstrUuidType;
1819 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeUuid)(bstrUuidType.asOutParam()));
1820 com::Bstr bstrUuidPartition;
1821 CHECK_ERROR(pHostDrivePartition, COMGETTER(Uuid)(bstrUuidPartition.asOutParam()));
1822 cbSize = 0;
1823 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize));
1824 LONG64 offStart = 0;
1825 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart));
1826 BOOL fActive = 0;
1827 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive));
1828 com::Bstr bstrName;
1829 CHECK_ERROR(pHostDrivePartition, COMGETTER(Name)(bstrName.asOutParam()));
1830
1831 PartitionType_T enmType = PartitionType_Unknown;
1832 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType));
1833
1834 Utf8Str strTypeConv;
1835 const char *pszTypeNm = PartitionTypeToString(enmType, NULL);
1836 if (!pszTypeNm)
1837 pszTypeNm = (strTypeConv = bstrUuidType).c_str();
1838 else if (strlen(pszTypeNm) >= RTUUID_STR_LENGTH /* includes '\0' */)
1839 pszTypeNm -= RTUUID_STR_LENGTH - 1 - strlen(pszTypeNm);
1840
1841 if (fOptLong)
1842 RTPrintf("%2u %-*s %36ls %19llu %19llu %-3s %ls\n", idx, cchMaxType, pszTypeNm,
1843 bstrUuidPartition.raw(), cbSize, offStart, fActive ? List::tr("on") : List::tr("off"),
1844 bstrName.raw());
1845 else
1846 RTPrintf("%2u %-*s %36ls %8Rhcb %8Rhcb %-3s %ls\n", idx, cchMaxType, pszTypeNm,
1847 bstrUuidPartition.raw(), cbSize, offStart, fActive ? List::tr("on") : List::tr("off"),
1848 bstrName.raw());
1849 }
1850 }
1851 }
1852 return rc;
1853}
1854
1855
1856/**
1857 * The type of lists we can produce.
1858 */
1859enum ListType_T
1860{
1861 kListNotSpecified = 1000,
1862 kListVMs,
1863 kListRunningVMs,
1864 kListOsTypes,
1865 kListHostDvds,
1866 kListHostFloppies,
1867 kListInternalNetworks,
1868 kListBridgedInterfaces,
1869#if defined(VBOX_WITH_NETFLT)
1870 kListHostOnlyInterfaces,
1871#endif
1872#if defined(VBOX_WITH_VMNET)
1873 kListHostOnlyNetworks,
1874#endif
1875#if defined(VBOX_WITH_CLOUD_NET)
1876 kListCloudNetworks,
1877#endif
1878 kListHostCpuIDs,
1879 kListHostInfo,
1880 kListHddBackends,
1881 kListHdds,
1882 kListDvds,
1883 kListFloppies,
1884 kListUsbHost,
1885 kListUsbFilters,
1886 kListSystemProperties,
1887 kListDhcpServers,
1888 kListExtPacks,
1889 kListGroups,
1890 kListNatNetworks,
1891 kListVideoInputDevices,
1892 kListScreenShotFormats,
1893 kListCloudProviders,
1894 kListCloudProfiles,
1895 kListCPUProfiles,
1896 kListHostDrives
1897};
1898
1899
1900/**
1901 * Produces the specified listing.
1902 *
1903 * @returns S_OK or some COM error code that has been reported in full.
1904 * @param enmList The list to produce.
1905 * @param fOptLong Long (@c true) or short list format.
1906 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1907 */
1908static HRESULT produceList(enum ListType_T enmCommand, bool fOptLong, bool fOptSorted, const ComPtr<IVirtualBox> &pVirtualBox)
1909{
1910 HRESULT rc = S_OK;
1911 switch (enmCommand)
1912 {
1913 case kListNotSpecified:
1914 AssertFailed();
1915 return E_FAIL;
1916
1917 case kListVMs:
1918 {
1919 /*
1920 * Get the list of all registered VMs
1921 */
1922 com::SafeIfaceArray<IMachine> machines;
1923 rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
1924 if (SUCCEEDED(rc))
1925 {
1926 /*
1927 * Display it.
1928 */
1929 if (!fOptSorted)
1930 {
1931 for (size_t i = 0; i < machines.size(); ++i)
1932 if (machines[i])
1933 rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
1934 }
1935 else
1936 {
1937 /*
1938 * Sort the list by name before displaying it.
1939 */
1940 std::vector<std::pair<com::Bstr, IMachine *> > sortedMachines;
1941 for (size_t i = 0; i < machines.size(); ++i)
1942 {
1943 IMachine *pMachine = machines[i];
1944 if (pMachine) /* no idea why we need to do this... */
1945 {
1946 Bstr bstrName;
1947 pMachine->COMGETTER(Name)(bstrName.asOutParam());
1948 sortedMachines.push_back(std::pair<com::Bstr, IMachine *>(bstrName, pMachine));
1949 }
1950 }
1951
1952 std::sort(sortedMachines.begin(), sortedMachines.end());
1953
1954 for (size_t i = 0; i < sortedMachines.size(); ++i)
1955 rc = showVMInfo(pVirtualBox, sortedMachines[i].second, NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
1956 }
1957 }
1958 break;
1959 }
1960
1961 case kListRunningVMs:
1962 {
1963 /*
1964 * Get the list of all _running_ VMs
1965 */
1966 com::SafeIfaceArray<IMachine> machines;
1967 rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
1968 com::SafeArray<MachineState_T> states;
1969 if (SUCCEEDED(rc))
1970 rc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
1971 if (SUCCEEDED(rc))
1972 {
1973 /*
1974 * Iterate through the collection
1975 */
1976 for (size_t i = 0; i < machines.size(); ++i)
1977 {
1978 if (machines[i])
1979 {
1980 MachineState_T machineState = states[i];
1981 switch (machineState)
1982 {
1983 case MachineState_Running:
1984 case MachineState_Teleporting:
1985 case MachineState_LiveSnapshotting:
1986 case MachineState_Paused:
1987 case MachineState_TeleportingPausedVM:
1988 rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
1989 break;
1990 default: break; /* Shut up MSC */
1991 }
1992 }
1993 }
1994 }
1995 break;
1996 }
1997
1998 case kListOsTypes:
1999 {
2000 com::SafeIfaceArray<IGuestOSType> coll;
2001 rc = pVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
2002 if (SUCCEEDED(rc))
2003 {
2004 /*
2005 * Iterate through the collection.
2006 */
2007 for (size_t i = 0; i < coll.size(); ++i)
2008 {
2009 ComPtr<IGuestOSType> guestOS;
2010 guestOS = coll[i];
2011 Bstr guestId;
2012 guestOS->COMGETTER(Id)(guestId.asOutParam());
2013 RTPrintf("ID: %ls\n", guestId.raw());
2014 Bstr guestDescription;
2015 guestOS->COMGETTER(Description)(guestDescription.asOutParam());
2016 RTPrintf(List::tr("Description: %ls\n"), guestDescription.raw());
2017 Bstr familyId;
2018 guestOS->COMGETTER(FamilyId)(familyId.asOutParam());
2019 RTPrintf(List::tr("Family ID: %ls\n"), familyId.raw());
2020 Bstr familyDescription;
2021 guestOS->COMGETTER(FamilyDescription)(familyDescription.asOutParam());
2022 RTPrintf(List::tr("Family Desc: %ls\n"), familyDescription.raw());
2023 BOOL is64Bit;
2024 guestOS->COMGETTER(Is64Bit)(&is64Bit);
2025 RTPrintf(List::tr("64 bit: %RTbool\n"), is64Bit);
2026 RTPrintf("\n");
2027 }
2028 }
2029 break;
2030 }
2031
2032 case kListHostDvds:
2033 {
2034 ComPtr<IHost> host;
2035 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
2036 com::SafeIfaceArray<IMedium> coll;
2037 CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
2038 if (SUCCEEDED(rc))
2039 {
2040 for (size_t i = 0; i < coll.size(); ++i)
2041 {
2042 ComPtr<IMedium> dvdDrive = coll[i];
2043 Bstr uuid;
2044 dvdDrive->COMGETTER(Id)(uuid.asOutParam());
2045 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
2046 Bstr location;
2047 dvdDrive->COMGETTER(Location)(location.asOutParam());
2048 RTPrintf(List::tr("Name: %ls\n\n"), location.raw());
2049 }
2050 }
2051 break;
2052 }
2053
2054 case kListHostFloppies:
2055 {
2056 ComPtr<IHost> host;
2057 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
2058 com::SafeIfaceArray<IMedium> coll;
2059 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
2060 if (SUCCEEDED(rc))
2061 {
2062 for (size_t i = 0; i < coll.size(); ++i)
2063 {
2064 ComPtr<IMedium> floppyDrive = coll[i];
2065 Bstr uuid;
2066 floppyDrive->COMGETTER(Id)(uuid.asOutParam());
2067 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
2068 Bstr location;
2069 floppyDrive->COMGETTER(Location)(location.asOutParam());
2070 RTPrintf(List::tr("Name: %ls\n\n"), location.raw());
2071 }
2072 }
2073 break;
2074 }
2075
2076 case kListInternalNetworks:
2077 rc = listInternalNetworks(pVirtualBox);
2078 break;
2079
2080 case kListBridgedInterfaces:
2081#if defined(VBOX_WITH_NETFLT)
2082 case kListHostOnlyInterfaces:
2083#endif
2084 rc = listNetworkInterfaces(pVirtualBox, enmCommand == kListBridgedInterfaces);
2085 break;
2086
2087#if defined(VBOX_WITH_VMNET)
2088 case kListHostOnlyNetworks:
2089 rc = listHostOnlyNetworks(pVirtualBox);
2090 break;
2091#endif
2092
2093#if defined(VBOX_WITH_CLOUD_NET)
2094 case kListCloudNetworks:
2095 rc = listCloudNetworks(pVirtualBox);
2096 break;
2097#endif
2098 case kListHostInfo:
2099 rc = listHostInfo(pVirtualBox);
2100 break;
2101
2102 case kListHostCpuIDs:
2103 {
2104 ComPtr<IHost> Host;
2105 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
2106
2107 RTPrintf(List::tr("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n"));
2108 ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
2109 static uint32_t const s_auCpuIdRanges[] =
2110 {
2111 UINT32_C(0x00000000), UINT32_C(0x0000007f),
2112 UINT32_C(0x80000000), UINT32_C(0x8000007f),
2113 UINT32_C(0xc0000000), UINT32_C(0xc000007f)
2114 };
2115 for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
2116 {
2117 ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
2118 CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
2119 if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
2120 continue;
2121 cLeafs++;
2122 for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
2123 {
2124 CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
2125 RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
2126 }
2127 }
2128 break;
2129 }
2130
2131 case kListHddBackends:
2132 rc = listHddBackends(pVirtualBox);
2133 break;
2134
2135 case kListHdds:
2136 {
2137 com::SafeIfaceArray<IMedium> hdds;
2138 CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
2139 rc = listMedia(pVirtualBox, hdds, List::tr("base"), fOptLong);
2140 break;
2141 }
2142
2143 case kListDvds:
2144 {
2145 com::SafeIfaceArray<IMedium> dvds;
2146 CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
2147 rc = listMedia(pVirtualBox, dvds, NULL, fOptLong);
2148 break;
2149 }
2150
2151 case kListFloppies:
2152 {
2153 com::SafeIfaceArray<IMedium> floppies;
2154 CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
2155 rc = listMedia(pVirtualBox, floppies, NULL, fOptLong);
2156 break;
2157 }
2158
2159 case kListUsbHost:
2160 rc = listUsbHost(pVirtualBox);
2161 break;
2162
2163 case kListUsbFilters:
2164 rc = listUsbFilters(pVirtualBox);
2165 break;
2166
2167 case kListSystemProperties:
2168 rc = listSystemProperties(pVirtualBox);
2169 break;
2170
2171 case kListDhcpServers:
2172 rc = listDhcpServers(pVirtualBox);
2173 break;
2174
2175 case kListExtPacks:
2176 rc = listExtensionPacks(pVirtualBox);
2177 break;
2178
2179 case kListGroups:
2180 rc = listGroups(pVirtualBox);
2181 break;
2182
2183 case kListNatNetworks:
2184 {
2185 com::SafeIfaceArray<INATNetwork> nets;
2186 CHECK_ERROR(pVirtualBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(nets)));
2187 for (size_t i = 0; i < nets.size(); ++i)
2188 {
2189 ComPtr<INATNetwork> net = nets[i];
2190 Bstr netName;
2191 net->COMGETTER(NetworkName)(netName.asOutParam());
2192 RTPrintf(List::tr("NetworkName: %ls\n"), netName.raw());
2193 Bstr gateway;
2194 net->COMGETTER(Gateway)(gateway.asOutParam());
2195 RTPrintf("IP: %ls\n", gateway.raw());
2196 Bstr network;
2197 net->COMGETTER(Network)(network.asOutParam());
2198 RTPrintf(List::tr("Network: %ls\n"), network.raw());
2199 BOOL fEnabled;
2200 net->COMGETTER(IPv6Enabled)(&fEnabled);
2201 RTPrintf(List::tr("IPv6 Enabled: %s\n"), fEnabled ? List::tr("Yes") : List::tr("No"));
2202 Bstr ipv6prefix;
2203 net->COMGETTER(IPv6Prefix)(ipv6prefix.asOutParam());
2204 RTPrintf(List::tr("IPv6 Prefix: %ls\n"), ipv6prefix.raw());
2205 net->COMGETTER(NeedDhcpServer)(&fEnabled);
2206 RTPrintf(List::tr("DHCP Enabled: %s\n"), fEnabled ? List::tr("Yes") : List::tr("No"));
2207 net->COMGETTER(Enabled)(&fEnabled);
2208 RTPrintf(List::tr("Enabled: %s\n"), fEnabled ? List::tr("Yes") : List::tr("No"));
2209
2210#define PRINT_STRING_ARRAY(title) \
2211 if (strs.size() > 0) \
2212 { \
2213 RTPrintf(title); \
2214 size_t j = 0; \
2215 for (;j < strs.size(); ++j) \
2216 RTPrintf(" %s\n", Utf8Str(strs[j]).c_str()); \
2217 }
2218
2219 com::SafeArray<BSTR> strs;
2220
2221 CHECK_ERROR(nets[i], COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(strs)));
2222 PRINT_STRING_ARRAY(List::tr("Port-forwarding (ipv4)\n"));
2223 strs.setNull();
2224
2225 CHECK_ERROR(nets[i], COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(strs)));
2226 PRINT_STRING_ARRAY(List::tr("Port-forwarding (ipv6)\n"));
2227 strs.setNull();
2228
2229 CHECK_ERROR(nets[i], COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs)));
2230 PRINT_STRING_ARRAY(List::tr("loopback mappings (ipv4)\n"));
2231 strs.setNull();
2232
2233#undef PRINT_STRING_ARRAY
2234 RTPrintf("\n");
2235 }
2236 break;
2237 }
2238
2239 case kListVideoInputDevices:
2240 rc = listVideoInputDevices(pVirtualBox);
2241 break;
2242
2243 case kListScreenShotFormats:
2244 rc = listScreenShotFormats(pVirtualBox);
2245 break;
2246
2247 case kListCloudProviders:
2248 rc = listCloudProviders(pVirtualBox);
2249 break;
2250
2251 case kListCloudProfiles:
2252 rc = listCloudProfiles(pVirtualBox, fOptLong);
2253 break;
2254
2255 case kListCPUProfiles:
2256 rc = listCPUProfiles(pVirtualBox, fOptLong, fOptSorted);
2257 break;
2258
2259 case kListHostDrives:
2260 rc = listHostDrives(pVirtualBox, fOptLong);
2261 break;
2262 /* No default here, want gcc warnings. */
2263
2264 } /* end switch */
2265
2266 return rc;
2267}
2268
2269/**
2270 * Handles the 'list' command.
2271 *
2272 * @returns Appropriate exit code.
2273 * @param a Handler argument.
2274 */
2275RTEXITCODE handleList(HandlerArg *a)
2276{
2277 bool fOptLong = false;
2278 bool fOptMultiple = false;
2279 bool fOptSorted = false;
2280 bool fFirst = true;
2281 enum ListType_T enmOptCommand = kListNotSpecified;
2282 RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
2283
2284 static const RTGETOPTDEF s_aListOptions[] =
2285 {
2286 { "--long", 'l', RTGETOPT_REQ_NOTHING },
2287 { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */
2288 { "--sorted", 's', RTGETOPT_REQ_NOTHING },
2289 { "vms", kListVMs, RTGETOPT_REQ_NOTHING },
2290 { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING },
2291 { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING },
2292 { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING },
2293 { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING },
2294 { "intnets", kListInternalNetworks, RTGETOPT_REQ_NOTHING },
2295 { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
2296 { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING },
2297#if defined(VBOX_WITH_NETFLT)
2298 { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
2299#endif
2300#if defined(VBOX_WITH_VMNET)
2301 { "hostonlynets", kListHostOnlyNetworks, RTGETOPT_REQ_NOTHING },
2302#endif
2303#if defined(VBOX_WITH_CLOUD_NET)
2304 { "cloudnets", kListCloudNetworks, RTGETOPT_REQ_NOTHING },
2305#endif
2306 { "natnetworks", kListNatNetworks, RTGETOPT_REQ_NOTHING },
2307 { "natnets", kListNatNetworks, RTGETOPT_REQ_NOTHING },
2308 { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING },
2309 { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING },
2310 { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING },
2311 { "hdds", kListHdds, RTGETOPT_REQ_NOTHING },
2312 { "dvds", kListDvds, RTGETOPT_REQ_NOTHING },
2313 { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING },
2314 { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING },
2315 { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING },
2316 { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING },
2317 { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING },
2318 { "extpacks", kListExtPacks, RTGETOPT_REQ_NOTHING },
2319 { "groups", kListGroups, RTGETOPT_REQ_NOTHING },
2320 { "webcams", kListVideoInputDevices, RTGETOPT_REQ_NOTHING },
2321 { "screenshotformats", kListScreenShotFormats, RTGETOPT_REQ_NOTHING },
2322 { "cloudproviders", kListCloudProviders, RTGETOPT_REQ_NOTHING },
2323 { "cloudprofiles", kListCloudProfiles, RTGETOPT_REQ_NOTHING },
2324 { "cpu-profiles", kListCPUProfiles, RTGETOPT_REQ_NOTHING },
2325 { "hostdrives", kListHostDrives, RTGETOPT_REQ_NOTHING },
2326 };
2327
2328 int ch;
2329 RTGETOPTUNION ValueUnion;
2330 RTGETOPTSTATE GetState;
2331 RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
2332 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
2333 while ((ch = RTGetOpt(&GetState, &ValueUnion)))
2334 {
2335 switch (ch)
2336 {
2337 case 'l': /* --long */
2338 fOptLong = true;
2339 break;
2340
2341 case 's':
2342 fOptSorted = true;
2343 break;
2344
2345 case 'm':
2346 fOptMultiple = true;
2347 if (enmOptCommand == kListNotSpecified)
2348 break;
2349 ch = enmOptCommand;
2350 RT_FALL_THRU();
2351
2352 case kListVMs:
2353 case kListRunningVMs:
2354 case kListOsTypes:
2355 case kListHostDvds:
2356 case kListHostFloppies:
2357 case kListInternalNetworks:
2358 case kListBridgedInterfaces:
2359#if defined(VBOX_WITH_NETFLT)
2360 case kListHostOnlyInterfaces:
2361#endif
2362#if defined(VBOX_WITH_VMNET)
2363 case kListHostOnlyNetworks:
2364#endif
2365#if defined(VBOX_WITH_CLOUD_NET)
2366 case kListCloudNetworks:
2367#endif
2368 case kListHostInfo:
2369 case kListHostCpuIDs:
2370 case kListHddBackends:
2371 case kListHdds:
2372 case kListDvds:
2373 case kListFloppies:
2374 case kListUsbHost:
2375 case kListUsbFilters:
2376 case kListSystemProperties:
2377 case kListDhcpServers:
2378 case kListExtPacks:
2379 case kListGroups:
2380 case kListNatNetworks:
2381 case kListVideoInputDevices:
2382 case kListScreenShotFormats:
2383 case kListCloudProviders:
2384 case kListCloudProfiles:
2385 case kListCPUProfiles:
2386 case kListHostDrives:
2387 enmOptCommand = (enum ListType_T)ch;
2388 if (fOptMultiple)
2389 {
2390 if (fFirst)
2391 fFirst = false;
2392 else
2393 RTPrintf("\n");
2394 RTPrintf("[%s]\n", ValueUnion.pDef->pszLong);
2395 HRESULT hrc = produceList(enmOptCommand, fOptLong, fOptSorted, a->virtualBox);
2396 if (FAILED(hrc))
2397 rcExit = RTEXITCODE_FAILURE;
2398 }
2399 break;
2400
2401 case VINF_GETOPT_NOT_OPTION:
2402 return errorSyntax(USAGE_LIST, List::tr("Unknown subcommand \"%s\"."), ValueUnion.psz);
2403
2404 default:
2405 return errorGetOpt(USAGE_LIST, ch, &ValueUnion);
2406 }
2407 }
2408
2409 /*
2410 * If not in multiple list mode, we have to produce the list now.
2411 */
2412 if (enmOptCommand == kListNotSpecified)
2413 return errorSyntax(USAGE_LIST, List::tr("Missing subcommand for \"list\" command.\n"));
2414 if (!fOptMultiple)
2415 {
2416 HRESULT hrc = produceList(enmOptCommand, fOptLong, fOptSorted, a->virtualBox);
2417 if (FAILED(hrc))
2418 rcExit = RTEXITCODE_FAILURE;
2419 }
2420
2421 return rcExit;
2422}
2423
2424#endif /* !VBOX_ONLY_DOCS */
2425/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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