1 | /* $Id: VBoxManageList.cpp 82407 2019-12-05 11:01:49Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - The 'list' command.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VBOX_ONLY_DOCS
|
---|
19 |
|
---|
20 |
|
---|
21 | /*********************************************************************************************************************************
|
---|
22 | * Header Files *
|
---|
23 | *********************************************************************************************************************************/
|
---|
24 | #include <VBox/com/com.h>
|
---|
25 | #include <VBox/com/string.h>
|
---|
26 | #include <VBox/com/Guid.h>
|
---|
27 | #include <VBox/com/array.h>
|
---|
28 | #include <VBox/com/ErrorInfo.h>
|
---|
29 | #include <VBox/com/errorprint.h>
|
---|
30 |
|
---|
31 | #include <VBox/com/VirtualBox.h>
|
---|
32 |
|
---|
33 | #include <VBox/log.h>
|
---|
34 | #include <iprt/stream.h>
|
---|
35 | #include <iprt/string.h>
|
---|
36 | #include <iprt/time.h>
|
---|
37 | #include <iprt/getopt.h>
|
---|
38 | #include <iprt/ctype.h>
|
---|
39 |
|
---|
40 | #include <vector>
|
---|
41 | #include <algorithm>
|
---|
42 |
|
---|
43 | #include "VBoxManage.h"
|
---|
44 | using namespace com;
|
---|
45 |
|
---|
46 | #ifdef VBOX_WITH_HOSTNETIF_API
|
---|
47 | static const char *getHostIfMediumTypeText(HostNetworkInterfaceMediumType_T enmType)
|
---|
48 | {
|
---|
49 | switch (enmType)
|
---|
50 | {
|
---|
51 | case HostNetworkInterfaceMediumType_Ethernet: return "Ethernet";
|
---|
52 | case HostNetworkInterfaceMediumType_PPP: return "PPP";
|
---|
53 | case HostNetworkInterfaceMediumType_SLIP: return "SLIP";
|
---|
54 | case HostNetworkInterfaceMediumType_Unknown: return "Unknown";
|
---|
55 | #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
|
---|
56 | case HostNetworkInterfaceMediumType_32BitHack: break; /* Shut up compiler warnings. */
|
---|
57 | #endif
|
---|
58 | }
|
---|
59 | return "unknown";
|
---|
60 | }
|
---|
61 |
|
---|
62 | static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
|
---|
63 | {
|
---|
64 | switch (enmStatus)
|
---|
65 | {
|
---|
66 | case HostNetworkInterfaceStatus_Up: return "Up";
|
---|
67 | case HostNetworkInterfaceStatus_Down: return "Down";
|
---|
68 | case HostNetworkInterfaceStatus_Unknown: return "Unknown";
|
---|
69 | #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
|
---|
70 | case HostNetworkInterfaceStatus_32BitHack: break; /* Shut up compiler warnings. */
|
---|
71 | #endif
|
---|
72 | }
|
---|
73 | return "unknown";
|
---|
74 | }
|
---|
75 | #endif /* VBOX_WITH_HOSTNETIF_API */
|
---|
76 |
|
---|
77 | static const char*getDeviceTypeText(DeviceType_T enmType)
|
---|
78 | {
|
---|
79 | switch (enmType)
|
---|
80 | {
|
---|
81 | case DeviceType_HardDisk: return "HardDisk";
|
---|
82 | case DeviceType_DVD: return "DVD";
|
---|
83 | case DeviceType_Floppy: return "Floppy";
|
---|
84 | /* Make MSC happy */
|
---|
85 | case DeviceType_Null: return "Null";
|
---|
86 | case DeviceType_Network: return "Network";
|
---|
87 | case DeviceType_USB: return "USB";
|
---|
88 | case DeviceType_SharedFolder: return "SharedFolder";
|
---|
89 | case DeviceType_Graphics3D: return "Graphics3D";
|
---|
90 | #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
|
---|
91 | case DeviceType_32BitHack: break; /* Shut up compiler warnings. */
|
---|
92 | #endif
|
---|
93 | }
|
---|
94 | return "Unknown";
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * List internal networks.
|
---|
100 | *
|
---|
101 | * @returns See produceList.
|
---|
102 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
103 | */
|
---|
104 | static HRESULT listInternalNetworks(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
105 | {
|
---|
106 | HRESULT rc;
|
---|
107 | com::SafeArray<BSTR> internalNetworks;
|
---|
108 | CHECK_ERROR(pVirtualBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks)));
|
---|
109 | for (size_t i = 0; i < internalNetworks.size(); ++i)
|
---|
110 | {
|
---|
111 | RTPrintf("Name: %ls\n", internalNetworks[i]);
|
---|
112 | }
|
---|
113 | return rc;
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * List network interfaces information (bridged/host only).
|
---|
119 | *
|
---|
120 | * @returns See produceList.
|
---|
121 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
122 | * @param fIsBridged Selects between listing host interfaces (for
|
---|
123 | * use with bridging) or host only interfaces.
|
---|
124 | */
|
---|
125 | static HRESULT listNetworkInterfaces(const ComPtr<IVirtualBox> pVirtualBox,
|
---|
126 | bool fIsBridged)
|
---|
127 | {
|
---|
128 | HRESULT rc;
|
---|
129 | ComPtr<IHost> host;
|
---|
130 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
131 | com::SafeIfaceArray<IHostNetworkInterface> hostNetworkInterfaces;
|
---|
132 | #if defined(VBOX_WITH_NETFLT)
|
---|
133 | if (fIsBridged)
|
---|
134 | CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged,
|
---|
135 | ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
136 | else
|
---|
137 | CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_HostOnly,
|
---|
138 | ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
139 | #else
|
---|
140 | RT_NOREF(fIsBridged);
|
---|
141 | CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
142 | #endif
|
---|
143 | for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
|
---|
144 | {
|
---|
145 | ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
|
---|
146 | #ifndef VBOX_WITH_HOSTNETIF_API
|
---|
147 | Bstr interfaceName;
|
---|
148 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
149 | RTPrintf("Name: %ls\n", interfaceName.raw());
|
---|
150 | Guid interfaceGuid;
|
---|
151 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
152 | RTPrintf("GUID: %ls\n\n", Bstr(interfaceGuid.toString()).raw());
|
---|
153 | #else /* VBOX_WITH_HOSTNETIF_API */
|
---|
154 | Bstr interfaceName;
|
---|
155 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
156 | RTPrintf("Name: %ls\n", interfaceName.raw());
|
---|
157 | Bstr interfaceGuid;
|
---|
158 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
159 | RTPrintf("GUID: %ls\n", interfaceGuid.raw());
|
---|
160 | BOOL fDHCPEnabled = FALSE;
|
---|
161 | networkInterface->COMGETTER(DHCPEnabled)(&fDHCPEnabled);
|
---|
162 | RTPrintf("DHCP: %s\n", fDHCPEnabled ? "Enabled" : "Disabled");
|
---|
163 |
|
---|
164 | Bstr IPAddress;
|
---|
165 | networkInterface->COMGETTER(IPAddress)(IPAddress.asOutParam());
|
---|
166 | RTPrintf("IPAddress: %ls\n", IPAddress.raw());
|
---|
167 | Bstr NetworkMask;
|
---|
168 | networkInterface->COMGETTER(NetworkMask)(NetworkMask.asOutParam());
|
---|
169 | RTPrintf("NetworkMask: %ls\n", NetworkMask.raw());
|
---|
170 | Bstr IPV6Address;
|
---|
171 | networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
|
---|
172 | RTPrintf("IPV6Address: %ls\n", IPV6Address.raw());
|
---|
173 | ULONG IPV6NetworkMaskPrefixLength;
|
---|
174 | networkInterface->COMGETTER(IPV6NetworkMaskPrefixLength)(&IPV6NetworkMaskPrefixLength);
|
---|
175 | RTPrintf("IPV6NetworkMaskPrefixLength: %d\n", IPV6NetworkMaskPrefixLength);
|
---|
176 | Bstr HardwareAddress;
|
---|
177 | networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
|
---|
178 | RTPrintf("HardwareAddress: %ls\n", HardwareAddress.raw());
|
---|
179 | HostNetworkInterfaceMediumType_T Type;
|
---|
180 | networkInterface->COMGETTER(MediumType)(&Type);
|
---|
181 | RTPrintf("MediumType: %s\n", getHostIfMediumTypeText(Type));
|
---|
182 | BOOL fWireless = FALSE;
|
---|
183 | networkInterface->COMGETTER(Wireless)(&fWireless);
|
---|
184 | RTPrintf("Wireless: %s\n", fWireless ? "Yes" : "No");
|
---|
185 | HostNetworkInterfaceStatus_T Status;
|
---|
186 | networkInterface->COMGETTER(Status)(&Status);
|
---|
187 | RTPrintf("Status: %s\n", getHostIfStatusText(Status));
|
---|
188 | Bstr netName;
|
---|
189 | networkInterface->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
190 | RTPrintf("VBoxNetworkName: %ls\n\n", netName.raw());
|
---|
191 | #endif
|
---|
192 | }
|
---|
193 | return rc;
|
---|
194 | }
|
---|
195 |
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * List host information.
|
---|
199 | *
|
---|
200 | * @returns See produceList.
|
---|
201 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
202 | */
|
---|
203 | static HRESULT listHostInfo(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
204 | {
|
---|
205 | static struct
|
---|
206 | {
|
---|
207 | ProcessorFeature_T feature;
|
---|
208 | const char *pszName;
|
---|
209 | } features[]
|
---|
210 | =
|
---|
211 | {
|
---|
212 | { ProcessorFeature_HWVirtEx, "HW virtualization" },
|
---|
213 | { ProcessorFeature_PAE, "PAE" },
|
---|
214 | { ProcessorFeature_LongMode, "long mode" },
|
---|
215 | { ProcessorFeature_NestedPaging, "nested paging" },
|
---|
216 | { ProcessorFeature_UnrestrictedGuest, "unrestricted guest" },
|
---|
217 | { ProcessorFeature_NestedHWVirt, "nested HW virtualization" },
|
---|
218 | };
|
---|
219 | HRESULT rc;
|
---|
220 | ComPtr<IHost> Host;
|
---|
221 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
222 |
|
---|
223 | RTPrintf("Host Information:\n\n");
|
---|
224 |
|
---|
225 | LONG64 u64UtcTime = 0;
|
---|
226 | CHECK_ERROR(Host, COMGETTER(UTCTime)(&u64UtcTime));
|
---|
227 | RTTIMESPEC timeSpec;
|
---|
228 | char szTime[32];
|
---|
229 | RTPrintf("Host time: %s\n", RTTimeSpecToString(RTTimeSpecSetMilli(&timeSpec, u64UtcTime), szTime, sizeof(szTime)));
|
---|
230 |
|
---|
231 | ULONG processorOnlineCount = 0;
|
---|
232 | CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
|
---|
233 | RTPrintf("Processor online count: %lu\n", processorOnlineCount);
|
---|
234 | ULONG processorCount = 0;
|
---|
235 | CHECK_ERROR(Host, COMGETTER(ProcessorCount)(&processorCount));
|
---|
236 | RTPrintf("Processor count: %lu\n", processorCount);
|
---|
237 | ULONG processorOnlineCoreCount = 0;
|
---|
238 | CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCoreCount)(&processorOnlineCoreCount));
|
---|
239 | RTPrintf("Processor online core count: %lu\n", processorOnlineCoreCount);
|
---|
240 | ULONG processorCoreCount = 0;
|
---|
241 | CHECK_ERROR(Host, COMGETTER(ProcessorCoreCount)(&processorCoreCount));
|
---|
242 | RTPrintf("Processor core count: %lu\n", processorCoreCount);
|
---|
243 | for (unsigned i = 0; i < RT_ELEMENTS(features); i++)
|
---|
244 | {
|
---|
245 | BOOL supported;
|
---|
246 | CHECK_ERROR(Host, GetProcessorFeature(features[i].feature, &supported));
|
---|
247 | RTPrintf("Processor supports %s: %s\n", features[i].pszName, supported ? "yes" : "no");
|
---|
248 | }
|
---|
249 | for (ULONG i = 0; i < processorCount; i++)
|
---|
250 | {
|
---|
251 | ULONG processorSpeed = 0;
|
---|
252 | CHECK_ERROR(Host, GetProcessorSpeed(i, &processorSpeed));
|
---|
253 | if (processorSpeed)
|
---|
254 | RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
|
---|
255 | else
|
---|
256 | RTPrintf("Processor#%u speed: unknown\n", i);
|
---|
257 | Bstr processorDescription;
|
---|
258 | CHECK_ERROR(Host, GetProcessorDescription(i, processorDescription.asOutParam()));
|
---|
259 | RTPrintf("Processor#%u description: %ls\n", i, processorDescription.raw());
|
---|
260 | }
|
---|
261 |
|
---|
262 | ULONG memorySize = 0;
|
---|
263 | CHECK_ERROR(Host, COMGETTER(MemorySize)(&memorySize));
|
---|
264 | RTPrintf("Memory size: %lu MByte\n", memorySize);
|
---|
265 |
|
---|
266 | ULONG memoryAvailable = 0;
|
---|
267 | CHECK_ERROR(Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
|
---|
268 | RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
|
---|
269 |
|
---|
270 | Bstr operatingSystem;
|
---|
271 | CHECK_ERROR(Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
|
---|
272 | RTPrintf("Operating system: %ls\n", operatingSystem.raw());
|
---|
273 |
|
---|
274 | Bstr oSVersion;
|
---|
275 | CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
|
---|
276 | RTPrintf("Operating system version: %ls\n", oSVersion.raw());
|
---|
277 | return rc;
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * List media information.
|
---|
283 | *
|
---|
284 | * @returns See produceList.
|
---|
285 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
286 | * @param aMedia Medium objects to list information for.
|
---|
287 | * @param pszParentUUIDStr String with the parent UUID string (or "base").
|
---|
288 | * @param fOptLong Long (@c true) or short list format.
|
---|
289 | */
|
---|
290 | static HRESULT listMedia(const ComPtr<IVirtualBox> pVirtualBox,
|
---|
291 | const com::SafeIfaceArray<IMedium> &aMedia,
|
---|
292 | const char *pszParentUUIDStr,
|
---|
293 | bool fOptLong)
|
---|
294 | {
|
---|
295 | HRESULT rc = S_OK;
|
---|
296 | for (size_t i = 0; i < aMedia.size(); ++i)
|
---|
297 | {
|
---|
298 | ComPtr<IMedium> pMedium = aMedia[i];
|
---|
299 |
|
---|
300 | rc = showMediumInfo(pVirtualBox, pMedium, pszParentUUIDStr, fOptLong);
|
---|
301 |
|
---|
302 | RTPrintf("\n");
|
---|
303 |
|
---|
304 | com::SafeIfaceArray<IMedium> children;
|
---|
305 | CHECK_ERROR(pMedium, COMGETTER(Children)(ComSafeArrayAsOutParam(children)));
|
---|
306 | if (children.size() > 0)
|
---|
307 | {
|
---|
308 | Bstr uuid;
|
---|
309 | pMedium->COMGETTER(Id)(uuid.asOutParam());
|
---|
310 |
|
---|
311 | // depth first listing of child media
|
---|
312 | rc = listMedia(pVirtualBox, children, Utf8Str(uuid).c_str(), fOptLong);
|
---|
313 | }
|
---|
314 | }
|
---|
315 |
|
---|
316 | return rc;
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 | /**
|
---|
321 | * List virtual image backends.
|
---|
322 | *
|
---|
323 | * @returns See produceList.
|
---|
324 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
325 | */
|
---|
326 | static HRESULT listHddBackends(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
327 | {
|
---|
328 | HRESULT rc;
|
---|
329 | ComPtr<ISystemProperties> systemProperties;
|
---|
330 | CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
|
---|
331 | com::SafeIfaceArray<IMediumFormat> mediumFormats;
|
---|
332 | CHECK_ERROR(systemProperties, COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
|
---|
333 |
|
---|
334 | RTPrintf("Supported hard disk backends:\n\n");
|
---|
335 | for (size_t i = 0; i < mediumFormats.size(); ++i)
|
---|
336 | {
|
---|
337 | /* General information */
|
---|
338 | Bstr id;
|
---|
339 | CHECK_ERROR(mediumFormats[i], COMGETTER(Id)(id.asOutParam()));
|
---|
340 |
|
---|
341 | Bstr description;
|
---|
342 | CHECK_ERROR(mediumFormats[i],
|
---|
343 | COMGETTER(Name)(description.asOutParam()));
|
---|
344 |
|
---|
345 | ULONG caps = 0;
|
---|
346 | com::SafeArray <MediumFormatCapabilities_T> mediumFormatCap;
|
---|
347 | CHECK_ERROR(mediumFormats[i],
|
---|
348 | COMGETTER(Capabilities)(ComSafeArrayAsOutParam(mediumFormatCap)));
|
---|
349 | for (ULONG j = 0; j < mediumFormatCap.size(); j++)
|
---|
350 | caps |= mediumFormatCap[j];
|
---|
351 |
|
---|
352 |
|
---|
353 | RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
|
---|
354 | i, id.raw(), description.raw(), caps);
|
---|
355 |
|
---|
356 | /* File extensions */
|
---|
357 | com::SafeArray<BSTR> fileExtensions;
|
---|
358 | com::SafeArray<DeviceType_T> deviceTypes;
|
---|
359 | CHECK_ERROR(mediumFormats[i],
|
---|
360 | DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes)));
|
---|
361 | for (size_t j = 0; j < fileExtensions.size(); ++j)
|
---|
362 | {
|
---|
363 | RTPrintf("%ls (%s)", Bstr(fileExtensions[j]).raw(), getDeviceTypeText(deviceTypes[j]));
|
---|
364 | if (j != fileExtensions.size()-1)
|
---|
365 | RTPrintf(",");
|
---|
366 | }
|
---|
367 | RTPrintf("'");
|
---|
368 |
|
---|
369 | /* Configuration keys */
|
---|
370 | com::SafeArray<BSTR> propertyNames;
|
---|
371 | com::SafeArray<BSTR> propertyDescriptions;
|
---|
372 | com::SafeArray<DataType_T> propertyTypes;
|
---|
373 | com::SafeArray<ULONG> propertyFlags;
|
---|
374 | com::SafeArray<BSTR> propertyDefaults;
|
---|
375 | CHECK_ERROR(mediumFormats[i],
|
---|
376 | DescribeProperties(ComSafeArrayAsOutParam(propertyNames),
|
---|
377 | ComSafeArrayAsOutParam(propertyDescriptions),
|
---|
378 | ComSafeArrayAsOutParam(propertyTypes),
|
---|
379 | ComSafeArrayAsOutParam(propertyFlags),
|
---|
380 | ComSafeArrayAsOutParam(propertyDefaults)));
|
---|
381 |
|
---|
382 | RTPrintf(" properties=(");
|
---|
383 | if (propertyNames.size() > 0)
|
---|
384 | {
|
---|
385 | for (size_t j = 0; j < propertyNames.size(); ++j)
|
---|
386 | {
|
---|
387 | RTPrintf("\n name='%ls' desc='%ls' type=",
|
---|
388 | Bstr(propertyNames[j]).raw(), Bstr(propertyDescriptions[j]).raw());
|
---|
389 | switch (propertyTypes[j])
|
---|
390 | {
|
---|
391 | case DataType_Int32: RTPrintf("int"); break;
|
---|
392 | case DataType_Int8: RTPrintf("byte"); break;
|
---|
393 | case DataType_String: RTPrintf("string"); break;
|
---|
394 | #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
|
---|
395 | case DataType_32BitHack: break; /* Shut up compiler warnings. */
|
---|
396 | #endif
|
---|
397 | }
|
---|
398 | RTPrintf(" flags=%#04x", propertyFlags[j]);
|
---|
399 | RTPrintf(" default='%ls'", Bstr(propertyDefaults[j]).raw());
|
---|
400 | if (j != propertyNames.size()-1)
|
---|
401 | RTPrintf(", ");
|
---|
402 | }
|
---|
403 | }
|
---|
404 | RTPrintf(")\n");
|
---|
405 | }
|
---|
406 | return rc;
|
---|
407 | }
|
---|
408 |
|
---|
409 |
|
---|
410 | /**
|
---|
411 | * List USB devices attached to the host.
|
---|
412 | *
|
---|
413 | * @returns See produceList.
|
---|
414 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
415 | */
|
---|
416 | static HRESULT listUsbHost(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
417 | {
|
---|
418 | HRESULT rc;
|
---|
419 | ComPtr<IHost> Host;
|
---|
420 | CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
|
---|
421 |
|
---|
422 | SafeIfaceArray<IHostUSBDevice> CollPtr;
|
---|
423 | CHECK_ERROR_RET(Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1);
|
---|
424 |
|
---|
425 | RTPrintf("Host USB Devices:\n\n");
|
---|
426 |
|
---|
427 | if (CollPtr.size() == 0)
|
---|
428 | {
|
---|
429 | RTPrintf("<none>\n\n");
|
---|
430 | }
|
---|
431 | else
|
---|
432 | {
|
---|
433 | for (size_t i = 0; i < CollPtr.size(); ++i)
|
---|
434 | {
|
---|
435 | ComPtr<IHostUSBDevice> dev = CollPtr[i];
|
---|
436 |
|
---|
437 | /* Query info. */
|
---|
438 | Bstr id;
|
---|
439 | CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), 1);
|
---|
440 | USHORT usVendorId;
|
---|
441 | CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), 1);
|
---|
442 | USHORT usProductId;
|
---|
443 | CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), 1);
|
---|
444 | USHORT bcdRevision;
|
---|
445 | CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), 1);
|
---|
446 | USHORT usPort;
|
---|
447 | CHECK_ERROR_RET(dev, COMGETTER(Port)(&usPort), 1);
|
---|
448 | USHORT usVersion;
|
---|
449 | CHECK_ERROR_RET(dev, COMGETTER(Version)(&usVersion), 1);
|
---|
450 | USBConnectionSpeed_T enmSpeed;
|
---|
451 | CHECK_ERROR_RET(dev, COMGETTER(Speed)(&enmSpeed), 1);
|
---|
452 |
|
---|
453 | RTPrintf("UUID: %s\n"
|
---|
454 | "VendorId: %#06x (%04X)\n"
|
---|
455 | "ProductId: %#06x (%04X)\n"
|
---|
456 | "Revision: %u.%u (%02u%02u)\n"
|
---|
457 | "Port: %u\n",
|
---|
458 | Utf8Str(id).c_str(),
|
---|
459 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
460 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
461 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
462 | usPort);
|
---|
463 |
|
---|
464 | const char *pszSpeed = "?";
|
---|
465 | switch (enmSpeed)
|
---|
466 | {
|
---|
467 | case USBConnectionSpeed_Low:
|
---|
468 | pszSpeed = "Low";
|
---|
469 | break;
|
---|
470 | case USBConnectionSpeed_Full:
|
---|
471 | pszSpeed = "Full";
|
---|
472 | break;
|
---|
473 | case USBConnectionSpeed_High:
|
---|
474 | pszSpeed = "High";
|
---|
475 | break;
|
---|
476 | case USBConnectionSpeed_Super:
|
---|
477 | pszSpeed = "Super";
|
---|
478 | break;
|
---|
479 | case USBConnectionSpeed_SuperPlus:
|
---|
480 | pszSpeed = "SuperPlus";
|
---|
481 | break;
|
---|
482 | default:
|
---|
483 | ASSERT(false);
|
---|
484 | break;
|
---|
485 | }
|
---|
486 |
|
---|
487 | RTPrintf("USB version/speed: %u/%s\n", usVersion, pszSpeed);
|
---|
488 |
|
---|
489 | /* optional stuff. */
|
---|
490 | SafeArray<BSTR> CollDevInfo;
|
---|
491 | Bstr bstr;
|
---|
492 | CHECK_ERROR_RET(dev, COMGETTER(DeviceInfo)(ComSafeArrayAsOutParam(CollDevInfo)), 1);
|
---|
493 | if (CollDevInfo.size() >= 1)
|
---|
494 | bstr = Bstr(CollDevInfo[0]);
|
---|
495 | if (!bstr.isEmpty())
|
---|
496 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
497 | if (CollDevInfo.size() >= 2)
|
---|
498 | bstr = Bstr(CollDevInfo[1]);
|
---|
499 | if (!bstr.isEmpty())
|
---|
500 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
501 | CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
502 | if (!bstr.isEmpty())
|
---|
503 | RTPrintf("SerialNumber: %ls\n", bstr.raw());
|
---|
504 | CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), 1);
|
---|
505 | if (!bstr.isEmpty())
|
---|
506 | RTPrintf("Address: %ls\n", bstr.raw());
|
---|
507 | CHECK_ERROR_RET(dev, COMGETTER(PortPath)(bstr.asOutParam()), 1);
|
---|
508 | if (!bstr.isEmpty())
|
---|
509 | RTPrintf("Port path: %ls\n", bstr.raw());
|
---|
510 |
|
---|
511 | /* current state */
|
---|
512 | USBDeviceState_T state;
|
---|
513 | CHECK_ERROR_RET(dev, COMGETTER(State)(&state), 1);
|
---|
514 | const char *pszState = "?";
|
---|
515 | switch (state)
|
---|
516 | {
|
---|
517 | case USBDeviceState_NotSupported:
|
---|
518 | pszState = "Not supported";
|
---|
519 | break;
|
---|
520 | case USBDeviceState_Unavailable:
|
---|
521 | pszState = "Unavailable";
|
---|
522 | break;
|
---|
523 | case USBDeviceState_Busy:
|
---|
524 | pszState = "Busy";
|
---|
525 | break;
|
---|
526 | case USBDeviceState_Available:
|
---|
527 | pszState = "Available";
|
---|
528 | break;
|
---|
529 | case USBDeviceState_Held:
|
---|
530 | pszState = "Held";
|
---|
531 | break;
|
---|
532 | case USBDeviceState_Captured:
|
---|
533 | pszState = "Captured";
|
---|
534 | break;
|
---|
535 | default:
|
---|
536 | ASSERT(false);
|
---|
537 | break;
|
---|
538 | }
|
---|
539 | RTPrintf("Current State: %s\n\n", pszState);
|
---|
540 | }
|
---|
541 | }
|
---|
542 | return rc;
|
---|
543 | }
|
---|
544 |
|
---|
545 |
|
---|
546 | /**
|
---|
547 | * List USB filters.
|
---|
548 | *
|
---|
549 | * @returns See produceList.
|
---|
550 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
551 | */
|
---|
552 | static HRESULT listUsbFilters(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
553 | {
|
---|
554 | HRESULT rc;
|
---|
555 |
|
---|
556 | RTPrintf("Global USB Device Filters:\n\n");
|
---|
557 |
|
---|
558 | ComPtr<IHost> host;
|
---|
559 | CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(host.asOutParam()), 1);
|
---|
560 |
|
---|
561 | SafeIfaceArray<IHostUSBDeviceFilter> coll;
|
---|
562 | CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
|
---|
563 |
|
---|
564 | if (coll.size() == 0)
|
---|
565 | {
|
---|
566 | RTPrintf("<none>\n\n");
|
---|
567 | }
|
---|
568 | else
|
---|
569 | {
|
---|
570 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
571 | {
|
---|
572 | ComPtr<IHostUSBDeviceFilter> flt = coll[index];
|
---|
573 |
|
---|
574 | /* Query info. */
|
---|
575 |
|
---|
576 | RTPrintf("Index: %zu\n", index);
|
---|
577 |
|
---|
578 | BOOL active = FALSE;
|
---|
579 | CHECK_ERROR_RET(flt, COMGETTER(Active)(&active), 1);
|
---|
580 | RTPrintf("Active: %s\n", active ? "yes" : "no");
|
---|
581 |
|
---|
582 | USBDeviceFilterAction_T action;
|
---|
583 | CHECK_ERROR_RET(flt, COMGETTER(Action)(&action), 1);
|
---|
584 | const char *pszAction = "<invalid>";
|
---|
585 | switch (action)
|
---|
586 | {
|
---|
587 | case USBDeviceFilterAction_Ignore:
|
---|
588 | pszAction = "Ignore";
|
---|
589 | break;
|
---|
590 | case USBDeviceFilterAction_Hold:
|
---|
591 | pszAction = "Hold";
|
---|
592 | break;
|
---|
593 | default:
|
---|
594 | break;
|
---|
595 | }
|
---|
596 | RTPrintf("Action: %s\n", pszAction);
|
---|
597 |
|
---|
598 | Bstr bstr;
|
---|
599 | CHECK_ERROR_RET(flt, COMGETTER(Name)(bstr.asOutParam()), 1);
|
---|
600 | RTPrintf("Name: %ls\n", bstr.raw());
|
---|
601 | CHECK_ERROR_RET(flt, COMGETTER(VendorId)(bstr.asOutParam()), 1);
|
---|
602 | RTPrintf("VendorId: %ls\n", bstr.raw());
|
---|
603 | CHECK_ERROR_RET(flt, COMGETTER(ProductId)(bstr.asOutParam()), 1);
|
---|
604 | RTPrintf("ProductId: %ls\n", bstr.raw());
|
---|
605 | CHECK_ERROR_RET(flt, COMGETTER(Revision)(bstr.asOutParam()), 1);
|
---|
606 | RTPrintf("Revision: %ls\n", bstr.raw());
|
---|
607 | CHECK_ERROR_RET(flt, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
|
---|
608 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
609 | CHECK_ERROR_RET(flt, COMGETTER(Product)(bstr.asOutParam()), 1);
|
---|
610 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
611 | CHECK_ERROR_RET(flt, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
612 | RTPrintf("Serial Number: %ls\n\n", bstr.raw());
|
---|
613 | }
|
---|
614 | }
|
---|
615 | return rc;
|
---|
616 | }
|
---|
617 |
|
---|
618 |
|
---|
619 | /**
|
---|
620 | * List system properties.
|
---|
621 | *
|
---|
622 | * @returns See produceList.
|
---|
623 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
624 | */
|
---|
625 | static HRESULT listSystemProperties(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
626 | {
|
---|
627 | ComPtr<ISystemProperties> systemProperties;
|
---|
628 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), hrcCheck);
|
---|
629 |
|
---|
630 | Bstr str;
|
---|
631 | ULONG ulValue;
|
---|
632 | LONG64 i64Value;
|
---|
633 | BOOL fValue;
|
---|
634 | const char *psz;
|
---|
635 |
|
---|
636 | pVirtualBox->COMGETTER(APIVersion)(str.asOutParam());
|
---|
637 | RTPrintf("API version: %ls\n", str.raw());
|
---|
638 |
|
---|
639 | systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
|
---|
640 | RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
|
---|
641 | systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
|
---|
642 | RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
|
---|
643 | systemProperties->COMGETTER(MinGuestVRAM)(&ulValue);
|
---|
644 | RTPrintf("Minimum video RAM size: %u Megabytes\n", ulValue);
|
---|
645 | systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
|
---|
646 | RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
|
---|
647 | systemProperties->COMGETTER(MaxGuestMonitors)(&ulValue);
|
---|
648 | RTPrintf("Maximum guest monitor count: %u\n", ulValue);
|
---|
649 | systemProperties->COMGETTER(MinGuestCPUCount)(&ulValue);
|
---|
650 | RTPrintf("Minimum guest CPU count: %u\n", ulValue);
|
---|
651 | systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
|
---|
652 | RTPrintf("Maximum guest CPU count: %u\n", ulValue);
|
---|
653 | systemProperties->COMGETTER(InfoVDSize)(&i64Value);
|
---|
654 | RTPrintf("Virtual disk limit (info): %lld Bytes\n", i64Value);
|
---|
655 | systemProperties->COMGETTER(SerialPortCount)(&ulValue);
|
---|
656 | RTPrintf("Maximum Serial Port count: %u\n", ulValue);
|
---|
657 | systemProperties->COMGETTER(ParallelPortCount)(&ulValue);
|
---|
658 | RTPrintf("Maximum Parallel Port count: %u\n", ulValue);
|
---|
659 | systemProperties->COMGETTER(MaxBootPosition)(&ulValue);
|
---|
660 | RTPrintf("Maximum Boot Position: %u\n", ulValue);
|
---|
661 | systemProperties->GetMaxNetworkAdapters(ChipsetType_PIIX3, &ulValue);
|
---|
662 | RTPrintf("Maximum PIIX3 Network Adapter count: %u\n", ulValue);
|
---|
663 | systemProperties->GetMaxNetworkAdapters(ChipsetType_ICH9, &ulValue);
|
---|
664 | RTPrintf("Maximum ICH9 Network Adapter count: %u\n", ulValue);
|
---|
665 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_IDE, &ulValue);
|
---|
666 | RTPrintf("Maximum PIIX3 IDE Controllers: %u\n", ulValue);
|
---|
667 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_IDE, &ulValue);
|
---|
668 | RTPrintf("Maximum ICH9 IDE Controllers: %u\n", ulValue);
|
---|
669 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_IDE, &ulValue);
|
---|
670 | RTPrintf("Maximum IDE Port count: %u\n", ulValue);
|
---|
671 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_IDE, &ulValue);
|
---|
672 | RTPrintf("Maximum Devices per IDE Port: %u\n", ulValue);
|
---|
673 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SATA, &ulValue);
|
---|
674 | RTPrintf("Maximum PIIX3 SATA Controllers: %u\n", ulValue);
|
---|
675 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SATA, &ulValue);
|
---|
676 | RTPrintf("Maximum ICH9 SATA Controllers: %u\n", ulValue);
|
---|
677 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SATA, &ulValue);
|
---|
678 | RTPrintf("Maximum SATA Port count: %u\n", ulValue);
|
---|
679 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SATA, &ulValue);
|
---|
680 | RTPrintf("Maximum Devices per SATA Port: %u\n", ulValue);
|
---|
681 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SCSI, &ulValue);
|
---|
682 | RTPrintf("Maximum PIIX3 SCSI Controllers: %u\n", ulValue);
|
---|
683 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SCSI, &ulValue);
|
---|
684 | RTPrintf("Maximum ICH9 SCSI Controllers: %u\n", ulValue);
|
---|
685 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
686 | RTPrintf("Maximum SCSI Port count: %u\n", ulValue);
|
---|
687 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
688 | RTPrintf("Maximum Devices per SCSI Port: %u\n", ulValue);
|
---|
689 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SAS, &ulValue);
|
---|
690 | RTPrintf("Maximum SAS PIIX3 Controllers: %u\n", ulValue);
|
---|
691 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SAS, &ulValue);
|
---|
692 | RTPrintf("Maximum SAS ICH9 Controllers: %u\n", ulValue);
|
---|
693 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SAS, &ulValue);
|
---|
694 | RTPrintf("Maximum SAS Port count: %u\n", ulValue);
|
---|
695 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SAS, &ulValue);
|
---|
696 | RTPrintf("Maximum Devices per SAS Port: %u\n", ulValue);
|
---|
697 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_PCIe, &ulValue);
|
---|
698 | RTPrintf("Maximum NVMe PIIX3 Controllers: %u\n", ulValue);
|
---|
699 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_PCIe, &ulValue);
|
---|
700 | RTPrintf("Maximum NVMe ICH9 Controllers: %u\n", ulValue);
|
---|
701 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_PCIe, &ulValue);
|
---|
702 | RTPrintf("Maximum NVMe Port count: %u\n", ulValue);
|
---|
703 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_PCIe, &ulValue);
|
---|
704 | RTPrintf("Maximum Devices per NVMe Port: %u\n", ulValue);
|
---|
705 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_VirtioSCSI, &ulValue);
|
---|
706 | RTPrintf("Maximum virtio-scsi PIIX3 Controllers: %u\n", ulValue);
|
---|
707 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_VirtioSCSI, &ulValue);
|
---|
708 | RTPrintf("Maximum virtio-scsi ICH9 Controllers: %u\n", ulValue);
|
---|
709 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_VirtioSCSI, &ulValue);
|
---|
710 | RTPrintf("Maximum virtio-scsi Port count: %u\n", ulValue);
|
---|
711 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_VirtioSCSI, &ulValue);
|
---|
712 | RTPrintf("Maximum Devices per virtio-scsi Port: %u\n", ulValue);
|
---|
713 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_Floppy, &ulValue);
|
---|
714 | RTPrintf("Maximum PIIX3 Floppy Controllers:%u\n", ulValue);
|
---|
715 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_Floppy, &ulValue);
|
---|
716 | RTPrintf("Maximum ICH9 Floppy Controllers: %u\n", ulValue);
|
---|
717 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
718 | RTPrintf("Maximum Floppy Port count: %u\n", ulValue);
|
---|
719 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
720 | RTPrintf("Maximum Devices per Floppy Port: %u\n", ulValue);
|
---|
721 | #if 0
|
---|
722 | systemProperties->GetFreeDiskSpaceWarning(&i64Value);
|
---|
723 | RTPrintf("Free disk space warning at: %u Bytes\n", i64Value);
|
---|
724 | systemProperties->GetFreeDiskSpacePercentWarning(&ulValue);
|
---|
725 | RTPrintf("Free disk space warning at: %u %%\n", ulValue);
|
---|
726 | systemProperties->GetFreeDiskSpaceError(&i64Value);
|
---|
727 | RTPrintf("Free disk space error at: %u Bytes\n", i64Value);
|
---|
728 | systemProperties->GetFreeDiskSpacePercentError(&ulValue);
|
---|
729 | RTPrintf("Free disk space error at: %u %%\n", ulValue);
|
---|
730 | #endif
|
---|
731 | systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
|
---|
732 | RTPrintf("Default machine folder: %ls\n", str.raw());
|
---|
733 | systemProperties->COMGETTER(RawModeSupported)(&fValue);
|
---|
734 | RTPrintf("Raw-mode Supported: %s\n", fValue ? "yes" : "no");
|
---|
735 | systemProperties->COMGETTER(ExclusiveHwVirt)(&fValue);
|
---|
736 | RTPrintf("Exclusive HW virtualization use: %s\n", fValue ? "on" : "off");
|
---|
737 | systemProperties->COMGETTER(DefaultHardDiskFormat)(str.asOutParam());
|
---|
738 | RTPrintf("Default hard disk format: %ls\n", str.raw());
|
---|
739 | systemProperties->COMGETTER(VRDEAuthLibrary)(str.asOutParam());
|
---|
740 | RTPrintf("VRDE auth library: %ls\n", str.raw());
|
---|
741 | systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
|
---|
742 | RTPrintf("Webservice auth. library: %ls\n", str.raw());
|
---|
743 | systemProperties->COMGETTER(DefaultVRDEExtPack)(str.asOutParam());
|
---|
744 | RTPrintf("Remote desktop ExtPack: %ls\n", str.raw());
|
---|
745 | systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
|
---|
746 | RTPrintf("Log history count: %u\n", ulValue);
|
---|
747 | systemProperties->COMGETTER(DefaultFrontend)(str.asOutParam());
|
---|
748 | RTPrintf("Default frontend: %ls\n", str.raw());
|
---|
749 | AudioDriverType_T enmAudio;
|
---|
750 | systemProperties->COMGETTER(DefaultAudioDriver)(&enmAudio);
|
---|
751 | switch (enmAudio)
|
---|
752 | {
|
---|
753 | case AudioDriverType_Null: psz = "Null"; break;
|
---|
754 | case AudioDriverType_WinMM: psz = "WinMM"; break;
|
---|
755 | case AudioDriverType_OSS: psz = "OSS"; break;
|
---|
756 | case AudioDriverType_ALSA: psz = "ALSA"; break;
|
---|
757 | case AudioDriverType_DirectSound: psz = "DirectSound"; break;
|
---|
758 | case AudioDriverType_CoreAudio: psz = "CoreAudio"; break;
|
---|
759 | case AudioDriverType_MMPM: psz = "MMPM"; break;
|
---|
760 | case AudioDriverType_Pulse: psz = "Pulse"; break;
|
---|
761 | case AudioDriverType_SolAudio: psz = "SolAudio"; break;
|
---|
762 | default: psz = "Unknown";
|
---|
763 | }
|
---|
764 | RTPrintf("Default audio driver: %s\n", psz);
|
---|
765 | systemProperties->COMGETTER(AutostartDatabasePath)(str.asOutParam());
|
---|
766 | RTPrintf("Autostart database path: %ls\n", str.raw());
|
---|
767 | systemProperties->COMGETTER(DefaultAdditionsISO)(str.asOutParam());
|
---|
768 | RTPrintf("Default Guest Additions ISO: %ls\n", str.raw());
|
---|
769 | systemProperties->COMGETTER(LoggingLevel)(str.asOutParam());
|
---|
770 | RTPrintf("Logging Level: %ls\n", str.raw());
|
---|
771 | ProxyMode_T enmProxyMode = (ProxyMode_T)42;
|
---|
772 | systemProperties->COMGETTER(ProxyMode)(&enmProxyMode);
|
---|
773 | psz = "Unknown";
|
---|
774 | switch (enmProxyMode)
|
---|
775 | {
|
---|
776 | case ProxyMode_System: psz = "System"; break;
|
---|
777 | case ProxyMode_NoProxy: psz = "NoProxy"; break;
|
---|
778 | case ProxyMode_Manual: psz = "Manual"; break;
|
---|
779 | #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
|
---|
780 | case ProxyMode_32BitHack: break; /* Shut up compiler warnings. */
|
---|
781 | #endif
|
---|
782 | }
|
---|
783 | RTPrintf("Proxy Mode: %s\n", psz);
|
---|
784 | systemProperties->COMGETTER(ProxyURL)(str.asOutParam());
|
---|
785 | RTPrintf("Proxy URL: %ls\n", str.raw());
|
---|
786 | return S_OK;
|
---|
787 | }
|
---|
788 |
|
---|
789 |
|
---|
790 | /**
|
---|
791 | * Helper for listDhcpServers() that shows a DHCP configuration.
|
---|
792 | */
|
---|
793 | static HRESULT showDhcpConfig(ComPtr<IDHCPConfig> ptrConfig)
|
---|
794 | {
|
---|
795 | HRESULT hrcRet = S_OK;
|
---|
796 |
|
---|
797 | ULONG secs = 0;
|
---|
798 | CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MinLeaseTime)(&secs), hrcRet = hrcCheck);
|
---|
799 | if (secs == 0)
|
---|
800 | RTPrintf(" minLeaseTime: default\n");
|
---|
801 | else
|
---|
802 | RTPrintf(" minLeaseTime: %u sec\n", secs);
|
---|
803 |
|
---|
804 | secs = 0;
|
---|
805 | CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(DefaultLeaseTime)(&secs), hrcRet = hrcCheck);
|
---|
806 | if (secs == 0)
|
---|
807 | RTPrintf(" defaultLeaseTime: default\n");
|
---|
808 | else
|
---|
809 | RTPrintf(" defaultLeaseTime: %u sec\n", secs);
|
---|
810 |
|
---|
811 | secs = 0;
|
---|
812 | CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MaxLeaseTime)(&secs), hrcRet = hrcCheck);
|
---|
813 | if (secs == 0)
|
---|
814 | RTPrintf(" maxLeaseTime: default\n");
|
---|
815 | else
|
---|
816 | RTPrintf(" maxLeaseTime: %u sec\n", secs);
|
---|
817 |
|
---|
818 | com::SafeArray<DHCPOption_T> Options;
|
---|
819 | HRESULT hrc;
|
---|
820 | CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(ForcedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
|
---|
821 | if (FAILED(hrc))
|
---|
822 | RTPrintf(" Forced options: %Rhrc\n", hrc);
|
---|
823 | else if (Options.size() == 0)
|
---|
824 | RTPrintf(" Forced options: None\n");
|
---|
825 | else
|
---|
826 | {
|
---|
827 | RTPrintf(" Forced options: ");
|
---|
828 | for (size_t i = 0; i < Options.size(); i++)
|
---|
829 | RTPrintf(i ? ", %u" : "%u", Options[i]);
|
---|
830 | RTPrintf("\n");
|
---|
831 | }
|
---|
832 |
|
---|
833 | CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(SuppressedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
|
---|
834 | if (FAILED(hrc))
|
---|
835 | RTPrintf(" Suppressed opt.s: %Rhrc\n", hrc);
|
---|
836 | else if (Options.size() == 0)
|
---|
837 | RTPrintf(" Suppressed opts.: None\n");
|
---|
838 | else
|
---|
839 | {
|
---|
840 | RTPrintf(" Suppressed opts.: ");
|
---|
841 | for (size_t i = 0; i < Options.size(); i++)
|
---|
842 | RTPrintf(i ? ", %u" : "%u", Options[i]);
|
---|
843 | RTPrintf("\n");
|
---|
844 | }
|
---|
845 |
|
---|
846 | com::SafeArray<DHCPOptionEncoding_T> Encodings;
|
---|
847 | com::SafeArray<BSTR> Values;
|
---|
848 | CHECK_ERROR2_STMT(hrc, ptrConfig, GetAllOptions(ComSafeArrayAsOutParam(Options),
|
---|
849 | ComSafeArrayAsOutParam(Encodings),
|
---|
850 | ComSafeArrayAsOutParam(Values)), hrcRet = hrc);
|
---|
851 | if (FAILED(hrc))
|
---|
852 | RTPrintf(" DHCP options: %Rhrc\n", hrc);
|
---|
853 | else if (Options.size() != Encodings.size() || Options.size() != Values.size())
|
---|
854 | {
|
---|
855 | RTPrintf(" DHCP options: Return count mismatch: %zu, %zu, %zu\n", Options.size(), Encodings.size(), Values.size());
|
---|
856 | hrcRet = E_FAIL;
|
---|
857 | }
|
---|
858 | else if (Options.size() == 0)
|
---|
859 | RTPrintf(" DHCP options: None\n");
|
---|
860 | else
|
---|
861 | for (size_t i = 0; i < Options.size(); i++)
|
---|
862 | {
|
---|
863 | switch (Encodings[i])
|
---|
864 | {
|
---|
865 | case DHCPOptionEncoding_Normal:
|
---|
866 | RTPrintf(" %3d/legacy: %ls\n", Options[i], Values[i]);
|
---|
867 | break;
|
---|
868 | case DHCPOptionEncoding_Hex:
|
---|
869 | RTPrintf(" %3d/hex: %ls\n", Options[i], Values[i]);
|
---|
870 | break;
|
---|
871 | default:
|
---|
872 | RTPrintf(" %3d/%u?: %ls\n", Options[i], Encodings[i], Values[i]);
|
---|
873 | break;
|
---|
874 | }
|
---|
875 | }
|
---|
876 |
|
---|
877 | return S_OK;
|
---|
878 | }
|
---|
879 |
|
---|
880 |
|
---|
881 | /**
|
---|
882 | * List DHCP servers.
|
---|
883 | *
|
---|
884 | * @returns See produceList.
|
---|
885 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
886 | */
|
---|
887 | static HRESULT listDhcpServers(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
888 | {
|
---|
889 | HRESULT hrcRet = S_OK;
|
---|
890 | com::SafeIfaceArray<IDHCPServer> DHCPServers;
|
---|
891 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers)), hrcCheck);
|
---|
892 | for (size_t i = 0; i < DHCPServers.size(); ++i)
|
---|
893 | {
|
---|
894 | if (i > 0)
|
---|
895 | RTPrintf("\n");
|
---|
896 |
|
---|
897 | ComPtr<IDHCPServer> ptrDHCPServer = DHCPServers[i];
|
---|
898 | Bstr bstr;
|
---|
899 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkName)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
900 | RTPrintf("NetworkName: %ls\n", bstr.raw());
|
---|
901 |
|
---|
902 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(IPAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
903 | RTPrintf("Dhcpd IP: %ls\n", bstr.raw());
|
---|
904 |
|
---|
905 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(LowerIP)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
906 | RTPrintf("LowerIPAddress: %ls\n", bstr.raw());
|
---|
907 |
|
---|
908 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(UpperIP)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
909 | RTPrintf("UpperIPAddress: %ls\n", bstr.raw());
|
---|
910 |
|
---|
911 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkMask)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
912 | RTPrintf("NetworkMask: %ls\n", bstr.raw());
|
---|
913 |
|
---|
914 | BOOL fEnabled = FALSE;
|
---|
915 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(Enabled)(&fEnabled), hrcRet = hrcCheck);
|
---|
916 | RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
917 |
|
---|
918 | /* Global configuration: */
|
---|
919 | RTPrintf("Global Configuration:\n");
|
---|
920 | HRESULT hrc;
|
---|
921 | ComPtr<IDHCPGlobalConfig> ptrGlobal;
|
---|
922 | CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GlobalConfig)(ptrGlobal.asOutParam()), hrcRet = hrc);
|
---|
923 | if (SUCCEEDED(hrc))
|
---|
924 | {
|
---|
925 | hrc = showDhcpConfig(ptrGlobal);
|
---|
926 | if (FAILED(hrc))
|
---|
927 | hrcRet = hrc;
|
---|
928 | }
|
---|
929 |
|
---|
930 | /* Group configurations: */
|
---|
931 | com::SafeIfaceArray<IDHCPGroupConfig> Groups;
|
---|
932 | CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GroupConfigs)(ComSafeArrayAsOutParam(Groups)), hrcRet = hrc);
|
---|
933 | if (FAILED(hrc))
|
---|
934 | RTPrintf("Groups: %Rrc\n", hrc);
|
---|
935 | else if (Groups.size() == 0)
|
---|
936 | RTPrintf("Groups: None\n");
|
---|
937 | else
|
---|
938 | {
|
---|
939 | for (size_t iGrp = 0; iGrp < Groups.size(); iGrp++)
|
---|
940 | {
|
---|
941 | CHECK_ERROR2I_STMT(Groups[iGrp], COMGETTER(Name)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
942 | RTPrintf("Group: %ls\n", bstr.raw());
|
---|
943 |
|
---|
944 | com::SafeIfaceArray<IDHCPGroupCondition> Conditions;
|
---|
945 | CHECK_ERROR2_STMT(hrc, Groups[iGrp], COMGETTER(Conditions)(ComSafeArrayAsOutParam(Conditions)), hrcRet = hrc);
|
---|
946 | if (FAILED(hrc))
|
---|
947 | RTPrintf(" Conditions: %Rhrc\n", hrc);
|
---|
948 | else if (Conditions.size() == 0)
|
---|
949 | RTPrintf(" Conditions: None\n");
|
---|
950 | else
|
---|
951 | for (size_t iCond = 0; iCond < Conditions.size(); iCond++)
|
---|
952 | {
|
---|
953 | BOOL fInclusive = TRUE;
|
---|
954 | CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Inclusive)(&fInclusive), hrcRet = hrc);
|
---|
955 | DHCPGroupConditionType_T enmType = DHCPGroupConditionType_MAC;
|
---|
956 | CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Type)(&enmType), hrcRet = hrc);
|
---|
957 | CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Value)(bstr.asOutParam()), hrcRet = hrc);
|
---|
958 |
|
---|
959 | RTPrintf(" Conditions: %s %s %ls\n",
|
---|
960 | fInclusive ? "include" : "exclude",
|
---|
961 | enmType == DHCPGroupConditionType_MAC ? "MAC "
|
---|
962 | : enmType == DHCPGroupConditionType_MACWildcard ? "MAC* "
|
---|
963 | : enmType == DHCPGroupConditionType_vendorClassID ? "VendorCID "
|
---|
964 | : enmType == DHCPGroupConditionType_vendorClassIDWildcard ? "VendorCID*"
|
---|
965 | : enmType == DHCPGroupConditionType_userClassID ? "UserCID "
|
---|
966 | : enmType == DHCPGroupConditionType_userClassIDWildcard ? "UserCID* "
|
---|
967 | : "!UNKNOWN! ",
|
---|
968 | bstr.raw());
|
---|
969 | }
|
---|
970 |
|
---|
971 | hrc = showDhcpConfig(Groups[iGrp]);
|
---|
972 | if (FAILED(hrc))
|
---|
973 | hrcRet = hrc;
|
---|
974 | }
|
---|
975 | Groups.setNull();
|
---|
976 | }
|
---|
977 |
|
---|
978 | /* Individual host / NIC configurations: */
|
---|
979 | com::SafeIfaceArray<IDHCPIndividualConfig> Hosts;
|
---|
980 | CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(IndividualConfigs)(ComSafeArrayAsOutParam(Hosts)), hrcRet = hrc);
|
---|
981 | if (FAILED(hrc))
|
---|
982 | RTPrintf("Individual Configs: %Rrc\n", hrc);
|
---|
983 | else if (Hosts.size() == 0)
|
---|
984 | RTPrintf("Individual Configs: None\n");
|
---|
985 | else
|
---|
986 | {
|
---|
987 | for (size_t iHost = 0; iHost < Hosts.size(); iHost++)
|
---|
988 | {
|
---|
989 | DHCPConfigScope_T enmScope = DHCPConfigScope_MAC;
|
---|
990 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Scope)(&enmScope), hrcRet = hrcCheck);
|
---|
991 |
|
---|
992 | if (enmScope == DHCPConfigScope_MAC)
|
---|
993 | {
|
---|
994 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MACAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
995 | RTPrintf("Individual Config: MAC %ls\n", bstr.raw());
|
---|
996 | }
|
---|
997 | else
|
---|
998 | {
|
---|
999 | ULONG uSlot = 0;
|
---|
1000 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Slot)(&uSlot), hrcRet = hrcCheck);
|
---|
1001 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MachineId)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
1002 | Bstr bstrMACAddress;
|
---|
1003 | hrc = Hosts[iHost]->COMGETTER(MACAddress)(bstrMACAddress.asOutParam()); /* No CHECK_ERROR2 stuff! */
|
---|
1004 | if (SUCCEEDED(hrc))
|
---|
1005 | RTPrintf("Individual Config: VM NIC: %ls slot %u, MAC %ls\n", bstr.raw(), uSlot, bstrMACAddress.raw());
|
---|
1006 | else
|
---|
1007 | RTPrintf("Individual Config: VM NIC: %ls slot %u, MAC %Rhrc\n", bstr.raw(), uSlot, hrc);
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(FixedAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
1011 | if (bstr.isNotEmpty())
|
---|
1012 | RTPrintf(" Fixed Address: %ls\n", bstr.raw());
|
---|
1013 | else
|
---|
1014 | RTPrintf(" Fixed Address: dynamic\n");
|
---|
1015 |
|
---|
1016 | hrc = showDhcpConfig(Hosts[iHost]);
|
---|
1017 | if (FAILED(hrc))
|
---|
1018 | hrcRet = hrc;
|
---|
1019 | }
|
---|
1020 | Hosts.setNull();
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 | return hrcRet;
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | /**
|
---|
1028 | * List extension packs.
|
---|
1029 | *
|
---|
1030 | * @returns See produceList.
|
---|
1031 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
1032 | */
|
---|
1033 | static HRESULT listExtensionPacks(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
1034 | {
|
---|
1035 | ComObjPtr<IExtPackManager> ptrExtPackMgr;
|
---|
1036 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
|
---|
1037 |
|
---|
1038 | SafeIfaceArray<IExtPack> extPacks;
|
---|
1039 | CHECK_ERROR2I_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
|
---|
1040 | RTPrintf("Extension Packs: %u\n", extPacks.size());
|
---|
1041 |
|
---|
1042 | HRESULT hrc = S_OK;
|
---|
1043 | for (size_t i = 0; i < extPacks.size(); i++)
|
---|
1044 | {
|
---|
1045 | /* Read all the properties. */
|
---|
1046 | Bstr bstrName;
|
---|
1047 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
|
---|
1048 | Bstr bstrDesc;
|
---|
1049 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
|
---|
1050 | Bstr bstrVersion;
|
---|
1051 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
|
---|
1052 | ULONG uRevision;
|
---|
1053 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Revision)(&uRevision), hrc = hrcCheck; uRevision = 0);
|
---|
1054 | Bstr bstrEdition;
|
---|
1055 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
|
---|
1056 | Bstr bstrVrdeModule;
|
---|
1057 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.setNull());
|
---|
1058 | BOOL fUsable;
|
---|
1059 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Usable)(&fUsable), hrc = hrcCheck; fUsable = FALSE);
|
---|
1060 | Bstr bstrWhy;
|
---|
1061 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
|
---|
1062 |
|
---|
1063 | /* Display them. */
|
---|
1064 | if (i)
|
---|
1065 | RTPrintf("\n");
|
---|
1066 | RTPrintf("Pack no.%2zu: %ls\n"
|
---|
1067 | "Version: %ls\n"
|
---|
1068 | "Revision: %u\n"
|
---|
1069 | "Edition: %ls\n"
|
---|
1070 | "Description: %ls\n"
|
---|
1071 | "VRDE Module: %ls\n"
|
---|
1072 | "Usable: %RTbool\n"
|
---|
1073 | "Why unusable: %ls\n",
|
---|
1074 | i, bstrName.raw(),
|
---|
1075 | bstrVersion.raw(),
|
---|
1076 | uRevision,
|
---|
1077 | bstrEdition.raw(),
|
---|
1078 | bstrDesc.raw(),
|
---|
1079 | bstrVrdeModule.raw(),
|
---|
1080 | fUsable != FALSE,
|
---|
1081 | bstrWhy.raw());
|
---|
1082 |
|
---|
1083 | /* Query plugins and display them. */
|
---|
1084 | }
|
---|
1085 | return hrc;
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 |
|
---|
1089 | /**
|
---|
1090 | * List machine groups.
|
---|
1091 | *
|
---|
1092 | * @returns See produceList.
|
---|
1093 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
1094 | */
|
---|
1095 | static HRESULT listGroups(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
1096 | {
|
---|
1097 | SafeArray<BSTR> groups;
|
---|
1098 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(MachineGroups)(ComSafeArrayAsOutParam(groups)), hrcCheck);
|
---|
1099 |
|
---|
1100 | for (size_t i = 0; i < groups.size(); i++)
|
---|
1101 | {
|
---|
1102 | RTPrintf("\"%ls\"\n", groups[i]);
|
---|
1103 | }
|
---|
1104 | return S_OK;
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 |
|
---|
1108 | /**
|
---|
1109 | * List video capture devices.
|
---|
1110 | *
|
---|
1111 | * @returns See produceList.
|
---|
1112 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1113 | */
|
---|
1114 | static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
1115 | {
|
---|
1116 | HRESULT rc;
|
---|
1117 | ComPtr<IHost> host;
|
---|
1118 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1119 | com::SafeIfaceArray<IHostVideoInputDevice> hostVideoInputDevices;
|
---|
1120 | CHECK_ERROR(host, COMGETTER(VideoInputDevices)(ComSafeArrayAsOutParam(hostVideoInputDevices)));
|
---|
1121 | RTPrintf("Video Input Devices: %u\n", hostVideoInputDevices.size());
|
---|
1122 | for (size_t i = 0; i < hostVideoInputDevices.size(); ++i)
|
---|
1123 | {
|
---|
1124 | ComPtr<IHostVideoInputDevice> p = hostVideoInputDevices[i];
|
---|
1125 | Bstr name;
|
---|
1126 | p->COMGETTER(Name)(name.asOutParam());
|
---|
1127 | Bstr path;
|
---|
1128 | p->COMGETTER(Path)(path.asOutParam());
|
---|
1129 | Bstr alias;
|
---|
1130 | p->COMGETTER(Alias)(alias.asOutParam());
|
---|
1131 | RTPrintf("%ls \"%ls\"\n%ls\n", alias.raw(), name.raw(), path.raw());
|
---|
1132 | }
|
---|
1133 | return rc;
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 | /**
|
---|
1137 | * List supported screen shot formats.
|
---|
1138 | *
|
---|
1139 | * @returns See produceList.
|
---|
1140 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1141 | */
|
---|
1142 | static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
1143 | {
|
---|
1144 | HRESULT rc = S_OK;
|
---|
1145 | ComPtr<ISystemProperties> systemProperties;
|
---|
1146 | CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
|
---|
1147 | com::SafeArray<BitmapFormat_T> formats;
|
---|
1148 | CHECK_ERROR(systemProperties, COMGETTER(ScreenShotFormats)(ComSafeArrayAsOutParam(formats)));
|
---|
1149 |
|
---|
1150 | RTPrintf("Supported %d screen shot formats:\n", formats.size());
|
---|
1151 | for (size_t i = 0; i < formats.size(); ++i)
|
---|
1152 | {
|
---|
1153 | uint32_t u32Format = (uint32_t)formats[i];
|
---|
1154 | char szFormat[5];
|
---|
1155 | szFormat[0] = RT_BYTE1(u32Format);
|
---|
1156 | szFormat[1] = RT_BYTE2(u32Format);
|
---|
1157 | szFormat[2] = RT_BYTE3(u32Format);
|
---|
1158 | szFormat[3] = RT_BYTE4(u32Format);
|
---|
1159 | szFormat[4] = 0;
|
---|
1160 | RTPrintf(" BitmapFormat_%s (0x%08X)\n", szFormat, u32Format);
|
---|
1161 | }
|
---|
1162 | return rc;
|
---|
1163 | }
|
---|
1164 |
|
---|
1165 | /**
|
---|
1166 | * List available cloud providers.
|
---|
1167 | *
|
---|
1168 | * @returns See produceList.
|
---|
1169 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1170 | */
|
---|
1171 | static HRESULT listCloudProviders(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
1172 | {
|
---|
1173 | HRESULT rc = S_OK;
|
---|
1174 | ComPtr<ICloudProviderManager> pCloudProviderManager;
|
---|
1175 | CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
|
---|
1176 | com::SafeIfaceArray<ICloudProvider> apCloudProviders;
|
---|
1177 | CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
|
---|
1178 |
|
---|
1179 | RTPrintf("Supported %d cloud providers:\n", apCloudProviders.size());
|
---|
1180 | for (size_t i = 0; i < apCloudProviders.size(); ++i)
|
---|
1181 | {
|
---|
1182 | ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
|
---|
1183 | Bstr bstrProviderName;
|
---|
1184 | pCloudProvider->COMGETTER(Name)(bstrProviderName.asOutParam());
|
---|
1185 | RTPrintf("Name: %ls\n", bstrProviderName.raw());
|
---|
1186 | pCloudProvider->COMGETTER(ShortName)(bstrProviderName.asOutParam());
|
---|
1187 | RTPrintf("Short Name: %ls\n", bstrProviderName.raw());
|
---|
1188 | Bstr bstrProviderID;
|
---|
1189 | pCloudProvider->COMGETTER(Id)(bstrProviderID.asOutParam());
|
---|
1190 | RTPrintf("GUID: %ls\n", bstrProviderID.raw());
|
---|
1191 |
|
---|
1192 | RTPrintf("\n");
|
---|
1193 | }
|
---|
1194 | return rc;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 |
|
---|
1198 | /**
|
---|
1199 | * List all available cloud profiles (by iterating over the cloud providers).
|
---|
1200 | *
|
---|
1201 | * @returns See produceList.
|
---|
1202 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1203 | * @param fOptLong If true, list all profile properties.
|
---|
1204 | */
|
---|
1205 | static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> pVirtualBox, bool fOptLong)
|
---|
1206 | {
|
---|
1207 | HRESULT rc = S_OK;
|
---|
1208 | ComPtr<ICloudProviderManager> pCloudProviderManager;
|
---|
1209 | CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
|
---|
1210 | com::SafeIfaceArray<ICloudProvider> apCloudProviders;
|
---|
1211 | CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
|
---|
1212 |
|
---|
1213 | for (size_t i = 0; i < apCloudProviders.size(); ++i)
|
---|
1214 | {
|
---|
1215 | ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
|
---|
1216 | com::SafeIfaceArray<ICloudProfile> apCloudProfiles;
|
---|
1217 | CHECK_ERROR(pCloudProvider, COMGETTER(Profiles)(ComSafeArrayAsOutParam(apCloudProfiles)));
|
---|
1218 | for (size_t j = 0; j < apCloudProfiles.size(); ++j)
|
---|
1219 | {
|
---|
1220 | ComPtr<ICloudProfile> pCloudProfile = apCloudProfiles[j];
|
---|
1221 | Bstr bstrProfileName;
|
---|
1222 | pCloudProfile->COMGETTER(Name)(bstrProfileName.asOutParam());
|
---|
1223 | RTPrintf("Name: %ls\n", bstrProfileName.raw());
|
---|
1224 | Bstr bstrProviderID;
|
---|
1225 | pCloudProfile->COMGETTER(ProviderId)(bstrProviderID.asOutParam());
|
---|
1226 | RTPrintf("Provider GUID: %ls\n", bstrProviderID.raw());
|
---|
1227 |
|
---|
1228 | if (fOptLong)
|
---|
1229 | {
|
---|
1230 | com::SafeArray<BSTR> names;
|
---|
1231 | com::SafeArray<BSTR> values;
|
---|
1232 | pCloudProfile->GetProperties(Bstr().raw(), ComSafeArrayAsOutParam(names), ComSafeArrayAsOutParam(values));
|
---|
1233 | size_t cNames = names.size();
|
---|
1234 | size_t cValues = values.size();
|
---|
1235 | bool fFirst = true;
|
---|
1236 | for (size_t k = 0; k < cNames; k++)
|
---|
1237 | {
|
---|
1238 | Bstr value;
|
---|
1239 | if (k < cValues)
|
---|
1240 | value = values[k];
|
---|
1241 | RTPrintf("%s%ls=%ls\n",
|
---|
1242 | fFirst ? "Property: " : " ",
|
---|
1243 | names[k], value.raw());
|
---|
1244 | fFirst = false;
|
---|
1245 | }
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | RTPrintf("\n");
|
---|
1249 | }
|
---|
1250 | }
|
---|
1251 | return rc;
|
---|
1252 | }
|
---|
1253 |
|
---|
1254 |
|
---|
1255 | /**
|
---|
1256 | * The type of lists we can produce.
|
---|
1257 | */
|
---|
1258 | enum enmListType
|
---|
1259 | {
|
---|
1260 | kListNotSpecified = 1000,
|
---|
1261 | kListVMs,
|
---|
1262 | kListRunningVMs,
|
---|
1263 | kListOsTypes,
|
---|
1264 | kListHostDvds,
|
---|
1265 | kListHostFloppies,
|
---|
1266 | kListInternalNetworks,
|
---|
1267 | kListBridgedInterfaces,
|
---|
1268 | #if defined(VBOX_WITH_NETFLT)
|
---|
1269 | kListHostOnlyInterfaces,
|
---|
1270 | #endif
|
---|
1271 | kListHostCpuIDs,
|
---|
1272 | kListHostInfo,
|
---|
1273 | kListHddBackends,
|
---|
1274 | kListHdds,
|
---|
1275 | kListDvds,
|
---|
1276 | kListFloppies,
|
---|
1277 | kListUsbHost,
|
---|
1278 | kListUsbFilters,
|
---|
1279 | kListSystemProperties,
|
---|
1280 | kListDhcpServers,
|
---|
1281 | kListExtPacks,
|
---|
1282 | kListGroups,
|
---|
1283 | kListNatNetworks,
|
---|
1284 | kListVideoInputDevices,
|
---|
1285 | kListScreenShotFormats,
|
---|
1286 | kListCloudProviders,
|
---|
1287 | kListCloudProfiles,
|
---|
1288 | };
|
---|
1289 |
|
---|
1290 |
|
---|
1291 | /**
|
---|
1292 | * Produces the specified listing.
|
---|
1293 | *
|
---|
1294 | * @returns S_OK or some COM error code that has been reported in full.
|
---|
1295 | * @param enmList The list to produce.
|
---|
1296 | * @param fOptLong Long (@c true) or short list format.
|
---|
1297 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
1298 | */
|
---|
1299 | static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, bool fOptSorted, const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
1300 | {
|
---|
1301 | HRESULT rc = S_OK;
|
---|
1302 | switch (enmCommand)
|
---|
1303 | {
|
---|
1304 | case kListNotSpecified:
|
---|
1305 | AssertFailed();
|
---|
1306 | return E_FAIL;
|
---|
1307 |
|
---|
1308 | case kListVMs:
|
---|
1309 | {
|
---|
1310 | /*
|
---|
1311 | * Get the list of all registered VMs
|
---|
1312 | */
|
---|
1313 | com::SafeIfaceArray<IMachine> machines;
|
---|
1314 | rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
1315 | if (SUCCEEDED(rc))
|
---|
1316 | {
|
---|
1317 | /*
|
---|
1318 | * Display it.
|
---|
1319 | */
|
---|
1320 | if (!fOptSorted)
|
---|
1321 | {
|
---|
1322 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
1323 | if (machines[i])
|
---|
1324 | rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
1325 | }
|
---|
1326 | else
|
---|
1327 | {
|
---|
1328 | /*
|
---|
1329 | * Sort the list by name before displaying it.
|
---|
1330 | */
|
---|
1331 | std::vector<std::pair<com::Bstr, IMachine *> > sortedMachines;
|
---|
1332 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
1333 | {
|
---|
1334 | IMachine *pMachine = machines[i];
|
---|
1335 | if (pMachine) /* no idea why we need to do this... */
|
---|
1336 | {
|
---|
1337 | Bstr bstrName;
|
---|
1338 | pMachine->COMGETTER(Name)(bstrName.asOutParam());
|
---|
1339 | sortedMachines.push_back(std::pair<com::Bstr, IMachine *>(bstrName, pMachine));
|
---|
1340 | }
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | std::sort(sortedMachines.begin(), sortedMachines.end());
|
---|
1344 |
|
---|
1345 | for (size_t i = 0; i < sortedMachines.size(); ++i)
|
---|
1346 | rc = showVMInfo(pVirtualBox, sortedMachines[i].second, NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
1347 | }
|
---|
1348 | }
|
---|
1349 | break;
|
---|
1350 | }
|
---|
1351 |
|
---|
1352 | case kListRunningVMs:
|
---|
1353 | {
|
---|
1354 | /*
|
---|
1355 | * Get the list of all _running_ VMs
|
---|
1356 | */
|
---|
1357 | com::SafeIfaceArray<IMachine> machines;
|
---|
1358 | rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
1359 | com::SafeArray<MachineState_T> states;
|
---|
1360 | if (SUCCEEDED(rc))
|
---|
1361 | rc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
|
---|
1362 | if (SUCCEEDED(rc))
|
---|
1363 | {
|
---|
1364 | /*
|
---|
1365 | * Iterate through the collection
|
---|
1366 | */
|
---|
1367 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
1368 | {
|
---|
1369 | if (machines[i])
|
---|
1370 | {
|
---|
1371 | MachineState_T machineState = states[i];
|
---|
1372 | switch (machineState)
|
---|
1373 | {
|
---|
1374 | case MachineState_Running:
|
---|
1375 | case MachineState_Teleporting:
|
---|
1376 | case MachineState_LiveSnapshotting:
|
---|
1377 | case MachineState_Paused:
|
---|
1378 | case MachineState_TeleportingPausedVM:
|
---|
1379 | rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
1380 | break;
|
---|
1381 | default: break; /* Shut up MSC */
|
---|
1382 | }
|
---|
1383 | }
|
---|
1384 | }
|
---|
1385 | }
|
---|
1386 | break;
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 | case kListOsTypes:
|
---|
1390 | {
|
---|
1391 | com::SafeIfaceArray<IGuestOSType> coll;
|
---|
1392 | rc = pVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
|
---|
1393 | if (SUCCEEDED(rc))
|
---|
1394 | {
|
---|
1395 | /*
|
---|
1396 | * Iterate through the collection.
|
---|
1397 | */
|
---|
1398 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1399 | {
|
---|
1400 | ComPtr<IGuestOSType> guestOS;
|
---|
1401 | guestOS = coll[i];
|
---|
1402 | Bstr guestId;
|
---|
1403 | guestOS->COMGETTER(Id)(guestId.asOutParam());
|
---|
1404 | RTPrintf("ID: %ls\n", guestId.raw());
|
---|
1405 | Bstr guestDescription;
|
---|
1406 | guestOS->COMGETTER(Description)(guestDescription.asOutParam());
|
---|
1407 | RTPrintf("Description: %ls\n", guestDescription.raw());
|
---|
1408 | Bstr familyId;
|
---|
1409 | guestOS->COMGETTER(FamilyId)(familyId.asOutParam());
|
---|
1410 | RTPrintf("Family ID: %ls\n", familyId.raw());
|
---|
1411 | Bstr familyDescription;
|
---|
1412 | guestOS->COMGETTER(FamilyDescription)(familyDescription.asOutParam());
|
---|
1413 | RTPrintf("Family Desc: %ls\n", familyDescription.raw());
|
---|
1414 | BOOL is64Bit;
|
---|
1415 | guestOS->COMGETTER(Is64Bit)(&is64Bit);
|
---|
1416 | RTPrintf("64 bit: %RTbool\n", is64Bit);
|
---|
1417 | RTPrintf("\n");
|
---|
1418 | }
|
---|
1419 | }
|
---|
1420 | break;
|
---|
1421 | }
|
---|
1422 |
|
---|
1423 | case kListHostDvds:
|
---|
1424 | {
|
---|
1425 | ComPtr<IHost> host;
|
---|
1426 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1427 | com::SafeIfaceArray<IMedium> coll;
|
---|
1428 | CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
1429 | if (SUCCEEDED(rc))
|
---|
1430 | {
|
---|
1431 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1432 | {
|
---|
1433 | ComPtr<IMedium> dvdDrive = coll[i];
|
---|
1434 | Bstr uuid;
|
---|
1435 | dvdDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
1436 | RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
|
---|
1437 | Bstr location;
|
---|
1438 | dvdDrive->COMGETTER(Location)(location.asOutParam());
|
---|
1439 | RTPrintf("Name: %ls\n\n", location.raw());
|
---|
1440 | }
|
---|
1441 | }
|
---|
1442 | break;
|
---|
1443 | }
|
---|
1444 |
|
---|
1445 | case kListHostFloppies:
|
---|
1446 | {
|
---|
1447 | ComPtr<IHost> host;
|
---|
1448 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1449 | com::SafeIfaceArray<IMedium> coll;
|
---|
1450 | CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
1451 | if (SUCCEEDED(rc))
|
---|
1452 | {
|
---|
1453 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1454 | {
|
---|
1455 | ComPtr<IMedium> floppyDrive = coll[i];
|
---|
1456 | Bstr uuid;
|
---|
1457 | floppyDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
1458 | RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
|
---|
1459 | Bstr location;
|
---|
1460 | floppyDrive->COMGETTER(Location)(location.asOutParam());
|
---|
1461 | RTPrintf("Name: %ls\n\n", location.raw());
|
---|
1462 | }
|
---|
1463 | }
|
---|
1464 | break;
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 | case kListInternalNetworks:
|
---|
1468 | rc = listInternalNetworks(pVirtualBox);
|
---|
1469 | break;
|
---|
1470 |
|
---|
1471 | case kListBridgedInterfaces:
|
---|
1472 | #if defined(VBOX_WITH_NETFLT)
|
---|
1473 | case kListHostOnlyInterfaces:
|
---|
1474 | #endif
|
---|
1475 | rc = listNetworkInterfaces(pVirtualBox, enmCommand == kListBridgedInterfaces);
|
---|
1476 | break;
|
---|
1477 |
|
---|
1478 | case kListHostInfo:
|
---|
1479 | rc = listHostInfo(pVirtualBox);
|
---|
1480 | break;
|
---|
1481 |
|
---|
1482 | case kListHostCpuIDs:
|
---|
1483 | {
|
---|
1484 | ComPtr<IHost> Host;
|
---|
1485 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
1486 |
|
---|
1487 | RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n");
|
---|
1488 | ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
|
---|
1489 | static uint32_t const s_auCpuIdRanges[] =
|
---|
1490 | {
|
---|
1491 | UINT32_C(0x00000000), UINT32_C(0x0000007f),
|
---|
1492 | UINT32_C(0x80000000), UINT32_C(0x8000007f),
|
---|
1493 | UINT32_C(0xc0000000), UINT32_C(0xc000007f)
|
---|
1494 | };
|
---|
1495 | for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
|
---|
1496 | {
|
---|
1497 | ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
|
---|
1498 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
|
---|
1499 | if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
|
---|
1500 | continue;
|
---|
1501 | cLeafs++;
|
---|
1502 | for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
|
---|
1503 | {
|
---|
1504 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
|
---|
1505 | RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
|
---|
1506 | }
|
---|
1507 | }
|
---|
1508 | break;
|
---|
1509 | }
|
---|
1510 |
|
---|
1511 | case kListHddBackends:
|
---|
1512 | rc = listHddBackends(pVirtualBox);
|
---|
1513 | break;
|
---|
1514 |
|
---|
1515 | case kListHdds:
|
---|
1516 | {
|
---|
1517 | com::SafeIfaceArray<IMedium> hdds;
|
---|
1518 | CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
|
---|
1519 | rc = listMedia(pVirtualBox, hdds, "base", fOptLong);
|
---|
1520 | break;
|
---|
1521 | }
|
---|
1522 |
|
---|
1523 | case kListDvds:
|
---|
1524 | {
|
---|
1525 | com::SafeIfaceArray<IMedium> dvds;
|
---|
1526 | CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
|
---|
1527 | rc = listMedia(pVirtualBox, dvds, NULL, fOptLong);
|
---|
1528 | break;
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 | case kListFloppies:
|
---|
1532 | {
|
---|
1533 | com::SafeIfaceArray<IMedium> floppies;
|
---|
1534 | CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
|
---|
1535 | rc = listMedia(pVirtualBox, floppies, NULL, fOptLong);
|
---|
1536 | break;
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 | case kListUsbHost:
|
---|
1540 | rc = listUsbHost(pVirtualBox);
|
---|
1541 | break;
|
---|
1542 |
|
---|
1543 | case kListUsbFilters:
|
---|
1544 | rc = listUsbFilters(pVirtualBox);
|
---|
1545 | break;
|
---|
1546 |
|
---|
1547 | case kListSystemProperties:
|
---|
1548 | rc = listSystemProperties(pVirtualBox);
|
---|
1549 | break;
|
---|
1550 |
|
---|
1551 | case kListDhcpServers:
|
---|
1552 | rc = listDhcpServers(pVirtualBox);
|
---|
1553 | break;
|
---|
1554 |
|
---|
1555 | case kListExtPacks:
|
---|
1556 | rc = listExtensionPacks(pVirtualBox);
|
---|
1557 | break;
|
---|
1558 |
|
---|
1559 | case kListGroups:
|
---|
1560 | rc = listGroups(pVirtualBox);
|
---|
1561 | break;
|
---|
1562 |
|
---|
1563 | case kListNatNetworks:
|
---|
1564 | {
|
---|
1565 | com::SafeIfaceArray<INATNetwork> nets;
|
---|
1566 | CHECK_ERROR(pVirtualBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(nets)));
|
---|
1567 | for (size_t i = 0; i < nets.size(); ++i)
|
---|
1568 | {
|
---|
1569 | ComPtr<INATNetwork> net = nets[i];
|
---|
1570 | Bstr netName;
|
---|
1571 | net->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
1572 | RTPrintf("NetworkName: %ls\n", netName.raw());
|
---|
1573 | Bstr gateway;
|
---|
1574 | net->COMGETTER(Gateway)(gateway.asOutParam());
|
---|
1575 | RTPrintf("IP: %ls\n", gateway.raw());
|
---|
1576 | Bstr network;
|
---|
1577 | net->COMGETTER(Network)(network.asOutParam());
|
---|
1578 | RTPrintf("Network: %ls\n", network.raw());
|
---|
1579 | BOOL fEnabled;
|
---|
1580 | net->COMGETTER(IPv6Enabled)(&fEnabled);
|
---|
1581 | RTPrintf("IPv6 Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1582 | Bstr ipv6prefix;
|
---|
1583 | net->COMGETTER(IPv6Prefix)(ipv6prefix.asOutParam());
|
---|
1584 | RTPrintf("IPv6 Prefix: %ls\n", ipv6prefix.raw());
|
---|
1585 | net->COMGETTER(NeedDhcpServer)(&fEnabled);
|
---|
1586 | RTPrintf("DHCP Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1587 | net->COMGETTER(Enabled)(&fEnabled);
|
---|
1588 | RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1589 |
|
---|
1590 | #define PRINT_STRING_ARRAY(title) \
|
---|
1591 | if (strs.size() > 0) \
|
---|
1592 | { \
|
---|
1593 | RTPrintf(title); \
|
---|
1594 | size_t j = 0; \
|
---|
1595 | for (;j < strs.size(); ++j) \
|
---|
1596 | RTPrintf(" %s\n", Utf8Str(strs[j]).c_str()); \
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | com::SafeArray<BSTR> strs;
|
---|
1600 |
|
---|
1601 | CHECK_ERROR(nets[i], COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(strs)));
|
---|
1602 | PRINT_STRING_ARRAY("Port-forwarding (ipv4)\n");
|
---|
1603 | strs.setNull();
|
---|
1604 |
|
---|
1605 | CHECK_ERROR(nets[i], COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(strs)));
|
---|
1606 | PRINT_STRING_ARRAY("Port-forwarding (ipv6)\n");
|
---|
1607 | strs.setNull();
|
---|
1608 |
|
---|
1609 | CHECK_ERROR(nets[i], COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs)));
|
---|
1610 | PRINT_STRING_ARRAY("loopback mappings (ipv4)\n");
|
---|
1611 | strs.setNull();
|
---|
1612 |
|
---|
1613 | #undef PRINT_STRING_ARRAY
|
---|
1614 | RTPrintf("\n");
|
---|
1615 | }
|
---|
1616 | break;
|
---|
1617 | }
|
---|
1618 |
|
---|
1619 | case kListVideoInputDevices:
|
---|
1620 | rc = listVideoInputDevices(pVirtualBox);
|
---|
1621 | break;
|
---|
1622 |
|
---|
1623 | case kListScreenShotFormats:
|
---|
1624 | rc = listScreenShotFormats(pVirtualBox);
|
---|
1625 | break;
|
---|
1626 |
|
---|
1627 | case kListCloudProviders:
|
---|
1628 | rc = listCloudProviders(pVirtualBox);
|
---|
1629 | break;
|
---|
1630 |
|
---|
1631 | case kListCloudProfiles:
|
---|
1632 | rc = listCloudProfiles(pVirtualBox, fOptLong);
|
---|
1633 | break;
|
---|
1634 |
|
---|
1635 | /* No default here, want gcc warnings. */
|
---|
1636 |
|
---|
1637 | } /* end switch */
|
---|
1638 |
|
---|
1639 | return rc;
|
---|
1640 | }
|
---|
1641 |
|
---|
1642 | /**
|
---|
1643 | * Handles the 'list' command.
|
---|
1644 | *
|
---|
1645 | * @returns Appropriate exit code.
|
---|
1646 | * @param a Handler argument.
|
---|
1647 | */
|
---|
1648 | RTEXITCODE handleList(HandlerArg *a)
|
---|
1649 | {
|
---|
1650 | bool fOptLong = false;
|
---|
1651 | bool fOptMultiple = false;
|
---|
1652 | bool fOptSorted = false;
|
---|
1653 | enum enmListType enmOptCommand = kListNotSpecified;
|
---|
1654 |
|
---|
1655 | static const RTGETOPTDEF s_aListOptions[] =
|
---|
1656 | {
|
---|
1657 | { "--long", 'l', RTGETOPT_REQ_NOTHING },
|
---|
1658 | { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */
|
---|
1659 | { "--sorted", 's', RTGETOPT_REQ_NOTHING },
|
---|
1660 | { "vms", kListVMs, RTGETOPT_REQ_NOTHING },
|
---|
1661 | { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING },
|
---|
1662 | { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING },
|
---|
1663 | { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING },
|
---|
1664 | { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING },
|
---|
1665 | { "intnets", kListInternalNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1666 | { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
|
---|
1667 | { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING },
|
---|
1668 | #if defined(VBOX_WITH_NETFLT)
|
---|
1669 | { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
|
---|
1670 | #endif
|
---|
1671 | { "natnetworks", kListNatNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1672 | { "natnets", kListNatNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1673 | { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING },
|
---|
1674 | { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING },
|
---|
1675 | { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING },
|
---|
1676 | { "hdds", kListHdds, RTGETOPT_REQ_NOTHING },
|
---|
1677 | { "dvds", kListDvds, RTGETOPT_REQ_NOTHING },
|
---|
1678 | { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING },
|
---|
1679 | { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING },
|
---|
1680 | { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING },
|
---|
1681 | { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING },
|
---|
1682 | { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING },
|
---|
1683 | { "extpacks", kListExtPacks, RTGETOPT_REQ_NOTHING },
|
---|
1684 | { "groups", kListGroups, RTGETOPT_REQ_NOTHING },
|
---|
1685 | { "webcams", kListVideoInputDevices, RTGETOPT_REQ_NOTHING },
|
---|
1686 | { "screenshotformats", kListScreenShotFormats, RTGETOPT_REQ_NOTHING },
|
---|
1687 | { "cloudproviders", kListCloudProviders, RTGETOPT_REQ_NOTHING },
|
---|
1688 | { "cloudprofiles", kListCloudProfiles, RTGETOPT_REQ_NOTHING },
|
---|
1689 | };
|
---|
1690 |
|
---|
1691 | int ch;
|
---|
1692 | RTGETOPTUNION ValueUnion;
|
---|
1693 | RTGETOPTSTATE GetState;
|
---|
1694 | RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
|
---|
1695 | 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
|
---|
1696 | while ((ch = RTGetOpt(&GetState, &ValueUnion)))
|
---|
1697 | {
|
---|
1698 | switch (ch)
|
---|
1699 | {
|
---|
1700 | case 'l': /* --long */
|
---|
1701 | fOptLong = true;
|
---|
1702 | break;
|
---|
1703 |
|
---|
1704 | case 's':
|
---|
1705 | fOptSorted = true;
|
---|
1706 | break;
|
---|
1707 |
|
---|
1708 | case 'm':
|
---|
1709 | fOptMultiple = true;
|
---|
1710 | if (enmOptCommand == kListNotSpecified)
|
---|
1711 | break;
|
---|
1712 | ch = enmOptCommand;
|
---|
1713 | RT_FALL_THRU();
|
---|
1714 |
|
---|
1715 | case kListVMs:
|
---|
1716 | case kListRunningVMs:
|
---|
1717 | case kListOsTypes:
|
---|
1718 | case kListHostDvds:
|
---|
1719 | case kListHostFloppies:
|
---|
1720 | case kListInternalNetworks:
|
---|
1721 | case kListBridgedInterfaces:
|
---|
1722 | #if defined(VBOX_WITH_NETFLT)
|
---|
1723 | case kListHostOnlyInterfaces:
|
---|
1724 | #endif
|
---|
1725 | case kListHostInfo:
|
---|
1726 | case kListHostCpuIDs:
|
---|
1727 | case kListHddBackends:
|
---|
1728 | case kListHdds:
|
---|
1729 | case kListDvds:
|
---|
1730 | case kListFloppies:
|
---|
1731 | case kListUsbHost:
|
---|
1732 | case kListUsbFilters:
|
---|
1733 | case kListSystemProperties:
|
---|
1734 | case kListDhcpServers:
|
---|
1735 | case kListExtPacks:
|
---|
1736 | case kListGroups:
|
---|
1737 | case kListNatNetworks:
|
---|
1738 | case kListVideoInputDevices:
|
---|
1739 | case kListScreenShotFormats:
|
---|
1740 | case kListCloudProviders:
|
---|
1741 | case kListCloudProfiles:
|
---|
1742 | enmOptCommand = (enum enmListType)ch;
|
---|
1743 | if (fOptMultiple)
|
---|
1744 | {
|
---|
1745 | HRESULT hrc = produceList((enum enmListType)ch, fOptLong, fOptSorted, a->virtualBox);
|
---|
1746 | if (FAILED(hrc))
|
---|
1747 | return RTEXITCODE_FAILURE;
|
---|
1748 | }
|
---|
1749 | break;
|
---|
1750 |
|
---|
1751 | case VINF_GETOPT_NOT_OPTION:
|
---|
1752 | return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
|
---|
1753 |
|
---|
1754 | default:
|
---|
1755 | return errorGetOpt(USAGE_LIST, ch, &ValueUnion);
|
---|
1756 | }
|
---|
1757 | }
|
---|
1758 |
|
---|
1759 | /*
|
---|
1760 | * If not in multiple list mode, we have to produce the list now.
|
---|
1761 | */
|
---|
1762 | if (enmOptCommand == kListNotSpecified)
|
---|
1763 | return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
|
---|
1764 | if (!fOptMultiple)
|
---|
1765 | {
|
---|
1766 | HRESULT hrc = produceList(enmOptCommand, fOptLong, fOptSorted, a->virtualBox);
|
---|
1767 | if (FAILED(hrc))
|
---|
1768 | return RTEXITCODE_FAILURE;
|
---|
1769 | }
|
---|
1770 |
|
---|
1771 | return RTEXITCODE_SUCCESS;
|
---|
1772 | }
|
---|
1773 |
|
---|
1774 | #endif /* !VBOX_ONLY_DOCS */
|
---|
1775 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|