VBoxManageList.cpp revision eaa687a9ede02b3b161a4595f7e42590a2e1b932
/* $Id$ */
/** @file
* VBoxManage - The 'list' command.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef VBOX_ONLY_DOCS
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBoxManage.h"
using namespace com;
#ifdef VBOX_WITH_HOSTNETIF_API
{
switch (enmType)
{
case HostNetworkInterfaceMediumType_Ethernet: return "Ethernet";
case HostNetworkInterfaceMediumType_PPP: return "PPP";
case HostNetworkInterfaceMediumType_SLIP: return "SLIP";
}
return "Unknown";
}
{
switch (enmStatus)
{
case HostNetworkInterfaceStatus_Up: return "Up";
case HostNetworkInterfaceStatus_Down: return "Down";
}
return "Unknown";
}
#endif /* VBOX_WITH_HOSTNETIF_API */
{
switch (enmType)
{
case DeviceType_HardDisk: return "HardDisk";
case DeviceType_DVD: return "DVD";
case DeviceType_Floppy: return "Floppy";
}
return "Unknown";
}
const char *pszParentUUIDStr)
{
{
if (pszParentUUIDStr)
const char *stateStr = "unknown";
switch (enmState)
{
case MediumState_NotCreated:
stateStr = "not created";
break;
case MediumState_Created:
stateStr = "created";
break;
case MediumState_LockedRead:
stateStr = "locked read";
break;
case MediumState_LockedWrite:
stateStr = "locked write";
break;
case MediumState_Inaccessible:
stateStr = "inaccessible";
break;
case MediumState_Creating:
stateStr = "creating";
break;
case MediumState_Deleting:
stateStr = "deleting";
break;
}
const char *typeStr = "unknown";
switch (type)
{
case MediumType_Normal:
typeStr = "normal";
break;
case MediumType_Immutable:
typeStr = "immutable";
break;
case MediumType_Writethrough:
typeStr = "writethrough";
break;
case MediumType_Shareable:
typeStr = "shareable";
break;
case MediumType_Readonly:
typeStr = "readonly";
break;
}
{
RTPrintf("%s%lS (UUID: %lS)",
j == 0 ? "Usage: " : " ",
{
if (snapshot)
{
}
}
RTPrintf("\n");
}
RTPrintf("\n");
{
// depth first listing of child media
}
}
}
/**
* List extension packs.
*
* @returns See produceList.
* @param rptrVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
CHECK_ERROR2_RET(rptrVirtualBox, COMGETTER(ExtensionPackManager)(ptrExtPackMgr.asOutParam()), hrcCheck);
CHECK_ERROR2_RET(ptrExtPackMgr, COMGETTER(InstalledExtPacks)(ComSafeArrayAsOutParam(extPacks)), hrcCheck);
{
/* Read all the properties. */
CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Name)(bstrName.asOutParam()), hrc = hrcCheck; bstrName.setNull());
CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Description)(bstrDesc.asOutParam()), hrc = hrcCheck; bstrDesc.setNull());
CHECK_ERROR2_STMT(extPacks[i], COMGETTER(Version)(bstrVersion.asOutParam()), hrc = hrcCheck; bstrVersion.setNull());
CHECK_ERROR2_STMT(extPacks[i], COMGETTER(WhyUnusable)(bstrWhy.asOutParam()), hrc = hrcCheck; bstrWhy.setNull());
/* Display them. */
if (i)
RTPrintf("\n");
RTPrintf("Pack no.%2zu: %lS\n"
"Version: %lS\n"
"Revision: %u\n"
"Description: %lS\n"
"Usable: %RTbool\n"
"Why unusable: %lS\n",
bstrVersion.raw(),
}
return hrc;
}
/**
* The type of lists we can produce.
*/
enum enmListType
{
kListNotSpecified = 1000,
#if defined(VBOX_WITH_NETFLT)
#endif
};
/**
* Produces the specified listing.
*
* @returns S_OK or some COM error code that has been reported in full.
* @param enmList The list to produce.
* @param fOptLong Long (@c true) or short list format.
* @param rptrVirtualBox Reference to the IVirtualBox smart pointer.
*/
static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, const ComPtr<IVirtualBox> &rptrVirtualBox)
{
switch (enmCommand)
{
case kListNotSpecified:
AssertFailed();
return E_FAIL;
case kListVMs:
{
/*
* Get the list of all registered VMs
*/
{
/*
* Iterate through the collection
*/
{
if (machines[i])
}
}
break;
}
case kListRunningVMs:
{
/*
* Get the list of all _running_ VMs
*/
{
/*
* Iterate through the collection
*/
{
if (machines[i])
{
{
switch (machineState)
{
case MachineState_Running:
case MachineState_Teleporting:
case MachineState_Paused:
break;
}
}
}
}
}
break;
}
case kListOsTypes:
{
{
/*
* Iterate through the collection.
*/
{
}
}
break;
}
case kListHostDvds:
{
{
{
}
}
break;
}
case kListHostFloppies:
{
{
{
}
}
break;
}
/** @todo function. */
case kListBridgedInterfaces:
#if defined(VBOX_WITH_NETFLT)
case kListHostOnlyInterfaces:
#endif
{
#if defined(VBOX_WITH_NETFLT)
if (enmCommand == kListBridgedInterfaces)
else
#else
#endif
{
#ifndef VBOX_WITH_HOSTNETIF_API
#else /* VBOX_WITH_HOSTNETIF_API */
#endif
}
break;
}
/** @todo function. */
case kListHostInfo:
{
RTPrintf("Host Information:\n\n");
LONG64 u64UtcTime = 0;
char szTime[32];
RTPrintf("Host time: %s\n", RTTimeSpecToString(RTTimeSpecSetMilli(&timeSpec, u64UtcTime), szTime, sizeof(szTime)));
ULONG processorCount = 0;
ULONG processorSpeed = 0;
for (ULONG i = 0; i < processorCount; i++)
{
if (processorSpeed)
else
}
ULONG memorySize = 0;
ULONG memoryAvailable = 0;
break;
}
case kListHostCpuIDs:
{
RTPrintf("Host CPUIDs:\n\nLeaf no. EAX EBX ECX EDX\n");
static uint32_t const s_auCpuIdRanges[] =
{
};
{
CHECK_ERROR(Host, GetProcessorCPUIDLeaf(uCpuNo, s_auCpuIdRanges[i], 0, &cLeafs, &uEBX, &uECX, &uEDX));
continue;
cLeafs++;
{
}
}
break;
}
/** @todo function. */
case kListHddBackends:
{
RTPrintf("Supported hard disk backends:\n\n");
{
/* General information */
RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
/* File extensions */
DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes)));
{
RTPrintf(",");
}
RTPrintf("'");
/* Configuration keys */
RTPrintf(" properties=(");
if (propertyNames.size() > 0)
{
{
RTPrintf("\n name='%ls' desc='%ls' type=",
switch (propertyTypes[j])
{
}
RTPrintf(", ");
}
}
RTPrintf(")\n");
}
break;
}
case kListHdds:
{
break;
}
case kListDvds:
{
break;
}
case kListFloppies:
{
break;
}
/** @todo function. */
case kListUsbHost:
{
RTPrintf("Host USB Devices:\n\n");
{
RTPrintf("<none>\n\n");
}
else
{
{
/* Query info. */
RTPrintf("UUID: %S\n"
"VendorId: %#06x (%04X)\n"
"ProductId: %#06x (%04X)\n"
"Revision: %u.%u (%02u%02u)\n",
/* optional stuff. */
/* current state */
const char *pszState = "?";
switch (state)
{
pszState = "Not supported";
break;
pszState = "Unavailable";
break;
case USBDeviceState_Busy:
pszState = "Busy";
break;
case USBDeviceState_Available:
pszState = "Available";
break;
case USBDeviceState_Held:
pszState = "Held";
break;
case USBDeviceState_Captured:
pszState = "Captured";
break;
default:
ASSERT(false);
break;
}
}
}
break;
}
/** @todo function. */
case kListUsbFilters:
{
RTPrintf("Global USB Device Filters:\n\n");
{
RTPrintf("<none>\n\n");
}
else
{
{
/* Query info. */
const char *pszAction = "<invalid>";
switch (action)
{
pszAction = "Ignore";
break;
pszAction = "Hold";
break;
default:
break;
}
}
}
break;
}
/** @todo function. */
case kListSystemProperties:
{
break;
}
case kListDhcpServers:
{
{
RTPrintf("\n");
}
break;
}
case kListVrdeLibraries:
{
{
{
}
}
break;
}
case kListExtPacks:
break;
/* No default here, want gcc warnings. */
} /* end switch */
return rc;
}
/**
* Handles the 'list' command.
*
* @returns Appropriate exit code.
* @param a Handler argument.
*/
int handleList(HandlerArg *a)
{
bool fOptLong = false;
bool fOptMultiple = false;
static const RTGETOPTDEF s_aListOptions[] =
{
#if defined(VBOX_WITH_NETFLT)
#endif
};
int ch;
{
switch (ch)
{
case 'l': /* --long */
fOptLong = true;
break;
case 'm':
fOptMultiple = true;
if (enmOptCommand == kListNotSpecified)
break;
ch = enmOptCommand;
/* fall thru */
case kListVMs:
case kListRunningVMs:
case kListOsTypes:
case kListHostDvds:
case kListHostFloppies:
case kListBridgedInterfaces:
#if defined(VBOX_WITH_NETFLT)
case kListHostOnlyInterfaces:
#endif
case kListHostInfo:
case kListHostCpuIDs:
case kListHddBackends:
case kListHdds:
case kListDvds:
case kListFloppies:
case kListUsbHost:
case kListUsbFilters:
case kListSystemProperties:
case kListDhcpServers:
case kListVrdeLibraries:
case kListExtPacks:
if (fOptMultiple)
{
return 1;
}
break;
case VINF_GETOPT_NOT_OPTION:
default:
}
}
/*
* If not in multiple list mode, we have to produce the list now.
*/
if (enmOptCommand == kListNotSpecified)
if (!fOptMultiple)
{
return 1;
}
return 0;
}
#endif /* !VBOX_ONLY_DOCS */
/* vi: set tabstop=4 shiftwidth=4 expandtab: */