VBoxManageList.cpp revision 38342f0883d4ea5c17b46c2bd44b55ea40b1dee1
/* $Id$ */
/** @file
* VBoxManage - The 'list' command.
*/
/*
* Copyright (C) 2006-2013 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";
}
/**
* List internal networks.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
{
}
return rc;
}
/**
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
* @param fIsBridged Selects between listing host interfaces (for
* use with bridging) or host only interfaces.
*/
bool fIsBridged)
{
#if defined(VBOX_WITH_NETFLT)
if (fIsBridged)
else
#else
#endif
{
#ifndef VBOX_WITH_HOSTNETIF_API
#else /* VBOX_WITH_HOSTNETIF_API */
#endif
}
return rc;
}
/**
* List host information.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
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
RTPrintf("Processor#%u speed: unknown\n", i);
}
ULONG memorySize = 0;
ULONG memoryAvailable = 0;
return rc;
}
/**
* List media information.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
* @param aMedia Medium objects to list information for.
* @param pszParentUUIDStr String with the parent UUID string (or "base").
* @param fOptLong Long (@c true) or short list format.
*/
const char *pszParentUUIDStr,
bool fOptLong)
{
{
RTPrintf("\n");
{
// depth first listing of child media
}
}
return rc;
}
/**
* List virtual image backends.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
RTPrintf("Supported hard disk backends:\n\n");
{
/* General information */
caps |= mediumFormatCap[j];
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");
}
return rc;
}
/**
* List USB devices attached to the host.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
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"
"Port: %u\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;
}
}
}
return rc;
}
/**
* List USB filters.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
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;
}
}
}
return rc;
}
/**
* List system properties.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
#if 0
#endif
return S_OK;
}
/**
* List extension packs.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
CHECK_ERROR2_RET(pVirtualBox, 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(Edition)(bstrEdition.asOutParam()), hrc = hrcCheck; bstrEdition.setNull());
CHECK_ERROR2_STMT(extPacks[i], COMGETTER(VRDEModule)(bstrVrdeModule.asOutParam()),hrc=hrcCheck; bstrVrdeModule.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"
"Edition: %ls\n"
"Description: %ls\n"
"VRDE Module: %ls\n"
"Usable: %RTbool\n"
"Why unusable: %ls\n",
bstrVersion.raw(),
bstrEdition.raw(),
/* Query plugins and display them. */
}
return hrc;
}
/**
* List machine groups.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox smart pointer.
*/
{
{
}
return S_OK;
}
/**
* List video capture devices.
*
* @returns See produceList.
* @param pVirtualBox Reference to the IVirtualBox pointer.
*/
{
{
}
return rc;
}
/**
* 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 pVirtualBox Reference to the IVirtualBox smart pointer.
*/
static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, const ComPtr<IVirtualBox> &pVirtualBox)
{
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
*/
rc = pVirtualBox->GetMachineStates(ComSafeArrayAsInParam(machines), ComSafeArrayAsOutParam(states));
{
/*
* 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.
*/
{
RTPrintf("\n");
}
}
break;
}
case kListHostDvds:
{
{
{
}
}
break;
}
case kListHostFloppies:
{
{
{
}
}
break;
}
case kListInternalNetworks:
break;
case kListBridgedInterfaces:
#if defined(VBOX_WITH_NETFLT)
case kListHostOnlyInterfaces:
#endif
break;
case kListHostInfo:
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;
}
case kListHddBackends:
break;
case kListHdds:
{
break;
}
case kListDvds:
{
break;
}
case kListFloppies:
{
break;
}
case kListUsbHost:
break;
case kListUsbFilters:
break;
case kListSystemProperties:
break;
case kListDhcpServers:
{
{
RTPrintf("\n");
}
break;
}
case kListExtPacks:
break;
case kListGroups:
break;
case kListNatNetworks:
{
{
#define PRINT_STRING_ARRAY(title) \
{ \
size_t j = 0; \
}
PRINT_STRING_ARRAY("Port-forwarding (ipv4)\n");
PRINT_STRING_ARRAY("Port-forwarding (ipv6)\n");
PRINT_STRING_ARRAY("loopback mappings (ipv4)\n");
RTPrintf("\n");
}
break;
}
case kListVideoInputDevices:
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 kListInternalNetworks:
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 kListExtPacks:
case kListGroups:
case kListNatNetworks:
case kListVideoInputDevices:
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: */