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