VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp@ 47376

Last change on this file since 47376 was 46122, checked in by vboxsync, 12 years ago

build fix

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette