VirtualBox

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

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

Main: change API. Interface IMediumFormat was touched. Attribute capabilities got the type MediumFormatCapabilities and option safeArray. PR5434.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.8 KB
Line 
1/* $Id: VBoxManageList.cpp 44503 2013-02-01 06:28:53Z 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(Id)(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(MinGuestCPUCount)(&ulValue);
540 RTPrintf("Minimum guest CPU count: %u\n", ulValue);
541 systemProperties->COMGETTER(MaxGuestCPUCount)(&ulValue);
542 RTPrintf("Maximum guest CPU count: %u\n", ulValue);
543 systemProperties->COMGETTER(InfoVDSize)(&i64Value);
544 RTPrintf("Virtual disk limit (info): %lld Bytes\n", i64Value);
545 systemProperties->COMGETTER(SerialPortCount)(&ulValue);
546 RTPrintf("Maximum Serial Port count: %u\n", ulValue);
547 systemProperties->COMGETTER(ParallelPortCount)(&ulValue);
548 RTPrintf("Maximum Parallel Port count: %u\n", ulValue);
549 systemProperties->COMGETTER(MaxBootPosition)(&ulValue);
550 RTPrintf("Maximum Boot Position: %u\n", ulValue);
551 systemProperties->GetMaxNetworkAdapters(ChipsetType_PIIX3, &ulValue);
552 RTPrintf("Maximum PIIX3 Network Adapter count: %u\n", ulValue);
553 systemProperties->GetMaxNetworkAdapters(ChipsetType_ICH9, &ulValue);
554 RTPrintf("Maximum ICH9 Network Adapter count: %u\n", ulValue);
555 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_IDE, &ulValue);
556 RTPrintf("Maximum PIIX3 IDE Controllers: %u\n", ulValue);
557 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_IDE, &ulValue);
558 RTPrintf("Maximum ICH9 IDE Controllers: %u\n", ulValue);
559 systemProperties->GetMaxPortCountForStorageBus(StorageBus_IDE, &ulValue);
560 RTPrintf("Maximum IDE Port count: %u\n", ulValue);
561 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_IDE, &ulValue);
562 RTPrintf("Maximum Devices per IDE Port: %u\n", ulValue);
563 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SATA, &ulValue);
564 RTPrintf("Maximum PIIX3 SATA Controllers: %u\n", ulValue);
565 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SATA, &ulValue);
566 RTPrintf("Maximum ICH9 SATA Controllers: %u\n", ulValue);
567 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SATA, &ulValue);
568 RTPrintf("Maximum SATA Port count: %u\n", ulValue);
569 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SATA, &ulValue);
570 RTPrintf("Maximum Devices per SATA Port: %u\n", ulValue);
571 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SCSI, &ulValue);
572 RTPrintf("Maximum PIIX3 SCSI Controllers: %u\n", ulValue);
573 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SCSI, &ulValue);
574 RTPrintf("Maximum ICH9 SCSI Controllers: %u\n", ulValue);
575 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SCSI, &ulValue);
576 RTPrintf("Maximum SCSI Port count: %u\n", ulValue);
577 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SCSI, &ulValue);
578 RTPrintf("Maximum Devices per SCSI Port: %u\n", ulValue);
579 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_SAS, &ulValue);
580 RTPrintf("Maximum SAS PIIX3 Controllers: %u\n", ulValue);
581 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_SAS, &ulValue);
582 RTPrintf("Maximum SAS ICH9 Controllers: %u\n", ulValue);
583 systemProperties->GetMaxPortCountForStorageBus(StorageBus_SAS, &ulValue);
584 RTPrintf("Maximum SAS Port count: %u\n", ulValue);
585 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_SAS, &ulValue);
586 RTPrintf("Maximum Devices per SAS Port: %u\n", ulValue);
587 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_PIIX3, StorageBus_Floppy, &ulValue);
588 RTPrintf("Maximum PIIX3 Floppy Controllers:%u\n", ulValue);
589 systemProperties->GetMaxInstancesOfStorageBus(ChipsetType_ICH9, StorageBus_Floppy, &ulValue);
590 RTPrintf("Maximum ICH9 Floppy Controllers: %u\n", ulValue);
591 systemProperties->GetMaxPortCountForStorageBus(StorageBus_Floppy, &ulValue);
592 RTPrintf("Maximum Floppy Port count: %u\n", ulValue);
593 systemProperties->GetMaxDevicesPerPortForStorageBus(StorageBus_Floppy, &ulValue);
594 RTPrintf("Maximum Devices per Floppy Port: %u\n", ulValue);
595 systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
596 RTPrintf("Default machine folder: %ls\n", str.raw());
597 systemProperties->COMGETTER(VRDEAuthLibrary)(str.asOutParam());
598 RTPrintf("VRDE auth library: %ls\n", str.raw());
599 systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
600 RTPrintf("Webservice auth. library: %ls\n", str.raw());
601 systemProperties->COMGETTER(DefaultVRDEExtPack)(str.asOutParam());
602 RTPrintf("Remote desktop ExtPack: %ls\n", str.raw());
603 systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
604 RTPrintf("Log history count: %u\n", ulValue);
605 systemProperties->COMGETTER(AutostartDatabasePath)(str.asOutParam());
606 RTPrintf("Autostart database path: %ls\n", str.raw());
607 systemProperties->COMGETTER(DefaultAdditionsISO)(str.asOutParam());
608 RTPrintf("Default Guest Additions ISO: %ls\n", str.raw());
609 return S_OK;
610}
611
612
613/**
614 * List extension packs.
615 *
616 * @returns See produceList.
617 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
618 */
619static HRESULT listExtensionPacks(const ComPtr<IVirtualBox> &pVirtualBox)
620{
621 ComObjPtr<IExtPackManager> ptrExtPackMgr;
622 CHECK_ERROR2_RET(pVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
623
624 SafeIfaceArray<IExtPack> extPacks;
625 CHECK_ERROR2_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
626 RTPrintf("Extension Packs: %u\n", extPacks.size());
627
628 HRESULT hrc = S_OK;
629 for (size_t i = 0; i < extPacks.size(); i++)
630 {
631 /* Read all the properties. */
632 Bstr bstrName;
633 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
634 Bstr bstrDesc;
635 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
636 Bstr bstrVersion;
637 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
638 ULONG uRevision;
639 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Revision)(&uRevision), hrc = hrcCheck; uRevision = 0);
640 Bstr bstrEdition;
641 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
642 Bstr bstrVrdeModule;
643 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.setNull());
644 BOOL fUsable;
645 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Usable)(&fUsable), hrc = hrcCheck; fUsable = FALSE);
646 Bstr bstrWhy;
647 CHECK_ERROR2_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
648
649 /* Display them. */
650 if (i)
651 RTPrintf("\n");
652 RTPrintf("Pack no.%2zu: %ls\n"
653 "Version: %ls\n"
654 "Revision: %u\n"
655 "Edition: %ls\n"
656 "Description: %ls\n"
657 "VRDE Module: %ls\n"
658 "Usable: %RTbool\n"
659 "Why unusable: %ls\n",
660 i, bstrName.raw(),
661 bstrVersion.raw(),
662 uRevision,
663 bstrEdition.raw(),
664 bstrDesc.raw(),
665 bstrVrdeModule.raw(),
666 fUsable != FALSE,
667 bstrWhy.raw());
668
669 /* Query plugins and display them. */
670 }
671 return hrc;
672}
673
674
675/**
676 * List machine groups.
677 *
678 * @returns See produceList.
679 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
680 */
681static HRESULT listGroups(const ComPtr<IVirtualBox> &pVirtualBox)
682{
683 SafeArray<BSTR> groups;
684 CHECK_ERROR2_RET(pVirtualBox, COMGETTER(MachineGroups)(ComSafeArrayAsOutParam(groups)), hrcCheck);
685
686 for (size_t i = 0; i < groups.size(); i++)
687 {
688 RTPrintf("\"%ls\"\n", groups[i]);
689 }
690 return S_OK;
691}
692
693
694/**
695 * The type of lists we can produce.
696 */
697enum enmListType
698{
699 kListNotSpecified = 1000,
700 kListVMs,
701 kListRunningVMs,
702 kListOsTypes,
703 kListHostDvds,
704 kListHostFloppies,
705 kListBridgedInterfaces,
706#if defined(VBOX_WITH_NETFLT)
707 kListHostOnlyInterfaces,
708#endif
709 kListHostCpuIDs,
710 kListHostInfo,
711 kListHddBackends,
712 kListHdds,
713 kListDvds,
714 kListFloppies,
715 kListUsbHost,
716 kListUsbFilters,
717 kListSystemProperties,
718 kListDhcpServers,
719 kListExtPacks,
720 kListGroups
721};
722
723
724/**
725 * Produces the specified listing.
726 *
727 * @returns S_OK or some COM error code that has been reported in full.
728 * @param enmList The list to produce.
729 * @param fOptLong Long (@c true) or short list format.
730 * @param pVirtualBox Reference to the IVirtualBox smart pointer.
731 */
732static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, const ComPtr<IVirtualBox> &pVirtualBox)
733{
734 HRESULT rc = S_OK;
735 switch (enmCommand)
736 {
737 case kListNotSpecified:
738 AssertFailed();
739 return E_FAIL;
740
741 case kListVMs:
742 {
743 /*
744 * Get the list of all registered VMs
745 */
746 com::SafeIfaceArray<IMachine> machines;
747 rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
748 if (SUCCEEDED(rc))
749 {
750 /*
751 * Iterate through the collection
752 */
753 for (size_t i = 0; i < machines.size(); ++i)
754 {
755 if (machines[i])
756 rc = showVMInfo(pVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
757 }
758 }
759 break;
760 }
761
762 case kListRunningVMs:
763 {
764 /*
765 * Get the list of all _running_ VMs
766 */
767 com::SafeIfaceArray<IMachine> machines;
768 rc = pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
769 com::SafeArray<MachineState_T> states;
770 if (SUCCEEDED(rc))
771 rc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
772 if (SUCCEEDED(rc))
773 {
774 /*
775 * Iterate through the collection
776 */
777 for (size_t i = 0; i < machines.size(); ++i)
778 {
779 if (machines[i])
780 {
781 MachineState_T machineState = states[i];
782 switch (machineState)
783 {
784 case MachineState_Running:
785 case MachineState_Teleporting:
786 case MachineState_LiveSnapshotting:
787 case MachineState_Paused:
788 case MachineState_TeleportingPausedVM:
789 rc = showVMInfo(pVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
790 break;
791 }
792 }
793 }
794 }
795 break;
796 }
797
798 case kListOsTypes:
799 {
800 com::SafeIfaceArray<IGuestOSType> coll;
801 rc = pVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
802 if (SUCCEEDED(rc))
803 {
804 /*
805 * Iterate through the collection.
806 */
807 for (size_t i = 0; i < coll.size(); ++i)
808 {
809 ComPtr<IGuestOSType> guestOS;
810 guestOS = coll[i];
811 Bstr guestId;
812 guestOS->COMGETTER(Id)(guestId.asOutParam());
813 RTPrintf("ID: %ls\n", guestId.raw());
814 Bstr guestDescription;
815 guestOS->COMGETTER(Description)(guestDescription.asOutParam());
816 RTPrintf("Description: %ls\n", guestDescription.raw());
817 Bstr familyId;
818 guestOS->COMGETTER(FamilyId)(familyId.asOutParam());
819 RTPrintf("Family ID: %ls\n", familyId.raw());
820 Bstr familyDescription;
821 guestOS->COMGETTER(FamilyDescription)(familyDescription.asOutParam());
822 RTPrintf("Family Desc: %ls\n", familyDescription.raw());
823 BOOL is64Bit;
824 guestOS->COMGETTER(Is64Bit)(&is64Bit);
825 RTPrintf("64 bit: %RTbool\n", is64Bit);
826 RTPrintf("\n");
827 }
828 }
829 break;
830 }
831
832 case kListHostDvds:
833 {
834 ComPtr<IHost> host;
835 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
836 com::SafeIfaceArray<IMedium> coll;
837 CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
838 if (SUCCEEDED(rc))
839 {
840 for (size_t i = 0; i < coll.size(); ++i)
841 {
842 ComPtr<IMedium> dvdDrive = coll[i];
843 Bstr uuid;
844 dvdDrive->COMGETTER(Id)(uuid.asOutParam());
845 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
846 Bstr location;
847 dvdDrive->COMGETTER(Location)(location.asOutParam());
848 RTPrintf("Name: %ls\n\n", location.raw());
849 }
850 }
851 break;
852 }
853
854 case kListHostFloppies:
855 {
856 ComPtr<IHost> host;
857 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(host.asOutParam()));
858 com::SafeIfaceArray<IMedium> coll;
859 CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
860 if (SUCCEEDED(rc))
861 {
862 for (size_t i = 0; i < coll.size(); ++i)
863 {
864 ComPtr<IMedium> floppyDrive = coll[i];
865 Bstr uuid;
866 floppyDrive->COMGETTER(Id)(uuid.asOutParam());
867 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
868 Bstr location;
869 floppyDrive->COMGETTER(Location)(location.asOutParam());
870 RTPrintf("Name: %ls\n\n", location.raw());
871 }
872 }
873 break;
874 }
875
876 case kListBridgedInterfaces:
877#if defined(VBOX_WITH_NETFLT)
878 case kListHostOnlyInterfaces:
879#endif
880 rc = listNetworkInterfaces(pVirtualBox, enmCommand == kListBridgedInterfaces);
881 break;
882
883 case kListHostInfo:
884 rc = listHostInfo(pVirtualBox);
885 break;
886
887 case kListHostCpuIDs:
888 {
889 ComPtr<IHost> Host;
890 CHECK_ERROR(pVirtualBox, COMGETTER(Host)(Host.asOutParam()));
891
892 RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n");
893 ULONG uCpuNo = 0; /* ASSUMES that CPU#0 is online. */
894 static uint32_t const s_auCpuIdRanges[] =
895 {
896 UINT32_C(0x00000000), UINT32_C(0x0000007f),
897 UINT32_C(0x80000000), UINT32_C(0x8000007f),
898 UINT32_C(0xc0000000), UINT32_C(0xc000007f)
899 };
900 for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
901 {
902 ULONG uEAX, uEBX, uECX, uEDX, cLeafs;
903 CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
904 if (cLeafs < s_auCpuIdRanges[i] || cLeafs > s_auCpuIdRanges[i+1])
905 continue;
906 cLeafs++;
907 for (ULONG iLeaf = s_auCpuIdRanges[i]; iLeaf <= cLeafs; iLeaf++)
908 {
909 CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, iLeaf, 0, &uEAX, &uEBX, &uECX, &uEDX));
910 RTPrintf("%08x %08x %08x %08x %08x\n", iLeaf, uEAX, uEBX, uECX, uEDX);
911 }
912 }
913 break;
914 }
915
916 case kListHddBackends:
917 rc = listHddBackends(pVirtualBox);
918 break;
919
920 case kListHdds:
921 {
922 com::SafeIfaceArray<IMedium> hdds;
923 CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
924 rc = listMedia(pVirtualBox, hdds, "base", fOptLong);
925 break;
926 }
927
928 case kListDvds:
929 {
930 com::SafeIfaceArray<IMedium> dvds;
931 CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
932 rc = listMedia(pVirtualBox, dvds, NULL, fOptLong);
933 break;
934 }
935
936 case kListFloppies:
937 {
938 com::SafeIfaceArray<IMedium> floppies;
939 CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
940 rc = listMedia(pVirtualBox, floppies, NULL, fOptLong);
941 break;
942 }
943
944 case kListUsbHost:
945 rc = listUsbHost(pVirtualBox);
946 break;
947
948 case kListUsbFilters:
949 rc = listUsbFilters(pVirtualBox);
950 break;
951
952 case kListSystemProperties:
953 rc = listSystemProperties(pVirtualBox);
954 break;
955
956 case kListDhcpServers:
957 {
958 com::SafeIfaceArray<IDHCPServer> svrs;
959 CHECK_ERROR(pVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs)));
960 for (size_t i = 0; i < svrs.size(); ++i)
961 {
962 ComPtr<IDHCPServer> svr = svrs[i];
963 Bstr netName;
964 svr->COMGETTER(NetworkName)(netName.asOutParam());
965 RTPrintf("NetworkName: %ls\n", netName.raw());
966 Bstr ip;
967 svr->COMGETTER(IPAddress)(ip.asOutParam());
968 RTPrintf("IP: %ls\n", ip.raw());
969 Bstr netmask;
970 svr->COMGETTER(NetworkMask)(netmask.asOutParam());
971 RTPrintf("NetworkMask: %ls\n", netmask.raw());
972 Bstr lowerIp;
973 svr->COMGETTER(LowerIP)(lowerIp.asOutParam());
974 RTPrintf("lowerIPAddress: %ls\n", lowerIp.raw());
975 Bstr upperIp;
976 svr->COMGETTER(UpperIP)(upperIp.asOutParam());
977 RTPrintf("upperIPAddress: %ls\n", upperIp.raw());
978 BOOL fEnabled;
979 svr->COMGETTER(Enabled)(&fEnabled);
980 RTPrintf("Enabled: %s\n", fEnabled ? "Yes" : "No");
981 RTPrintf("\n");
982 }
983 break;
984 }
985
986 case kListExtPacks:
987 rc = listExtensionPacks(pVirtualBox);
988 break;
989
990 case kListGroups:
991 rc = listGroups(pVirtualBox);
992 break;
993
994 /* No default here, want gcc warnings. */
995
996 } /* end switch */
997
998 return rc;
999}
1000
1001/**
1002 * Handles the 'list' command.
1003 *
1004 * @returns Appropriate exit code.
1005 * @param a Handler argument.
1006 */
1007int handleList(HandlerArg *a)
1008{
1009 bool fOptLong = false;
1010 bool fOptMultiple = false;
1011 enum enmListType enmOptCommand = kListNotSpecified;
1012
1013 static const RTGETOPTDEF s_aListOptions[] =
1014 {
1015 { "--long", 'l', RTGETOPT_REQ_NOTHING },
1016 { "--multiple", 'm', RTGETOPT_REQ_NOTHING }, /* not offical yet */
1017 { "vms", kListVMs, RTGETOPT_REQ_NOTHING },
1018 { "runningvms", kListRunningVMs, RTGETOPT_REQ_NOTHING },
1019 { "ostypes", kListOsTypes, RTGETOPT_REQ_NOTHING },
1020 { "hostdvds", kListHostDvds, RTGETOPT_REQ_NOTHING },
1021 { "hostfloppies", kListHostFloppies, RTGETOPT_REQ_NOTHING },
1022 { "hostifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING }, /* backward compatibility */
1023 { "bridgedifs", kListBridgedInterfaces, RTGETOPT_REQ_NOTHING },
1024#if defined(VBOX_WITH_NETFLT)
1025 { "hostonlyifs", kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
1026#endif
1027 { "hostinfo", kListHostInfo, RTGETOPT_REQ_NOTHING },
1028 { "hostcpuids", kListHostCpuIDs, RTGETOPT_REQ_NOTHING },
1029 { "hddbackends", kListHddBackends, RTGETOPT_REQ_NOTHING },
1030 { "hdds", kListHdds, RTGETOPT_REQ_NOTHING },
1031 { "dvds", kListDvds, RTGETOPT_REQ_NOTHING },
1032 { "floppies", kListFloppies, RTGETOPT_REQ_NOTHING },
1033 { "usbhost", kListUsbHost, RTGETOPT_REQ_NOTHING },
1034 { "usbfilters", kListUsbFilters, RTGETOPT_REQ_NOTHING },
1035 { "systemproperties", kListSystemProperties, RTGETOPT_REQ_NOTHING },
1036 { "dhcpservers", kListDhcpServers, RTGETOPT_REQ_NOTHING },
1037 { "extpacks", kListExtPacks, RTGETOPT_REQ_NOTHING },
1038 { "groups", kListGroups, RTGETOPT_REQ_NOTHING },
1039 };
1040
1041 int ch;
1042 RTGETOPTUNION ValueUnion;
1043 RTGETOPTSTATE GetState;
1044 RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
1045 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
1046 while ((ch = RTGetOpt(&GetState, &ValueUnion)))
1047 {
1048 switch (ch)
1049 {
1050 case 'l': /* --long */
1051 fOptLong = true;
1052 break;
1053
1054 case 'm':
1055 fOptMultiple = true;
1056 if (enmOptCommand == kListNotSpecified)
1057 break;
1058 ch = enmOptCommand;
1059 /* fall thru */
1060
1061 case kListVMs:
1062 case kListRunningVMs:
1063 case kListOsTypes:
1064 case kListHostDvds:
1065 case kListHostFloppies:
1066 case kListBridgedInterfaces:
1067#if defined(VBOX_WITH_NETFLT)
1068 case kListHostOnlyInterfaces:
1069#endif
1070 case kListHostInfo:
1071 case kListHostCpuIDs:
1072 case kListHddBackends:
1073 case kListHdds:
1074 case kListDvds:
1075 case kListFloppies:
1076 case kListUsbHost:
1077 case kListUsbFilters:
1078 case kListSystemProperties:
1079 case kListDhcpServers:
1080 case kListExtPacks:
1081 case kListGroups:
1082 enmOptCommand = (enum enmListType)ch;
1083 if (fOptMultiple)
1084 {
1085 HRESULT hrc = produceList((enum enmListType)ch, fOptLong, a->virtualBox);
1086 if (FAILED(hrc))
1087 return 1;
1088 }
1089 break;
1090
1091 case VINF_GETOPT_NOT_OPTION:
1092 return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
1093
1094 default:
1095 return errorGetOpt(USAGE_LIST, ch, &ValueUnion);
1096 }
1097 }
1098
1099 /*
1100 * If not in multiple list mode, we have to produce the list now.
1101 */
1102 if (enmOptCommand == kListNotSpecified)
1103 return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
1104 if (!fOptMultiple)
1105 {
1106 HRESULT hrc = produceList(enmOptCommand, fOptLong, a->virtualBox);
1107 if (FAILED(hrc))
1108 return 1;
1109 }
1110
1111 return 0;
1112}
1113
1114#endif /* !VBOX_ONLY_DOCS */
1115/* 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