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