VirtualBox

Changeset 80114 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 2, 2019 9:04:00 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132555
Message:

Main/IMachineDebugger: Added method for getting the CPU load (as seen by the VMM) in pct over a period (typically 1 sec).

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r80074 r80114  
    1980719807  <interface
    1980819808    name="IMachineDebugger" extends="$unknown"
    19809     uuid="e91bb944-f211-4bd5-b44c-8f1d0beafa13"
     19809    uuid="00ae6af4-00a7-4104-0009-49bc00b2da80"
    1981019810    wsmap="managed"
    1981119811    reservedMethods="16" reservedAttributes="16"
     
    2017320173      <param name="stats" type="wstring" dir="return">
    2017420174        <desc>The XML document containing the statistics.</desc>
     20175      </param>
     20176    </method>
     20177
     20178    <method name="getCPULoad">
     20179      <desc>
     20180        Get the load percentages (as observed by the VMM) for all virtual CPUs
     20181        or a specific one.
     20182      </desc>
     20183      <param name="cpuId" type="unsigned long" dir="in">
     20184        <desc>The ID of the virtual CPU to retrieve stats for, pass 0x7fffffff
     20185          or higher for the average accross all CPUs.</desc>
     20186      </param>
     20187      <param name="pctExecuting" type="unsigned long" dir="out">
     20188        <desc>Percentage of the interval that the CPU(s) spend executing guest code.</desc>
     20189      </param>
     20190      <param name="pctHalted" type="unsigned long" dir="out">
     20191        <desc>Percentage of the interval that the CPU(s) spend halted.</desc>
     20192      </param>
     20193      <param name="pctOther" type="unsigned long" dir="out">
     20194        <desc>Percentage of the interval that the CPU(s) preempted by the host
     20195        scheduler, on virtualization overhead and on other tasks.</desc>
     20196      </param>
     20197      <param name="msInterval" type="long long" dir="return">
     20198        <desc>The interval the percentage was calculated over in milliseconds</desc>
    2017520199      </param>
    2017620200    </method>
  • trunk/src/VBox/Main/include/MachineDebuggerImpl.h

    r76562 r80114  
    133133                     BOOL aWithDescriptions,
    134134                     com::Utf8Str &aStats);
     135    HRESULT getCPULoad(ULONG aCpuId, ULONG *aPctExecuting, ULONG *aPctHalted, ULONG *aPctOther, LONG64 *aMsInterval) RT_OVERRIDE;
    135136
    136137    // private methods
  • trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp

    r80074 r80114  
    15411541{
    15421542    Console::SafeVMPtrQuiet ptrVM(mParent);
    1543 
    15441543    if (!ptrVM.isOk())
    15451544        return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
     
    15621561
    15631562
     1563/** Wrapper around TMR3GetCpuLoadPercents. */
     1564HRESULT MachineDebugger::getCPULoad(ULONG aCpuId, ULONG *aPctExecuting, ULONG *aPctHalted, ULONG *aPctOther, LONG64 *aMsInterval)
     1565{
     1566    HRESULT hrc;
     1567    Console::SafeVMPtrQuiet ptrVM(mParent);
     1568    if (ptrVM.isOk())
     1569    {
     1570        uint8_t uPctExecuting = 0;
     1571        uint8_t uPctHalted    = 0;
     1572        uint8_t uPctOther     = 0;
     1573        uint64_t msInterval   = 0;
     1574        int vrc = TMR3GetCpuLoadPercents(ptrVM.rawUVM(), aCpuId >= UINT32_MAX / 2 ? VMCPUID_ALL : aCpuId,
     1575                                         &msInterval, &uPctExecuting, &uPctHalted, &uPctOther);
     1576        if (RT_SUCCESS(vrc))
     1577        {
     1578            *aPctExecuting = uPctExecuting;
     1579            *aPctHalted    = uPctHalted;
     1580            *aPctOther     = uPctOther;
     1581            *aMsInterval   = msInterval;
     1582            hrc = S_OK;
     1583        }
     1584        else
     1585            hrc = setErrorVrc(vrc);
     1586    }
     1587    else
     1588        hrc = setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
     1589    return hrc;
     1590}
     1591
     1592
    15641593// public methods only for internal purposes
    15651594/////////////////////////////////////////////////////////////////////////////
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