VirtualBox

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

Last change on this file since 35761 was 35761, checked in by vboxsync, 14 years ago

Main, frontends: proper description for maximal number of NICs per VM

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