VirtualBox

Changeset 5204 in vbox


Ignore:
Timestamp:
Oct 9, 2007 1:54:46 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25131
Message:

Added a vmstatistics command.

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r4071 r5204  
    5151
    5252/** flag whether we're in internal mode */
    53 bool fInternalMode;
     53bool g_fInternalMode;
    5454
    5555/**
     
    400400                           ComPtr <IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
    401401{
    402     fInternalMode = true;
     402    g_fInternalMode = true;
    403403
    404404    /* at least a command is required */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r5201 r5204  
    596596                 "\n");
    597597    }
     598
     599    if (u64Cmd & USAGE_VM_STATISTICS)
     600    {
     601        RTPrintf("VBoxManage vmstatistics     <vmname>|<uuid>\n"
     602                 "                            [-pattern <pattern>] [-descriptions]\n"
     603                 "\n");
     604    }
    598605}
    599606
     
    605612    va_list args;
    606613    showLogo(); // show logo even if suppressed
    607     if (fInternalMode)
     614    if (g_fInternalMode)
    608615        printUsageInternal(u64Cmd);
    609616    else
     
    47944801                u32LineSpeed = atoi(nicspeed[n]);
    47954802
    4796                 if (u32LineSpeed < 1000 || u32LineSpeed > 4000000) 
     4803                if (u32LineSpeed < 1000 || u32LineSpeed > 4000000)
    47974804                {
    47984805                    errorArgument("Invalid -nicspeed%lu argument '%s'", n + 1, nicspeed[n]);
    47994806                    rc = E_FAIL;
    48004807                    break;
    4801                 }
    4802                 else
    4803                 {
    4804                     CHECK_ERROR_RET(nic, COMSETTER(LineSpeed)(u32LineSpeed), 1);
    4805                 }
     4808                }
     4809                CHECK_ERROR_RET(nic, COMSETTER(LineSpeed)(u32LineSpeed), 1);
    48064810            }
    48074811
     
    69997003    }
    70007004    return 0;
     7005}
     7006
     7007static int handleVMStatistics(int argc, char *argv[],
     7008                              ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
     7009{
     7010    HRESULT rc;
     7011
     7012    /* at least one option: the UUID or name of the VM */
     7013    if (argc < 1)
     7014        return errorSyntax(USAGE_VM_STATISTICS, "Incorrect number of parameters");
     7015
     7016    /* try to find the given machine */
     7017    ComPtr <IMachine> machine;
     7018    Guid uuid (argv[0]);
     7019    if (!uuid.isEmpty())
     7020        CHECK_ERROR(aVirtualBox, GetMachine(uuid, machine.asOutParam()));
     7021    else
     7022    {
     7023        CHECK_ERROR(aVirtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
     7024        if (SUCCEEDED (rc))
     7025            machine->COMGETTER(Id)(uuid.asOutParam());
     7026    }
     7027    if (FAILED(rc))
     7028        return 1;
     7029
     7030    /*  */
     7031    bool fWithDescriptions = false;
     7032    const char *pszPattern = NULL; /* all */
     7033    for (int i = 1; i < argc; i++)
     7034    {
     7035        if (!strcmp(argv[i], "-pattern"))
     7036        {
     7037            if (pszPattern)
     7038                return errorSyntax(USAGE_VM_STATISTICS, "Multiple -patterns options is not permitted");
     7039            if (i + 1 >= argc)
     7040                return errorArgument("Missing argument to '%s'", argv[i]);
     7041            pszPattern = argv[++i];
     7042        }
     7043        else if (!strcmp(argv[i], "-descriptions"))
     7044            fWithDescriptions = true;
     7045        /* add: -file <filename> and -formatted */
     7046        else
     7047            return errorSyntax(USAGE_VM_STATISTICS, "Unknown option '%s'", argv[i]);
     7048    }
     7049
     7050    /* open an existing session for the VM. */
     7051    CHECK_ERROR(aVirtualBox, OpenExistingSession(aSession, uuid));
     7052    if (SUCCEEDED(rc))
     7053    {
     7054        /* get the session console. */
     7055        ComPtr <IConsole> console;
     7056        CHECK_ERROR(aSession, COMGETTER(Console)(console.asOutParam()));
     7057        if (SUCCEEDED(rc))
     7058        {
     7059            /* get the machine debugger. */
     7060            ComPtr <IMachineDebugger> debugger;
     7061            CHECK_ERROR(console, COMGETTER(Debugger)(debugger.asOutParam()));
     7062            if (SUCCEEDED(rc))
     7063            {
     7064                if (1/*fDumpStats*/)
     7065                {
     7066                    Bstr stats;
     7067                    CHECK_ERROR(debugger, GetStats(Bstr(pszPattern).raw(), fWithDescriptions, stats.asOutParam()));
     7068                    if (SUCCEEDED(rc))
     7069                    {
     7070                        RTPrintf("%ls\n", stats.raw());
     7071                    }
     7072                }
     7073            }
     7074            aSession->Close();
     7075        }
     7076    }
     7077
     7078    return SUCCEEDED(rc) ? 0 : 1;
    70017079}
    70027080
     
    73887466        { "usbfilter",        handleUSBFilter },
    73897467        { "sharedfolder",     handleSharedFolder },
     7468        { "vmstatistics",     handleVMStatistics },
    73907469        { NULL,               NULL }
    73917470    };
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r5146 r5204  
    11/** @file
    2  *
    32 * VBox frontends: VBoxManage (command-line interface):
    43 * VBoxManage header.
     
    1716 */
    1817
    19 #ifndef __H_VBOXMANAGE
    20 #define __H_VBOXMANAGE
     18#ifndef ___H_VBOXMANAGE
     19#define ___H_VBOXMANAGE
    2120
    2221#include <iprt/types.h>
     
    2423#include <VBox/com/VirtualBox.h>
    2524
    26 /** Syntax diagram category. */
     25/** @name Syntax diagram category.
     26 * @{ */
    2727#define USAGE_DUMPOPTS              0
    2828#define USAGE_LIST                  BIT64(0)
     
    6161#define USAGE_CONVERTDD             BIT64(32)
    6262#ifdef VBOX_OSE
    63 #define USAGE_LISTPARTITIONS        (0)
    64 #define USAGE_CREATERAWVMDK         (0)
     63# define USAGE_LISTPARTITIONS       (0)
     64# define USAGE_CREATERAWVMDK        (0)
    6565#else /* !VBOX_OSE */
    66 #define USAGE_LISTPARTITIONS        BIT64(33)
    67 #define USAGE_CREATERAWVMDK         BIT64(34)
     66# define USAGE_LISTPARTITIONS       BIT64(33)
     67# define USAGE_CREATERAWVMDK        BIT64(34)
    6868#endif /* !VBOX_OSE */
     69#define USAGE_VM_STATISTICS         BIT64(35)
    6970#define USAGE_ALL                   (~(uint64_t)0)
     71/** @} */
    7072
    7173typedef uint64_t USAGECATEGORY;
    7274
    7375/** flag whether we're in internal mode */
    74 extern bool fInternalMode;
     76extern bool g_fInternalMode;
    7577
    7678/** showVMInfo details */
     
    7880{
    7981    VMINFO_NONE             = 0,
    80     VMINFO_STANDARD         = 1,    /* standard details */
    81     VMINFO_STATISTICS       = 2,    /* guest statistics */
    82     VMINFO_FULL             = 3,    /* both */
    83     VMINFO_MACHINEREADABLE  = 4,    /* both, and make it machine readable */
     82    VMINFO_STANDARD         = 1,    /**< standard details */
     83    VMINFO_STATISTICS       = 2,    /**< guest statistics */
     84    VMINFO_FULL             = 3,    /**< both */
     85    VMINFO_MACHINEREADABLE  = 4     /**< both, and make it machine readable */
    8486} VMINFO_DETAILS;
    8587
     
    9395int handleInternalCommands(int argc, char *argv[],
    9496                           ComPtr <IVirtualBox> aVirtualBox, ComPtr<ISession> aSession);
    95 unsigned long VBoxSVNRev ();
     97unsigned long VBoxSVNRev();
    9698
    97 #endif /* !__H_VBOXMANAGE */
     99#endif /* !___H_VBOXMANAGE */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageSVN.cpp

    r5146 r5204  
     1/* $Id$ */
    12/** @file
    2  *
    33 * VBox frontends: VBoxManage (command-line interface):
    44 * SVN revision.
     
    2626 * the version number is requested.
    2727 */
    28 unsigned long VBoxSVNRev ()
     28unsigned long VBoxSVNRev()
    2929{
    3030    return VBOX_SVN_REV;
    3131}
     32
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette