VirtualBox

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

Last change on this file since 96313 was 95364, checked in by vboxsync, 2 years ago

Main/FE: Added new audio driver type "default" to make it possible to move VMs (appliances) between different platforms without the need of changing the audio driver explicitly. When the "default" driver is selected, the best audio backend option for a platform will be used.

While at it, also added the "WAS" (Windows Audio Session) driver type for which we only had a hack so far. This now can be explicitly selected, also by the frontends. bugref:10051

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