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