1 | /* $Id: VBoxManageList.cpp 81943 2019-11-18 15:10:36Z 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 |
|
---|
508 | /* current state */
|
---|
509 | USBDeviceState_T state;
|
---|
510 | CHECK_ERROR_RET(dev, COMGETTER(State)(&state), 1);
|
---|
511 | const char *pszState = "?";
|
---|
512 | switch (state)
|
---|
513 | {
|
---|
514 | case USBDeviceState_NotSupported:
|
---|
515 | pszState = "Not supported";
|
---|
516 | break;
|
---|
517 | case USBDeviceState_Unavailable:
|
---|
518 | pszState = "Unavailable";
|
---|
519 | break;
|
---|
520 | case USBDeviceState_Busy:
|
---|
521 | pszState = "Busy";
|
---|
522 | break;
|
---|
523 | case USBDeviceState_Available:
|
---|
524 | pszState = "Available";
|
---|
525 | break;
|
---|
526 | case USBDeviceState_Held:
|
---|
527 | pszState = "Held";
|
---|
528 | break;
|
---|
529 | case USBDeviceState_Captured:
|
---|
530 | pszState = "Captured";
|
---|
531 | break;
|
---|
532 | default:
|
---|
533 | ASSERT(false);
|
---|
534 | break;
|
---|
535 | }
|
---|
536 | RTPrintf("Current State: %s\n\n", pszState);
|
---|
537 | }
|
---|
538 | }
|
---|
539 | return rc;
|
---|
540 | }
|
---|
541 |
|
---|
542 |
|
---|
543 | /**
|
---|
544 | * List USB filters.
|
---|
545 | *
|
---|
546 | * @returns See produceList.
|
---|
547 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
548 | */
|
---|
549 | static HRESULT listUsbFilters(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
550 | {
|
---|
551 | HRESULT rc;
|
---|
552 |
|
---|
553 | RTPrintf("Global USB Device Filters:\n\n");
|
---|
554 |
|
---|
555 | ComPtr<IHost> host;
|
---|
556 | CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(host.asOutParam()), 1);
|
---|
557 |
|
---|
558 | SafeIfaceArray<IHostUSBDeviceFilter> coll;
|
---|
559 | CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
|
---|
560 |
|
---|
561 | if (coll.size() == 0)
|
---|
562 | {
|
---|
563 | RTPrintf("<none>\n\n");
|
---|
564 | }
|
---|
565 | else
|
---|
566 | {
|
---|
567 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
568 | {
|
---|
569 | ComPtr<IHostUSBDeviceFilter> flt = coll[index];
|
---|
570 |
|
---|
571 | /* Query info. */
|
---|
572 |
|
---|
573 | RTPrintf("Index: %zu\n", index);
|
---|
574 |
|
---|
575 | BOOL active = FALSE;
|
---|
576 | CHECK_ERROR_RET(flt, COMGETTER(Active)(&active), 1);
|
---|
577 | RTPrintf("Active: %s\n", active ? "yes" : "no");
|
---|
578 |
|
---|
579 | USBDeviceFilterAction_T action;
|
---|
580 | CHECK_ERROR_RET(flt, COMGETTER(Action)(&action), 1);
|
---|
581 | const char *pszAction = "<invalid>";
|
---|
582 | switch (action)
|
---|
583 | {
|
---|
584 | case USBDeviceFilterAction_Ignore:
|
---|
585 | pszAction = "Ignore";
|
---|
586 | break;
|
---|
587 | case USBDeviceFilterAction_Hold:
|
---|
588 | pszAction = "Hold";
|
---|
589 | break;
|
---|
590 | default:
|
---|
591 | break;
|
---|
592 | }
|
---|
593 | RTPrintf("Action: %s\n", pszAction);
|
---|
594 |
|
---|
595 | Bstr bstr;
|
---|
596 | CHECK_ERROR_RET(flt, COMGETTER(Name)(bstr.asOutParam()), 1);
|
---|
597 | RTPrintf("Name: %ls\n", bstr.raw());
|
---|
598 | CHECK_ERROR_RET(flt, COMGETTER(VendorId)(bstr.asOutParam()), 1);
|
---|
599 | RTPrintf("VendorId: %ls\n", bstr.raw());
|
---|
600 | CHECK_ERROR_RET(flt, COMGETTER(ProductId)(bstr.asOutParam()), 1);
|
---|
601 | RTPrintf("ProductId: %ls\n", bstr.raw());
|
---|
602 | CHECK_ERROR_RET(flt, COMGETTER(Revision)(bstr.asOutParam()), 1);
|
---|
603 | RTPrintf("Revision: %ls\n", bstr.raw());
|
---|
604 | CHECK_ERROR_RET(flt, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
|
---|
605 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
606 | CHECK_ERROR_RET(flt, COMGETTER(Product)(bstr.asOutParam()), 1);
|
---|
607 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
608 | CHECK_ERROR_RET(flt, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
609 | RTPrintf("Serial Number: %ls\n\n", bstr.raw());
|
---|
610 | }
|
---|
611 | }
|
---|
612 | return rc;
|
---|
613 | }
|
---|
614 |
|
---|
615 |
|
---|
616 | /**
|
---|
617 | * List system properties.
|
---|
618 | *
|
---|
619 | * @returns See produceList.
|
---|
620 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
621 | */
|
---|
622 | static HRESULT listSystemProperties(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
623 | {
|
---|
624 | ComPtr<ISystemProperties> systemProperties;
|
---|
625 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), hrcCheck);
|
---|
626 |
|
---|
627 | Bstr str;
|
---|
628 | ULONG ulValue;
|
---|
629 | LONG64 i64Value;
|
---|
630 | BOOL fValue;
|
---|
631 | const char *psz;
|
---|
632 |
|
---|
633 | pVirtualBox->COMGETTER(APIVersion)(str.asOutParam());
|
---|
634 | RTPrintf("API version: %ls\n", str.raw());
|
---|
635 |
|
---|
636 | systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
|
---|
637 | RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
|
---|
638 | systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
|
---|
639 | RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
|
---|
640 | systemProperties->COMGETTER(MinGuestVRAM)(&ulValue);
|
---|
641 | RTPrintf("Minimum video RAM size: %u Megabytes\n", ulValue);
|
---|
642 | systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
|
---|
643 | RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
|
---|
644 | systemProperties->COMGETTER(MaxGuestMonitors)(&ulValue);
|
---|
645 | RTPrintf("Maximum guest monitor count: %u\n", ulValue);
|
---|
646 | systemProperties->COMGETTER(MinGuestCPUCount)(&ulValue);
|
---|
647 | RTPrintf("Minimum guest CPU count: %u\n", ulValue);
|
---|
648 | systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
|
---|
649 | RTPrintf("Maximum guest CPU count: %u\n", ulValue);
|
---|
650 | systemProperties->COMGETTER(InfoVDSize)(&i64Value);
|
---|
651 | RTPrintf("Virtual disk limit (info): %lld Bytes\n", i64Value);
|
---|
652 | systemProperties->COMGETTER(SerialPortCount)(&ulValue);
|
---|
653 | RTPrintf("Maximum Serial Port count: %u\n", ulValue);
|
---|
654 | systemProperties->COMGETTER(ParallelPortCount)(&ulValue);
|
---|
655 | RTPrintf("Maximum Parallel Port count: %u\n", ulValue);
|
---|
656 | systemProperties->COMGETTER(MaxBootPosition)(&ulValue);
|
---|
657 | RTPrintf("Maximum Boot Position: %u\n", ulValue);
|
---|
658 | systemProperties->GetMaxNetworkAdapters(ChipsetType_PIIX3, &ulValue);
|
---|
659 | RTPrintf("Maximum PIIX3 Network Adapter count: %u\n", ulValue);
|
---|
660 | systemProperties->GetMaxNetworkAdapters(ChipsetType_ICH9, &ulValue);
|
---|
661 | RTPrintf("Maximum ICH9 Network Adapter count: %u\n", ulValue);
|
---|
662 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_IDE, &ulValue);
|
---|
663 | RTPrintf("Maximum PIIX3 IDE Controllers: %u\n", ulValue);
|
---|
664 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_IDE, &ulValue);
|
---|
665 | RTPrintf("Maximum ICH9 IDE Controllers: %u\n", ulValue);
|
---|
666 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_IDE, &ulValue);
|
---|
667 | RTPrintf("Maximum IDE Port count: %u\n", ulValue);
|
---|
668 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_IDE, &ulValue);
|
---|
669 | RTPrintf("Maximum Devices per IDE Port: %u\n", ulValue);
|
---|
670 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SATA, &ulValue);
|
---|
671 | RTPrintf("Maximum PIIX3 SATA Controllers: %u\n", ulValue);
|
---|
672 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SATA, &ulValue);
|
---|
673 | RTPrintf("Maximum ICH9 SATA Controllers: %u\n", ulValue);
|
---|
674 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SATA, &ulValue);
|
---|
675 | RTPrintf("Maximum SATA Port count: %u\n", ulValue);
|
---|
676 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SATA, &ulValue);
|
---|
677 | RTPrintf("Maximum Devices per SATA Port: %u\n", ulValue);
|
---|
678 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SCSI, &ulValue);
|
---|
679 | RTPrintf("Maximum PIIX3 SCSI Controllers: %u\n", ulValue);
|
---|
680 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SCSI, &ulValue);
|
---|
681 | RTPrintf("Maximum ICH9 SCSI Controllers: %u\n", ulValue);
|
---|
682 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
683 | RTPrintf("Maximum SCSI Port count: %u\n", ulValue);
|
---|
684 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
685 | RTPrintf("Maximum Devices per SCSI Port: %u\n", ulValue);
|
---|
686 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SAS, &ulValue);
|
---|
687 | RTPrintf("Maximum SAS PIIX3 Controllers: %u\n", ulValue);
|
---|
688 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SAS, &ulValue);
|
---|
689 | RTPrintf("Maximum SAS ICH9 Controllers: %u\n", ulValue);
|
---|
690 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SAS, &ulValue);
|
---|
691 | RTPrintf("Maximum SAS Port count: %u\n", ulValue);
|
---|
692 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SAS, &ulValue);
|
---|
693 | RTPrintf("Maximum Devices per SAS Port: %u\n", ulValue);
|
---|
694 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_PCIe, &ulValue);
|
---|
695 | RTPrintf("Maximum NVMe PIIX3 Controllers: %u\n", ulValue);
|
---|
696 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_PCIe, &ulValue);
|
---|
697 | RTPrintf("Maximum NVMe ICH9 Controllers: %u\n", ulValue);
|
---|
698 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_PCIe, &ulValue);
|
---|
699 | RTPrintf("Maximum NVMe Port count: %u\n", ulValue);
|
---|
700 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_PCIe, &ulValue);
|
---|
701 | RTPrintf("Maximum Devices per NVMe Port: %u\n", ulValue);
|
---|
702 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_VirtioSCSI, &ulValue);
|
---|
703 | RTPrintf("Maximum virtio-scsi PIIX3 Controllers: %u\n", ulValue);
|
---|
704 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_VirtioSCSI, &ulValue);
|
---|
705 | RTPrintf("Maximum virtio-scsi ICH9 Controllers: %u\n", ulValue);
|
---|
706 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_VirtioSCSI, &ulValue);
|
---|
707 | RTPrintf("Maximum virtio-scsi Port count: %u\n", ulValue);
|
---|
708 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_VirtioSCSI, &ulValue);
|
---|
709 | RTPrintf("Maximum Devices per virtio-scsi Port: %u\n", ulValue);
|
---|
710 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_Floppy, &ulValue);
|
---|
711 | RTPrintf("Maximum PIIX3 Floppy Controllers:%u\n", ulValue);
|
---|
712 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_Floppy, &ulValue);
|
---|
713 | RTPrintf("Maximum ICH9 Floppy Controllers: %u\n", ulValue);
|
---|
714 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
715 | RTPrintf("Maximum Floppy Port count: %u\n", ulValue);
|
---|
716 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
717 | RTPrintf("Maximum Devices per Floppy Port: %u\n", ulValue);
|
---|
718 | #if 0
|
---|
719 | systemProperties->GetFreeDiskSpaceWarning(&i64Value);
|
---|
720 | RTPrintf("Free disk space warning at: %u Bytes\n", i64Value);
|
---|
721 | systemProperties->GetFreeDiskSpacePercentWarning(&ulValue);
|
---|
722 | RTPrintf("Free disk space warning at: %u %%\n", ulValue);
|
---|
723 | systemProperties->GetFreeDiskSpaceError(&i64Value);
|
---|
724 | RTPrintf("Free disk space error at: %u Bytes\n", i64Value);
|
---|
725 | systemProperties->GetFreeDiskSpacePercentError(&ulValue);
|
---|
726 | RTPrintf("Free disk space error at: %u %%\n", ulValue);
|
---|
727 | #endif
|
---|
728 | systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
|
---|
729 | RTPrintf("Default machine folder: %ls\n", str.raw());
|
---|
730 | systemProperties->COMGETTER(RawModeSupported)(&fValue);
|
---|
731 | RTPrintf("Raw-mode Supported: %s\n", fValue ? "yes" : "no");
|
---|
732 | systemProperties->COMGETTER(ExclusiveHwVirt)(&fValue);
|
---|
733 | RTPrintf("Exclusive HW virtualization use: %s\n", fValue ? "on" : "off");
|
---|
734 | systemProperties->COMGETTER(DefaultHardDiskFormat)(str.asOutParam());
|
---|
735 | RTPrintf("Default hard disk format: %ls\n", str.raw());
|
---|
736 | systemProperties->COMGETTER(VRDEAuthLibrary)(str.asOutParam());
|
---|
737 | RTPrintf("VRDE auth library: %ls\n", str.raw());
|
---|
738 | systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
|
---|
739 | RTPrintf("Webservice auth. library: %ls\n", str.raw());
|
---|
740 | systemProperties->COMGETTER(DefaultVRDEExtPack)(str.asOutParam());
|
---|
741 | RTPrintf("Remote desktop ExtPack: %ls\n", str.raw());
|
---|
742 | systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
|
---|
743 | RTPrintf("Log history count: %u\n", ulValue);
|
---|
744 | systemProperties->COMGETTER(DefaultFrontend)(str.asOutParam());
|
---|
745 | RTPrintf("Default frontend: %ls\n", str.raw());
|
---|
746 | AudioDriverType_T enmAudio;
|
---|
747 | systemProperties->COMGETTER(DefaultAudioDriver)(&enmAudio);
|
---|
748 | switch (enmAudio)
|
---|
749 | {
|
---|
750 | case AudioDriverType_Null: psz = "Null"; break;
|
---|
751 | case AudioDriverType_WinMM: psz = "WinMM"; break;
|
---|
752 | case AudioDriverType_OSS: psz = "OSS"; break;
|
---|
753 | case AudioDriverType_ALSA: psz = "ALSA"; break;
|
---|
754 | case AudioDriverType_DirectSound: psz = "DirectSound"; break;
|
---|
755 | case AudioDriverType_CoreAudio: psz = "CoreAudio"; break;
|
---|
756 | case AudioDriverType_MMPM: psz = "MMPM"; break;
|
---|
757 | case AudioDriverType_Pulse: psz = "Pulse"; break;
|
---|
758 | case AudioDriverType_SolAudio: psz = "SolAudio"; break;
|
---|
759 | default: psz = "Unknown";
|
---|
760 | }
|
---|
761 | RTPrintf("Default audio driver: %s\n", psz);
|
---|
762 | systemProperties->COMGETTER(AutostartDatabasePath)(str.asOutParam());
|
---|
763 | RTPrintf("Autostart database path: %ls\n", str.raw());
|
---|
764 | systemProperties->COMGETTER(DefaultAdditionsISO)(str.asOutParam());
|
---|
765 | RTPrintf("Default Guest Additions ISO: %ls\n", str.raw());
|
---|
766 | systemProperties->COMGETTER(LoggingLevel)(str.asOutParam());
|
---|
767 | RTPrintf("Logging Level: %ls\n", str.raw());
|
---|
768 | ProxyMode_T enmProxyMode = (ProxyMode_T)42;
|
---|
769 | systemProperties->COMGETTER(ProxyMode)(&enmProxyMode);
|
---|
770 | psz = "Unknown";
|
---|
771 | switch (enmProxyMode)
|
---|
772 | {
|
---|
773 | case ProxyMode_System: psz = "System"; break;
|
---|
774 | case ProxyMode_NoProxy: psz = "NoProxy"; break;
|
---|
775 | case ProxyMode_Manual: psz = "Manual"; break;
|
---|
776 | #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
|
---|
777 | case ProxyMode_32BitHack: break; /* Shut up compiler warnings. */
|
---|
778 | #endif
|
---|
779 | }
|
---|
780 | RTPrintf("Proxy Mode: %s\n", psz);
|
---|
781 | systemProperties->COMGETTER(ProxyURL)(str.asOutParam());
|
---|
782 | RTPrintf("Proxy URL: %ls\n", str.raw());
|
---|
783 | return S_OK;
|
---|
784 | }
|
---|
785 |
|
---|
786 |
|
---|
787 | /**
|
---|
788 | * Helper for listDhcpServers() that shows a DHCP configuration.
|
---|
789 | */
|
---|
790 | static HRESULT showDhcpConfig(ComPtr<IDHCPConfig> ptrConfig)
|
---|
791 | {
|
---|
792 | HRESULT hrcRet = S_OK;
|
---|
793 |
|
---|
794 | ULONG secs = 0;
|
---|
795 | CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MinLeaseTime)(&secs), hrcRet = hrcCheck);
|
---|
796 | if (secs == 0)
|
---|
797 | RTPrintf(" minLeaseTime: default\n");
|
---|
798 | else
|
---|
799 | RTPrintf(" minLeaseTime: %u sec\n", secs);
|
---|
800 |
|
---|
801 | secs = 0;
|
---|
802 | CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(DefaultLeaseTime)(&secs), hrcRet = hrcCheck);
|
---|
803 | if (secs == 0)
|
---|
804 | RTPrintf(" defaultLeaseTime: default\n");
|
---|
805 | else
|
---|
806 | RTPrintf(" defaultLeaseTime: %u sec\n", secs);
|
---|
807 |
|
---|
808 | secs = 0;
|
---|
809 | CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(MaxLeaseTime)(&secs), hrcRet = hrcCheck);
|
---|
810 | if (secs == 0)
|
---|
811 | RTPrintf(" maxLeaseTime: default\n");
|
---|
812 | else
|
---|
813 | RTPrintf(" maxLeaseTime: %u sec\n", secs);
|
---|
814 |
|
---|
815 | com::SafeArray<DHCPOption_T> Options;
|
---|
816 | HRESULT hrc;
|
---|
817 | CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(ForcedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
|
---|
818 | if (FAILED(hrc))
|
---|
819 | RTPrintf(" Forced options: %Rhrc\n", hrc);
|
---|
820 | else if (Options.size() == 0)
|
---|
821 | RTPrintf(" Forced options: None\n");
|
---|
822 | else
|
---|
823 | {
|
---|
824 | RTPrintf(" Forced options: ");
|
---|
825 | for (size_t i = 0; i < Options.size(); i++)
|
---|
826 | RTPrintf(i ? ", %u" : "%u", Options[i]);
|
---|
827 | RTPrintf("\n");
|
---|
828 | }
|
---|
829 |
|
---|
830 | CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(SuppressedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
|
---|
831 | if (FAILED(hrc))
|
---|
832 | RTPrintf(" Suppressed opt.s: %Rhrc\n", hrc);
|
---|
833 | else if (Options.size() == 0)
|
---|
834 | RTPrintf(" Suppressed opts.: None\n");
|
---|
835 | else
|
---|
836 | {
|
---|
837 | RTPrintf(" Suppressed opts.: ");
|
---|
838 | for (size_t i = 0; i < Options.size(); i++)
|
---|
839 | RTPrintf(i ? ", %u" : "%u", Options[i]);
|
---|
840 | RTPrintf("\n");
|
---|
841 | }
|
---|
842 |
|
---|
843 | com::SafeArray<DHCPOptionEncoding_T> Encodings;
|
---|
844 | com::SafeArray<BSTR> Values;
|
---|
845 | CHECK_ERROR2_STMT(hrc, ptrConfig, GetAllOptions(ComSafeArrayAsOutParam(Options),
|
---|
846 | ComSafeArrayAsOutParam(Encodings),
|
---|
847 | ComSafeArrayAsOutParam(Values)), hrcRet = hrc);
|
---|
848 | if (FAILED(hrc))
|
---|
849 | RTPrintf(" DHCP options: %Rhrc\n", hrc);
|
---|
850 | else if (Options.size() != Encodings.size() || Options.size() != Values.size())
|
---|
851 | {
|
---|
852 | RTPrintf(" DHCP options: Return count mismatch: %zu, %zu, %zu\n", Options.size(), Encodings.size(), Values.size());
|
---|
853 | hrcRet = E_FAIL;
|
---|
854 | }
|
---|
855 | else if (Options.size() == 0)
|
---|
856 | RTPrintf(" DHCP options: None\n");
|
---|
857 | else
|
---|
858 | for (size_t i = 0; i < Options.size(); i++)
|
---|
859 | {
|
---|
860 | switch (Encodings[i])
|
---|
861 | {
|
---|
862 | case DHCPOptionEncoding_Normal:
|
---|
863 | RTPrintf(" %3d/legacy: %ls\n", Options[i], Values[i]);
|
---|
864 | break;
|
---|
865 | case DHCPOptionEncoding_Hex:
|
---|
866 | RTPrintf(" %3d/hex: %ls\n", Options[i], Values[i]);
|
---|
867 | break;
|
---|
868 | default:
|
---|
869 | RTPrintf(" %3d/%u?: %ls\n", Options[i], Encodings[i], Values[i]);
|
---|
870 | break;
|
---|
871 | }
|
---|
872 | }
|
---|
873 |
|
---|
874 | return S_OK;
|
---|
875 | }
|
---|
876 |
|
---|
877 |
|
---|
878 | /**
|
---|
879 | * List DHCP servers.
|
---|
880 | *
|
---|
881 | * @returns See produceList.
|
---|
882 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
883 | */
|
---|
884 | static HRESULT listDhcpServers(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
885 | {
|
---|
886 | HRESULT hrcRet = S_OK;
|
---|
887 | com::SafeIfaceArray<IDHCPServer> DHCPServers;
|
---|
888 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers)), hrcCheck);
|
---|
889 | for (size_t i = 0; i < DHCPServers.size(); ++i)
|
---|
890 | {
|
---|
891 | if (i > 0)
|
---|
892 | RTPrintf("\n");
|
---|
893 |
|
---|
894 | ComPtr<IDHCPServer> ptrDHCPServer = DHCPServers[i];
|
---|
895 | Bstr bstr;
|
---|
896 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkName)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
897 | RTPrintf("NetworkName: %ls\n", bstr.raw());
|
---|
898 |
|
---|
899 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(IPAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
900 | RTPrintf("Dhcpd IP: %ls\n", bstr.raw());
|
---|
901 |
|
---|
902 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(LowerIP)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
903 | RTPrintf("LowerIPAddress: %ls\n", bstr.raw());
|
---|
904 |
|
---|
905 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(UpperIP)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
906 | RTPrintf("UpperIPAddress: %ls\n", bstr.raw());
|
---|
907 |
|
---|
908 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(NetworkMask)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
909 | RTPrintf("NetworkMask: %ls\n", bstr.raw());
|
---|
910 |
|
---|
911 | BOOL fEnabled = FALSE;
|
---|
912 | CHECK_ERROR2I_STMT(ptrDHCPServer, COMGETTER(Enabled)(&fEnabled), hrcRet = hrcCheck);
|
---|
913 | RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
914 |
|
---|
915 | /* Global configuration: */
|
---|
916 | RTPrintf("Global Configuration:\n");
|
---|
917 | HRESULT hrc;
|
---|
918 | ComPtr<IDHCPGlobalConfig> ptrGlobal;
|
---|
919 | CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GlobalConfig)(ptrGlobal.asOutParam()), hrcRet = hrc);
|
---|
920 | if (SUCCEEDED(hrc))
|
---|
921 | {
|
---|
922 | hrc = showDhcpConfig(ptrGlobal);
|
---|
923 | if (FAILED(hrc))
|
---|
924 | hrcRet = hrc;
|
---|
925 | }
|
---|
926 |
|
---|
927 | /* Group configurations: */
|
---|
928 | com::SafeIfaceArray<IDHCPGroupConfig> Groups;
|
---|
929 | CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(GroupConfigs)(ComSafeArrayAsOutParam(Groups)), hrcRet = hrc);
|
---|
930 | if (FAILED(hrc))
|
---|
931 | RTPrintf("Groups: %Rrc\n", hrc);
|
---|
932 | else if (Groups.size() == 0)
|
---|
933 | RTPrintf("Groups: None\n");
|
---|
934 | else
|
---|
935 | {
|
---|
936 | for (size_t iGrp = 0; iGrp < Groups.size(); iGrp++)
|
---|
937 | {
|
---|
938 | CHECK_ERROR2I_STMT(Groups[iGrp], COMGETTER(Name)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
939 | RTPrintf("Group: %ls\n", bstr.raw());
|
---|
940 |
|
---|
941 | com::SafeIfaceArray<IDHCPGroupCondition> Conditions;
|
---|
942 | CHECK_ERROR2_STMT(hrc, Groups[iGrp], COMGETTER(Conditions)(ComSafeArrayAsOutParam(Conditions)), hrcRet = hrc);
|
---|
943 | if (FAILED(hrc))
|
---|
944 | RTPrintf(" Conditions: %Rhrc\n", hrc);
|
---|
945 | else if (Conditions.size() == 0)
|
---|
946 | RTPrintf(" Conditions: None\n");
|
---|
947 | else
|
---|
948 | for (size_t iCond = 0; iCond < Conditions.size(); iCond++)
|
---|
949 | {
|
---|
950 | BOOL fInclusive = TRUE;
|
---|
951 | CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Inclusive)(&fInclusive), hrcRet = hrc);
|
---|
952 | DHCPGroupConditionType_T enmType = DHCPGroupConditionType_MAC;
|
---|
953 | CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Type)(&enmType), hrcRet = hrc);
|
---|
954 | CHECK_ERROR2_STMT(hrc, Conditions[iCond], COMGETTER(Value)(bstr.asOutParam()), hrcRet = hrc);
|
---|
955 |
|
---|
956 | RTPrintf(" Conditions: %s %s %ls\n",
|
---|
957 | fInclusive ? "include" : "exclude",
|
---|
958 | enmType == DHCPGroupConditionType_MAC ? "MAC "
|
---|
959 | : enmType == DHCPGroupConditionType_MACWildcard ? "MAC* "
|
---|
960 | : enmType == DHCPGroupConditionType_vendorClassID ? "VendorCID "
|
---|
961 | : enmType == DHCPGroupConditionType_vendorClassIDWildcard ? "VendorCID*"
|
---|
962 | : enmType == DHCPGroupConditionType_userClassID ? "UserCID "
|
---|
963 | : enmType == DHCPGroupConditionType_userClassIDWildcard ? "UserCID* "
|
---|
964 | : "!UNKNOWN! ",
|
---|
965 | bstr.raw());
|
---|
966 | }
|
---|
967 |
|
---|
968 | hrc = showDhcpConfig(Groups[iGrp]);
|
---|
969 | if (FAILED(hrc))
|
---|
970 | hrcRet = hrc;
|
---|
971 | }
|
---|
972 | Groups.setNull();
|
---|
973 | }
|
---|
974 |
|
---|
975 | /* Individual host / NIC configurations: */
|
---|
976 | com::SafeIfaceArray<IDHCPIndividualConfig> Hosts;
|
---|
977 | CHECK_ERROR2_STMT(hrc, ptrDHCPServer, COMGETTER(IndividualConfigs)(ComSafeArrayAsOutParam(Hosts)), hrcRet = hrc);
|
---|
978 | if (FAILED(hrc))
|
---|
979 | RTPrintf("Individual Configs: %Rrc\n", hrc);
|
---|
980 | else if (Hosts.size() == 0)
|
---|
981 | RTPrintf("Individual Configs: None\n");
|
---|
982 | else
|
---|
983 | {
|
---|
984 | for (size_t iHost = 0; iHost < Hosts.size(); iHost++)
|
---|
985 | {
|
---|
986 | DHCPConfigScope_T enmScope = DHCPConfigScope_MAC;
|
---|
987 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Scope)(&enmScope), hrcRet = hrcCheck);
|
---|
988 |
|
---|
989 | if (enmScope == DHCPConfigScope_MAC)
|
---|
990 | {
|
---|
991 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MACAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
992 | RTPrintf("Individual Config: MAC %ls\n", bstr.raw());
|
---|
993 | }
|
---|
994 | else
|
---|
995 | {
|
---|
996 | ULONG uSlot = 0;
|
---|
997 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(Slot)(&uSlot), hrcRet = hrcCheck);
|
---|
998 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(MachineId)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
999 | Bstr bstrMACAddress;
|
---|
1000 | hrc = Hosts[iHost]->COMGETTER(MACAddress)(bstrMACAddress.asOutParam()); /* No CHECK_ERROR2 stuff! */
|
---|
1001 | if (SUCCEEDED(hrc))
|
---|
1002 | RTPrintf("Individual Config: VM NIC: %ls slot %u, MAC %ls\n", bstr.raw(), uSlot, bstrMACAddress.raw());
|
---|
1003 | else
|
---|
1004 | RTPrintf("Individual Config: VM NIC: %ls slot %u, MAC %Rhrc\n", bstr.raw(), uSlot, hrc);
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | CHECK_ERROR2I_STMT(Hosts[iHost], COMGETTER(FixedAddress)(bstr.asOutParam()), hrcRet = hrcCheck);
|
---|
1008 | if (bstr.isNotEmpty())
|
---|
1009 | RTPrintf(" Fixed Address: %ls\n", bstr.raw());
|
---|
1010 | else
|
---|
1011 | RTPrintf(" Fixed Address: dynamic\n");
|
---|
1012 |
|
---|
1013 | hrc = showDhcpConfig(Hosts[iHost]);
|
---|
1014 | if (FAILED(hrc))
|
---|
1015 | hrcRet = hrc;
|
---|
1016 | }
|
---|
1017 | Hosts.setNull();
|
---|
1018 | }
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | return hrcRet;
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 | /**
|
---|
1025 | * List extension packs.
|
---|
1026 | *
|
---|
1027 | * @returns See produceList.
|
---|
1028 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
1029 | */
|
---|
1030 | static HRESULT listExtensionPacks(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
1031 | {
|
---|
1032 | ComObjPtr<IExtPackManager> ptrExtPackMgr;
|
---|
1033 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
|
---|
1034 |
|
---|
1035 | SafeIfaceArray<IExtPack> extPacks;
|
---|
1036 | CHECK_ERROR2I_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
|
---|
1037 | RTPrintf("Extension Packs: %u\n", extPacks.size());
|
---|
1038 |
|
---|
1039 | HRESULT hrc = S_OK;
|
---|
1040 | for (size_t i = 0; i < extPacks.size(); i++)
|
---|
1041 | {
|
---|
1042 | /* Read all the properties. */
|
---|
1043 | Bstr bstrName;
|
---|
1044 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
|
---|
1045 | Bstr bstrDesc;
|
---|
1046 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
|
---|
1047 | Bstr bstrVersion;
|
---|
1048 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
|
---|
1049 | ULONG uRevision;
|
---|
1050 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Revision)(&uRevision), hrc = hrcCheck; uRevision = 0);
|
---|
1051 | Bstr bstrEdition;
|
---|
1052 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
|
---|
1053 | Bstr bstrVrdeModule;
|
---|
1054 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.setNull());
|
---|
1055 | BOOL fUsable;
|
---|
1056 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Usable)(&fUsable), hrc = hrcCheck; fUsable = FALSE);
|
---|
1057 | Bstr bstrWhy;
|
---|
1058 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
|
---|
1059 |
|
---|
1060 | /* Display them. */
|
---|
1061 | if (i)
|
---|
1062 | RTPrintf("\n");
|
---|
1063 | RTPrintf("Pack no.%2zu: %ls\n"
|
---|
1064 | "Version: %ls\n"
|
---|
1065 | "Revision: %u\n"
|
---|
1066 | "Edition: %ls\n"
|
---|
1067 | "Description: %ls\n"
|
---|
1068 | "VRDE Module: %ls\n"
|
---|
1069 | "Usable: %RTbool\n"
|
---|
1070 | "Why unusable: %ls\n",
|
---|
1071 | i, bstrName.raw(),
|
---|
1072 | bstrVersion.raw(),
|
---|
1073 | uRevision,
|
---|
1074 | bstrEdition.raw(),
|
---|
1075 | bstrDesc.raw(),
|
---|
1076 | bstrVrdeModule.raw(),
|
---|
1077 | fUsable != FALSE,
|
---|
1078 | bstrWhy.raw());
|
---|
1079 |
|
---|
1080 | /* Query plugins and display them. */
|
---|
1081 | }
|
---|
1082 | return hrc;
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 |
|
---|
1086 | /**
|
---|
1087 | * List machine groups.
|
---|
1088 | *
|
---|
1089 | * @returns See produceList.
|
---|
1090 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
1091 | */
|
---|
1092 | static HRESULT listGroups(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
1093 | {
|
---|
1094 | SafeArray<BSTR> groups;
|
---|
1095 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(MachineGroups)(ComSafeArrayAsOutParam(groups)), hrcCheck);
|
---|
1096 |
|
---|
1097 | for (size_t i = 0; i < groups.size(); i++)
|
---|
1098 | {
|
---|
1099 | RTPrintf("\"%ls\"\n", groups[i]);
|
---|
1100 | }
|
---|
1101 | return S_OK;
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 |
|
---|
1105 | /**
|
---|
1106 | * List video capture devices.
|
---|
1107 | *
|
---|
1108 | * @returns See produceList.
|
---|
1109 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1110 | */
|
---|
1111 | static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
1112 | {
|
---|
1113 | HRESULT rc;
|
---|
1114 | ComPtr<IHost> host;
|
---|
1115 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1116 | com::SafeIfaceArray<IHostVideoInputDevice> hostVideoInputDevices;
|
---|
1117 | CHECK_ERROR(host, COMGETTER(VideoInputDevices)(ComSafeArrayAsOutParam(hostVideoInputDevices)));
|
---|
1118 | RTPrintf("Video Input Devices: %u\n", hostVideoInputDevices.size());
|
---|
1119 | for (size_t i = 0; i < hostVideoInputDevices.size(); ++i)
|
---|
1120 | {
|
---|
1121 | ComPtr<IHostVideoInputDevice> p = hostVideoInputDevices[i];
|
---|
1122 | Bstr name;
|
---|
1123 | p->COMGETTER(Name)(name.asOutParam());
|
---|
1124 | Bstr path;
|
---|
1125 | p->COMGETTER(Path)(path.asOutParam());
|
---|
1126 | Bstr alias;
|
---|
1127 | p->COMGETTER(Alias)(alias.asOutParam());
|
---|
1128 | RTPrintf("%ls \"%ls\"\n%ls\n", alias.raw(), name.raw(), path.raw());
|
---|
1129 | }
|
---|
1130 | return rc;
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | /**
|
---|
1134 | * List supported screen shot formats.
|
---|
1135 | *
|
---|
1136 | * @returns See produceList.
|
---|
1137 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1138 | */
|
---|
1139 | static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
1140 | {
|
---|
1141 | HRESULT rc = S_OK;
|
---|
1142 | ComPtr<ISystemProperties> systemProperties;
|
---|
1143 | CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
|
---|
1144 | com::SafeArray<BitmapFormat_T> formats;
|
---|
1145 | CHECK_ERROR(systemProperties, COMGETTER(ScreenShotFormats)(ComSafeArrayAsOutParam(formats)));
|
---|
1146 |
|
---|
1147 | RTPrintf("Supported %d screen shot formats:\n", formats.size());
|
---|
1148 | for (size_t i = 0; i < formats.size(); ++i)
|
---|
1149 | {
|
---|
1150 | uint32_t u32Format = (uint32_t)formats[i];
|
---|
1151 | char szFormat[5];
|
---|
1152 | szFormat[0] = RT_BYTE1(u32Format);
|
---|
1153 | szFormat[1] = RT_BYTE2(u32Format);
|
---|
1154 | szFormat[2] = RT_BYTE3(u32Format);
|
---|
1155 | szFormat[3] = RT_BYTE4(u32Format);
|
---|
1156 | szFormat[4] = 0;
|
---|
1157 | RTPrintf(" BitmapFormat_%s (0x%08X)\n", szFormat, u32Format);
|
---|
1158 | }
|
---|
1159 | return rc;
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 | /**
|
---|
1163 | * List available cloud providers.
|
---|
1164 | *
|
---|
1165 | * @returns See produceList.
|
---|
1166 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1167 | */
|
---|
1168 | static HRESULT listCloudProviders(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
1169 | {
|
---|
1170 | HRESULT rc = S_OK;
|
---|
1171 | ComPtr<ICloudProviderManager> pCloudProviderManager;
|
---|
1172 | CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
|
---|
1173 | com::SafeIfaceArray<ICloudProvider> apCloudProviders;
|
---|
1174 | CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
|
---|
1175 |
|
---|
1176 | RTPrintf("Supported %d cloud providers:\n", apCloudProviders.size());
|
---|
1177 | for (size_t i = 0; i < apCloudProviders.size(); ++i)
|
---|
1178 | {
|
---|
1179 | ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
|
---|
1180 | Bstr bstrProviderName;
|
---|
1181 | pCloudProvider->COMGETTER(Name)(bstrProviderName.asOutParam());
|
---|
1182 | RTPrintf("Name: %ls\n", bstrProviderName.raw());
|
---|
1183 | pCloudProvider->COMGETTER(ShortName)(bstrProviderName.asOutParam());
|
---|
1184 | RTPrintf("Short Name: %ls\n", bstrProviderName.raw());
|
---|
1185 | Bstr bstrProviderID;
|
---|
1186 | pCloudProvider->COMGETTER(Id)(bstrProviderID.asOutParam());
|
---|
1187 | RTPrintf("GUID: %ls\n", bstrProviderID.raw());
|
---|
1188 |
|
---|
1189 | RTPrintf("\n");
|
---|
1190 | }
|
---|
1191 | return rc;
|
---|
1192 | }
|
---|
1193 |
|
---|
1194 |
|
---|
1195 | /**
|
---|
1196 | * List all available cloud profiles (by iterating over the cloud providers).
|
---|
1197 | *
|
---|
1198 | * @returns See produceList.
|
---|
1199 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
1200 | * @param fOptLong If true, list all profile properties.
|
---|
1201 | */
|
---|
1202 | static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> pVirtualBox, bool fOptLong)
|
---|
1203 | {
|
---|
1204 | HRESULT rc = S_OK;
|
---|
1205 | ComPtr<ICloudProviderManager> pCloudProviderManager;
|
---|
1206 | CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
|
---|
1207 | com::SafeIfaceArray<ICloudProvider> apCloudProviders;
|
---|
1208 | CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
|
---|
1209 |
|
---|
1210 | for (size_t i = 0; i < apCloudProviders.size(); ++i)
|
---|
1211 | {
|
---|
1212 | ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
|
---|
1213 | com::SafeIfaceArray<ICloudProfile> apCloudProfiles;
|
---|
1214 | CHECK_ERROR(pCloudProvider, COMGETTER(Profiles)(ComSafeArrayAsOutParam(apCloudProfiles)));
|
---|
1215 | for (size_t j = 0; j < apCloudProfiles.size(); ++j)
|
---|
1216 | {
|
---|
1217 | ComPtr<ICloudProfile> pCloudProfile = apCloudProfiles[j];
|
---|
1218 | Bstr bstrProfileName;
|
---|
1219 | pCloudProfile->COMGETTER(Name)(bstrProfileName.asOutParam());
|
---|
1220 | RTPrintf("Name: %ls\n", bstrProfileName.raw());
|
---|
1221 | Bstr bstrProviderID;
|
---|
1222 | pCloudProfile->COMGETTER(ProviderId)(bstrProviderID.asOutParam());
|
---|
1223 | RTPrintf("Provider GUID: %ls\n", bstrProviderID.raw());
|
---|
1224 |
|
---|
1225 | if (fOptLong)
|
---|
1226 | {
|
---|
1227 | com::SafeArray<BSTR> names;
|
---|
1228 | com::SafeArray<BSTR> values;
|
---|
1229 | pCloudProfile->GetProperties(Bstr().raw(), ComSafeArrayAsOutParam(names), ComSafeArrayAsOutParam(values));
|
---|
1230 | size_t cNames = names.size();
|
---|
1231 | size_t cValues = values.size();
|
---|
1232 | bool fFirst = true;
|
---|
1233 | for (size_t k = 0; k < cNames; k++)
|
---|
1234 | {
|
---|
1235 | Bstr value;
|
---|
1236 | if (k < cValues)
|
---|
1237 | value = values[k];
|
---|
1238 | RTPrintf("%s%ls=%ls\n",
|
---|
1239 | fFirst ? "Property: " : " ",
|
---|
1240 | names[k], value.raw());
|
---|
1241 | fFirst = false;
|
---|
1242 | }
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 | RTPrintf("\n");
|
---|
1246 | }
|
---|
1247 | }
|
---|
1248 | return rc;
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 |
|
---|
1252 | /**
|
---|
1253 | * The type of lists we can produce.
|
---|
1254 | */
|
---|
1255 | enum enmListType
|
---|
1256 | {
|
---|
1257 | kListNotSpecified = 1000,
|
---|
1258 | kListVMs,
|
---|
1259 | kListRunningVMs,
|
---|
1260 | kListOsTypes,
|
---|
1261 | kListHostDvds,
|
---|
1262 | kListHostFloppies,
|
---|
1263 | kListInternalNetworks,
|
---|
1264 | kListBridgedInterfaces,
|
---|
1265 | #if defined(VBOX_WITH_NETFLT)
|
---|
1266 | kListHostOnlyInterfaces,
|
---|
1267 | #endif
|
---|
1268 | kListHostCpuIDs,
|
---|
1269 | kListHostInfo,
|
---|
1270 | kListHddBackends,
|
---|
1271 | kListHdds,
|
---|
1272 | kListDvds,
|
---|
1273 | kListFloppies,
|
---|
1274 | kListUsbHost,
|
---|
1275 | kListUsbFilters,
|
---|
1276 | kListSystemProperties,
|
---|
1277 | kListDhcpServers,
|
---|
1278 | kListExtPacks,
|
---|
1279 | kListGroups,
|
---|
1280 | kListNatNetworks,
|
---|
1281 | kListVideoInputDevices,
|
---|
1282 | kListScreenShotFormats,
|
---|
1283 | kListCloudProviders,
|
---|
1284 | kListCloudProfiles,
|
---|
1285 | };
|
---|
1286 |
|
---|
1287 |
|
---|
1288 | /**
|
---|
1289 | * Produces the specified listing.
|
---|
1290 | *
|
---|
1291 | * @returns S_OK or some COM error code that has been reported in full.
|
---|
1292 | * @param enmList The list to produce.
|
---|
1293 | * @param fOptLong Long (@c true) or short list format.
|
---|
1294 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
1295 | */
|
---|
1296 | static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, bool fOptSorted, const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
1297 | {
|
---|
1298 | HRESULT rc = S_OK;
|
---|
1299 | switch (enmCommand)
|
---|
1300 | {
|
---|
1301 | case kListNotSpecified:
|
---|
1302 | AssertFailed();
|
---|
1303 | return E_FAIL;
|
---|
1304 |
|
---|
1305 | case kListVMs:
|
---|
1306 | {
|
---|
1307 | /*
|
---|
1308 | * Get the list of all registered VMs
|
---|
1309 | */
|
---|
1310 | com::SafeIfaceArray<IMachine> machines;
|
---|
1311 | rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
1312 | if (SUCCEEDED(rc))
|
---|
1313 | {
|
---|
1314 | /*
|
---|
1315 | * Display it.
|
---|
1316 | */
|
---|
1317 | if (!fOptSorted)
|
---|
1318 | {
|
---|
1319 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
1320 | if (machines[i])
|
---|
1321 | rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
1322 | }
|
---|
1323 | else
|
---|
1324 | {
|
---|
1325 | /*
|
---|
1326 | * Sort the list by name before displaying it.
|
---|
1327 | */
|
---|
1328 | std::vector<std::pair<com::Bstr, IMachine *> > sortedMachines;
|
---|
1329 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
1330 | {
|
---|
1331 | IMachine *pMachine = machines[i];
|
---|
1332 | if (pMachine) /* no idea why we need to do this... */
|
---|
1333 | {
|
---|
1334 | Bstr bstrName;
|
---|
1335 | pMachine->COMGETTER(Name)(bstrName.asOutParam());
|
---|
1336 | sortedMachines.push_back(std::pair<com::Bstr, IMachine *>(bstrName, pMachine));
|
---|
1337 | }
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | std::sort(sortedMachines.begin(), sortedMachines.end());
|
---|
1341 |
|
---|
1342 | for (size_t i = 0; i < sortedMachines.size(); ++i)
|
---|
1343 | rc = showVMInfo(pVirtualBox, sortedMachines[i].second, NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
1344 | }
|
---|
1345 | }
|
---|
1346 | break;
|
---|
1347 | }
|
---|
1348 |
|
---|
1349 | case kListRunningVMs:
|
---|
1350 | {
|
---|
1351 | /*
|
---|
1352 | * Get the list of all _running_ VMs
|
---|
1353 | */
|
---|
1354 | com::SafeIfaceArray<IMachine> machines;
|
---|
1355 | rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
1356 | com::SafeArray<MachineState_T> states;
|
---|
1357 | if (SUCCEEDED(rc))
|
---|
1358 | rc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
|
---|
1359 | if (SUCCEEDED(rc))
|
---|
1360 | {
|
---|
1361 | /*
|
---|
1362 | * Iterate through the collection
|
---|
1363 | */
|
---|
1364 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
1365 | {
|
---|
1366 | if (machines[i])
|
---|
1367 | {
|
---|
1368 | MachineState_T machineState = states[i];
|
---|
1369 | switch (machineState)
|
---|
1370 | {
|
---|
1371 | case MachineState_Running:
|
---|
1372 | case MachineState_Teleporting:
|
---|
1373 | case MachineState_LiveSnapshotting:
|
---|
1374 | case MachineState_Paused:
|
---|
1375 | case MachineState_TeleportingPausedVM:
|
---|
1376 | rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
1377 | break;
|
---|
1378 | default: break; /* Shut up MSC */
|
---|
1379 | }
|
---|
1380 | }
|
---|
1381 | }
|
---|
1382 | }
|
---|
1383 | break;
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | case kListOsTypes:
|
---|
1387 | {
|
---|
1388 | com::SafeIfaceArray<IGuestOSType> coll;
|
---|
1389 | rc = pVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
|
---|
1390 | if (SUCCEEDED(rc))
|
---|
1391 | {
|
---|
1392 | /*
|
---|
1393 | * Iterate through the collection.
|
---|
1394 | */
|
---|
1395 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1396 | {
|
---|
1397 | ComPtr<IGuestOSType> guestOS;
|
---|
1398 | guestOS = coll[i];
|
---|
1399 | Bstr guestId;
|
---|
1400 | guestOS->COMGETTER(Id)(guestId.asOutParam());
|
---|
1401 | RTPrintf("ID: %ls\n", guestId.raw());
|
---|
1402 | Bstr guestDescription;
|
---|
1403 | guestOS->COMGETTER(Description)(guestDescription.asOutParam());
|
---|
1404 | RTPrintf("Description: %ls\n", guestDescription.raw());
|
---|
1405 | Bstr familyId;
|
---|
1406 | guestOS->COMGETTER(FamilyId)(familyId.asOutParam());
|
---|
1407 | RTPrintf("Family ID: %ls\n", familyId.raw());
|
---|
1408 | Bstr familyDescription;
|
---|
1409 | guestOS->COMGETTER(FamilyDescription)(familyDescription.asOutParam());
|
---|
1410 | RTPrintf("Family Desc: %ls\n", familyDescription.raw());
|
---|
1411 | BOOL is64Bit;
|
---|
1412 | guestOS->COMGETTER(Is64Bit)(&is64Bit);
|
---|
1413 | RTPrintf("64 bit: %RTbool\n", is64Bit);
|
---|
1414 | RTPrintf("\n");
|
---|
1415 | }
|
---|
1416 | }
|
---|
1417 | break;
|
---|
1418 | }
|
---|
1419 |
|
---|
1420 | case kListHostDvds:
|
---|
1421 | {
|
---|
1422 | ComPtr<IHost> host;
|
---|
1423 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1424 | com::SafeIfaceArray<IMedium> coll;
|
---|
1425 | CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
1426 | if (SUCCEEDED(rc))
|
---|
1427 | {
|
---|
1428 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1429 | {
|
---|
1430 | ComPtr<IMedium> dvdDrive = coll[i];
|
---|
1431 | Bstr uuid;
|
---|
1432 | dvdDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
1433 | RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
|
---|
1434 | Bstr location;
|
---|
1435 | dvdDrive->COMGETTER(Location)(location.asOutParam());
|
---|
1436 | RTPrintf("Name: %ls\n\n", location.raw());
|
---|
1437 | }
|
---|
1438 | }
|
---|
1439 | break;
|
---|
1440 | }
|
---|
1441 |
|
---|
1442 | case kListHostFloppies:
|
---|
1443 | {
|
---|
1444 | ComPtr<IHost> host;
|
---|
1445 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1446 | com::SafeIfaceArray<IMedium> coll;
|
---|
1447 | CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
1448 | if (SUCCEEDED(rc))
|
---|
1449 | {
|
---|
1450 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1451 | {
|
---|
1452 | ComPtr<IMedium> floppyDrive = coll[i];
|
---|
1453 | Bstr uuid;
|
---|
1454 | floppyDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
1455 | RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
|
---|
1456 | Bstr location;
|
---|
1457 | floppyDrive->COMGETTER(Location)(location.asOutParam());
|
---|
1458 | RTPrintf("Name: %ls\n\n", location.raw());
|
---|
1459 | }
|
---|
1460 | }
|
---|
1461 | break;
|
---|
1462 | }
|
---|
1463 |
|
---|
1464 | case kListInternalNetworks:
|
---|
1465 | rc = listInternalNetworks(pVirtualBox);
|
---|
1466 | break;
|
---|
1467 |
|
---|
1468 | case kListBridgedInterfaces:
|
---|
1469 | #if defined(VBOX_WITH_NETFLT)
|
---|
1470 | case kListHostOnlyInterfaces:
|
---|
1471 | #endif
|
---|
1472 | rc = listNetworkInterfaces(pVirtualBox, enmCommand == kListBridgedInterfaces);
|
---|
1473 | break;
|
---|
1474 |
|
---|
1475 | case kListHostInfo:
|
---|
1476 | rc = listHostInfo(pVirtualBox);
|
---|
1477 | break;
|
---|
1478 |
|
---|
1479 | case kListHostCpuIDs:
|
---|
1480 | {
|
---|
1481 | ComPtr<IHost> Host;
|
---|
1482 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
1483 |
|
---|
1484 | RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n");
|
---|
1485 | ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
|
---|
1486 | static uint32_t const s_auCpuIdRanges[] =
|
---|
1487 | {
|
---|
1488 | UINT32_C(0x00000000), UINT32_C(0x0000007f),
|
---|
1489 | UINT32_C(0x80000000), UINT32_C(0x8000007f),
|
---|
1490 | UINT32_C(0xc0000000), UINT32_C(0xc000007f)
|
---|
1491 | };
|
---|
1492 | for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
|
---|
1493 | {
|
---|
1494 | ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
|
---|
1495 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
|
---|
1496 | if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
|
---|
1497 | continue;
|
---|
1498 | cLeafs++;
|
---|
1499 | for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
|
---|
1500 | {
|
---|
1501 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
|
---|
1502 | RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
|
---|
1503 | }
|
---|
1504 | }
|
---|
1505 | break;
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 | case kListHddBackends:
|
---|
1509 | rc = listHddBackends(pVirtualBox);
|
---|
1510 | break;
|
---|
1511 |
|
---|
1512 | case kListHdds:
|
---|
1513 | {
|
---|
1514 | com::SafeIfaceArray<IMedium> hdds;
|
---|
1515 | CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
|
---|
1516 | rc = listMedia(pVirtualBox, hdds, "base", fOptLong);
|
---|
1517 | break;
|
---|
1518 | }
|
---|
1519 |
|
---|
1520 | case kListDvds:
|
---|
1521 | {
|
---|
1522 | com::SafeIfaceArray<IMedium> dvds;
|
---|
1523 | CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
|
---|
1524 | rc = listMedia(pVirtualBox, dvds, NULL, fOptLong);
|
---|
1525 | break;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | case kListFloppies:
|
---|
1529 | {
|
---|
1530 | com::SafeIfaceArray<IMedium> floppies;
|
---|
1531 | CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
|
---|
1532 | rc = listMedia(pVirtualBox, floppies, NULL, fOptLong);
|
---|
1533 | break;
|
---|
1534 | }
|
---|
1535 |
|
---|
1536 | case kListUsbHost:
|
---|
1537 | rc = listUsbHost(pVirtualBox);
|
---|
1538 | break;
|
---|
1539 |
|
---|
1540 | case kListUsbFilters:
|
---|
1541 | rc = listUsbFilters(pVirtualBox);
|
---|
1542 | break;
|
---|
1543 |
|
---|
1544 | case kListSystemProperties:
|
---|
1545 | rc = listSystemProperties(pVirtualBox);
|
---|
1546 | break;
|
---|
1547 |
|
---|
1548 | case kListDhcpServers:
|
---|
1549 | rc = listDhcpServers(pVirtualBox);
|
---|
1550 | break;
|
---|
1551 |
|
---|
1552 | case kListExtPacks:
|
---|
1553 | rc = listExtensionPacks(pVirtualBox);
|
---|
1554 | break;
|
---|
1555 |
|
---|
1556 | case kListGroups:
|
---|
1557 | rc = listGroups(pVirtualBox);
|
---|
1558 | break;
|
---|
1559 |
|
---|
1560 | case kListNatNetworks:
|
---|
1561 | {
|
---|
1562 | com::SafeIfaceArray<INATNetwork> nets;
|
---|
1563 | CHECK_ERROR(pVirtualBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(nets)));
|
---|
1564 | for (size_t i = 0; i < nets.size(); ++i)
|
---|
1565 | {
|
---|
1566 | ComPtr<INATNetwork> net = nets[i];
|
---|
1567 | Bstr netName;
|
---|
1568 | net->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
1569 | RTPrintf("NetworkName: %ls\n", netName.raw());
|
---|
1570 | Bstr gateway;
|
---|
1571 | net->COMGETTER(Gateway)(gateway.asOutParam());
|
---|
1572 | RTPrintf("IP: %ls\n", gateway.raw());
|
---|
1573 | Bstr network;
|
---|
1574 | net->COMGETTER(Network)(network.asOutParam());
|
---|
1575 | RTPrintf("Network: %ls\n", network.raw());
|
---|
1576 | BOOL fEnabled;
|
---|
1577 | net->COMGETTER(IPv6Enabled)(&fEnabled);
|
---|
1578 | RTPrintf("IPv6 Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1579 | Bstr ipv6prefix;
|
---|
1580 | net->COMGETTER(IPv6Prefix)(ipv6prefix.asOutParam());
|
---|
1581 | RTPrintf("IPv6 Prefix: %ls\n", ipv6prefix.raw());
|
---|
1582 | net->COMGETTER(NeedDhcpServer)(&fEnabled);
|
---|
1583 | RTPrintf("DHCP Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1584 | net->COMGETTER(Enabled)(&fEnabled);
|
---|
1585 | RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1586 |
|
---|
1587 | #define PRINT_STRING_ARRAY(title) \
|
---|
1588 | if (strs.size() > 0) \
|
---|
1589 | { \
|
---|
1590 | RTPrintf(title); \
|
---|
1591 | size_t j = 0; \
|
---|
1592 | for (;j < strs.size(); ++j) \
|
---|
1593 | RTPrintf(" %s\n", Utf8Str(strs[j]).c_str()); \
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 | com::SafeArray<BSTR> strs;
|
---|
1597 |
|
---|
1598 | CHECK_ERROR(nets[i], COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(strs)));
|
---|
1599 | PRINT_STRING_ARRAY("Port-forwarding (ipv4)\n");
|
---|
1600 | strs.setNull();
|
---|
1601 |
|
---|
1602 | CHECK_ERROR(nets[i], COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(strs)));
|
---|
1603 | PRINT_STRING_ARRAY("Port-forwarding (ipv6)\n");
|
---|
1604 | strs.setNull();
|
---|
1605 |
|
---|
1606 | CHECK_ERROR(nets[i], COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs)));
|
---|
1607 | PRINT_STRING_ARRAY("loopback mappings (ipv4)\n");
|
---|
1608 | strs.setNull();
|
---|
1609 |
|
---|
1610 | #undef PRINT_STRING_ARRAY
|
---|
1611 | RTPrintf("\n");
|
---|
1612 | }
|
---|
1613 | break;
|
---|
1614 | }
|
---|
1615 |
|
---|
1616 | case kListVideoInputDevices:
|
---|
1617 | rc = listVideoInputDevices(pVirtualBox);
|
---|
1618 | break;
|
---|
1619 |
|
---|
1620 | case kListScreenShotFormats:
|
---|
1621 | rc = listScreenShotFormats(pVirtualBox);
|
---|
1622 | break;
|
---|
1623 |
|
---|
1624 | case kListCloudProviders:
|
---|
1625 | rc = listCloudProviders(pVirtualBox);
|
---|
1626 | break;
|
---|
1627 |
|
---|
1628 | case kListCloudProfiles:
|
---|
1629 | rc = listCloudProfiles(pVirtualBox, fOptLong);
|
---|
1630 | break;
|
---|
1631 |
|
---|
1632 | /* No default here, want gcc warnings. */
|
---|
1633 |
|
---|
1634 | } /* end switch */
|
---|
1635 |
|
---|
1636 | return rc;
|
---|
1637 | }
|
---|
1638 |
|
---|
1639 | /**
|
---|
1640 | * Handles the 'list' command.
|
---|
1641 | *
|
---|
1642 | * @returns Appropriate exit code.
|
---|
1643 | * @param a Handler argument.
|
---|
1644 | */
|
---|
1645 | RTEXITCODE handleList(HandlerArg *a)
|
---|
1646 | {
|
---|
1647 | bool fOptLong = false;
|
---|
1648 | bool fOptMultiple = false;
|
---|
1649 | bool fOptSorted = false;
|
---|
1650 | enum enmListType enmOptCommand = kListNotSpecified;
|
---|
1651 |
|
---|
1652 | static const RTGETOPTDEF s_aListOptions[] =
|
---|
1653 | {
|
---|
1654 | { "--long", 'l', RTGETOPT_REQ_NOTHING },
|
---|
1655 | { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */
|
---|
1656 | { "--sorted", 's', RTGETOPT_REQ_NOTHING },
|
---|
1657 | { "vms", kListVMs, RTGETOPT_REQ_NOTHING },
|
---|
1658 | { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING },
|
---|
1659 | { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING },
|
---|
1660 | { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING },
|
---|
1661 | { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING },
|
---|
1662 | { "intnets", kListInternalNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1663 | { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
|
---|
1664 | { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING },
|
---|
1665 | #if defined(VBOX_WITH_NETFLT)
|
---|
1666 | { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
|
---|
1667 | #endif
|
---|
1668 | { "natnetworks", kListNatNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1669 | { "natnets", kListNatNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1670 | { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING },
|
---|
1671 | { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING },
|
---|
1672 | { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING },
|
---|
1673 | { "hdds", kListHdds, RTGETOPT_REQ_NOTHING },
|
---|
1674 | { "dvds", kListDvds, RTGETOPT_REQ_NOTHING },
|
---|
1675 | { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING },
|
---|
1676 | { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING },
|
---|
1677 | { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING },
|
---|
1678 | { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING },
|
---|
1679 | { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING },
|
---|
1680 | { "extpacks", kListExtPacks, RTGETOPT_REQ_NOTHING },
|
---|
1681 | { "groups", kListGroups, RTGETOPT_REQ_NOTHING },
|
---|
1682 | { "webcams", kListVideoInputDevices, RTGETOPT_REQ_NOTHING },
|
---|
1683 | { "screenshotformats", kListScreenShotFormats, RTGETOPT_REQ_NOTHING },
|
---|
1684 | { "cloudproviders", kListCloudProviders, RTGETOPT_REQ_NOTHING },
|
---|
1685 | { "cloudprofiles", kListCloudProfiles, RTGETOPT_REQ_NOTHING },
|
---|
1686 | };
|
---|
1687 |
|
---|
1688 | int ch;
|
---|
1689 | RTGETOPTUNION ValueUnion;
|
---|
1690 | RTGETOPTSTATE GetState;
|
---|
1691 | RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
|
---|
1692 | 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
|
---|
1693 | while ((ch = RTGetOpt(&GetState, &ValueUnion)))
|
---|
1694 | {
|
---|
1695 | switch (ch)
|
---|
1696 | {
|
---|
1697 | case 'l': /* --long */
|
---|
1698 | fOptLong = true;
|
---|
1699 | break;
|
---|
1700 |
|
---|
1701 | case 's':
|
---|
1702 | fOptSorted = true;
|
---|
1703 | break;
|
---|
1704 |
|
---|
1705 | case 'm':
|
---|
1706 | fOptMultiple = true;
|
---|
1707 | if (enmOptCommand == kListNotSpecified)
|
---|
1708 | break;
|
---|
1709 | ch = enmOptCommand;
|
---|
1710 | RT_FALL_THRU();
|
---|
1711 |
|
---|
1712 | case kListVMs:
|
---|
1713 | case kListRunningVMs:
|
---|
1714 | case kListOsTypes:
|
---|
1715 | case kListHostDvds:
|
---|
1716 | case kListHostFloppies:
|
---|
1717 | case kListInternalNetworks:
|
---|
1718 | case kListBridgedInterfaces:
|
---|
1719 | #if defined(VBOX_WITH_NETFLT)
|
---|
1720 | case kListHostOnlyInterfaces:
|
---|
1721 | #endif
|
---|
1722 | case kListHostInfo:
|
---|
1723 | case kListHostCpuIDs:
|
---|
1724 | case kListHddBackends:
|
---|
1725 | case kListHdds:
|
---|
1726 | case kListDvds:
|
---|
1727 | case kListFloppies:
|
---|
1728 | case kListUsbHost:
|
---|
1729 | case kListUsbFilters:
|
---|
1730 | case kListSystemProperties:
|
---|
1731 | case kListDhcpServers:
|
---|
1732 | case kListExtPacks:
|
---|
1733 | case kListGroups:
|
---|
1734 | case kListNatNetworks:
|
---|
1735 | case kListVideoInputDevices:
|
---|
1736 | case kListScreenShotFormats:
|
---|
1737 | case kListCloudProviders:
|
---|
1738 | case kListCloudProfiles:
|
---|
1739 | enmOptCommand = (enum enmListType)ch;
|
---|
1740 | if (fOptMultiple)
|
---|
1741 | {
|
---|
1742 | HRESULT hrc = produceList((enum enmListType)ch, fOptLong, fOptSorted, a->virtualBox);
|
---|
1743 | if (FAILED(hrc))
|
---|
1744 | return RTEXITCODE_FAILURE;
|
---|
1745 | }
|
---|
1746 | break;
|
---|
1747 |
|
---|
1748 | case VINF_GETOPT_NOT_OPTION:
|
---|
1749 | return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
|
---|
1750 |
|
---|
1751 | default:
|
---|
1752 | return errorGetOpt(USAGE_LIST, ch, &ValueUnion);
|
---|
1753 | }
|
---|
1754 | }
|
---|
1755 |
|
---|
1756 | /*
|
---|
1757 | * If not in multiple list mode, we have to produce the list now.
|
---|
1758 | */
|
---|
1759 | if (enmOptCommand == kListNotSpecified)
|
---|
1760 | return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
|
---|
1761 | if (!fOptMultiple)
|
---|
1762 | {
|
---|
1763 | HRESULT hrc = produceList(enmOptCommand, fOptLong, fOptSorted, a->virtualBox);
|
---|
1764 | if (FAILED(hrc))
|
---|
1765 | return RTEXITCODE_FAILURE;
|
---|
1766 | }
|
---|
1767 |
|
---|
1768 | return RTEXITCODE_SUCCESS;
|
---|
1769 | }
|
---|
1770 |
|
---|
1771 | #endif /* !VBOX_ONLY_DOCS */
|
---|
1772 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|