VirtualBox

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

最後變更 在這個檔案是 108003,由 vboxsync 提交於 6 週 前

Parfait: fixed the warning "Change of signedness on implicit conversion" in VBoxManage part of the code

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 114.0 KB
 
1/* $Id: VBoxManageList.cpp 108003 2025-01-31 14:05:57Z 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.alldomusa.eu.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", "" , (size_t)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 /* Deprecated; not (ever) supported; leave this in for backwards compatibility. See @bugref{10845} */
1070 case AudioDriverType_WinMM: psz = "WinMM"; break;
1071 case AudioDriverType_DirectSound: psz = "DirectSound"; break;
1072 case AudioDriverType_WAS: psz = "Windows Audio Session"; break;
1073 case AudioDriverType_CoreAudio: psz = "CoreAudio"; break;
1074 case AudioDriverType_SolAudio: psz = "SolAudio"; break;
1075 case AudioDriverType_MMPM: psz = "MMPM"; break;
1076 default: psz = List::tr("Unknown");
1077 }
1078 RTPrintf(List::tr("Default audio driver: %s\n"), psz);
1079 systemProperties->COMGETTER(AutostartDatabasePath)(str.asOutParam());
1080 RTPrintf(List::tr("Autostart database path: %ls\n"), str.raw());
1081 systemProperties->COMGETTER(DefaultAdditionsISO)(str.asOutParam());
1082 RTPrintf(List::tr("Default Guest Additions ISO: %ls\n"), str.raw());
1083 systemProperties->COMGETTER(LoggingLevel)(str.asOutParam());
1084 RTPrintf(List::tr("Logging Level: %ls\n"), str.raw());
1085 ProxyMode_T enmProxyMode = (ProxyMode_T)42;
1086 systemProperties->COMGETTER(ProxyMode)(&enmProxyMode);
1087 psz = List::tr("Unknown");
1088 switch (enmProxyMode)
1089 {
1090 case ProxyMode_System: psz = List::tr("System"); break;
1091 case ProxyMode_NoProxy: psz = List::tr("NoProxy"); break;
1092 case ProxyMode_Manual: psz = List::tr("Manual"); break;
1093#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
1094 case ProxyMode_32BitHack: break; /* Shut up compiler warnings. */
1095#endif
1096 }
1097 RTPrintf(List::tr("Proxy Mode: %s\n"), psz);
1098 systemProperties->COMGETTER(ProxyURL)(str.asOutParam());
1099 RTPrintf(List::tr("Proxy URL: %ls\n"), str.raw());
1100#ifdef VBOX_WITH_MAIN_NLS
1101 systemProperties->COMGETTER(LanguageId)(str.asOutParam());
1102 RTPrintf(List::tr("User language: %ls\n"), str.raw());
1103#endif
1104
1105 RTPrintf("Host platform properties:\n");
1106 listPlatformProperties(hostPlatformProperties);
1107
1108 /* Separate host system / platform properties stuff from guest platform properties a bit. */
1109 RTPrintf("\n");
1110
1111 SafeArray <PlatformArchitecture_T> saPlatformArch;
1112 systemProperties->COMGETTER(SupportedPlatformArchitectures(ComSafeArrayAsOutParam(saPlatformArch)));
1113 RTPrintf("Supported platform architectures: ");
1114 for (size_t i = 0; i < saPlatformArch.size(); ++i)
1115 {
1116 if (i > 0)
1117 RTPrintf(",");
1118 RTPrintf(platformArchitectureToStr(saPlatformArch[i]));
1119 }
1120 RTPrintf("\n\n");
1121
1122 for (size_t i = 0; i < saPlatformArch.size(); ++i)
1123 {
1124 if (i > 0)
1125 RTPrintf("\n");
1126 ComPtr<IPlatformProperties> platformProperties;
1127 pVirtualBox->GetPlatformProperties(saPlatformArch[i], platformProperties.asOutParam());
1128 RTPrintf(List::tr("%s platform properties:\n"), platformArchitectureToStr(saPlatformArch[i]));
1129 listPlatformProperties(platformProperties);
1130 }
1131
1132 return S_OK;
1133}
1134
1135#ifdef VBOX_WITH_UPDATE_AGENT
1136static HRESULT listUpdateAgentConfig(ComPtr<IUpdateAgent> ptrUpdateAgent)
1137{
1138 BOOL fValue;
1139 ptrUpdateAgent->COMGETTER(Enabled)(&fValue);
1140 RTPrintf(List::tr("Enabled: %s\n"), fValue ? List::tr("yes") : List::tr("no"));
1141 ULONG ulValue;
1142 ptrUpdateAgent->COMGETTER(CheckCount)(&ulValue);
1143 RTPrintf(List::tr("Check count: %u\n"), ulValue);
1144 ptrUpdateAgent->COMGETTER(CheckFrequency)(&ulValue);
1145 if (ulValue == 0)
1146 RTPrintf(List::tr("Check frequency: never\n"));
1147 else if (ulValue == 1)
1148 RTPrintf(List::tr("Check frequency: every day\n"));
1149 else
1150 RTPrintf(List::tr("Check frequency: every %u days\n", "", ulValue), ulValue);
1151
1152 Bstr str;
1153 const char *psz;
1154 UpdateChannel_T enmUpdateChannel;
1155 ptrUpdateAgent->COMGETTER(Channel)(&enmUpdateChannel);
1156 switch (enmUpdateChannel)
1157 {
1158 case UpdateChannel_Stable:
1159 psz = List::tr("Stable: Maintenance and minor releases within the same major release");
1160 break;
1161 case UpdateChannel_All:
1162 psz = List::tr("All releases: All stable releases, including major versions");
1163 break;
1164 case UpdateChannel_WithBetas:
1165 psz = List::tr("With Betas: All stable and major releases, including beta versions");
1166 break;
1167 case UpdateChannel_WithTesting:
1168 psz = List::tr("With Testing: All stable, major and beta releases, including testing versions");
1169 break;
1170 default:
1171 psz = List::tr("Unset");
1172 break;
1173 }
1174 RTPrintf(List::tr("Channel: %s\n"), psz);
1175 ptrUpdateAgent->COMGETTER(RepositoryURL)(str.asOutParam());
1176 RTPrintf(List::tr("Repository: %ls\n"), str.raw());
1177 ptrUpdateAgent->COMGETTER(LastCheckDate)(str.asOutParam());
1178 RTPrintf(List::tr("Last check date: %ls\n"), str.raw());
1179
1180 return S_OK;
1181}
1182
1183static HRESULT listUpdateAgents(const ComPtr<IVirtualBox> &pVirtualBox)
1184{
1185 ComPtr<IHost> pHost;
1186 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(Host)(pHost.asOutParam()), RTEXITCODE_FAILURE);
1187
1188 ComPtr<IUpdateAgent> pUpdateHost;
1189 CHECK_ERROR2I_RET(pHost, COMGETTER(UpdateHost)(pUpdateHost.asOutParam()), RTEXITCODE_FAILURE);
1190 /** @todo Add other update agents here. */
1191
1192 return listUpdateAgentConfig(pUpdateHost);
1193}
1194#endif /* VBOX_WITH_UPDATE_AGENT */
1195
1196/**
1197 * Helper for listDhcpServers() that shows a DHCP configuration.
1198 */
1199static HRESULT showDhcpConfig(ComPtr<IDHCPConfig> ptrConfig)
1200{
1201 HRESULT hrcRet = S_OK;
1202
1203 ULONG secs = 0;
1204 CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MinLeaseTime)(&secs), hrcRet = hrcCheck);
1205 if (secs == 0)
1206 RTPrintf(List::tr(" minLeaseTime: default\n"));
1207 else
1208 RTPrintf(List::tr(" minLeaseTime: %u sec\n"), secs);
1209
1210 secs = 0;
1211 CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(DefaultLeaseTime)(&secs), hrcRet = hrcCheck);
1212 if (secs == 0)
1213 RTPrintf(List::tr(" defaultLeaseTime: default\n"));
1214 else
1215 RTPrintf(List::tr(" defaultLeaseTime: %u sec\n"), secs);
1216
1217 secs = 0;
1218 CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MaxLeaseTime)(&secs), hrcRet = hrcCheck);
1219 if (secs == 0)
1220 RTPrintf(List::tr(" maxLeaseTime: default\n"));
1221 else
1222 RTPrintf(List::tr(" maxLeaseTime: %u sec\n"), secs);
1223
1224 com::SafeArray<DHCPOption_T> Options;
1225 HRESULT hrc;
1226 CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(ForcedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
1227 if (FAILED(hrc))
1228 RTPrintf(List::tr(" Forced options: %Rhrc\n"), hrc);
1229 else if (Options.size() == 0)
1230 RTPrintf(List::tr(" Forced options: None\n"));
1231 else
1232 {
1233 RTPrintf(List::tr(" Forced options: "));
1234 for (size_t i = 0; i < Options.size(); i++)
1235 RTPrintf(i ? ", %u" : "%u", Options[i]);
1236 RTPrintf("\n");
1237 }
1238
1239 CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(SuppressedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
1240 if (FAILED(hrc))
1241 RTPrintf(List::tr(" Suppressed opt.s: %Rhrc\n"), hrc);
1242 else if (Options.size() == 0)
1243 RTPrintf(List::tr(" Suppressed opts.: None\n"));
1244 else
1245 {
1246 RTPrintf(List::tr(" Suppressed opts.: "));
1247 for (size_t i = 0; i < Options.size(); i++)
1248 RTPrintf(i ? ", %u" : "%u", Options[i]);
1249 RTPrintf("\n");
1250 }
1251
1252 com::SafeArray<DHCPOptionEncoding_T> Encodings;
1253 com::SafeArray<BSTR> Values;
1254 CHECK_ERROR2_STMT(hrc, ptrConfig, GetAllOptions(ComSafeArrayAsOutParam(Options),
1255 ComSafeArrayAsOutParam(Encodings),
1256 ComSafeArrayAsOutParam(Values)), hrcRet = hrc);
1257 if (FAILED(hrc))
1258 RTPrintf(List::tr(" DHCP options: %Rhrc\n"), hrc);
1259 else if (Options.size() != Encodings.size() || Options.size() != Values.size())
1260 {
1261 RTPrintf(List::tr(" DHCP options: Return count mismatch: %zu, %zu, %zu\n"),
1262 Options.size(), Encodings.size(), Values.size());
1263 hrcRet = E_FAIL;
1264 }
1265 else if (Options.size() == 0)
1266 RTPrintf(List::tr(" DHCP options: None\n"));
1267 else
1268 for (size_t i = 0; i < Options.size(); i++)
1269 {
1270 switch (Encodings[i])
1271 {
1272 case DHCPOptionEncoding_Normal:
1273 RTPrintf(List::tr(" %3d/legacy: %ls\n"), Options[i], Values[i]);
1274 break;
1275 case DHCPOptionEncoding_Hex:
1276 RTPrintf(" %3d/hex: %ls\n", Options[i], Values[i]);
1277 break;
1278 default:
1279 RTPrintf(" %3d/%u?: %ls\n", Options[i], Encodings[i], Values[i]);
1280 break;
1281 }
1282 }
1283
1284 return hrc;
1285}
1286
1287
1288/**
1289 * List DHCP servers.
1290 *
1291 * @returns See produceList.
1292 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1293 */
1294static HRESULT listDhcpServers(const ComPtr<IVirtualBox> &pVirtualBox)
1295{
1296 HRESULT hrcRet = S_OK;
1297 com::SafeIfaceArray<IDHCPServer> DHCPServers;
1298 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers)), hrcCheck);
1299 for (size_t i = 0; i < DHCPServers.size(); ++i)
1300 {
1301 if (i > 0)
1302 RTPrintf("\n");
1303
1304 ComPtr<IDHCPServer> ptrDHCPServer = DHCPServers[i];
1305 Bstr bstr;
1306 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkName)(bstr.asOutParam()), hrcRet = hrcCheck);
1307 RTPrintf(List::tr("NetworkName: %ls\n"), bstr.raw());
1308
1309 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(IPAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
1310 RTPrintf("Dhcpd IP: %ls\n", bstr.raw());
1311
1312 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(LowerIP)(bstr.asOutParam()), hrcRet = hrcCheck);
1313 RTPrintf(List::tr("LowerIPAddress: %ls\n"), bstr.raw());
1314
1315 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(UpperIP)(bstr.asOutParam()), hrcRet = hrcCheck);
1316 RTPrintf(List::tr("UpperIPAddress: %ls\n"), bstr.raw());
1317
1318 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkMask)(bstr.asOutParam()), hrcRet = hrcCheck);
1319 RTPrintf(List::tr("NetworkMask: %ls\n"), bstr.raw());
1320
1321 BOOL fEnabled = FALSE;
1322 CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(Enabled)(&fEnabled), hrcRet = hrcCheck);
1323 RTPrintf(List::tr("Enabled: %s\n"), fEnabled ? List::tr("Yes") : List::tr("No"));
1324
1325 /* Global configuration: */
1326 RTPrintf(List::tr("Global Configuration:\n"));
1327 HRESULT hrc;
1328 ComPtr<IDHCPGlobalConfig> ptrGlobal;
1329 CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GlobalConfig)(ptrGlobal.asOutParam()), hrcRet = hrc);
1330 if (SUCCEEDED(hrc))
1331 {
1332 hrc = showDhcpConfig(ptrGlobal);
1333 if (FAILED(hrc))
1334 hrcRet = hrc;
1335 }
1336
1337 /* Group configurations: */
1338 com::SafeIfaceArray<IDHCPGroupConfig> Groups;
1339 CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GroupConfigs)(ComSafeArrayAsOutParam(Groups)), hrcRet = hrc);
1340 if (FAILED(hrc))
1341 RTPrintf(List::tr("Groups: %Rrc\n"), hrc);
1342 else if (Groups.size() == 0)
1343 RTPrintf(List::tr("Groups: None\n"));
1344 else
1345 {
1346 for (size_t iGrp = 0; iGrp < Groups.size(); iGrp++)
1347 {
1348 CHECK_ERROR2I_STMT(Groups[iGrp], COMGETTER(Name)(bstr.asOutParam()), hrcRet = hrcCheck);
1349 RTPrintf(List::tr("Group: %ls\n"), bstr.raw());
1350
1351 com::SafeIfaceArray<IDHCPGroupCondition> Conditions;
1352 CHECK_ERROR2_STMT(hrc, Groups[iGrp], COMGETTER(Conditions)(ComSafeArrayAsOutParam(Conditions)), hrcRet = hrc);
1353 if (FAILED(hrc))
1354 RTPrintf(List::tr(" Conditions: %Rhrc\n"), hrc);
1355 else if (Conditions.size() == 0)
1356 RTPrintf(List::tr(" Conditions: None\n"));
1357 else
1358 for (size_t iCond = 0; iCond < Conditions.size(); iCond++)
1359 {
1360 BOOL fInclusive = TRUE;
1361 CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Inclusive)(&fInclusive), hrcRet = hrc);
1362 DHCPGroupConditionType_T enmType = DHCPGroupConditionType_MAC;
1363 CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Type)(&enmType), hrcRet = hrc);
1364 CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Value)(bstr.asOutParam()), hrcRet = hrc);
1365
1366 RTPrintf(List::tr(" Conditions: %s %s %ls\n"),
1367 fInclusive ? List::tr("include") : List::tr("exclude"),
1368 enmType == DHCPGroupConditionType_MAC ? "MAC "
1369 : enmType == DHCPGroupConditionType_MACWildcard ? "MAC* "
1370 : enmType == DHCPGroupConditionType_vendorClassID ? "VendorCID "
1371 : enmType == DHCPGroupConditionType_vendorClassIDWildcard ? "VendorCID*"
1372 : enmType == DHCPGroupConditionType_userClassID ? "UserCID "
1373 : enmType == DHCPGroupConditionType_userClassIDWildcard ? "UserCID* "
1374 : "!UNKNOWN! ",
1375 bstr.raw());
1376 }
1377
1378 hrc = showDhcpConfig(Groups[iGrp]);
1379 if (FAILED(hrc))
1380 hrcRet = hrc;
1381 }
1382 Groups.setNull();
1383 }
1384
1385 /* Individual host / NIC configurations: */
1386 com::SafeIfaceArray<IDHCPIndividualConfig> Hosts;
1387 CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(IndividualConfigs)(ComSafeArrayAsOutParam(Hosts)), hrcRet = hrc);
1388 if (FAILED(hrc))
1389 RTPrintf(List::tr("Individual Configs: %Rrc\n"), hrc);
1390 else if (Hosts.size() == 0)
1391 RTPrintf(List::tr("Individual Configs: None\n"));
1392 else
1393 {
1394 for (size_t iHost = 0; iHost < Hosts.size(); iHost++)
1395 {
1396 DHCPConfigScope_T enmScope = DHCPConfigScope_MAC;
1397 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Scope)(&enmScope), hrcRet = hrcCheck);
1398
1399 if (enmScope == DHCPConfigScope_MAC)
1400 {
1401 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MACAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
1402 RTPrintf(List::tr("Individual Config: MAC %ls\n"), bstr.raw());
1403 }
1404 else
1405 {
1406 ULONG uSlot = 0;
1407 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Slot)(&uSlot), hrcRet = hrcCheck);
1408 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MachineId)(bstr.asOutParam()), hrcRet = hrcCheck);
1409 Bstr bstrMACAddress;
1410 hrc = Hosts[iHost]->COMGETTER(MACAddress)(bstrMACAddress.asOutParam()); /* No CHECK_ERROR2 stuff! */
1411 if (SUCCEEDED(hrc))
1412 RTPrintf(List::tr("Individual Config: VM NIC: %ls slot %u, MAC %ls\n"), bstr.raw(), uSlot,
1413 bstrMACAddress.raw());
1414 else
1415 RTPrintf(List::tr("Individual Config: VM NIC: %ls slot %u, MAC %Rhrc\n"), bstr.raw(), uSlot, hrc);
1416 }
1417
1418 CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(FixedAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
1419 if (bstr.isNotEmpty())
1420 RTPrintf(List::tr(" Fixed Address: %ls\n"), bstr.raw());
1421 else
1422 RTPrintf(List::tr(" Fixed Address: dynamic\n"));
1423
1424 hrc = showDhcpConfig(Hosts[iHost]);
1425 if (FAILED(hrc))
1426 hrcRet = hrc;
1427 }
1428 Hosts.setNull();
1429 }
1430 }
1431
1432 return hrcRet;
1433}
1434
1435/**
1436 * List extension packs.
1437 *
1438 * @returns See produceList.
1439 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1440 */
1441static HRESULT listExtensionPacks(const ComPtr<IVirtualBox> &pVirtualBox)
1442{
1443 ComObjPtr<IExtPackManager> ptrExtPackMgr;
1444 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
1445
1446 SafeIfaceArray<IExtPack> extPacks;
1447 CHECK_ERROR2I_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
1448 RTPrintf(List::tr("Extension Packs: %u\n"), extPacks.size());
1449
1450 HRESULT hrc = S_OK;
1451 for (size_t i = 0; i < extPacks.size(); i++)
1452 {
1453 /* Read all the properties. */
1454 Bstr bstrName;
1455 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
1456 Bstr bstrDesc;
1457 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
1458 Bstr bstrVersion;
1459 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
1460 ULONG uRevision;
1461 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Revision)(&uRevision), hrc = hrcCheck; uRevision = 0);
1462 Bstr bstrEdition;
1463 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
1464 Bstr bstrVrdeModule;
1465 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.setNull());
1466 Bstr bstrCryptoModule;
1467 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(CryptoModule)(bstrCryptoModule.asOutParam()),hrc=hrcCheck; bstrCryptoModule.setNull());
1468 BOOL fUsable;
1469 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Usable)(&fUsable), hrc = hrcCheck; fUsable = FALSE);
1470 Bstr bstrWhy;
1471 CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
1472
1473 /* Display them. */
1474 if (i)
1475 RTPrintf("\n");
1476 RTPrintf(List::tr(
1477 "Pack no.%2zu: %ls\n"
1478 "Version: %ls\n"
1479 "Revision: %u\n"
1480 "Edition: %ls\n"
1481 "Description: %ls\n"
1482 "VRDE Module: %ls\n"
1483 "Crypto Module: %ls\n"
1484 "Usable: %RTbool\n"
1485 "Why unusable: %ls\n"),
1486 i, bstrName.raw(),
1487 bstrVersion.raw(),
1488 uRevision,
1489 bstrEdition.raw(),
1490 bstrDesc.raw(),
1491 bstrVrdeModule.raw(),
1492 bstrCryptoModule.raw(),
1493 fUsable != FALSE,
1494 bstrWhy.raw());
1495
1496 /* Query plugins and display them. */
1497 }
1498 return hrc;
1499}
1500
1501
1502/**
1503 * List machine groups.
1504 *
1505 * @returns See produceList.
1506 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
1507 */
1508static HRESULT listGroups(const ComPtr<IVirtualBox> &pVirtualBox)
1509{
1510 SafeArray<BSTR> groups;
1511 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(MachineGroups)(ComSafeArrayAsOutParam(groups)), hrcCheck);
1512
1513 for (size_t i = 0; i < groups.size(); i++)
1514 {
1515 RTPrintf("\"%ls\"\n", groups[i]);
1516 }
1517 return S_OK;
1518}
1519
1520
1521/**
1522 * List video capture devices.
1523 *
1524 * @returns See produceList.
1525 * @param pVirtualBox Reference to the IVirtualBox pointer.
1526 */
1527static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> &pVirtualBox)
1528{
1529 HRESULT hrc;
1530 ComPtr<IHost> host;
1531 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
1532 com::SafeIfaceArray<IHostVideoInputDevice> hostVideoInputDevices;
1533 CHECK_ERROR(host, COMGETTER(VideoInputDevices)(ComSafeArrayAsOutParam(hostVideoInputDevices)));
1534 RTPrintf(List::tr("Video Input Devices: %u\n"), hostVideoInputDevices.size());
1535 for (size_t i = 0; i < hostVideoInputDevices.size(); ++i)
1536 {
1537 ComPtr<IHostVideoInputDevice> p = hostVideoInputDevices[i];
1538 Bstr name;
1539 p->COMGETTER(Name)(name.asOutParam());
1540 Bstr path;
1541 p->COMGETTER(Path)(path.asOutParam());
1542 Bstr alias;
1543 p->COMGETTER(Alias)(alias.asOutParam());
1544 RTPrintf("%ls \"%ls\"\n%ls\n", alias.raw(), name.raw(), path.raw());
1545 }
1546 return hrc;
1547}
1548
1549/**
1550 * List supported screen shot formats.
1551 *
1552 * @returns See produceList.
1553 * @param pVirtualBox Reference to the IVirtualBox pointer.
1554 */
1555static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> &pVirtualBox)
1556{
1557 HRESULT hrc = S_OK;
1558 ComPtr<ISystemProperties> systemProperties;
1559 CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
1560 com::SafeArray<BitmapFormat_T> formats;
1561 CHECK_ERROR(systemProperties, COMGETTER(ScreenShotFormats)(ComSafeArrayAsOutParam(formats)));
1562
1563 RTPrintf(List::tr("Supported %d screen shot formats:\n", "", formats.size()), formats.size());
1564 for (size_t i = 0; i < formats.size(); ++i)
1565 {
1566 uint32_t u32Format = (uint32_t)formats[i];
1567 unsigned char szFormat[5];
1568 szFormat[0] = RT_BYTE1(u32Format);
1569 szFormat[1] = RT_BYTE2(u32Format);
1570 szFormat[2] = RT_BYTE3(u32Format);
1571 szFormat[3] = RT_BYTE4(u32Format);
1572 szFormat[4] = 0;
1573 RTPrintf(" BitmapFormat_%s (0x%08X)\n", szFormat, u32Format);
1574 }
1575 return hrc;
1576}
1577
1578/**
1579 * List available cloud providers.
1580 *
1581 * @returns See produceList.
1582 * @param pVirtualBox Reference to the IVirtualBox pointer.
1583 */
1584static HRESULT listCloudProviders(const ComPtr<IVirtualBox> &pVirtualBox)
1585{
1586 HRESULT hrc = S_OK;
1587 ComPtr<ICloudProviderManager> pCloudProviderManager;
1588 CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
1589 com::SafeIfaceArray<ICloudProvider> apCloudProviders;
1590 CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
1591
1592 RTPrintf(List::tr("Supported %d cloud providers:\n", "", apCloudProviders.size()), apCloudProviders.size());
1593 for (size_t i = 0; i < apCloudProviders.size(); ++i)
1594 {
1595 ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
1596 Bstr bstrProviderName;
1597 pCloudProvider->COMGETTER(Name)(bstrProviderName.asOutParam());
1598 RTPrintf(List::tr("Name: %ls\n"), bstrProviderName.raw());
1599 pCloudProvider->COMGETTER(ShortName)(bstrProviderName.asOutParam());
1600 RTPrintf(List::tr("Short Name: %ls\n"), bstrProviderName.raw());
1601 Bstr bstrProviderID;
1602 pCloudProvider->COMGETTER(Id)(bstrProviderID.asOutParam());
1603 RTPrintf("GUID: %ls\n", bstrProviderID.raw());
1604
1605 RTPrintf("\n");
1606 }
1607 return hrc;
1608}
1609
1610
1611/**
1612 * List all available cloud profiles (by iterating over the cloud providers).
1613 *
1614 * @returns See produceList.
1615 * @param pVirtualBox Reference to the IVirtualBox pointer.
1616 * @param fOptLong If true, list all profile properties.
1617 */
1618static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> &pVirtualBox, bool fOptLong)
1619{
1620 HRESULT hrc = S_OK;
1621 ComPtr<ICloudProviderManager> pCloudProviderManager;
1622 CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
1623 com::SafeIfaceArray<ICloudProvider> apCloudProviders;
1624 CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
1625
1626 for (size_t i = 0; i < apCloudProviders.size(); ++i)
1627 {
1628 ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
1629 com::SafeIfaceArray<ICloudProfile> apCloudProfiles;
1630 CHECK_ERROR(pCloudProvider, COMGETTER(Profiles)(ComSafeArrayAsOutParam(apCloudProfiles)));
1631 for (size_t j = 0; j < apCloudProfiles.size(); ++j)
1632 {
1633 ComPtr<ICloudProfile> pCloudProfile = apCloudProfiles[j];
1634 Bstr bstrProfileName;
1635 pCloudProfile->COMGETTER(Name)(bstrProfileName.asOutParam());
1636 RTPrintf(List::tr("Name: %ls\n"), bstrProfileName.raw());
1637 Bstr bstrProviderID;
1638 pCloudProfile->COMGETTER(ProviderId)(bstrProviderID.asOutParam());
1639 RTPrintf(List::tr("Provider GUID: %ls\n"), bstrProviderID.raw());
1640
1641 if (fOptLong)
1642 {
1643 com::SafeArray<BSTR> names;
1644 com::SafeArray<BSTR> values;
1645 pCloudProfile->GetProperties(Bstr().raw(), ComSafeArrayAsOutParam(names), ComSafeArrayAsOutParam(values));
1646 size_t cNames = names.size();
1647 size_t cValues = values.size();
1648 bool fFirst = true;
1649 for (size_t k = 0; k < cNames; k++)
1650 {
1651 Bstr value;
1652 if (k < cValues)
1653 value = values[k];
1654 RTPrintf("%s%ls=%ls\n",
1655 fFirst ? List::tr("Property: ") : " ",
1656 names[k], value.raw());
1657 fFirst = false;
1658 }
1659 }
1660
1661 RTPrintf("\n");
1662 }
1663 }
1664 return hrc;
1665}
1666
1667static HRESULT displayCPUProfile(ICPUProfile *pProfile, size_t idx, int cchIdx, bool fOptLong, HRESULT hrc)
1668{
1669 /* Retrieve the attributes needed for both long and short display. */
1670 Bstr bstrName;
1671 CHECK_ERROR2I_RET(pProfile, COMGETTER(Name)(bstrName.asOutParam()), hrcCheck);
1672
1673 CPUArchitecture_T enmArchitecture = CPUArchitecture_Any;
1674 CHECK_ERROR2I_RET(pProfile, COMGETTER(Architecture)(&enmArchitecture), hrcCheck);
1675 const char *pszArchitecture = "???";
1676 switch (enmArchitecture)
1677 {
1678 case CPUArchitecture_x86: pszArchitecture = "x86"; break;
1679 case CPUArchitecture_AMD64: pszArchitecture = "AMD64"; break;
1680 case CPUArchitecture_ARMv8_32: pszArchitecture = "ARMv8 (32-bit only)"; break;
1681 case CPUArchitecture_ARMv8_64: pszArchitecture = "ARMv8 (64-bit)"; break;
1682#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
1683 case CPUArchitecture_32BitHack:
1684#endif
1685 case CPUArchitecture_Any:
1686 break;
1687 }
1688
1689 /* Print what we've got. */
1690 if (!fOptLong)
1691 RTPrintf("#%0*zu: %ls [%s]\n", cchIdx, idx, bstrName.raw(), pszArchitecture);
1692 else
1693 {
1694 RTPrintf(List::tr("CPU Profile #%02zu:\n"), idx);
1695 RTPrintf(List::tr(" Architecture: %s\n"), pszArchitecture);
1696 RTPrintf(List::tr(" Name: %ls\n"), bstrName.raw());
1697 CHECK_ERROR2I_RET(pProfile, COMGETTER(FullName)(bstrName.asOutParam()), hrcCheck);
1698 RTPrintf(List::tr(" Full Name: %ls\n"), bstrName.raw());
1699 }
1700 return hrc;
1701}
1702
1703
1704/**
1705 * List all CPU profiles.
1706 *
1707 * @returns See produceList.
1708 * @param ptrVirtualBox Reference to the smart IVirtualBox pointer.
1709 * @param fOptLong If true, list all profile properties.
1710 * @param fOptSorted Sort the output if true, otherwise display in
1711 * system order.
1712 */
1713static HRESULT listCPUProfiles(const ComPtr<IVirtualBox> &ptrVirtualBox, bool fOptLong, bool fOptSorted)
1714{
1715 ComPtr<ISystemProperties> ptrSysProps;
1716 CHECK_ERROR2I_RET(ptrVirtualBox, COMGETTER(SystemProperties)(ptrSysProps.asOutParam()), hrcCheck);
1717 com::SafeIfaceArray<ICPUProfile> aCPUProfiles;
1718 CHECK_ERROR2I_RET(ptrSysProps, GetCPUProfiles(CPUArchitecture_Any, Bstr().raw(),
1719 ComSafeArrayAsOutParam(aCPUProfiles)), hrcCheck);
1720
1721 int const cchIdx = 1 + (aCPUProfiles.size() >= 10) + (aCPUProfiles.size() >= 100);
1722
1723 HRESULT hrc = S_OK;
1724 if (!fOptSorted)
1725 for (size_t i = 0; i < aCPUProfiles.size(); i++)
1726 hrc = displayCPUProfile(aCPUProfiles[i], i, cchIdx, fOptLong, hrc);
1727 else
1728 {
1729 std::vector<std::pair<com::Bstr, ICPUProfile *> > vecSortedProfiles;
1730 for (size_t i = 0; i < aCPUProfiles.size(); ++i)
1731 {
1732 Bstr bstrName;
1733 CHECK_ERROR2I_RET(aCPUProfiles[i], COMGETTER(Name)(bstrName.asOutParam()), hrcCheck);
1734 try
1735 {
1736 vecSortedProfiles.push_back(std::pair<com::Bstr, ICPUProfile *>(bstrName, aCPUProfiles[i]));
1737 }
1738 catch (std::bad_alloc &)
1739 {
1740 return E_OUTOFMEMORY;
1741 }
1742 }
1743
1744 std::sort(vecSortedProfiles.begin(), vecSortedProfiles.end());
1745
1746 for (size_t i = 0; i < vecSortedProfiles.size(); i++)
1747 hrc = displayCPUProfile(vecSortedProfiles[i].second, i, cchIdx, fOptLong, hrc);
1748 }
1749
1750 return hrc;
1751}
1752
1753
1754/**
1755 * Translates PartitionType_T to a string if possible.
1756 * @returns read-only string if known value, @a pszUnknown if not.
1757 */
1758static const char *PartitionTypeToString(PartitionType_T enmType, const char *pszUnknown)
1759{
1760#define MY_CASE_STR(a_Type) case RT_CONCAT(PartitionType_,a_Type): return #a_Type
1761 switch (enmType)
1762 {
1763 MY_CASE_STR(Empty);
1764 MY_CASE_STR(FAT12);
1765 MY_CASE_STR(FAT16);
1766 MY_CASE_STR(FAT);
1767 MY_CASE_STR(IFS);
1768 MY_CASE_STR(FAT32CHS);
1769 MY_CASE_STR(FAT32LBA);
1770 MY_CASE_STR(FAT16B);
1771 MY_CASE_STR(Extended);
1772 MY_CASE_STR(WindowsRE);
1773 MY_CASE_STR(LinuxSwapOld);
1774 MY_CASE_STR(LinuxOld);
1775 MY_CASE_STR(DragonFlyBSDSlice);
1776 MY_CASE_STR(LinuxSwap);
1777 MY_CASE_STR(Linux);
1778 MY_CASE_STR(LinuxExtended);
1779 MY_CASE_STR(LinuxLVM);
1780 MY_CASE_STR(BSDSlice);
1781 MY_CASE_STR(AppleUFS);
1782 MY_CASE_STR(AppleHFS);
1783 MY_CASE_STR(Solaris);
1784 MY_CASE_STR(GPT);
1785 MY_CASE_STR(EFI);
1786 MY_CASE_STR(Unknown);
1787 MY_CASE_STR(MBR);
1788 MY_CASE_STR(iFFS);
1789 MY_CASE_STR(SonyBoot);
1790 MY_CASE_STR(LenovoBoot);
1791 MY_CASE_STR(WindowsMSR);
1792 MY_CASE_STR(WindowsBasicData);
1793 MY_CASE_STR(WindowsLDMMeta);
1794 MY_CASE_STR(WindowsLDMData);
1795 MY_CASE_STR(WindowsRecovery);
1796 MY_CASE_STR(WindowsStorageSpaces);
1797 MY_CASE_STR(WindowsStorageReplica);
1798 MY_CASE_STR(IBMGPFS);
1799 MY_CASE_STR(LinuxData);
1800 MY_CASE_STR(LinuxRAID);
1801 MY_CASE_STR(LinuxRootX86);
1802 MY_CASE_STR(LinuxRootAMD64);
1803 MY_CASE_STR(LinuxRootARM32);
1804 MY_CASE_STR(LinuxRootARM64);
1805 MY_CASE_STR(LinuxHome);
1806 MY_CASE_STR(LinuxSrv);
1807 MY_CASE_STR(LinuxPlainDmCrypt);
1808 MY_CASE_STR(LinuxLUKS);
1809 MY_CASE_STR(LinuxReserved);
1810 MY_CASE_STR(FreeBSDBoot);
1811 MY_CASE_STR(FreeBSDData);
1812 MY_CASE_STR(FreeBSDSwap);
1813 MY_CASE_STR(FreeBSDUFS);
1814 MY_CASE_STR(FreeBSDVinum);
1815 MY_CASE_STR(FreeBSDZFS);
1816 MY_CASE_STR(FreeBSDUnknown);
1817 MY_CASE_STR(AppleHFSPlus);
1818 MY_CASE_STR(AppleAPFS);
1819 MY_CASE_STR(AppleRAID);
1820 MY_CASE_STR(AppleRAIDOffline);
1821 MY_CASE_STR(AppleBoot);
1822 MY_CASE_STR(AppleLabel);
1823 MY_CASE_STR(AppleTvRecovery);
1824 MY_CASE_STR(AppleCoreStorage);
1825 MY_CASE_STR(SoftRAIDStatus);
1826 MY_CASE_STR(SoftRAIDScratch);
1827 MY_CASE_STR(SoftRAIDVolume);
1828 MY_CASE_STR(SoftRAIDCache);
1829 MY_CASE_STR(AppleUnknown);
1830 MY_CASE_STR(SolarisBoot);
1831 MY_CASE_STR(SolarisRoot);
1832 MY_CASE_STR(SolarisSwap);
1833 MY_CASE_STR(SolarisBackup);
1834 MY_CASE_STR(SolarisUsr);
1835 MY_CASE_STR(SolarisVar);
1836 MY_CASE_STR(SolarisHome);
1837 MY_CASE_STR(SolarisAltSector);
1838 MY_CASE_STR(SolarisReserved);
1839 MY_CASE_STR(SolarisUnknown);
1840 MY_CASE_STR(NetBSDSwap);
1841 MY_CASE_STR(NetBSDFFS);
1842 MY_CASE_STR(NetBSDLFS);
1843 MY_CASE_STR(NetBSDRAID);
1844 MY_CASE_STR(NetBSDConcatenated);
1845 MY_CASE_STR(NetBSDEncrypted);
1846 MY_CASE_STR(NetBSDUnknown);
1847 MY_CASE_STR(ChromeOSKernel);
1848 MY_CASE_STR(ChromeOSRootFS);
1849 MY_CASE_STR(ChromeOSFuture);
1850 MY_CASE_STR(ContLnxUsr);
1851 MY_CASE_STR(ContLnxRoot);
1852 MY_CASE_STR(ContLnxReserved);
1853 MY_CASE_STR(ContLnxRootRAID);
1854 MY_CASE_STR(HaikuBFS);
1855 MY_CASE_STR(MidntBSDBoot);
1856 MY_CASE_STR(MidntBSDData);
1857 MY_CASE_STR(MidntBSDSwap);
1858 MY_CASE_STR(MidntBSDUFS);
1859 MY_CASE_STR(MidntBSDVium);
1860 MY_CASE_STR(MidntBSDZFS);
1861 MY_CASE_STR(MidntBSDUnknown);
1862 MY_CASE_STR(OpenBSDData);
1863 MY_CASE_STR(QNXPowerSafeFS);
1864 MY_CASE_STR(Plan9);
1865 MY_CASE_STR(VMWareVMKCore);
1866 MY_CASE_STR(VMWareVMFS);
1867 MY_CASE_STR(VMWareReserved);
1868 MY_CASE_STR(VMWareUnknown);
1869 MY_CASE_STR(AndroidX86Bootloader);
1870 MY_CASE_STR(AndroidX86Bootloader2);
1871 MY_CASE_STR(AndroidX86Boot);
1872 MY_CASE_STR(AndroidX86Recovery);
1873 MY_CASE_STR(AndroidX86Misc);
1874 MY_CASE_STR(AndroidX86Metadata);
1875 MY_CASE_STR(AndroidX86System);
1876 MY_CASE_STR(AndroidX86Cache);
1877 MY_CASE_STR(AndroidX86Data);
1878 MY_CASE_STR(AndroidX86Persistent);
1879 MY_CASE_STR(AndroidX86Vendor);
1880 MY_CASE_STR(AndroidX86Config);
1881 MY_CASE_STR(AndroidX86Factory);
1882 MY_CASE_STR(AndroidX86FactoryAlt);
1883 MY_CASE_STR(AndroidX86Fastboot);
1884 MY_CASE_STR(AndroidX86OEM);
1885 MY_CASE_STR(AndroidARMMeta);
1886 MY_CASE_STR(AndroidARMExt);
1887 MY_CASE_STR(ONIEBoot);
1888 MY_CASE_STR(ONIEConfig);
1889 MY_CASE_STR(PowerPCPrep);
1890 MY_CASE_STR(XDGShrBootConfig);
1891 MY_CASE_STR(CephBlock);
1892 MY_CASE_STR(CephBlockDB);
1893 MY_CASE_STR(CephBlockDBDmc);
1894 MY_CASE_STR(CephBlockDBDmcLUKS);
1895 MY_CASE_STR(CephBlockDmc);
1896 MY_CASE_STR(CephBlockDmcLUKS);
1897 MY_CASE_STR(CephBlockWALog);
1898 MY_CASE_STR(CephBlockWALogDmc);
1899 MY_CASE_STR(CephBlockWALogDmcLUKS);
1900 MY_CASE_STR(CephDisk);
1901 MY_CASE_STR(CephDiskDmc);
1902 MY_CASE_STR(CephJournal);
1903 MY_CASE_STR(CephJournalDmc);
1904 MY_CASE_STR(CephJournalDmcLUKS);
1905 MY_CASE_STR(CephLockbox);
1906 MY_CASE_STR(CephMultipathBlock1);
1907 MY_CASE_STR(CephMultipathBlock2);
1908 MY_CASE_STR(CephMultipathBlockDB);
1909 MY_CASE_STR(CephMultipathBLockWALog);
1910 MY_CASE_STR(CephMultipathJournal);
1911 MY_CASE_STR(CephMultipathOSD);
1912 MY_CASE_STR(CephOSD);
1913 MY_CASE_STR(CephOSDDmc);
1914 MY_CASE_STR(CephOSDDmcLUKS);
1915#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
1916 case PartitionType_32BitHack: break;
1917#endif
1918 /* no default! */
1919 }
1920#undef MY_CASE_STR
1921 return pszUnknown;
1922}
1923
1924
1925/**
1926 * List all available host drives with their partitions.
1927 *
1928 * @returns See produceList.
1929 * @param pVirtualBox Reference to the IVirtualBox pointer.
1930 * @param fOptLong Long listing or human readable.
1931 */
1932static HRESULT listHostDrives(const ComPtr<IVirtualBox> pVirtualBox, bool fOptLong)
1933{
1934 HRESULT hrc = S_OK;
1935 ComPtr<IHost> pHost;
1936 CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(Host)(pHost.asOutParam()), hrcCheck);
1937 com::SafeIfaceArray<IHostDrive> apHostDrives;
1938 CHECK_ERROR2I_RET(pHost, COMGETTER(HostDrives)(ComSafeArrayAsOutParam(apHostDrives)), hrcCheck);
1939 for (size_t i = 0; i < apHostDrives.size(); ++i)
1940 {
1941 ComPtr<IHostDrive> pHostDrive = apHostDrives[i];
1942
1943 /* The drivePath and model attributes are accessible even when the object
1944 is in 'limited' mode. */
1945 com::Bstr bstrDrivePath;
1946 CHECK_ERROR(pHostDrive,COMGETTER(DrivePath)(bstrDrivePath.asOutParam()));
1947 if (SUCCEEDED(hrc))
1948 RTPrintf(List::tr("%sDrive: %ls\n"), i > 0 ? "\n" : "", bstrDrivePath.raw());
1949 else
1950 RTPrintf(List::tr("%sDrive: %Rhrc\n"), i > 0 ? "\n" : "", hrc);
1951
1952 com::Bstr bstrModel;
1953 CHECK_ERROR(pHostDrive,COMGETTER(Model)(bstrModel.asOutParam()));
1954 if (FAILED(hrc))
1955 RTPrintf(List::tr("Model: %Rhrc\n"), hrc);
1956 else if (bstrModel.isNotEmpty())
1957 RTPrintf(List::tr("Model: \"%ls\"\n"), bstrModel.raw());
1958 else
1959 RTPrintf(List::tr("Model: unknown/inaccessible\n"));
1960
1961 /* The other attributes are not accessible in limited mode and will fail
1962 with E_ACCESSDENIED. Typically means the user cannot read the drive. */
1963 com::Bstr bstrUuidDisk;
1964 hrc = pHostDrive->COMGETTER(Uuid)(bstrUuidDisk.asOutParam());
1965 if (SUCCEEDED(hrc) && !com::Guid(bstrUuidDisk).isZero())
1966 RTPrintf("UUID: %ls\n", bstrUuidDisk.raw());
1967 else if (hrc == E_ACCESSDENIED)
1968 {
1969 RTPrintf(List::tr("Further disk and partitioning information is not available for drive \"%ls\". (E_ACCESSDENIED)\n"),
1970 bstrDrivePath.raw());
1971 continue;
1972 }
1973 else if (FAILED(hrc))
1974 {
1975 RTPrintf("UUID: %Rhrc\n", hrc);
1976 com::GlueHandleComErrorNoCtx(pHostDrive, hrc);
1977 }
1978
1979 LONG64 cbSize = 0;
1980 hrc = pHostDrive->COMGETTER(Size)(&cbSize);
1981 if (SUCCEEDED(hrc) && fOptLong)
1982 RTPrintf(List::tr("Size: %llu bytes (%Rhcb)\n", "", (size_t)cbSize), cbSize, cbSize);
1983 else if (SUCCEEDED(hrc))
1984 RTPrintf(List::tr("Size: %Rhcb\n"), cbSize);
1985 else
1986 {
1987 RTPrintf(List::tr("Size: %Rhrc\n"), hrc);
1988 com::GlueHandleComErrorNoCtx(pHostDrive, hrc);
1989 }
1990
1991 ULONG cbSectorSize = 0;
1992 hrc = pHostDrive->COMGETTER(SectorSize)(&cbSectorSize);
1993 if (SUCCEEDED(hrc))
1994 RTPrintf(List::tr("Sector Size: %u bytes\n", "", cbSectorSize), cbSectorSize);
1995 else
1996 {
1997 RTPrintf(List::tr("Sector Size: %Rhrc\n"), hrc);
1998 com::GlueHandleComErrorNoCtx(pHostDrive, hrc);
1999 }
2000
2001 PartitioningType_T partitioningType = (PartitioningType_T)9999;
2002 hrc = pHostDrive->COMGETTER(PartitioningType)(&partitioningType);
2003 if (SUCCEEDED(hrc))
2004 RTPrintf(List::tr("Scheme: %s\n"), partitioningType == PartitioningType_MBR ? "MBR" : "GPT");
2005 else
2006 {
2007 RTPrintf(List::tr("Scheme: %Rhrc\n"), hrc);
2008 com::GlueHandleComErrorNoCtx(pHostDrive, hrc);
2009 }
2010
2011 com::SafeIfaceArray<IHostDrivePartition> apHostDrivesPartitions;
2012 hrc = pHostDrive->COMGETTER(Partitions)(ComSafeArrayAsOutParam(apHostDrivesPartitions));
2013 if (FAILED(hrc))
2014 {
2015 RTPrintf(List::tr("Partitions: %Rhrc\n"), hrc);
2016 com::GlueHandleComErrorNoCtx(pHostDrive, hrc);
2017 }
2018 else if (apHostDrivesPartitions.size() == 0)
2019 RTPrintf(List::tr("Partitions: None (or not able to grok them).\n"));
2020 else if (partitioningType == PartitioningType_MBR)
2021 {
2022 if (fOptLong)
2023 RTPrintf(List::tr("Partitions: First Last\n"
2024 "## Type Byte Size Byte Offset Cyl/Head/Sec Cyl/Head/Sec Active\n"));
2025 else
2026 RTPrintf(List::tr("Partitions: First Last\n"
2027 "## Type Size Start Cyl/Head/Sec Cyl/Head/Sec Active\n"));
2028 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j)
2029 {
2030 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j];
2031
2032 ULONG idx = 0;
2033 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx));
2034 ULONG uType = 0;
2035 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeMBR)(&uType));
2036 ULONG uStartCylinder = 0;
2037 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartCylinder)(&uStartCylinder));
2038 ULONG uStartHead = 0;
2039 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartHead)(&uStartHead));
2040 ULONG uStartSector = 0;
2041 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartSector)(&uStartSector));
2042 ULONG uEndCylinder = 0;
2043 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndCylinder)(&uEndCylinder));
2044 ULONG uEndHead = 0;
2045 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndHead)(&uEndHead));
2046 ULONG uEndSector = 0;
2047 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndSector)(&uEndSector));
2048 cbSize = 0;
2049 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize));
2050 LONG64 offStart = 0;
2051 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart));
2052 BOOL fActive = 0;
2053 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive));
2054 PartitionType_T enmType = PartitionType_Unknown;
2055 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType));
2056
2057 /* Max size & offset here is around 16TiB with 4KiB sectors. */
2058 if (fOptLong) /* cb/off: max 16TiB; idx: max 64. */
2059 RTPrintf("%2u %02x %14llu %14llu %4u/%3u/%2u %4u/%3u/%2u %s %s\n",
2060 idx, uType, cbSize, offStart,
2061 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector,
2062 fActive ? List::tr("yes") : List::tr("no"), PartitionTypeToString(enmType, ""));
2063 else
2064 RTPrintf("%2u %02x %8Rhcb %8Rhcb %4u/%3u/%2u %4u/%3u/%2u %s %s\n",
2065 idx, uType, (uint64_t)cbSize, (uint64_t)offStart,
2066 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector,
2067 fActive ? List::tr("yes") : List::tr("no"), PartitionTypeToString(enmType, ""));
2068 }
2069 }
2070 else /* GPT */
2071 {
2072 /* Determin the max partition type length to try reduce the table width: */
2073 size_t cchMaxType = 0;
2074 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j)
2075 {
2076 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j];
2077 PartitionType_T enmType = PartitionType_Unknown;
2078 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType));
2079 size_t const cchTypeNm = strlen(PartitionTypeToString(enmType, "e530bf6d-2754-4e9d-b260-60a5d0b80457"));
2080 cchMaxType = RT_MAX(cchTypeNm, cchMaxType);
2081 }
2082 cchMaxType = RT_MIN(cchMaxType, RTUUID_STR_LENGTH);
2083
2084 if (fOptLong)
2085 RTPrintf(List::tr(
2086 "Partitions:\n"
2087 "## %-*s Uuid Byte Size Byte Offset Active Name\n"),
2088 (int)cchMaxType, List::tr("Type"));
2089 else
2090 RTPrintf(List::tr(
2091 "Partitions:\n"
2092 "## %-*s Uuid Size Start Active Name\n"),
2093 (int)cchMaxType, List::tr("Type"));
2094
2095 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j)
2096 {
2097 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j];
2098
2099 ULONG idx = 0;
2100 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx));
2101 com::Bstr bstrUuidType;
2102 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeUuid)(bstrUuidType.asOutParam()));
2103 com::Bstr bstrUuidPartition;
2104 CHECK_ERROR(pHostDrivePartition, COMGETTER(Uuid)(bstrUuidPartition.asOutParam()));
2105 cbSize = 0;
2106 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize));
2107 LONG64 offStart = 0;
2108 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart));
2109 BOOL fActive = 0;
2110 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive));
2111 com::Bstr bstrName;
2112 CHECK_ERROR(pHostDrivePartition, COMGETTER(Name)(bstrName.asOutParam()));
2113
2114 PartitionType_T enmType = PartitionType_Unknown;
2115 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType));
2116
2117 Utf8Str strTypeConv;
2118 const char *pszTypeNm = PartitionTypeToString(enmType, NULL);
2119 if (!pszTypeNm)
2120 pszTypeNm = (strTypeConv = bstrUuidType).c_str();
2121 else if (strlen(pszTypeNm) >= RTUUID_STR_LENGTH /* includes '\0' */)
2122 pszTypeNm -= RTUUID_STR_LENGTH - 1 - strlen(pszTypeNm);
2123
2124 if (fOptLong)
2125 RTPrintf("%2u %-*s %36ls %19llu %19llu %-3s %ls\n", idx, cchMaxType, pszTypeNm,
2126 bstrUuidPartition.raw(), cbSize, offStart, fActive ? List::tr("on") : List::tr("off"),
2127 bstrName.raw());
2128 else
2129 RTPrintf("%2u %-*s %36ls %8Rhcb %8Rhcb %-3s %ls\n", idx, cchMaxType, pszTypeNm,
2130 bstrUuidPartition.raw(), cbSize, offStart, fActive ? List::tr("on") : List::tr("off"),
2131 bstrName.raw());
2132 }
2133 }
2134 }
2135 return hrc;
2136}
2137
2138
2139static HRESULT listExecutionEnginesForCpuArchitecture(CPUArchitecture_T enmCpuArchitecture, const ComPtr<ISystemProperties> ptrSysProps, const ComPtr<IHost> pHost,
2140 HRESULT hrc)
2141{
2142 const char *pszArchitecture = "???";
2143 switch (enmCpuArchitecture)
2144 {
2145 case CPUArchitecture_x86: pszArchitecture = "x86"; break;
2146 case CPUArchitecture_AMD64: pszArchitecture = "AMD64"; break;
2147 case CPUArchitecture_ARMv8_32: pszArchitecture = "ARMv8 (32-bit only)"; break;
2148 case CPUArchitecture_ARMv8_64: pszArchitecture = "ARMv8 (64-bit)"; break;
2149#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
2150 case CPUArchitecture_32BitHack:
2151#endif
2152 case CPUArchitecture_Any:
2153 break;
2154 }
2155
2156 /* Query all possible execution engines supported by the build. */
2157 com::SafeArray<VMExecutionEngine_T> aExecutionEngines;
2158 CHECK_ERROR2I_RET(ptrSysProps, GetExecutionEnginesForVmCpuArchitecture(enmCpuArchitecture,
2159 ComSafeArrayAsOutParam(aExecutionEngines)), hrcCheck);
2160
2161 /* Don't dump anything if the architecture is not supported at all. */
2162 if (aExecutionEngines.size())
2163 {
2164 /* Now filter out the ones the host actually supports. */
2165 std::vector<VMExecutionEngine_T> vecExecEnginesSupported;
2166 for (size_t i = 0; i < aExecutionEngines.size(); i++)
2167 {
2168 BOOL fSupported = FALSE;
2169 CHECK_ERROR2I_RET(pHost, IsExecutionEngineSupported(enmCpuArchitecture, aExecutionEngines[i], &fSupported), hrcCheck);
2170 if (fSupported)
2171 vecExecEnginesSupported.push_back(aExecutionEngines[i]);
2172 }
2173
2174 RTPrintf(List::tr("CPU Architecture: %s\n"), pszArchitecture);
2175
2176 /* Print what we've got. */
2177 for (size_t i = 0; i < vecExecEnginesSupported.size(); i++)
2178 {
2179 const char *pszExecEngine = "???";
2180 switch (vecExecEnginesSupported[i])
2181 {
2182 case VMExecutionEngine_Default: pszExecEngine = "Default"; break;
2183 case VMExecutionEngine_HwVirt: pszExecEngine = "HwVirt"; break;
2184 case VMExecutionEngine_NativeApi: pszExecEngine = "NativeApi"; break;
2185 case VMExecutionEngine_Interpreter: pszExecEngine = "Interpreter"; break;
2186 case VMExecutionEngine_Recompiler: pszExecEngine = "Recompiler"; break;
2187 default: break;
2188 }
2189
2190 RTPrintf(" #%02zu: %s\n", i, pszExecEngine);
2191 }
2192 }
2193
2194 return hrc;
2195}
2196
2197
2198/**
2199 * List all execution engines supported by the host.
2200 *
2201 * @returns See produceList.
2202 * @param ptrVirtualBox Reference to the smart IVirtualBox pointer.
2203 */
2204static HRESULT listExecutionEngines(const ComPtr<IVirtualBox> &ptrVirtualBox)
2205{
2206 ComPtr<ISystemProperties> ptrSysProps;
2207 CHECK_ERROR2I_RET(ptrVirtualBox, COMGETTER(SystemProperties)(ptrSysProps.asOutParam()), hrcCheck);
2208 ComPtr<IHost> pHost;
2209 CHECK_ERROR2I_RET(ptrVirtualBox, COMGETTER(Host)(pHost.asOutParam()), hrcCheck);
2210
2211 HRESULT hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_x86, ptrSysProps, pHost, S_OK);
2212 hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_AMD64, ptrSysProps, pHost, hrc);
2213 hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_ARMv8_32, ptrSysProps, pHost, hrc);
2214 hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_ARMv8_64, ptrSysProps, pHost, hrc);
2215
2216 return hrc;
2217}
2218
2219
2220/**
2221 * The type of lists we can produce.
2222 */
2223enum ListType_T
2224{
2225 kListNotSpecified = 1000,
2226 kListVMs,
2227 kListRunningVMs,
2228 kListOsTypes,
2229 kListOsSubtypes,
2230 kListHostDvds,
2231 kListHostFloppies,
2232 kListInternalNetworks,
2233 kListBridgedInterfaces,
2234#if defined(VBOX_WITH_NETFLT)
2235 kListHostOnlyInterfaces,
2236#endif
2237#if defined(VBOX_WITH_VMNET)
2238 kListHostOnlyNetworks,
2239#endif
2240#if defined(VBOX_WITH_CLOUD_NET)
2241 kListCloudNetworks,
2242#endif
2243 kListHostCpuIDs,
2244 kListHostInfo,
2245 kListHddBackends,
2246 kListHdds,
2247 kListDvds,
2248 kListFloppies,
2249 kListUsbHost,
2250 kListUsbFilters,
2251 kListSystemProperties,
2252#if defined(VBOX_WITH_UPDATE_AGENT)
2253 kListUpdateAgents,
2254#endif
2255 kListDhcpServers,
2256 kListExtPacks,
2257 kListGroups,
2258 kListNatNetworks,
2259 kListVideoInputDevices,
2260 kListScreenShotFormats,
2261 kListCloudProviders,
2262 kListCloudProfiles,
2263 kListCPUProfiles,
2264 kListHostDrives,
2265 kListExecutionEngines
2266};
2267
2268
2269/**
2270 * Produces the specified listing.
2271 *
2272 * @returns S_OK or some COM error code that has been reported in full.
2273 * @param enmList The list to produce.
2274 * @param fOptLong Long (@c true) or short list format.
2275 * @param fOptSorted Whether the output shall be sorted or not (depends on the actual command).
2276 * @param enmPlatformArch Filters the list by the given platform architecture,
2277 * or processes all platforms if PlatformArchitecture_None is specified.
2278 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
2279 */
2280static HRESULT produceList(enum ListType_T enmCommand, bool fOptLong, bool fOptSorted, PlatformArchitecture_T enmPlatformArch,
2281 const ComPtr<IVirtualBox> &pVirtualBox)
2282{
2283 HRESULT hrc = S_OK;
2284 switch (enmCommand)
2285 {
2286 case kListNotSpecified:
2287 AssertFailed();
2288 return E_FAIL;
2289
2290 case kListVMs:
2291 {
2292 /*
2293 * Get the list of all registered VMs
2294 */
2295 com::SafeIfaceArray<IMachine> machines;
2296 hrc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
2297 if (SUCCEEDED(hrc))
2298 {
2299 /*
2300 * Display it.
2301 */
2302 if (!fOptSorted)
2303 {
2304 for (size_t i = 0; i < machines.size(); ++i)
2305 if (machines[i])
2306 hrc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
2307 }
2308 else
2309 {
2310 /*
2311 * Sort the list by name before displaying it.
2312 */
2313 std::vector<std::pair<com::Bstr, IMachine *> > sortedMachines;
2314 for (size_t i = 0; i < machines.size(); ++i)
2315 {
2316 IMachine *pMachine = machines[i];
2317 if (pMachine) /* no idea why we need to do this... */
2318 {
2319 Bstr bstrName;
2320 pMachine->COMGETTER(Name)(bstrName.asOutParam());
2321 sortedMachines.push_back(std::pair<com::Bstr, IMachine *>(bstrName, pMachine));
2322 }
2323 }
2324
2325 std::sort(sortedMachines.begin(), sortedMachines.end());
2326
2327 for (size_t i = 0; i < sortedMachines.size(); ++i)
2328 hrc = showVMInfo(pVirtualBox, sortedMachines[i].second, NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
2329 }
2330 }
2331 break;
2332 }
2333
2334 case kListRunningVMs:
2335 {
2336 /*
2337 * Get the list of all _running_ VMs
2338 */
2339 com::SafeIfaceArray<IMachine> machines;
2340 hrc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
2341 com::SafeArray<MachineState_T> states;
2342 if (SUCCEEDED(hrc))
2343 hrc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
2344 if (SUCCEEDED(hrc))
2345 {
2346 /*
2347 * Iterate through the collection
2348 */
2349 for (size_t i = 0; i < machines.size(); ++i)
2350 {
2351 if (machines[i])
2352 {
2353 MachineState_T machineState = states[i];
2354 switch (machineState)
2355 {
2356 case MachineState_Running:
2357 case MachineState_Teleporting:
2358 case MachineState_LiveSnapshotting:
2359 case MachineState_Paused:
2360 case MachineState_TeleportingPausedVM:
2361 hrc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
2362 break;
2363 default: break; /* Shut up MSC */
2364 }
2365 }
2366 }
2367 }
2368 break;
2369 }
2370
2371 case kListOsTypes:
2372 {
2373 com::SafeIfaceArray<IGuestOSType> coll;
2374 hrc = pVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
2375 if (SUCCEEDED(hrc))
2376 listGuestOSTypes(coll, fOptLong, fOptSorted, enmPlatformArch);
2377 break;
2378 }
2379
2380 case kListOsSubtypes:
2381 {
2382 com::SafeArray<BSTR> GuestOSFamilies;
2383 CHECK_ERROR(pVirtualBox, COMGETTER(GuestOSFamilies)(ComSafeArrayAsOutParam(GuestOSFamilies)));
2384 if (SUCCEEDED(hrc))
2385 {
2386 for (size_t i = 0; i < GuestOSFamilies.size(); ++i)
2387 {
2388 const Bstr bstrOSFamily = GuestOSFamilies[i];
2389 com::SafeArray<BSTR> GuestOSSubtypes;
2390 CHECK_ERROR(pVirtualBox,
2391 GetGuestOSSubtypesByFamilyId(bstrOSFamily.raw(),
2392 ComSafeArrayAsOutParam(GuestOSSubtypes)));
2393 if (SUCCEEDED(hrc))
2394 {
2395 RTPrintf("%ls\n", bstrOSFamily.raw());
2396 for (size_t j = 0; j < GuestOSSubtypes.size(); ++j)
2397 {
2398 RTPrintf("\t%ls\n", GuestOSSubtypes[j]);
2399 com::SafeArray<BSTR> GuestOSDescs;
2400 const Bstr bstrOSSubtype = GuestOSSubtypes[j];
2401 CHECK_ERROR(pVirtualBox,
2402 GetGuestOSDescsBySubtype(bstrOSSubtype.raw(),
2403 ComSafeArrayAsOutParam(GuestOSDescs)));
2404 if (SUCCEEDED(hrc))
2405 for (size_t k = 0; k < GuestOSDescs.size(); ++k)
2406 RTPrintf("\t\t%ls\n", GuestOSDescs[k]);
2407 }
2408 }
2409 }
2410 }
2411 break;
2412 }
2413
2414 case kListHostDvds:
2415 {
2416 ComPtr<IHost> host;
2417 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
2418 com::SafeIfaceArray<IMedium> coll;
2419 CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
2420 if (SUCCEEDED(hrc))
2421 {
2422 for (size_t i = 0; i < coll.size(); ++i)
2423 {
2424 ComPtr<IMedium> dvdDrive = coll[i];
2425 Bstr uuid;
2426 dvdDrive->COMGETTER(Id)(uuid.asOutParam());
2427 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
2428 Bstr location;
2429 dvdDrive->COMGETTER(Location)(location.asOutParam());
2430 RTPrintf(List::tr("Name: %ls\n\n"), location.raw());
2431 }
2432 }
2433 break;
2434 }
2435
2436 case kListHostFloppies:
2437 {
2438 ComPtr<IHost> host;
2439 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
2440 com::SafeIfaceArray<IMedium> coll;
2441 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
2442 if (SUCCEEDED(hrc))
2443 {
2444 for (size_t i = 0; i < coll.size(); ++i)
2445 {
2446 ComPtr<IMedium> floppyDrive = coll[i];
2447 Bstr uuid;
2448 floppyDrive->COMGETTER(Id)(uuid.asOutParam());
2449 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
2450 Bstr location;
2451 floppyDrive->COMGETTER(Location)(location.asOutParam());
2452 RTPrintf(List::tr("Name: %ls\n\n"), location.raw());
2453 }
2454 }
2455 break;
2456 }
2457
2458 case kListInternalNetworks:
2459 hrc = listInternalNetworks(pVirtualBox);
2460 break;
2461
2462 case kListBridgedInterfaces:
2463#if defined(VBOX_WITH_NETFLT)
2464 case kListHostOnlyInterfaces:
2465#endif
2466 hrc = listNetworkInterfaces(pVirtualBox, enmCommand == kListBridgedInterfaces);
2467 break;
2468
2469#if defined(VBOX_WITH_VMNET)
2470 case kListHostOnlyNetworks:
2471 hrc = listHostOnlyNetworks(pVirtualBox);
2472 break;
2473#endif
2474
2475#if defined(VBOX_WITH_CLOUD_NET)
2476 case kListCloudNetworks:
2477 hrc = listCloudNetworks(pVirtualBox);
2478 break;
2479#endif
2480 case kListHostInfo:
2481 hrc = listHostInfo(pVirtualBox);
2482 break;
2483
2484 case kListHostCpuIDs:
2485 {
2486 ComPtr<IHost> Host;
2487 CHECK_ERROR_BREAK(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
2488 PlatformArchitecture_T platformArch;
2489 CHECK_ERROR_BREAK(Host, COMGETTER(Architecture)(&platformArch));
2490
2491 switch (platformArch)
2492 {
2493 case PlatformArchitecture_x86:
2494 {
2495 ComPtr<IHostX86> HostX86;
2496 CHECK_ERROR_BREAK(Host, COMGETTER(X86)(HostX86.asOutParam()));
2497
2498 RTPrintf(List::tr("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n"));
2499 ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
2500 static uint32_t const s_auCpuIdRanges[] =
2501 {
2502 UINT32_C(0x00000000), UINT32_C(0x0000007f),
2503 UINT32_C(0x80000000), UINT32_C(0x8000007f),
2504 UINT32_C(0xc0000000), UINT32_C(0xc000007f)
2505 };
2506 for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
2507 {
2508 ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
2509 CHECK_ERROR(HostX86, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
2510 if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
2511 continue;
2512 cLeafs++;
2513 for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
2514 {
2515 CHECK_ERROR(HostX86, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
2516 RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
2517 }
2518 }
2519
2520 break;
2521 }
2522
2523 case PlatformArchitecture_ARM:
2524 {
2525 /** @todo BUGBUG Implement this for ARM! */
2526 break;
2527 }
2528
2529 default:
2530 AssertFailed();
2531 break;
2532 }
2533 break;
2534 }
2535
2536 case kListHddBackends:
2537 hrc = listHddBackends(pVirtualBox);
2538 break;
2539
2540 case kListHdds:
2541 {
2542 com::SafeIfaceArray<IMedium> hdds;
2543 CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
2544 hrc = listMedia(pVirtualBox, hdds, List::tr("base"), fOptLong);
2545 break;
2546 }
2547
2548 case kListDvds:
2549 {
2550 com::SafeIfaceArray<IMedium> dvds;
2551 CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
2552 hrc = listMedia(pVirtualBox, dvds, NULL, fOptLong);
2553 break;
2554 }
2555
2556 case kListFloppies:
2557 {
2558 com::SafeIfaceArray<IMedium> floppies;
2559 CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
2560 hrc = listMedia(pVirtualBox, floppies, NULL, fOptLong);
2561 break;
2562 }
2563
2564 case kListUsbHost:
2565 hrc = listUsbHost(pVirtualBox);
2566 break;
2567
2568 case kListUsbFilters:
2569 hrc = listUsbFilters(pVirtualBox);
2570 break;
2571
2572 case kListSystemProperties:
2573 hrc = listSystemProperties(pVirtualBox);
2574 break;
2575
2576#ifdef VBOX_WITH_UPDATE_AGENT
2577 case kListUpdateAgents:
2578 hrc = listUpdateAgents(pVirtualBox);
2579 break;
2580#endif
2581 case kListDhcpServers:
2582 hrc = listDhcpServers(pVirtualBox);
2583 break;
2584
2585 case kListExtPacks:
2586 hrc = listExtensionPacks(pVirtualBox);
2587 break;
2588
2589 case kListGroups:
2590 hrc = listGroups(pVirtualBox);
2591 break;
2592
2593 case kListNatNetworks:
2594 hrc = listNATNetworks(fOptLong, fOptSorted, pVirtualBox);
2595 break;
2596
2597 case kListVideoInputDevices:
2598 hrc = listVideoInputDevices(pVirtualBox);
2599 break;
2600
2601 case kListScreenShotFormats:
2602 hrc = listScreenShotFormats(pVirtualBox);
2603 break;
2604
2605 case kListCloudProviders:
2606 hrc = listCloudProviders(pVirtualBox);
2607 break;
2608
2609 case kListCloudProfiles:
2610 hrc = listCloudProfiles(pVirtualBox, fOptLong);
2611 break;
2612
2613 case kListCPUProfiles:
2614 hrc = listCPUProfiles(pVirtualBox, fOptLong, fOptSorted);
2615 break;
2616
2617 case kListHostDrives:
2618 hrc = listHostDrives(pVirtualBox, fOptLong);
2619 break;
2620
2621 case kListExecutionEngines:
2622 hrc = listExecutionEngines(pVirtualBox);
2623 break;
2624
2625 /* No default here, want gcc warnings. */
2626
2627 } /* end switch */
2628
2629 return hrc;
2630}
2631
2632/**
2633 * Handles the 'list' command.
2634 *
2635 * @returns Appropriate exit code.
2636 * @param a Handler argument.
2637 */
2638RTEXITCODE handleList(HandlerArg *a)
2639{
2640 bool fOptLong = false;
2641 bool fOptMultiple = false;
2642 bool fOptSorted = false;
2643 PlatformArchitecture_T enmPlatformArch = PlatformArchitecture_None;
2644 bool fFirst = true;
2645 enum ListType_T enmOptCommand = kListNotSpecified;
2646 RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
2647
2648 static const RTGETOPTDEF s_aListOptions[] =
2649 {
2650 { "--long", 'l', RTGETOPT_REQ_NOTHING },
2651 { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */
2652 { "--platform-arch", 'p', RTGETOPT_REQ_STRING },
2653 { "--platform", 'p', RTGETOPT_REQ_STRING }, /* shortcut for '--platform-arch' */
2654 { "--sorted", 's', RTGETOPT_REQ_NOTHING },
2655 { "vms", kListVMs, RTGETOPT_REQ_NOTHING },
2656 { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING },
2657 { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING },
2658 { "ossubtypes", kListOsSubtypes, RTGETOPT_REQ_NOTHING },
2659 { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING },
2660 { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING },
2661 { "intnets", kListInternalNetworks, RTGETOPT_REQ_NOTHING },
2662 { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
2663 { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING },
2664#if defined(VBOX_WITH_NETFLT)
2665 { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
2666#endif
2667#if defined(VBOX_WITH_VMNET)
2668 { "hostonlynets", kListHostOnlyNetworks, RTGETOPT_REQ_NOTHING },
2669#endif
2670#if defined(VBOX_WITH_CLOUD_NET)
2671 { "cloudnets", kListCloudNetworks, RTGETOPT_REQ_NOTHING },
2672#endif
2673 { "natnetworks", kListNatNetworks, RTGETOPT_REQ_NOTHING },
2674 { "natnets", kListNatNetworks, RTGETOPT_REQ_NOTHING },
2675 { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING },
2676 { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING },
2677 { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING },
2678 { "hdds", kListHdds, RTGETOPT_REQ_NOTHING },
2679 { "dvds", kListDvds, RTGETOPT_REQ_NOTHING },
2680 { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING },
2681 { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING },
2682 { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING },
2683 { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING },
2684#if defined(VBOX_WITH_UPDATE_AGENT)
2685 { "updates", kListUpdateAgents, RTGETOPT_REQ_NOTHING },
2686#endif
2687 { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING },
2688 { "extpacks", kListExtPacks, RTGETOPT_REQ_NOTHING },
2689 { "groups", kListGroups, RTGETOPT_REQ_NOTHING },
2690 { "webcams", kListVideoInputDevices, RTGETOPT_REQ_NOTHING },
2691 { "screenshotformats", kListScreenShotFormats, RTGETOPT_REQ_NOTHING },
2692 { "cloudproviders", kListCloudProviders, RTGETOPT_REQ_NOTHING },
2693 { "cloudprofiles", kListCloudProfiles, RTGETOPT_REQ_NOTHING },
2694 { "cpu-profiles", kListCPUProfiles, RTGETOPT_REQ_NOTHING },
2695 { "hostdrives", kListHostDrives, RTGETOPT_REQ_NOTHING },
2696 { "execution-engines", kListExecutionEngines, RTGETOPT_REQ_NOTHING },
2697 };
2698
2699 int ch;
2700 RTGETOPTUNION ValueUnion;
2701 RTGETOPTSTATE GetState;
2702 RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
2703 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
2704 while ((ch = RTGetOpt(&GetState, &ValueUnion)))
2705 {
2706 switch (ch)
2707 {
2708 case 'l': /* --long */
2709 fOptLong = true;
2710 break;
2711
2712 case 'm':
2713 fOptMultiple = true;
2714 if (enmOptCommand == kListNotSpecified)
2715 break;
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: */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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