VBoxManageInfo.cpp revision 08de270f07378125f9601f9b35acc0b46a13174f
/* $Id$ */
/** @file
* VBoxManage - The 'showvminfo' command and helper routines.
*/
/*
* Copyright (C) 2006-2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef VBOX_ONLY_DOCS
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBoxManage.h"
using namespace com;
// funcs
///////////////////////////////////////////////////////////////////////////////
void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const Bstr &prefix /* = ""*/, int level /*= 0*/)
{
/* start with the root */
if (details == VMINFO_MACHINEREADABLE)
{
/* print with hierarchical numbering */
}
else
{
/* print with indentation */
}
/* get the children */
{
{
if (snapshot)
{
if (details == VMINFO_MACHINEREADABLE)
else
/* recursive call */
}
}
}
}
{
RTTIME t;
RTTimeExplode (&t, &ts);
}
/* Disable global optimizations for MSC 8.0/64 to make it compile in reasonable
time. MSC 7.1/32 doesn't have quite as much trouble with it, but still
sufficient to qualify for this hack as well since this code isn't performance
critical and probably won't gain much from the extra optimizing in real life. */
#if defined(_MSC_VER)
#endif
{
/*
* The rules for output in -argdump format:
* 1) the key part (the [0-9a-zA-Z_]+ string before the '=' delimiter)
* is all lowercase for "VBoxManage modifyvm" parameters. Any
* other values printed are in CamelCase.
* 2) strings (anything non-decimal) are printed surrounded by
* double quotes '"'. If the strings themselves contain double
* quotes, these characters are escaped by '\'. Any '\' character
* in the original string is also escaped by '\'.
* 3) numbers (containing just [0-9\-]) are written out unchanged.
*/
/** @todo the quoting is not yet implemented! */
if (!accessible)
{
if (details == VMINFO_COMPACT)
else
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("name=\"<inaccessible>\"\n");
else
RTPrintf ("Name: <inaccessible!>\n");
if (details == VMINFO_MACHINEREADABLE)
else
if (details != VMINFO_MACHINEREADABLE)
{
RTPrintf ("Access error details:\n");
RTPrintf ("\n");
}
}
return S_OK;
}
if (details == VMINFO_COMPACT)
{
return S_OK;
}
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
const char *pszBootMenu = NULL;
switch (bootMenuMode)
{
pszBootMenu = "disabled";
break;
if (details == VMINFO_MACHINEREADABLE)
pszBootMenu = "menuonly";
else
pszBootMenu = "menu only";
break;
default:
if (details == VMINFO_MACHINEREADABLE)
pszBootMenu = "messageandmenu";
else
pszBootMenu = "message and menu";
}
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (hwVirtExEnabled == TSBool_Default)
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("hwvirtex=\"default\"\n");
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
else
}
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
switch (machineState)
{
case MachineState_PoweredOff:
if (details == VMINFO_MACHINEREADABLE)
pszState = "poweroff";
else
pszState = "powered off";
break;
case MachineState_Saved:
pszState = "saved";
break;
case MachineState_Aborted:
pszState = "aborted";
break;
case MachineState_Running:
pszState = "running";
break;
case MachineState_Paused:
pszState = "paused";
break;
case MachineState_Starting:
pszState = "starting";
break;
case MachineState_Stopping:
pszState = "stopping";
break;
case MachineState_Saving:
pszState = "saving";
break;
case MachineState_Restoring:
pszState = "restoring";
break;
default:
pszState = "unknown";
break;
}
char pszTime[30] = {0};
if (details == VMINFO_MACHINEREADABLE)
{
}
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
{
if (fFloppyEnabled)
{
switch (floppyState)
{
case DriveState_ImageMounted:
{
{
if (details == VMINFO_MACHINEREADABLE)
{
}
else
}
break;
}
{
{
if (details == VMINFO_MACHINEREADABLE)
else
}
break;
}
case DriveState_NotMounted:
{
pszFloppy = "empty";
break;
}
}
}
else
{
pszFloppy = "disabled";
}
if (details == VMINFO_MACHINEREADABLE)
else
}
/*
* SATA.
*
* Contributed by: James Lucas
*/
#ifdef VBOX_WITH_AHCI
{
fSataEnabled = false;
if (details == VMINFO_MACHINEREADABLE)
else
}
/*
* SATA Hard disks
*/
if (fSataEnabled)
{
for (ULONG i = 0; i < cSataPorts; ++ i)
{
{
if (details == VMINFO_MACHINEREADABLE)
{
}
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("sata%d=\"none\"\n",i);
}
}
}
#endif
/*
* IDE Hard disks
*/
const char *pszIdeController = NULL;
switch (ideController)
{
case IDEControllerType_PIIX3:
pszIdeController = "PIIX3";
break;
case IDEControllerType_PIIX4:
pszIdeController = "PIIX4";
break;
case IDEControllerType_ICH6:
pszIdeController = "ICH6";
break;
default:
pszIdeController = "unknown";
}
if (details == VMINFO_MACHINEREADABLE)
else
{
if (details == VMINFO_MACHINEREADABLE)
{
}
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("hda=\"none\"\n");
}
{
if (details == VMINFO_MACHINEREADABLE)
{
}
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("hdb=\"none\"\n");
}
{
if (details == VMINFO_MACHINEREADABLE)
{
}
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("hdd=\"none\"\n");
}
{
{
{
if (details == VMINFO_MACHINEREADABLE)
{
}
else
}
}
else
{
{
if (details == VMINFO_MACHINEREADABLE)
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("dvd=\"none\"\n");
else
RTPrintf("DVD: empty");
}
if (details == VMINFO_MACHINEREADABLE)
{
}
else
{
if (fPassthrough)
RTPrintf(" (passthrough enabled)");
RTPrintf("\n");
}
}
}
/* get the maximum amount of NICS */
{
{
if (!fEnabled)
{
if (details == VMINFO_MACHINEREADABLE)
else
}
else
{
switch (attachment)
{
if (details == VMINFO_MACHINEREADABLE)
strAttachment = "null";
else
strAttachment = "none";
break;
{
if (details == VMINFO_MACHINEREADABLE)
{
strAttachment = "nat";
}
else if (!strNetwork.isEmpty())
else
strAttachment = "NAT";
break;
}
{
if (details == VMINFO_MACHINEREADABLE)
{
strAttachment = "bridged";
}
else
break;
}
{
if (details == VMINFO_MACHINEREADABLE)
{
strAttachment = "intnet";
}
else
break;
}
{
#if (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
#endif
if (details == VMINFO_MACHINEREADABLE)
{
#if (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
#endif
strAttachment = "hostonly";
}
else
#if (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
#else
strAttachment = "Host-only Network";
#endif
break;
}
default:
strAttachment = "unknown";
break;
}
/* cable connected */
/* trace stuff */
/* NIC type */
switch (NICType) {
strNICType = "Am79C970A";
break;
strNICType = "Am79C973";
break;
#ifdef VBOX_WITH_E1000
strNICType = "82540EM";
break;
strNICType = "82543GC";
break;
#endif
default:
strNICType = "unknown";
break;
}
/* reported line speed */
if (details == VMINFO_MACHINEREADABLE)
{
}
else
RTPrintf("NIC %d: MAC: %lS, Attachment: %s, Cable connected: %s, Trace: %s (file: %lS), Type: %s, Reported speed: %d Mbps\n",
strNICType.raw(),
ulLineSpeed / 1000);
}
}
}
/* get the maximum amount of UARTs */
{
{
if (!fEnabled)
{
if (details == VMINFO_MACHINEREADABLE)
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
else
RTPrintf("UART %d: I/O base: 0x%04x, IRQ: %d",
switch (HostMode)
{
default:
case PortMode_Disconnected:
if (details == VMINFO_MACHINEREADABLE)
else
RTPrintf(", disconnected\n");
break;
case PortMode_HostPipe:
if (details == VMINFO_MACHINEREADABLE)
else
RTPrintf(", attached to pipe (%s) '%lS'\n",
break;
case PortMode_HostDevice:
if (details == VMINFO_MACHINEREADABLE)
else
break;
}
}
}
}
{
const char *pszDrv = "Unknown";
const char *pszCtrl = "Unknown";
{
switch (enmDrvType)
{
case AudioDriverType_Null:
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "null";
else
pszDrv = "Null";
break;
case AudioDriverType_WinMM:
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "winmm";
else
pszDrv = "WINMM";
break;
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "dsound";
else
pszDrv = "DSOUND";
break;
case AudioDriverType_OSS:
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "oss";
else
pszDrv = "OSS";
break;
case AudioDriverType_ALSA:
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "alsa";
else
pszDrv = "ALSA";
break;
case AudioDriverType_Pulse:
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "pulse";
else
pszDrv = "PulseAudio";
break;
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "coreaudio";
else
pszDrv = "CoreAudio";
break;
case AudioDriverType_SolAudio:
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "solaudio";
else
pszDrv = "SolAudio";
break;
default:
if (details == VMINFO_MACHINEREADABLE)
pszDrv = "unknown";
break;
}
switch (enmCtrlType)
{
case AudioControllerType_AC97:
if (details == VMINFO_MACHINEREADABLE)
pszCtrl = "ac97";
else
pszCtrl = "AC97";
break;
case AudioControllerType_SB16:
if (details == VMINFO_MACHINEREADABLE)
pszCtrl = "sb16";
else
pszCtrl = "SB16";
break;
}
}
else
if (details == VMINFO_MACHINEREADABLE)
{
if (fEnabled)
else
RTPrintf("audio=\"none\"\n");
}
else
RTPrintf("Audio: %s (Driver: %s, Controller: %s)\n",
}
/* Shared clipboard */
{
const char *psz = "Unknown";
switch (enmMode)
{
case ClipboardMode_Disabled:
if (details == VMINFO_MACHINEREADABLE)
psz = "disabled";
else
psz = "disabled";
break;
if (details == VMINFO_MACHINEREADABLE)
psz = "hosttoguest";
else
psz = "HostToGuest";
break;
if (details == VMINFO_MACHINEREADABLE)
psz = "guesttohost";
else
psz = "GuestToHost";
break;
if (details == VMINFO_MACHINEREADABLE)
psz = "bidirectional";
else
psz = "Bidirectional";
break;
default:
if (details == VMINFO_MACHINEREADABLE)
psz = "unknown";
break;
}
if (details == VMINFO_MACHINEREADABLE)
else
}
if (console)
{
do
{
if (rc == E_ACCESSDENIED)
break; /* VM not powered up */
{
return rc;
}
if (rc == E_ACCESSDENIED)
break; /* VM not powered up */
{
return rc;
}
if (rc == E_ACCESSDENIED)
break; /* VM not powered up */
{
return rc;
}
if (details == VMINFO_MACHINEREADABLE)
else
}
while (0);
}
/*
* VRDP
*/
{
if (fEnabled)
{
const char *strAuthType;
switch (vrdpAuthType)
{
case VRDPAuthType_Null:
strAuthType = "null";
break;
case VRDPAuthType_External:
strAuthType = "external";
break;
case VRDPAuthType_Guest:
strAuthType = "guest";
break;
default:
strAuthType = "unknown";
break;
}
if (details == VMINFO_MACHINEREADABLE)
{
RTPrintf("vrdp=\"on\"\n");
}
else
{
address = "0.0.0.0";
RTPrintf("VRDP: enabled (Address %lS, Port %d, MultiConn: %s, ReuseSingleConn: %s, Authentication type: %s)\n", address.raw(), port, fMultiCon ? "on" : "off", fReuseCon ? "on" : "off", strAuthType);
}
}
else
{
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("vrdp=\"off\"\n");
else
RTPrintf("VRDP: disabled\n");
}
}
/*
* USB.
*/
{
fEnabled = false;
if (details == VMINFO_MACHINEREADABLE)
else
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("\nUSB Device Filters:\n\n");
return rc;
if (!fMore)
{
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("<none>\n\n");
}
else
while (fMore)
{
return rc;
/* Query info. */
if (details != VMINFO_MACHINEREADABLE)
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (details != VMINFO_MACHINEREADABLE)
{
if (fMaskedIfs)
RTPrintf("\n");
}
return rc;
index ++;
}
if (console)
{
index = 0;
/* scope */
{
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("Available remote USB devices:\n\n");
return rc;
if (!more)
{
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("<none>\n\n");
}
else
while (more)
{
return rc;
/* Query info. */
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("USBRemoteUUID%d=\"%S\"\n"
"USBRemoteVendorId%d=\"%#06x\"\n"
"USBRemoteProductId%d=\"%#06x\"\n"
"USBRemoteRevision%d=\"%#04x%02x\"\n",
else
RTPrintf("UUID: %S\n"
"VendorId: 0x%04x (%04X)\n"
"ProductId: 0x%04x (%04X)\n"
"Revision: %u.%u (%02u%02u)\n",
/* optional stuff. */
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("\n");
return rc;
index ++;
}
}
index = 0;
/* scope */
{
if (details != VMINFO_MACHINEREADABLE)
RTPrintf ("Currently Attached USB Devices:\n\n");
return rc;
if (!more)
{
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("<none>\n\n");
}
else
while (more)
{
return rc;
/* Query info. */
if (details == VMINFO_MACHINEREADABLE)
RTPrintf("USBAttachedUUID%d=\"%S\"\n"
"USBAttachedVendorId%d=\"%#06x\"\n"
"USBAttachedProductId%d=\"%#06x\"\n"
"USBAttachedRevision%d=\"%#04x%02x\"\n",
else
RTPrintf("UUID: %S\n"
"VendorId: 0x%04x (%04X)\n"
"ProductId: 0x%04x (%04X)\n"
"Revision: %u.%u (%02u%02u)\n",
/* optional stuff. */
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("\n");
return rc;
index ++;
}
}
}
} /* USB */
/*
* Shared folders
*/
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("Shared folders: ");
uint32_t numSharedFolders = 0;
#if 0 // not yet implemented
/* globally shared folders first */
{
while (fMore)
{
}
}
#endif
/* now VM mappings */
{
{
RTPrintf("\n\n");
if (details == VMINFO_MACHINEREADABLE)
{
}
else
RTPrintf("Name: '%lS', Host path: '%lS' (machine mapping), %s\n",
}
}
/* transient mappings */
if (console)
{
{
RTPrintf("\n\n");
if (details == VMINFO_MACHINEREADABLE)
{
}
else
}
}
RTPrintf("<none>\n");
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("\n");
if (console)
{
/*
* Live VRDP info.
*/
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
if (NumberOfClients > 0)
{
char timestr[128];
if (Active)
{
if (details == VMINFO_MACHINEREADABLE)
else
}
else
{
if (details == VMINFO_MACHINEREADABLE)
else
if (details == VMINFO_MACHINEREADABLE)
else
}
uint64_t ThroughputSend = 0;
{
}
if (details == VMINFO_MACHINEREADABLE)
{
}
else
{
}
if (Active)
{
if (details == VMINFO_MACHINEREADABLE)
{
}
else
{
}
}
}
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("\n");
}
if ( details == VMINFO_STANDARD
|| details == VMINFO_FULL
|| details == VMINFO_MACHINEREADABLE)
{
if (!description.isEmpty())
{
if (details == VMINFO_MACHINEREADABLE)
else
}
}
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("Guest:\n\n");
#ifdef VBOX_WITH_MEM_BALLOONING
{
if (details == VMINFO_MACHINEREADABLE)
else
}
#endif
{
if (details == VMINFO_MACHINEREADABLE)
else
{
if (guestVal == 0)
RTPrintf("Statistics update: disabled\n");
else
}
}
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("\n");
if ( console
&& ( details == VMINFO_STATISTICS
|| details == VMINFO_FULL
|| details == VMINFO_MACHINEREADABLE))
{
{
if (details == VMINFO_MACHINEREADABLE)
else
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
#ifdef VBOX_WITH_MEM_BALLOONING
{
if (details == VMINFO_MACHINEREADABLE)
else
}
#endif
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
{
if (details == VMINFO_MACHINEREADABLE)
else
}
RTPrintf("\n");
}
else
{
if (details != VMINFO_MACHINEREADABLE)
{
}
}
}
/*
* snapshots
*/
{
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("Snapshots:\n\n");
}
if (details != VMINFO_MACHINEREADABLE)
RTPrintf("\n");
return S_OK;
}
#if defined(_MSC_VER)
#endif
int handleShowVMInfo(HandlerArg *a)
{
/* at least one option: the UUID or name of the VM */
if (a->argc < 1)
/* try to find the given machine */
{
}
else
{
}
return 1;
/* 2nd option can be -details, -statistics or -argdump */
bool fDetails = false;
bool fStatistics = false;
bool fMachinereadable = false;
for (int i=1;i<a->argc;i++)
{
fDetails = true;
else
fStatistics = true;
fMachinereadable = true;
}
if (fMachinereadable)
else
if (fDetails && fStatistics)
else
if (fDetails)
else
if (fStatistics)
/* open an existing session for the VM */
/* get the session machine */
/* get the session console */
if (console)
}
#endif /* !VBOX_ONLY_DOCS */