VirtualBox

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

Last change on this file since 107627 was 107627, checked in by vboxsync, 9 days ago

FE/VBoxManage/VBoxManageList.cpp: Missing error check, bugref:3409

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