1 | /* $Id: VBoxManageList.cpp 64910 2016-12-16 13:36:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - The 'list' command.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 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 "VBoxManage.h"
|
---|
41 | using namespace com;
|
---|
42 |
|
---|
43 | #ifdef VBOX_WITH_HOSTNETIF_API
|
---|
44 | static const char *getHostIfMediumTypeText(HostNetworkInterfaceMediumType_T enmType)
|
---|
45 | {
|
---|
46 | switch (enmType)
|
---|
47 | {
|
---|
48 | case HostNetworkInterfaceMediumType_Ethernet: return "Ethernet";
|
---|
49 | case HostNetworkInterfaceMediumType_PPP: return "PPP";
|
---|
50 | case HostNetworkInterfaceMediumType_SLIP: return "SLIP";
|
---|
51 | case HostNetworkInterfaceMediumType_Unknown: return "Unknown";
|
---|
52 | }
|
---|
53 | return "unknown";
|
---|
54 | }
|
---|
55 |
|
---|
56 | static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
|
---|
57 | {
|
---|
58 | switch (enmStatus)
|
---|
59 | {
|
---|
60 | case HostNetworkInterfaceStatus_Up: return "Up";
|
---|
61 | case HostNetworkInterfaceStatus_Down: return "Down";
|
---|
62 | case HostNetworkInterfaceStatus_Unknown: return "Unknown";
|
---|
63 | }
|
---|
64 | return "unknown";
|
---|
65 | }
|
---|
66 | #endif /* VBOX_WITH_HOSTNETIF_API */
|
---|
67 |
|
---|
68 | static const char*getDeviceTypeText(DeviceType_T enmType)
|
---|
69 | {
|
---|
70 | switch (enmType)
|
---|
71 | {
|
---|
72 | case DeviceType_HardDisk: return "HardDisk";
|
---|
73 | case DeviceType_DVD: return "DVD";
|
---|
74 | case DeviceType_Floppy: return "Floppy";
|
---|
75 | /* Make MSC happy */
|
---|
76 | case DeviceType_Null: return "Null";
|
---|
77 | case DeviceType_Network: return "Network";
|
---|
78 | case DeviceType_USB: return "USB";
|
---|
79 | case DeviceType_SharedFolder: return "SharedFolder";
|
---|
80 | case DeviceType_Graphics3D: return "Graphics3D";
|
---|
81 | }
|
---|
82 | return "Unknown";
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * List internal networks.
|
---|
88 | *
|
---|
89 | * @returns See produceList.
|
---|
90 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
91 | */
|
---|
92 | static HRESULT listInternalNetworks(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
93 | {
|
---|
94 | HRESULT rc;
|
---|
95 | com::SafeArray<BSTR> internalNetworks;
|
---|
96 | CHECK_ERROR(pVirtualBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks)));
|
---|
97 | for (size_t i = 0; i < internalNetworks.size(); ++i)
|
---|
98 | {
|
---|
99 | RTPrintf("Name: %ls\n", internalNetworks[i]);
|
---|
100 | }
|
---|
101 | return rc;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * List network interfaces information (bridged/host only).
|
---|
107 | *
|
---|
108 | * @returns See produceList.
|
---|
109 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
110 | * @param fIsBridged Selects between listing host interfaces (for
|
---|
111 | * use with bridging) or host only interfaces.
|
---|
112 | */
|
---|
113 | static HRESULT listNetworkInterfaces(const ComPtr<IVirtualBox> pVirtualBox,
|
---|
114 | bool fIsBridged)
|
---|
115 | {
|
---|
116 | HRESULT rc;
|
---|
117 | ComPtr<IHost> host;
|
---|
118 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
119 | com::SafeIfaceArray<IHostNetworkInterface> hostNetworkInterfaces;
|
---|
120 | #if defined(VBOX_WITH_NETFLT)
|
---|
121 | if (fIsBridged)
|
---|
122 | CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged,
|
---|
123 | ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
124 | else
|
---|
125 | CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_HostOnly,
|
---|
126 | ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
127 | #else
|
---|
128 | RT_NOREF(fIsBridged);
|
---|
129 | CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(hostNetworkInterfaces)));
|
---|
130 | #endif
|
---|
131 | for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
|
---|
132 | {
|
---|
133 | ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
|
---|
134 | #ifndef VBOX_WITH_HOSTNETIF_API
|
---|
135 | Bstr interfaceName;
|
---|
136 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
137 | RTPrintf("Name: %ls\n", interfaceName.raw());
|
---|
138 | Guid interfaceGuid;
|
---|
139 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
140 | RTPrintf("GUID: %ls\n\n", Bstr(interfaceGuid.toString()).raw());
|
---|
141 | #else /* VBOX_WITH_HOSTNETIF_API */
|
---|
142 | Bstr interfaceName;
|
---|
143 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
144 | RTPrintf("Name: %ls\n", interfaceName.raw());
|
---|
145 | Bstr interfaceGuid;
|
---|
146 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
147 | RTPrintf("GUID: %ls\n", interfaceGuid.raw());
|
---|
148 | BOOL bDHCPEnabled;
|
---|
149 | networkInterface->COMGETTER(DHCPEnabled)(&bDHCPEnabled);
|
---|
150 | RTPrintf("DHCP: %s\n", bDHCPEnabled ? "Enabled" : "Disabled");
|
---|
151 |
|
---|
152 | Bstr IPAddress;
|
---|
153 | networkInterface->COMGETTER(IPAddress)(IPAddress.asOutParam());
|
---|
154 | RTPrintf("IPAddress: %ls\n", IPAddress.raw());
|
---|
155 | Bstr NetworkMask;
|
---|
156 | networkInterface->COMGETTER(NetworkMask)(NetworkMask.asOutParam());
|
---|
157 | RTPrintf("NetworkMask: %ls\n", NetworkMask.raw());
|
---|
158 | Bstr IPV6Address;
|
---|
159 | networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
|
---|
160 | RTPrintf("IPV6Address: %ls\n", IPV6Address.raw());
|
---|
161 | ULONG IPV6NetworkMaskPrefixLength;
|
---|
162 | networkInterface->COMGETTER(IPV6NetworkMaskPrefixLength)(&IPV6NetworkMaskPrefixLength);
|
---|
163 | RTPrintf("IPV6NetworkMaskPrefixLength: %d\n", IPV6NetworkMaskPrefixLength);
|
---|
164 | Bstr HardwareAddress;
|
---|
165 | networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
|
---|
166 | RTPrintf("HardwareAddress: %ls\n", HardwareAddress.raw());
|
---|
167 | HostNetworkInterfaceMediumType_T Type;
|
---|
168 | networkInterface->COMGETTER(MediumType)(&Type);
|
---|
169 | RTPrintf("MediumType: %s\n", getHostIfMediumTypeText(Type));
|
---|
170 | HostNetworkInterfaceStatus_T Status;
|
---|
171 | networkInterface->COMGETTER(Status)(&Status);
|
---|
172 | RTPrintf("Status: %s\n", getHostIfStatusText(Status));
|
---|
173 | Bstr netName;
|
---|
174 | networkInterface->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
175 | RTPrintf("VBoxNetworkName: %ls\n\n", netName.raw());
|
---|
176 | #endif
|
---|
177 | }
|
---|
178 | return rc;
|
---|
179 | }
|
---|
180 |
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * List host information.
|
---|
184 | *
|
---|
185 | * @returns See produceList.
|
---|
186 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
187 | */
|
---|
188 | static HRESULT listHostInfo(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
189 | {
|
---|
190 | static struct
|
---|
191 | {
|
---|
192 | ProcessorFeature_T feature;
|
---|
193 | const char *pszName;
|
---|
194 | } features[]
|
---|
195 | =
|
---|
196 | {
|
---|
197 | { ProcessorFeature_HWVirtEx, "HW virtualization" },
|
---|
198 | { ProcessorFeature_PAE, "PAE" },
|
---|
199 | { ProcessorFeature_LongMode, "long mode" },
|
---|
200 | { ProcessorFeature_NestedPaging, "nested paging" },
|
---|
201 | };
|
---|
202 | HRESULT rc;
|
---|
203 | ComPtr<IHost> Host;
|
---|
204 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
205 |
|
---|
206 | RTPrintf("Host Information:\n\n");
|
---|
207 |
|
---|
208 | LONG64 u64UtcTime = 0;
|
---|
209 | CHECK_ERROR(Host, COMGETTER(UTCTime)(&u64UtcTime));
|
---|
210 | RTTIMESPEC timeSpec;
|
---|
211 | char szTime[32];
|
---|
212 | RTPrintf("Host time: %s\n", RTTimeSpecToString(RTTimeSpecSetMilli(&timeSpec, u64UtcTime), szTime, sizeof(szTime)));
|
---|
213 |
|
---|
214 | ULONG processorOnlineCount = 0;
|
---|
215 | CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
|
---|
216 | RTPrintf("Processor online count: %lu\n", processorOnlineCount);
|
---|
217 | ULONG processorCount = 0;
|
---|
218 | CHECK_ERROR(Host, COMGETTER(ProcessorCount)(&processorCount));
|
---|
219 | RTPrintf("Processor count: %lu\n", processorCount);
|
---|
220 | ULONG processorOnlineCoreCount = 0;
|
---|
221 | CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCoreCount)(&processorOnlineCoreCount));
|
---|
222 | RTPrintf("Processor online core count: %lu\n", processorOnlineCoreCount);
|
---|
223 | ULONG processorCoreCount = 0;
|
---|
224 | CHECK_ERROR(Host, COMGETTER(ProcessorCoreCount)(&processorCoreCount));
|
---|
225 | RTPrintf("Processor core count: %lu\n", processorCoreCount);
|
---|
226 | for (unsigned i = 0; i < RT_ELEMENTS(features); i++)
|
---|
227 | {
|
---|
228 | BOOL supported;
|
---|
229 | CHECK_ERROR(Host, GetProcessorFeature(features[i].feature, &supported));
|
---|
230 | RTPrintf("Processor supports %s: %s\n", features[i].pszName, supported ? "yes" : "no");
|
---|
231 | }
|
---|
232 | for (ULONG i = 0; i < processorCount; i++)
|
---|
233 | {
|
---|
234 | ULONG processorSpeed = 0;
|
---|
235 | CHECK_ERROR(Host, GetProcessorSpeed(i, &processorSpeed));
|
---|
236 | if (processorSpeed)
|
---|
237 | RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
|
---|
238 | else
|
---|
239 | RTPrintf("Processor#%u speed: unknown\n", i);
|
---|
240 | Bstr processorDescription;
|
---|
241 | CHECK_ERROR(Host, GetProcessorDescription(i, processorDescription.asOutParam()));
|
---|
242 | RTPrintf("Processor#%u description: %ls\n", i, processorDescription.raw());
|
---|
243 | }
|
---|
244 |
|
---|
245 | ULONG memorySize = 0;
|
---|
246 | CHECK_ERROR(Host, COMGETTER(MemorySize)(&memorySize));
|
---|
247 | RTPrintf("Memory size: %lu MByte\n", memorySize);
|
---|
248 |
|
---|
249 | ULONG memoryAvailable = 0;
|
---|
250 | CHECK_ERROR(Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
|
---|
251 | RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
|
---|
252 |
|
---|
253 | Bstr operatingSystem;
|
---|
254 | CHECK_ERROR(Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
|
---|
255 | RTPrintf("Operating system: %ls\n", operatingSystem.raw());
|
---|
256 |
|
---|
257 | Bstr oSVersion;
|
---|
258 | CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
|
---|
259 | RTPrintf("Operating system version: %ls\n", oSVersion.raw());
|
---|
260 | return rc;
|
---|
261 | }
|
---|
262 |
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * List media information.
|
---|
266 | *
|
---|
267 | * @returns See produceList.
|
---|
268 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
269 | * @param aMedia Medium objects to list information for.
|
---|
270 | * @param pszParentUUIDStr String with the parent UUID string (or "base").
|
---|
271 | * @param fOptLong Long (@c true) or short list format.
|
---|
272 | */
|
---|
273 | static HRESULT listMedia(const ComPtr<IVirtualBox> pVirtualBox,
|
---|
274 | const com::SafeIfaceArray<IMedium> &aMedia,
|
---|
275 | const char *pszParentUUIDStr,
|
---|
276 | bool fOptLong)
|
---|
277 | {
|
---|
278 | HRESULT rc = S_OK;
|
---|
279 | for (size_t i = 0; i < aMedia.size(); ++i)
|
---|
280 | {
|
---|
281 | ComPtr<IMedium> pMedium = aMedia[i];
|
---|
282 |
|
---|
283 | rc = showMediumInfo(pVirtualBox, pMedium, pszParentUUIDStr, fOptLong);
|
---|
284 |
|
---|
285 | RTPrintf("\n");
|
---|
286 |
|
---|
287 | com::SafeIfaceArray<IMedium> children;
|
---|
288 | CHECK_ERROR(pMedium, COMGETTER(Children)(ComSafeArrayAsOutParam(children)));
|
---|
289 | if (children.size() > 0)
|
---|
290 | {
|
---|
291 | Bstr uuid;
|
---|
292 | pMedium->COMGETTER(Id)(uuid.asOutParam());
|
---|
293 |
|
---|
294 | // depth first listing of child media
|
---|
295 | rc = listMedia(pVirtualBox, children, Utf8Str(uuid).c_str(), fOptLong);
|
---|
296 | }
|
---|
297 | }
|
---|
298 |
|
---|
299 | return rc;
|
---|
300 | }
|
---|
301 |
|
---|
302 |
|
---|
303 | /**
|
---|
304 | * List virtual image backends.
|
---|
305 | *
|
---|
306 | * @returns See produceList.
|
---|
307 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
308 | */
|
---|
309 | static HRESULT listHddBackends(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
310 | {
|
---|
311 | HRESULT rc;
|
---|
312 | ComPtr<ISystemProperties> systemProperties;
|
---|
313 | CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
|
---|
314 | com::SafeIfaceArray<IMediumFormat> mediumFormats;
|
---|
315 | CHECK_ERROR(systemProperties, COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
|
---|
316 |
|
---|
317 | RTPrintf("Supported hard disk backends:\n\n");
|
---|
318 | for (size_t i = 0; i < mediumFormats.size(); ++i)
|
---|
319 | {
|
---|
320 | /* General information */
|
---|
321 | Bstr id;
|
---|
322 | CHECK_ERROR(mediumFormats[i], COMGETTER(Id)(id.asOutParam()));
|
---|
323 |
|
---|
324 | Bstr description;
|
---|
325 | CHECK_ERROR(mediumFormats[i],
|
---|
326 | COMGETTER(Name)(description.asOutParam()));
|
---|
327 |
|
---|
328 | ULONG caps = 0;
|
---|
329 | com::SafeArray <MediumFormatCapabilities_T> mediumFormatCap;
|
---|
330 | CHECK_ERROR(mediumFormats[i],
|
---|
331 | COMGETTER(Capabilities)(ComSafeArrayAsOutParam(mediumFormatCap)));
|
---|
332 | for (ULONG j = 0; j < mediumFormatCap.size(); j++)
|
---|
333 | caps |= mediumFormatCap[j];
|
---|
334 |
|
---|
335 |
|
---|
336 | RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
|
---|
337 | i, id.raw(), description.raw(), caps);
|
---|
338 |
|
---|
339 | /* File extensions */
|
---|
340 | com::SafeArray<BSTR> fileExtensions;
|
---|
341 | com::SafeArray<DeviceType_T> deviceTypes;
|
---|
342 | CHECK_ERROR(mediumFormats[i],
|
---|
343 | DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes)));
|
---|
344 | for (size_t j = 0; j < fileExtensions.size(); ++j)
|
---|
345 | {
|
---|
346 | RTPrintf("%ls (%s)", Bstr(fileExtensions[j]).raw(), getDeviceTypeText(deviceTypes[j]));
|
---|
347 | if (j != fileExtensions.size()-1)
|
---|
348 | RTPrintf(",");
|
---|
349 | }
|
---|
350 | RTPrintf("'");
|
---|
351 |
|
---|
352 | /* Configuration keys */
|
---|
353 | com::SafeArray<BSTR> propertyNames;
|
---|
354 | com::SafeArray<BSTR> propertyDescriptions;
|
---|
355 | com::SafeArray<DataType_T> propertyTypes;
|
---|
356 | com::SafeArray<ULONG> propertyFlags;
|
---|
357 | com::SafeArray<BSTR> propertyDefaults;
|
---|
358 | CHECK_ERROR(mediumFormats[i],
|
---|
359 | DescribeProperties(ComSafeArrayAsOutParam(propertyNames),
|
---|
360 | ComSafeArrayAsOutParam(propertyDescriptions),
|
---|
361 | ComSafeArrayAsOutParam(propertyTypes),
|
---|
362 | ComSafeArrayAsOutParam(propertyFlags),
|
---|
363 | ComSafeArrayAsOutParam(propertyDefaults)));
|
---|
364 |
|
---|
365 | RTPrintf(" properties=(");
|
---|
366 | if (propertyNames.size() > 0)
|
---|
367 | {
|
---|
368 | for (size_t j = 0; j < propertyNames.size(); ++j)
|
---|
369 | {
|
---|
370 | RTPrintf("\n name='%ls' desc='%ls' type=",
|
---|
371 | Bstr(propertyNames[j]).raw(), Bstr(propertyDescriptions[j]).raw());
|
---|
372 | switch (propertyTypes[j])
|
---|
373 | {
|
---|
374 | case DataType_Int32: RTPrintf("int"); break;
|
---|
375 | case DataType_Int8: RTPrintf("byte"); break;
|
---|
376 | case DataType_String: RTPrintf("string"); break;
|
---|
377 | }
|
---|
378 | RTPrintf(" flags=%#04x", propertyFlags[j]);
|
---|
379 | RTPrintf(" default='%ls'", Bstr(propertyDefaults[j]).raw());
|
---|
380 | if (j != propertyNames.size()-1)
|
---|
381 | RTPrintf(", ");
|
---|
382 | }
|
---|
383 | }
|
---|
384 | RTPrintf(")\n");
|
---|
385 | }
|
---|
386 | return rc;
|
---|
387 | }
|
---|
388 |
|
---|
389 |
|
---|
390 | /**
|
---|
391 | * List USB devices attached to the host.
|
---|
392 | *
|
---|
393 | * @returns See produceList.
|
---|
394 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
395 | */
|
---|
396 | static HRESULT listUsbHost(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
397 | {
|
---|
398 | HRESULT rc;
|
---|
399 | ComPtr<IHost> Host;
|
---|
400 | CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
|
---|
401 |
|
---|
402 | SafeIfaceArray<IHostUSBDevice> CollPtr;
|
---|
403 | CHECK_ERROR_RET(Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1);
|
---|
404 |
|
---|
405 | RTPrintf("Host USB Devices:\n\n");
|
---|
406 |
|
---|
407 | if (CollPtr.size() == 0)
|
---|
408 | {
|
---|
409 | RTPrintf("<none>\n\n");
|
---|
410 | }
|
---|
411 | else
|
---|
412 | {
|
---|
413 | for (size_t i = 0; i < CollPtr.size(); ++i)
|
---|
414 | {
|
---|
415 | ComPtr<IHostUSBDevice> dev = CollPtr[i];
|
---|
416 |
|
---|
417 | /* Query info. */
|
---|
418 | Bstr id;
|
---|
419 | CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), 1);
|
---|
420 | USHORT usVendorId;
|
---|
421 | CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), 1);
|
---|
422 | USHORT usProductId;
|
---|
423 | CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), 1);
|
---|
424 | USHORT bcdRevision;
|
---|
425 | CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), 1);
|
---|
426 | USHORT usPort;
|
---|
427 | CHECK_ERROR_RET(dev, COMGETTER(Port)(&usPort), 1);
|
---|
428 | USHORT usVersion;
|
---|
429 | CHECK_ERROR_RET(dev, COMGETTER(Version)(&usVersion), 1);
|
---|
430 | USHORT usPortVersion;
|
---|
431 | CHECK_ERROR_RET(dev, COMGETTER(PortVersion)(&usPortVersion), 1);
|
---|
432 | USBConnectionSpeed_T enmSpeed;
|
---|
433 | CHECK_ERROR_RET(dev, COMGETTER(Speed)(&enmSpeed), 1);
|
---|
434 |
|
---|
435 | RTPrintf("UUID: %s\n"
|
---|
436 | "VendorId: %#06x (%04X)\n"
|
---|
437 | "ProductId: %#06x (%04X)\n"
|
---|
438 | "Revision: %u.%u (%02u%02u)\n"
|
---|
439 | "Port: %u\n",
|
---|
440 | Utf8Str(id).c_str(),
|
---|
441 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
442 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
443 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
444 | usPort);
|
---|
445 |
|
---|
446 | const char *pszSpeed = "?";
|
---|
447 | switch (enmSpeed)
|
---|
448 | {
|
---|
449 | case USBConnectionSpeed_Low:
|
---|
450 | pszSpeed = "Low";
|
---|
451 | break;
|
---|
452 | case USBConnectionSpeed_Full:
|
---|
453 | pszSpeed = "Full";
|
---|
454 | break;
|
---|
455 | case USBConnectionSpeed_High:
|
---|
456 | pszSpeed = "High";
|
---|
457 | break;
|
---|
458 | case USBConnectionSpeed_Super:
|
---|
459 | pszSpeed = "Super";
|
---|
460 | break;
|
---|
461 | case USBConnectionSpeed_SuperPlus:
|
---|
462 | pszSpeed = "SuperPlus";
|
---|
463 | break;
|
---|
464 | default:
|
---|
465 | ASSERT(false);
|
---|
466 | break;
|
---|
467 | }
|
---|
468 |
|
---|
469 | RTPrintf("USB version/speed: %u/%s\n", usVersion, pszSpeed);
|
---|
470 |
|
---|
471 | /* optional stuff. */
|
---|
472 | SafeArray<BSTR> CollDevInfo;
|
---|
473 | Bstr bstr;
|
---|
474 | CHECK_ERROR_RET(dev, COMGETTER(DeviceInfo)(ComSafeArrayAsOutParam(CollDevInfo)), 1);
|
---|
475 | if (CollDevInfo.size() >= 1)
|
---|
476 | bstr = Bstr(CollDevInfo[0]);
|
---|
477 | if (!bstr.isEmpty())
|
---|
478 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
479 | if (CollDevInfo.size() >= 2)
|
---|
480 | bstr = Bstr(CollDevInfo[1]);
|
---|
481 | if (!bstr.isEmpty())
|
---|
482 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
483 | CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
484 | if (!bstr.isEmpty())
|
---|
485 | RTPrintf("SerialNumber: %ls\n", bstr.raw());
|
---|
486 | CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), 1);
|
---|
487 | if (!bstr.isEmpty())
|
---|
488 | RTPrintf("Address: %ls\n", bstr.raw());
|
---|
489 |
|
---|
490 | /* current state */
|
---|
491 | USBDeviceState_T state;
|
---|
492 | CHECK_ERROR_RET(dev, COMGETTER(State)(&state), 1);
|
---|
493 | const char *pszState = "?";
|
---|
494 | switch (state)
|
---|
495 | {
|
---|
496 | case USBDeviceState_NotSupported:
|
---|
497 | pszState = "Not supported";
|
---|
498 | break;
|
---|
499 | case USBDeviceState_Unavailable:
|
---|
500 | pszState = "Unavailable";
|
---|
501 | break;
|
---|
502 | case USBDeviceState_Busy:
|
---|
503 | pszState = "Busy";
|
---|
504 | break;
|
---|
505 | case USBDeviceState_Available:
|
---|
506 | pszState = "Available";
|
---|
507 | break;
|
---|
508 | case USBDeviceState_Held:
|
---|
509 | pszState = "Held";
|
---|
510 | break;
|
---|
511 | case USBDeviceState_Captured:
|
---|
512 | pszState = "Captured";
|
---|
513 | break;
|
---|
514 | default:
|
---|
515 | ASSERT(false);
|
---|
516 | break;
|
---|
517 | }
|
---|
518 | RTPrintf("Current State: %s\n\n", pszState);
|
---|
519 | }
|
---|
520 | }
|
---|
521 | return rc;
|
---|
522 | }
|
---|
523 |
|
---|
524 |
|
---|
525 | /**
|
---|
526 | * List USB filters.
|
---|
527 | *
|
---|
528 | * @returns See produceList.
|
---|
529 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
530 | */
|
---|
531 | static HRESULT listUsbFilters(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
532 | {
|
---|
533 | HRESULT rc;
|
---|
534 |
|
---|
535 | RTPrintf("Global USB Device Filters:\n\n");
|
---|
536 |
|
---|
537 | ComPtr<IHost> host;
|
---|
538 | CHECK_ERROR_RET(pVirtualBox, COMGETTER(Host)(host.asOutParam()), 1);
|
---|
539 |
|
---|
540 | SafeIfaceArray<IHostUSBDeviceFilter> coll;
|
---|
541 | CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
|
---|
542 |
|
---|
543 | if (coll.size() == 0)
|
---|
544 | {
|
---|
545 | RTPrintf("<none>\n\n");
|
---|
546 | }
|
---|
547 | else
|
---|
548 | {
|
---|
549 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
550 | {
|
---|
551 | ComPtr<IHostUSBDeviceFilter> flt = coll[index];
|
---|
552 |
|
---|
553 | /* Query info. */
|
---|
554 |
|
---|
555 | RTPrintf("Index: %zu\n", index);
|
---|
556 |
|
---|
557 | BOOL active = FALSE;
|
---|
558 | CHECK_ERROR_RET(flt, COMGETTER(Active)(&active), 1);
|
---|
559 | RTPrintf("Active: %s\n", active ? "yes" : "no");
|
---|
560 |
|
---|
561 | USBDeviceFilterAction_T action;
|
---|
562 | CHECK_ERROR_RET(flt, COMGETTER(Action)(&action), 1);
|
---|
563 | const char *pszAction = "<invalid>";
|
---|
564 | switch (action)
|
---|
565 | {
|
---|
566 | case USBDeviceFilterAction_Ignore:
|
---|
567 | pszAction = "Ignore";
|
---|
568 | break;
|
---|
569 | case USBDeviceFilterAction_Hold:
|
---|
570 | pszAction = "Hold";
|
---|
571 | break;
|
---|
572 | default:
|
---|
573 | break;
|
---|
574 | }
|
---|
575 | RTPrintf("Action: %s\n", pszAction);
|
---|
576 |
|
---|
577 | Bstr bstr;
|
---|
578 | CHECK_ERROR_RET(flt, COMGETTER(Name)(bstr.asOutParam()), 1);
|
---|
579 | RTPrintf("Name: %ls\n", bstr.raw());
|
---|
580 | CHECK_ERROR_RET(flt, COMGETTER(VendorId)(bstr.asOutParam()), 1);
|
---|
581 | RTPrintf("VendorId: %ls\n", bstr.raw());
|
---|
582 | CHECK_ERROR_RET(flt, COMGETTER(ProductId)(bstr.asOutParam()), 1);
|
---|
583 | RTPrintf("ProductId: %ls\n", bstr.raw());
|
---|
584 | CHECK_ERROR_RET(flt, COMGETTER(Revision)(bstr.asOutParam()), 1);
|
---|
585 | RTPrintf("Revision: %ls\n", bstr.raw());
|
---|
586 | CHECK_ERROR_RET(flt, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
|
---|
587 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
588 | CHECK_ERROR_RET(flt, COMGETTER(Product)(bstr.asOutParam()), 1);
|
---|
589 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
590 | CHECK_ERROR_RET(flt, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
591 | RTPrintf("Serial Number: %ls\n\n", bstr.raw());
|
---|
592 | }
|
---|
593 | }
|
---|
594 | return rc;
|
---|
595 | }
|
---|
596 |
|
---|
597 |
|
---|
598 | /**
|
---|
599 | * List system properties.
|
---|
600 | *
|
---|
601 | * @returns See produceList.
|
---|
602 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
603 | */
|
---|
604 | static HRESULT listSystemProperties(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
605 | {
|
---|
606 | ComPtr<ISystemProperties> systemProperties;
|
---|
607 | pVirtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
|
---|
608 |
|
---|
609 | Bstr str;
|
---|
610 | ULONG ulValue;
|
---|
611 | LONG64 i64Value;
|
---|
612 | BOOL fValue;
|
---|
613 | const char *psz;
|
---|
614 |
|
---|
615 | pVirtualBox->COMGETTER(APIVersion)(str.asOutParam());
|
---|
616 | RTPrintf("API version: %ls\n", str.raw());
|
---|
617 |
|
---|
618 | systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
|
---|
619 | RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
|
---|
620 | systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
|
---|
621 | RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
|
---|
622 | systemProperties->COMGETTER(MinGuestVRAM)(&ulValue);
|
---|
623 | RTPrintf("Minimum video RAM size: %u Megabytes\n", ulValue);
|
---|
624 | systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
|
---|
625 | RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
|
---|
626 | systemProperties->COMGETTER(MaxGuestMonitors)(&ulValue);
|
---|
627 | RTPrintf("Maximum guest monitor count: %u\n", ulValue);
|
---|
628 | systemProperties->COMGETTER(MinGuestCPUCount)(&ulValue);
|
---|
629 | RTPrintf("Minimum guest CPU count: %u\n", ulValue);
|
---|
630 | systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
|
---|
631 | RTPrintf("Maximum guest CPU count: %u\n", ulValue);
|
---|
632 | systemProperties->COMGETTER(InfoVDSize)(&i64Value);
|
---|
633 | RTPrintf("Virtual disk limit (info): %lld Bytes\n", i64Value);
|
---|
634 | systemProperties->COMGETTER(SerialPortCount)(&ulValue);
|
---|
635 | RTPrintf("Maximum Serial Port count: %u\n", ulValue);
|
---|
636 | systemProperties->COMGETTER(ParallelPortCount)(&ulValue);
|
---|
637 | RTPrintf("Maximum Parallel Port count: %u\n", ulValue);
|
---|
638 | systemProperties->COMGETTER(MaxBootPosition)(&ulValue);
|
---|
639 | RTPrintf("Maximum Boot Position: %u\n", ulValue);
|
---|
640 | systemProperties->GetMaxNetworkAdapters(ChipsetType_PIIX3, &ulValue);
|
---|
641 | RTPrintf("Maximum PIIX3 Network Adapter count: %u\n", ulValue);
|
---|
642 | systemProperties->GetMaxNetworkAdapters(ChipsetType_ICH9, &ulValue);
|
---|
643 | RTPrintf("Maximum ICH9 Network Adapter count: %u\n", ulValue);
|
---|
644 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_IDE, &ulValue);
|
---|
645 | RTPrintf("Maximum PIIX3 IDE Controllers: %u\n", ulValue);
|
---|
646 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_IDE, &ulValue);
|
---|
647 | RTPrintf("Maximum ICH9 IDE Controllers: %u\n", ulValue);
|
---|
648 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_IDE, &ulValue);
|
---|
649 | RTPrintf("Maximum IDE Port count: %u\n", ulValue);
|
---|
650 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_IDE, &ulValue);
|
---|
651 | RTPrintf("Maximum Devices per IDE Port: %u\n", ulValue);
|
---|
652 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SATA, &ulValue);
|
---|
653 | RTPrintf("Maximum PIIX3 SATA Controllers: %u\n", ulValue);
|
---|
654 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SATA, &ulValue);
|
---|
655 | RTPrintf("Maximum ICH9 SATA Controllers: %u\n", ulValue);
|
---|
656 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SATA, &ulValue);
|
---|
657 | RTPrintf("Maximum SATA Port count: %u\n", ulValue);
|
---|
658 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SATA, &ulValue);
|
---|
659 | RTPrintf("Maximum Devices per SATA Port: %u\n", ulValue);
|
---|
660 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SCSI, &ulValue);
|
---|
661 | RTPrintf("Maximum PIIX3 SCSI Controllers: %u\n", ulValue);
|
---|
662 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SCSI, &ulValue);
|
---|
663 | RTPrintf("Maximum ICH9 SCSI Controllers: %u\n", ulValue);
|
---|
664 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
665 | RTPrintf("Maximum SCSI Port count: %u\n", ulValue);
|
---|
666 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SCSI, &ulValue);
|
---|
667 | RTPrintf("Maximum Devices per SCSI Port: %u\n", ulValue);
|
---|
668 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SAS, &ulValue);
|
---|
669 | RTPrintf("Maximum SAS PIIX3 Controllers: %u\n", ulValue);
|
---|
670 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SAS, &ulValue);
|
---|
671 | RTPrintf("Maximum SAS ICH9 Controllers: %u\n", ulValue);
|
---|
672 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_SAS, &ulValue);
|
---|
673 | RTPrintf("Maximum SAS Port count: %u\n", ulValue);
|
---|
674 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SAS, &ulValue);
|
---|
675 | RTPrintf("Maximum Devices per SAS Port: %u\n", ulValue);
|
---|
676 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_PCIe, &ulValue);
|
---|
677 | RTPrintf("Maximum NVMe PIIX3 Controllers: %u\n", ulValue);
|
---|
678 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_PCIe, &ulValue);
|
---|
679 | RTPrintf("Maximum NVMe ICH9 Controllers: %u\n", ulValue);
|
---|
680 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_PCIe, &ulValue);
|
---|
681 | RTPrintf("Maximum NVMe Port count: %u\n", ulValue);
|
---|
682 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_PCIe, &ulValue);
|
---|
683 | RTPrintf("Maximum Devices per NVMe Port: %u\n", ulValue);
|
---|
684 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_Floppy, &ulValue);
|
---|
685 | RTPrintf("Maximum PIIX3 Floppy Controllers:%u\n", ulValue);
|
---|
686 | systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_Floppy, &ulValue);
|
---|
687 | RTPrintf("Maximum ICH9 Floppy Controllers: %u\n", ulValue);
|
---|
688 | systemProperties->GetMaxPortCountForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
689 | RTPrintf("Maximum Floppy Port count: %u\n", ulValue);
|
---|
690 | systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_Floppy, &ulValue);
|
---|
691 | RTPrintf("Maximum Devices per Floppy Port: %u\n", ulValue);
|
---|
692 | #if 0
|
---|
693 | systemProperties->GetFreeDiskSpaceWarning(&i64Value);
|
---|
694 | RTPrintf("Free disk space warning at: %u Bytes\n", i64Value);
|
---|
695 | systemProperties->GetFreeDiskSpacePercentWarning(&ulValue);
|
---|
696 | RTPrintf("Free disk space warning at: %u %%\n", ulValue);
|
---|
697 | systemProperties->GetFreeDiskSpaceError(&i64Value);
|
---|
698 | RTPrintf("Free disk space error at: %u Bytes\n", i64Value);
|
---|
699 | systemProperties->GetFreeDiskSpacePercentError(&ulValue);
|
---|
700 | RTPrintf("Free disk space error at: %u %%\n", ulValue);
|
---|
701 | #endif
|
---|
702 | systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
|
---|
703 | RTPrintf("Default machine folder: %ls\n", str.raw());
|
---|
704 | systemProperties->COMGETTER(RawModeSupported)(&fValue);
|
---|
705 | RTPrintf("Raw-mode Supported: %s\n", fValue ? "yes" : "no");
|
---|
706 | systemProperties->COMGETTER(ExclusiveHwVirt)(&fValue);
|
---|
707 | RTPrintf("Exclusive HW virtualization use: %s\n", fValue ? "on" : "off");
|
---|
708 | systemProperties->COMGETTER(DefaultHardDiskFormat)(str.asOutParam());
|
---|
709 | RTPrintf("Default hard disk format: %ls\n", str.raw());
|
---|
710 | systemProperties->COMGETTER(VRDEAuthLibrary)(str.asOutParam());
|
---|
711 | RTPrintf("VRDE auth library: %ls\n", str.raw());
|
---|
712 | systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
|
---|
713 | RTPrintf("Webservice auth. library: %ls\n", str.raw());
|
---|
714 | systemProperties->COMGETTER(DefaultVRDEExtPack)(str.asOutParam());
|
---|
715 | RTPrintf("Remote desktop ExtPack: %ls\n", str.raw());
|
---|
716 | systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
|
---|
717 | RTPrintf("Log history count: %u\n", ulValue);
|
---|
718 | systemProperties->COMGETTER(DefaultFrontend)(str.asOutParam());
|
---|
719 | RTPrintf("Default frontend: %ls\n", str.raw());
|
---|
720 | AudioDriverType_T enmAudio;
|
---|
721 | systemProperties->COMGETTER(DefaultAudioDriver)(&enmAudio);
|
---|
722 | switch (enmAudio)
|
---|
723 | {
|
---|
724 | case AudioDriverType_Null: psz = "Null"; break;
|
---|
725 | case AudioDriverType_WinMM: psz = "WinMM"; break;
|
---|
726 | case AudioDriverType_OSS: psz = "OSS"; break;
|
---|
727 | case AudioDriverType_ALSA: psz = "ALSA"; break;
|
---|
728 | case AudioDriverType_DirectSound: psz = "DirectSound"; break;
|
---|
729 | case AudioDriverType_CoreAudio: psz = "CoreAudio"; break;
|
---|
730 | case AudioDriverType_MMPM: psz = "MMPM"; break;
|
---|
731 | case AudioDriverType_Pulse: psz = "Pulse"; break;
|
---|
732 | case AudioDriverType_SolAudio: psz = "SolAudio"; break;
|
---|
733 | default: psz = "Unknown";
|
---|
734 | }
|
---|
735 | RTPrintf("Default audio driver: %s\n", psz);
|
---|
736 | systemProperties->COMGETTER(AutostartDatabasePath)(str.asOutParam());
|
---|
737 | RTPrintf("Autostart database path: %ls\n", str.raw());
|
---|
738 | systemProperties->COMGETTER(DefaultAdditionsISO)(str.asOutParam());
|
---|
739 | RTPrintf("Default Guest Additions ISO: %ls\n", str.raw());
|
---|
740 | systemProperties->COMGETTER(LoggingLevel)(str.asOutParam());
|
---|
741 | RTPrintf("Logging Level: %ls\n", str.raw());
|
---|
742 | return S_OK;
|
---|
743 | }
|
---|
744 |
|
---|
745 |
|
---|
746 | /**
|
---|
747 | * List extension packs.
|
---|
748 | *
|
---|
749 | * @returns See produceList.
|
---|
750 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
751 | */
|
---|
752 | static HRESULT listExtensionPacks(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
753 | {
|
---|
754 | ComObjPtr<IExtPackManager> ptrExtPackMgr;
|
---|
755 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
|
---|
756 |
|
---|
757 | SafeIfaceArray<IExtPack> extPacks;
|
---|
758 | CHECK_ERROR2I_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
|
---|
759 | RTPrintf("Extension Packs: %u\n", extPacks.size());
|
---|
760 |
|
---|
761 | HRESULT hrc = S_OK;
|
---|
762 | for (size_t i = 0; i < extPacks.size(); i++)
|
---|
763 | {
|
---|
764 | /* Read all the properties. */
|
---|
765 | Bstr bstrName;
|
---|
766 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
|
---|
767 | Bstr bstrDesc;
|
---|
768 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
|
---|
769 | Bstr bstrVersion;
|
---|
770 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
|
---|
771 | ULONG uRevision;
|
---|
772 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Revision)(&uRevision), hrc = hrcCheck; uRevision = 0);
|
---|
773 | Bstr bstrEdition;
|
---|
774 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
|
---|
775 | Bstr bstrVrdeModule;
|
---|
776 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.setNull());
|
---|
777 | BOOL fUsable;
|
---|
778 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(Usable)(&fUsable), hrc = hrcCheck; fUsable = FALSE);
|
---|
779 | Bstr bstrWhy;
|
---|
780 | CHECK_ERROR2I_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
|
---|
781 |
|
---|
782 | /* Display them. */
|
---|
783 | if (i)
|
---|
784 | RTPrintf("\n");
|
---|
785 | RTPrintf("Pack no.%2zu: %ls\n"
|
---|
786 | "Version: %ls\n"
|
---|
787 | "Revision: %u\n"
|
---|
788 | "Edition: %ls\n"
|
---|
789 | "Description: %ls\n"
|
---|
790 | "VRDE Module: %ls\n"
|
---|
791 | "Usable: %RTbool\n"
|
---|
792 | "Why unusable: %ls\n",
|
---|
793 | i, bstrName.raw(),
|
---|
794 | bstrVersion.raw(),
|
---|
795 | uRevision,
|
---|
796 | bstrEdition.raw(),
|
---|
797 | bstrDesc.raw(),
|
---|
798 | bstrVrdeModule.raw(),
|
---|
799 | fUsable != FALSE,
|
---|
800 | bstrWhy.raw());
|
---|
801 |
|
---|
802 | /* Query plugins and display them. */
|
---|
803 | }
|
---|
804 | return hrc;
|
---|
805 | }
|
---|
806 |
|
---|
807 |
|
---|
808 | /**
|
---|
809 | * List machine groups.
|
---|
810 | *
|
---|
811 | * @returns See produceList.
|
---|
812 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
813 | */
|
---|
814 | static HRESULT listGroups(const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
815 | {
|
---|
816 | SafeArray<BSTR> groups;
|
---|
817 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(MachineGroups)(ComSafeArrayAsOutParam(groups)), hrcCheck);
|
---|
818 |
|
---|
819 | for (size_t i = 0; i < groups.size(); i++)
|
---|
820 | {
|
---|
821 | RTPrintf("\"%ls\"\n", groups[i]);
|
---|
822 | }
|
---|
823 | return S_OK;
|
---|
824 | }
|
---|
825 |
|
---|
826 |
|
---|
827 | /**
|
---|
828 | * List video capture devices.
|
---|
829 | *
|
---|
830 | * @returns See produceList.
|
---|
831 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
832 | */
|
---|
833 | static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
834 | {
|
---|
835 | HRESULT rc;
|
---|
836 | ComPtr<IHost> host;
|
---|
837 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
838 | com::SafeIfaceArray<IHostVideoInputDevice> hostVideoInputDevices;
|
---|
839 | CHECK_ERROR(host, COMGETTER(VideoInputDevices)(ComSafeArrayAsOutParam(hostVideoInputDevices)));
|
---|
840 | RTPrintf("Video Input Devices: %u\n", hostVideoInputDevices.size());
|
---|
841 | for (size_t i = 0; i < hostVideoInputDevices.size(); ++i)
|
---|
842 | {
|
---|
843 | ComPtr<IHostVideoInputDevice> p = hostVideoInputDevices[i];
|
---|
844 | Bstr name;
|
---|
845 | p->COMGETTER(Name)(name.asOutParam());
|
---|
846 | Bstr path;
|
---|
847 | p->COMGETTER(Path)(path.asOutParam());
|
---|
848 | Bstr alias;
|
---|
849 | p->COMGETTER(Alias)(alias.asOutParam());
|
---|
850 | RTPrintf("%ls \"%ls\"\n%ls\n", alias.raw(), name.raw(), path.raw());
|
---|
851 | }
|
---|
852 | return rc;
|
---|
853 | }
|
---|
854 |
|
---|
855 | /**
|
---|
856 | * List supported screen shot formats.
|
---|
857 | *
|
---|
858 | * @returns See produceList.
|
---|
859 | * @param pVirtualBox Reference to the IVirtualBox pointer.
|
---|
860 | */
|
---|
861 | static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> pVirtualBox)
|
---|
862 | {
|
---|
863 | HRESULT rc = S_OK;
|
---|
864 | ComPtr<ISystemProperties> systemProperties;
|
---|
865 | CHECK_ERROR(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
|
---|
866 | com::SafeArray<BitmapFormat_T> formats;
|
---|
867 | CHECK_ERROR(systemProperties, COMGETTER(ScreenShotFormats)(ComSafeArrayAsOutParam(formats)));
|
---|
868 |
|
---|
869 | RTPrintf("Supported %d screen shot formats:\n", formats.size());
|
---|
870 | for (size_t i = 0; i < formats.size(); ++i)
|
---|
871 | {
|
---|
872 | uint32_t u32Format = (uint32_t)formats[i];
|
---|
873 | char szFormat[5];
|
---|
874 | szFormat[0] = RT_BYTE1(u32Format);
|
---|
875 | szFormat[1] = RT_BYTE2(u32Format);
|
---|
876 | szFormat[2] = RT_BYTE3(u32Format);
|
---|
877 | szFormat[3] = RT_BYTE4(u32Format);
|
---|
878 | szFormat[4] = 0;
|
---|
879 | RTPrintf(" BitmapFormat_%s (0x%08X)\n", szFormat, u32Format);
|
---|
880 | }
|
---|
881 | return rc;
|
---|
882 | }
|
---|
883 |
|
---|
884 |
|
---|
885 | /**
|
---|
886 | * The type of lists we can produce.
|
---|
887 | */
|
---|
888 | enum enmListType
|
---|
889 | {
|
---|
890 | kListNotSpecified = 1000,
|
---|
891 | kListVMs,
|
---|
892 | kListRunningVMs,
|
---|
893 | kListOsTypes,
|
---|
894 | kListHostDvds,
|
---|
895 | kListHostFloppies,
|
---|
896 | kListInternalNetworks,
|
---|
897 | kListBridgedInterfaces,
|
---|
898 | #if defined(VBOX_WITH_NETFLT)
|
---|
899 | kListHostOnlyInterfaces,
|
---|
900 | #endif
|
---|
901 | kListHostCpuIDs,
|
---|
902 | kListHostInfo,
|
---|
903 | kListHddBackends,
|
---|
904 | kListHdds,
|
---|
905 | kListDvds,
|
---|
906 | kListFloppies,
|
---|
907 | kListUsbHost,
|
---|
908 | kListUsbFilters,
|
---|
909 | kListSystemProperties,
|
---|
910 | kListDhcpServers,
|
---|
911 | kListExtPacks,
|
---|
912 | kListGroups,
|
---|
913 | kListNatNetworks,
|
---|
914 | kListVideoInputDevices,
|
---|
915 | kListScreenShotFormats
|
---|
916 | };
|
---|
917 |
|
---|
918 |
|
---|
919 | /**
|
---|
920 | * Produces the specified listing.
|
---|
921 | *
|
---|
922 | * @returns S_OK or some COM error code that has been reported in full.
|
---|
923 | * @param enmList The list to produce.
|
---|
924 | * @param fOptLong Long (@c true) or short list format.
|
---|
925 | * @param pVirtualBox Reference to the IVirtualBox smart pointer.
|
---|
926 | */
|
---|
927 | static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, const ComPtr<IVirtualBox> &pVirtualBox)
|
---|
928 | {
|
---|
929 | HRESULT rc = S_OK;
|
---|
930 | switch (enmCommand)
|
---|
931 | {
|
---|
932 | case kListNotSpecified:
|
---|
933 | AssertFailed();
|
---|
934 | return E_FAIL;
|
---|
935 |
|
---|
936 | case kListVMs:
|
---|
937 | {
|
---|
938 | /*
|
---|
939 | * Get the list of all registered VMs
|
---|
940 | */
|
---|
941 | com::SafeIfaceArray<IMachine> machines;
|
---|
942 | rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
943 | if (SUCCEEDED(rc))
|
---|
944 | {
|
---|
945 | /*
|
---|
946 | * Iterate through the collection
|
---|
947 | */
|
---|
948 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
949 | {
|
---|
950 | if (machines[i])
|
---|
951 | rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
952 | }
|
---|
953 | }
|
---|
954 | break;
|
---|
955 | }
|
---|
956 |
|
---|
957 | case kListRunningVMs:
|
---|
958 | {
|
---|
959 | /*
|
---|
960 | * Get the list of all _running_ VMs
|
---|
961 | */
|
---|
962 | com::SafeIfaceArray<IMachine> machines;
|
---|
963 | rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
|
---|
964 | com::SafeArray<MachineState_T> states;
|
---|
965 | if (SUCCEEDED(rc))
|
---|
966 | rc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
|
---|
967 | if (SUCCEEDED(rc))
|
---|
968 | {
|
---|
969 | /*
|
---|
970 | * Iterate through the collection
|
---|
971 | */
|
---|
972 | for (size_t i = 0; i < machines.size(); ++i)
|
---|
973 | {
|
---|
974 | if (machines[i])
|
---|
975 | {
|
---|
976 | MachineState_T machineState = states[i];
|
---|
977 | switch (machineState)
|
---|
978 | {
|
---|
979 | case MachineState_Running:
|
---|
980 | case MachineState_Teleporting:
|
---|
981 | case MachineState_LiveSnapshotting:
|
---|
982 | case MachineState_Paused:
|
---|
983 | case MachineState_TeleportingPausedVM:
|
---|
984 | rc = showVMInfo(pVirtualBox, machines[i], NULL, fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
985 | break;
|
---|
986 | default: break; /* Shut up MSC */
|
---|
987 | }
|
---|
988 | }
|
---|
989 | }
|
---|
990 | }
|
---|
991 | break;
|
---|
992 | }
|
---|
993 |
|
---|
994 | case kListOsTypes:
|
---|
995 | {
|
---|
996 | com::SafeIfaceArray<IGuestOSType> coll;
|
---|
997 | rc = pVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
|
---|
998 | if (SUCCEEDED(rc))
|
---|
999 | {
|
---|
1000 | /*
|
---|
1001 | * Iterate through the collection.
|
---|
1002 | */
|
---|
1003 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1004 | {
|
---|
1005 | ComPtr<IGuestOSType> guestOS;
|
---|
1006 | guestOS = coll[i];
|
---|
1007 | Bstr guestId;
|
---|
1008 | guestOS->COMGETTER(Id)(guestId.asOutParam());
|
---|
1009 | RTPrintf("ID: %ls\n", guestId.raw());
|
---|
1010 | Bstr guestDescription;
|
---|
1011 | guestOS->COMGETTER(Description)(guestDescription.asOutParam());
|
---|
1012 | RTPrintf("Description: %ls\n", guestDescription.raw());
|
---|
1013 | Bstr familyId;
|
---|
1014 | guestOS->COMGETTER(FamilyId)(familyId.asOutParam());
|
---|
1015 | RTPrintf("Family ID: %ls\n", familyId.raw());
|
---|
1016 | Bstr familyDescription;
|
---|
1017 | guestOS->COMGETTER(FamilyDescription)(familyDescription.asOutParam());
|
---|
1018 | RTPrintf("Family Desc: %ls\n", familyDescription.raw());
|
---|
1019 | BOOL is64Bit;
|
---|
1020 | guestOS->COMGETTER(Is64Bit)(&is64Bit);
|
---|
1021 | RTPrintf("64 bit: %RTbool\n", is64Bit);
|
---|
1022 | RTPrintf("\n");
|
---|
1023 | }
|
---|
1024 | }
|
---|
1025 | break;
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | case kListHostDvds:
|
---|
1029 | {
|
---|
1030 | ComPtr<IHost> host;
|
---|
1031 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1032 | com::SafeIfaceArray<IMedium> coll;
|
---|
1033 | CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
1034 | if (SUCCEEDED(rc))
|
---|
1035 | {
|
---|
1036 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1037 | {
|
---|
1038 | ComPtr<IMedium> dvdDrive = coll[i];
|
---|
1039 | Bstr uuid;
|
---|
1040 | dvdDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
1041 | RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
|
---|
1042 | Bstr location;
|
---|
1043 | dvdDrive->COMGETTER(Location)(location.asOutParam());
|
---|
1044 | RTPrintf("Name: %ls\n\n", location.raw());
|
---|
1045 | }
|
---|
1046 | }
|
---|
1047 | break;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | case kListHostFloppies:
|
---|
1051 | {
|
---|
1052 | ComPtr<IHost> host;
|
---|
1053 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
1054 | com::SafeIfaceArray<IMedium> coll;
|
---|
1055 | CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
|
---|
1056 | if (SUCCEEDED(rc))
|
---|
1057 | {
|
---|
1058 | for (size_t i = 0; i < coll.size(); ++i)
|
---|
1059 | {
|
---|
1060 | ComPtr<IMedium> floppyDrive = coll[i];
|
---|
1061 | Bstr uuid;
|
---|
1062 | floppyDrive->COMGETTER(Id)(uuid.asOutParam());
|
---|
1063 | RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
|
---|
1064 | Bstr location;
|
---|
1065 | floppyDrive->COMGETTER(Location)(location.asOutParam());
|
---|
1066 | RTPrintf("Name: %ls\n\n", location.raw());
|
---|
1067 | }
|
---|
1068 | }
|
---|
1069 | break;
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | case kListInternalNetworks:
|
---|
1073 | rc = listInternalNetworks(pVirtualBox);
|
---|
1074 | break;
|
---|
1075 |
|
---|
1076 | case kListBridgedInterfaces:
|
---|
1077 | #if defined(VBOX_WITH_NETFLT)
|
---|
1078 | case kListHostOnlyInterfaces:
|
---|
1079 | #endif
|
---|
1080 | rc = listNetworkInterfaces(pVirtualBox, enmCommand == kListBridgedInterfaces);
|
---|
1081 | break;
|
---|
1082 |
|
---|
1083 | case kListHostInfo:
|
---|
1084 | rc = listHostInfo(pVirtualBox);
|
---|
1085 | break;
|
---|
1086 |
|
---|
1087 | case kListHostCpuIDs:
|
---|
1088 | {
|
---|
1089 | ComPtr<IHost> Host;
|
---|
1090 | CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
1091 |
|
---|
1092 | RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n");
|
---|
1093 | ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
|
---|
1094 | static uint32_t const s_auCpuIdRanges[] =
|
---|
1095 | {
|
---|
1096 | UINT32_C(0x00000000), UINT32_C(0x0000007f),
|
---|
1097 | UINT32_C(0x80000000), UINT32_C(0x8000007f),
|
---|
1098 | UINT32_C(0xc0000000), UINT32_C(0xc000007f)
|
---|
1099 | };
|
---|
1100 | for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
|
---|
1101 | {
|
---|
1102 | ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
|
---|
1103 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
|
---|
1104 | if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
|
---|
1105 | continue;
|
---|
1106 | cLeafs++;
|
---|
1107 | for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
|
---|
1108 | {
|
---|
1109 | CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
|
---|
1110 | RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
|
---|
1111 | }
|
---|
1112 | }
|
---|
1113 | break;
|
---|
1114 | }
|
---|
1115 |
|
---|
1116 | case kListHddBackends:
|
---|
1117 | rc = listHddBackends(pVirtualBox);
|
---|
1118 | break;
|
---|
1119 |
|
---|
1120 | case kListHdds:
|
---|
1121 | {
|
---|
1122 | com::SafeIfaceArray<IMedium> hdds;
|
---|
1123 | CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
|
---|
1124 | rc = listMedia(pVirtualBox, hdds, "base", fOptLong);
|
---|
1125 | break;
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | case kListDvds:
|
---|
1129 | {
|
---|
1130 | com::SafeIfaceArray<IMedium> dvds;
|
---|
1131 | CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
|
---|
1132 | rc = listMedia(pVirtualBox, dvds, NULL, fOptLong);
|
---|
1133 | break;
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 | case kListFloppies:
|
---|
1137 | {
|
---|
1138 | com::SafeIfaceArray<IMedium> floppies;
|
---|
1139 | CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
|
---|
1140 | rc = listMedia(pVirtualBox, floppies, NULL, fOptLong);
|
---|
1141 | break;
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | case kListUsbHost:
|
---|
1145 | rc = listUsbHost(pVirtualBox);
|
---|
1146 | break;
|
---|
1147 |
|
---|
1148 | case kListUsbFilters:
|
---|
1149 | rc = listUsbFilters(pVirtualBox);
|
---|
1150 | break;
|
---|
1151 |
|
---|
1152 | case kListSystemProperties:
|
---|
1153 | rc = listSystemProperties(pVirtualBox);
|
---|
1154 | break;
|
---|
1155 |
|
---|
1156 | case kListDhcpServers:
|
---|
1157 | {
|
---|
1158 | com::SafeIfaceArray<IDHCPServer> svrs;
|
---|
1159 | CHECK_ERROR(pVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs)));
|
---|
1160 | for (size_t i = 0; i < svrs.size(); ++i)
|
---|
1161 | {
|
---|
1162 | ComPtr<IDHCPServer> svr = svrs[i];
|
---|
1163 | Bstr netName;
|
---|
1164 | svr->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
1165 | RTPrintf("NetworkName: %ls\n", netName.raw());
|
---|
1166 | Bstr ip;
|
---|
1167 | svr->COMGETTER(IPAddress)(ip.asOutParam());
|
---|
1168 | RTPrintf("IP: %ls\n", ip.raw());
|
---|
1169 | Bstr netmask;
|
---|
1170 | svr->COMGETTER(NetworkMask)(netmask.asOutParam());
|
---|
1171 | RTPrintf("NetworkMask: %ls\n", netmask.raw());
|
---|
1172 | Bstr lowerIp;
|
---|
1173 | svr->COMGETTER(LowerIP)(lowerIp.asOutParam());
|
---|
1174 | RTPrintf("lowerIPAddress: %ls\n", lowerIp.raw());
|
---|
1175 | Bstr upperIp;
|
---|
1176 | svr->COMGETTER(UpperIP)(upperIp.asOutParam());
|
---|
1177 | RTPrintf("upperIPAddress: %ls\n", upperIp.raw());
|
---|
1178 | BOOL fEnabled;
|
---|
1179 | svr->COMGETTER(Enabled)(&fEnabled);
|
---|
1180 | RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1181 | RTPrintf("\n");
|
---|
1182 | }
|
---|
1183 | break;
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 | case kListExtPacks:
|
---|
1187 | rc = listExtensionPacks(pVirtualBox);
|
---|
1188 | break;
|
---|
1189 |
|
---|
1190 | case kListGroups:
|
---|
1191 | rc = listGroups(pVirtualBox);
|
---|
1192 | break;
|
---|
1193 |
|
---|
1194 | case kListNatNetworks:
|
---|
1195 | {
|
---|
1196 | com::SafeIfaceArray<INATNetwork> nets;
|
---|
1197 | CHECK_ERROR(pVirtualBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(nets)));
|
---|
1198 | for (size_t i = 0; i < nets.size(); ++i)
|
---|
1199 | {
|
---|
1200 | ComPtr<INATNetwork> net = nets[i];
|
---|
1201 | Bstr netName;
|
---|
1202 | net->COMGETTER(NetworkName)(netName.asOutParam());
|
---|
1203 | RTPrintf("NetworkName: %ls\n", netName.raw());
|
---|
1204 | Bstr gateway;
|
---|
1205 | net->COMGETTER(Gateway)(gateway.asOutParam());
|
---|
1206 | RTPrintf("IP: %ls\n", gateway.raw());
|
---|
1207 | Bstr network;
|
---|
1208 | net->COMGETTER(Network)(network.asOutParam());
|
---|
1209 | RTPrintf("Network: %ls\n", network.raw());
|
---|
1210 | BOOL fEnabled;
|
---|
1211 | net->COMGETTER(IPv6Enabled)(&fEnabled);
|
---|
1212 | RTPrintf("IPv6 Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1213 | Bstr ipv6prefix;
|
---|
1214 | net->COMGETTER(IPv6Prefix)(ipv6prefix.asOutParam());
|
---|
1215 | RTPrintf("IPv6 Prefix: %ls\n", ipv6prefix.raw());
|
---|
1216 | net->COMGETTER(NeedDhcpServer)(&fEnabled);
|
---|
1217 | RTPrintf("DHCP Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1218 | net->COMGETTER(Enabled)(&fEnabled);
|
---|
1219 | RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
|
---|
1220 |
|
---|
1221 | #define PRINT_STRING_ARRAY(title) \
|
---|
1222 | if (strs.size() > 0) \
|
---|
1223 | { \
|
---|
1224 | RTPrintf(title); \
|
---|
1225 | size_t j = 0; \
|
---|
1226 | for (;j < strs.size(); ++j) \
|
---|
1227 | RTPrintf(" %s\n", Utf8Str(strs[j]).c_str()); \
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | com::SafeArray<BSTR> strs;
|
---|
1231 |
|
---|
1232 | CHECK_ERROR(nets[i], COMGETTER(PortForwardRules4)(ComSafeArrayAsOutParam(strs)));
|
---|
1233 | PRINT_STRING_ARRAY("Port-forwarding (ipv4)\n");
|
---|
1234 | strs.setNull();
|
---|
1235 |
|
---|
1236 | CHECK_ERROR(nets[i], COMGETTER(PortForwardRules6)(ComSafeArrayAsOutParam(strs)));
|
---|
1237 | PRINT_STRING_ARRAY("Port-forwarding (ipv6)\n");
|
---|
1238 | strs.setNull();
|
---|
1239 |
|
---|
1240 | CHECK_ERROR(nets[i], COMGETTER(LocalMappings)(ComSafeArrayAsOutParam(strs)));
|
---|
1241 | PRINT_STRING_ARRAY("loopback mappings (ipv4)\n");
|
---|
1242 | strs.setNull();
|
---|
1243 |
|
---|
1244 | #undef PRINT_STRING_ARRAY
|
---|
1245 | RTPrintf("\n");
|
---|
1246 | }
|
---|
1247 | break;
|
---|
1248 | }
|
---|
1249 |
|
---|
1250 | case kListVideoInputDevices:
|
---|
1251 | rc = listVideoInputDevices(pVirtualBox);
|
---|
1252 | break;
|
---|
1253 |
|
---|
1254 | case kListScreenShotFormats:
|
---|
1255 | rc = listScreenShotFormats(pVirtualBox);
|
---|
1256 | break;
|
---|
1257 |
|
---|
1258 | /* No default here, want gcc warnings. */
|
---|
1259 |
|
---|
1260 | } /* end switch */
|
---|
1261 |
|
---|
1262 | return rc;
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | /**
|
---|
1266 | * Handles the 'list' command.
|
---|
1267 | *
|
---|
1268 | * @returns Appropriate exit code.
|
---|
1269 | * @param a Handler argument.
|
---|
1270 | */
|
---|
1271 | RTEXITCODE handleList(HandlerArg *a)
|
---|
1272 | {
|
---|
1273 | bool fOptLong = false;
|
---|
1274 | bool fOptMultiple = false;
|
---|
1275 | enum enmListType enmOptCommand = kListNotSpecified;
|
---|
1276 |
|
---|
1277 | static const RTGETOPTDEF s_aListOptions[] =
|
---|
1278 | {
|
---|
1279 | { "--long", 'l', RTGETOPT_REQ_NOTHING },
|
---|
1280 | { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */
|
---|
1281 | { "vms", kListVMs, RTGETOPT_REQ_NOTHING },
|
---|
1282 | { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING },
|
---|
1283 | { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING },
|
---|
1284 | { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING },
|
---|
1285 | { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING },
|
---|
1286 | { "intnets", kListInternalNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1287 | { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
|
---|
1288 | { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING },
|
---|
1289 | #if defined(VBOX_WITH_NETFLT)
|
---|
1290 | { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
|
---|
1291 | #endif
|
---|
1292 | { "natnetworks", kListNatNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1293 | { "natnets", kListNatNetworks, RTGETOPT_REQ_NOTHING },
|
---|
1294 | { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING },
|
---|
1295 | { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING },
|
---|
1296 | { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING },
|
---|
1297 | { "hdds", kListHdds, RTGETOPT_REQ_NOTHING },
|
---|
1298 | { "dvds", kListDvds, RTGETOPT_REQ_NOTHING },
|
---|
1299 | { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING },
|
---|
1300 | { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING },
|
---|
1301 | { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING },
|
---|
1302 | { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING },
|
---|
1303 | { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING },
|
---|
1304 | { "extpacks", kListExtPacks, RTGETOPT_REQ_NOTHING },
|
---|
1305 | { "groups", kListGroups, RTGETOPT_REQ_NOTHING },
|
---|
1306 | { "webcams", kListVideoInputDevices, RTGETOPT_REQ_NOTHING },
|
---|
1307 | { "screenshotformats", kListScreenShotFormats, RTGETOPT_REQ_NOTHING },
|
---|
1308 | };
|
---|
1309 |
|
---|
1310 | int ch;
|
---|
1311 | RTGETOPTUNION ValueUnion;
|
---|
1312 | RTGETOPTSTATE GetState;
|
---|
1313 | RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
|
---|
1314 | 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
|
---|
1315 | while ((ch = RTGetOpt(&GetState, &ValueUnion)))
|
---|
1316 | {
|
---|
1317 | switch (ch)
|
---|
1318 | {
|
---|
1319 | case 'l': /* --long */
|
---|
1320 | fOptLong = true;
|
---|
1321 | break;
|
---|
1322 |
|
---|
1323 | case 'm':
|
---|
1324 | fOptMultiple = true;
|
---|
1325 | if (enmOptCommand == kListNotSpecified)
|
---|
1326 | break;
|
---|
1327 | ch = enmOptCommand;
|
---|
1328 | /* fall thru */
|
---|
1329 |
|
---|
1330 | case kListVMs:
|
---|
1331 | case kListRunningVMs:
|
---|
1332 | case kListOsTypes:
|
---|
1333 | case kListHostDvds:
|
---|
1334 | case kListHostFloppies:
|
---|
1335 | case kListInternalNetworks:
|
---|
1336 | case kListBridgedInterfaces:
|
---|
1337 | #if defined(VBOX_WITH_NETFLT)
|
---|
1338 | case kListHostOnlyInterfaces:
|
---|
1339 | #endif
|
---|
1340 | case kListHostInfo:
|
---|
1341 | case kListHostCpuIDs:
|
---|
1342 | case kListHddBackends:
|
---|
1343 | case kListHdds:
|
---|
1344 | case kListDvds:
|
---|
1345 | case kListFloppies:
|
---|
1346 | case kListUsbHost:
|
---|
1347 | case kListUsbFilters:
|
---|
1348 | case kListSystemProperties:
|
---|
1349 | case kListDhcpServers:
|
---|
1350 | case kListExtPacks:
|
---|
1351 | case kListGroups:
|
---|
1352 | case kListNatNetworks:
|
---|
1353 | case kListVideoInputDevices:
|
---|
1354 | case kListScreenShotFormats:
|
---|
1355 | enmOptCommand = (enum enmListType)ch;
|
---|
1356 | if (fOptMultiple)
|
---|
1357 | {
|
---|
1358 | HRESULT hrc = produceList((enum enmListType)ch, fOptLong, a->virtualBox);
|
---|
1359 | if (FAILED(hrc))
|
---|
1360 | return RTEXITCODE_FAILURE;
|
---|
1361 | }
|
---|
1362 | break;
|
---|
1363 |
|
---|
1364 | case VINF_GETOPT_NOT_OPTION:
|
---|
1365 | return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
|
---|
1366 |
|
---|
1367 | default:
|
---|
1368 | return errorGetOpt(USAGE_LIST, ch, &ValueUnion);
|
---|
1369 | }
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 | /*
|
---|
1373 | * If not in multiple list mode, we have to produce the list now.
|
---|
1374 | */
|
---|
1375 | if (enmOptCommand == kListNotSpecified)
|
---|
1376 | return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
|
---|
1377 | if (!fOptMultiple)
|
---|
1378 | {
|
---|
1379 | HRESULT hrc = produceList(enmOptCommand, fOptLong, a->virtualBox);
|
---|
1380 | if (FAILED(hrc))
|
---|
1381 | return RTEXITCODE_FAILURE;
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | return RTEXITCODE_SUCCESS;
|
---|
1385 | }
|
---|
1386 |
|
---|
1387 | #endif /* !VBOX_ONLY_DOCS */
|
---|
1388 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|