VirtualBox

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

Last change on this file since 98032 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

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