VirtualBox

Changeset 31332 in vbox


Ignore:
Timestamp:
Aug 3, 2010 12:38:49 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64370
Message:

Support passing cpu priority change to a running guest.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r31270 r31332  
    269269        kOnMediumChanged,
    270270        kOnCPUChanged,
     271        kOnCPUPriorityChanged,
    271272        kOnVRDPServerChanged,
    272273        kOnRemoteDisplayInfoChanged,
     
    38093810    if (SUCCEEDED(rc))
    38103811        CONSOLE_DO_CALLBACKS2(OnCPUChanged, aCPU, aRemove);
     3812
     3813    LogFlowThisFunc(("Leaving rc=%#x\n", rc));
     3814    return rc;
     3815}
     3816
     3817/**
     3818 * Called by IInternalSessionControl::OnCPUPriorityChange().
     3819 *
     3820 * @note Locks this object for writing.
     3821 */
     3822HRESULT Console::onCPUPriorityChange(ULONG aCpuPriority)
     3823{
     3824    LogFlowThisFunc(("\n"));
     3825
     3826    AutoCaller autoCaller(this);
     3827    AssertComRCReturnRC(autoCaller.rc());
     3828
     3829    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     3830
     3831    HRESULT rc = S_OK;
     3832
     3833    /* don't trigger the CPU priority change if the VM isn't running */
     3834    if (mpVM)
     3835    {
     3836        /* protect mpVM */
     3837        AutoVMCaller autoVMCaller(this);
     3838        if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();
     3839
     3840        if (   mMachineState == MachineState_Running
     3841            || mMachineState == MachineState_Teleporting
     3842            || mMachineState == MachineState_LiveSnapshotting
     3843            )
     3844        {
     3845            /* No need to call in the EMT thread. */
     3846            rc = VMR3SetCpuPriority(mpVM, aCpuPriority);
     3847        }
     3848        else
     3849            rc = setInvalidMachineStateError();
     3850    }
     3851
     3852    /* notify console callbacks on success */
     3853    if (SUCCEEDED(rc))
     3854        CONSOLE_DO_CALLBACKS1(OnCPUPriorityChanged, aCpuPriority);
    38113855
    38123856    LogFlowThisFunc(("Leaving rc=%#x\n", rc));
  • trunk/src/VBox/Main/MachineImpl.cpp

    r31313 r31332  
    12991299STDMETHODIMP Machine::COMSETTER(CPUPriority)(ULONG aPriority)
    13001300{
     1301    HRESULT rc = S_OK;
     1302
    13011303    /* check priority limits */
    13021304    if (    aPriority < 1
     
    13121314    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    13131315
    1314     /* Todo: must always allow changes. */
    1315     HRESULT rc = checkStateDependency(MutableStateDep);
     1316    alock.release();
     1317    rc = onCPUPriorityChange(aPriority);
     1318    alock.acquire();
    13161319    if (FAILED(rc)) return rc;
    13171320
     
    13191322    mHWData.backup();
    13201323    mHWData->mCpuPriority = aPriority;
     1324
     1325    /* Save settings if online - todo why is this required?? */
     1326    if (Global::IsOnline(mData->mMachineState))
     1327        saveSettings(NULL);
    13211328
    13221329    return S_OK;
     
    1071510722}
    1071610723
     10724HRESULT SessionMachine::onCPUPriorityChange(ULONG aCpuPriority)
     10725{
     10726    LogFlowThisFunc(("\n"));
     10727
     10728    AutoCaller autoCaller(this);
     10729    AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     10730
     10731    ComPtr<IInternalSessionControl> directControl;
     10732    {
     10733        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     10734        directControl = mData->mSession.mDirectControl;
     10735    }
     10736
     10737    /* ignore notifications sent after #OnSessionEnd() is called */
     10738    if (!directControl)
     10739        return S_OK;
     10740
     10741    return directControl->OnCPUPriorityChange(aCpuPriority);
     10742}
     10743
    1071710744/**
    1071810745 *  @note Locks this object for reading.
  • trunk/src/VBox/Main/SessionImpl.cpp

    r31244 r31332  
    594594
    595595    return mConsole->onCPUChange(aCPU, aRemove);
     596}
     597
     598STDMETHODIMP Session::OnCPUPriorityChange(ULONG aCpuPriority)
     599{
     600    LogFlowThisFunc(("\n"));
     601
     602    AutoCaller autoCaller(this);
     603    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
     604
     605    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     606    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     607    AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
     608
     609    return mConsole->onCPUPriorityChange(aCpuPriority);
    596610}
    597611
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r31287 r31332  
    1239512395  <interface
    1239612396     name="IInternalSessionControl" extends="$unknown"
    12397      uuid="ab161f72-e4b3-44e6-a919-2256474bda66"
     12397     uuid="ef059f1d-2273-4f81-9342-c152a0d2cd40"
    1239812398     internal="yes"
    1239912399     wsmap="suppress"
     
    1257212572      <param name="add" type="boolean" dir="in">
    1257312573        <desc>Flag whether the CPU was added or removed</desc>
     12574      </param>
     12575    </method>
     12576
     12577    <method name="onCPUPriorityChange">
     12578      <desc>
     12579         Notification when the CPU priority changes.
     12580      </desc>
     12581      <param name="priority" type="unsigned long" dir="in">
     12582         <desc>The new CPU priority value. (1-100)</desc>
    1257412583      </param>
    1257512584    </method>
     
    1377613785  <enum
    1377713786     name="VBoxEventType"
    13778      uuid="7d695029-32b8-4855-86d3-75de9082923b">
     13787     uuid="2c76667e-6981-4122-a71a-cdfd6a6eb575">
    1377913788
    1378013789    <desc>
     
    1398013989      </desc>
    1398113990    </const>
     13991    <const name="OnCPUPriorityChanged" value="63">
     13992      <desc>
     13993        <see>ICPUPriorityChangedEvent</see>
     13994      </desc>
     13995    </const>
    1398213996    <!-- Last event marker -->
    13983     <const name="Last" value="63">
     13997    <const name="Last" value="64">
    1398413998      <desc>
    1398513999        Must be last event, used for iterations and structures relying on numerical event values.
     
    1467314687
    1467414688  <interface
     14689    name="ICPUPriorityChangedEvent" extends="IEvent"
     14690    uuid="657fe2fe-a75a-4cb6-8cf9-072aa41e7d75"
     14691    wsmap="managed" autogen="VBoxEvent" id="OnCPUPriorityChanged"
     14692    >
     14693   <desc>
     14694      Notification when the CPU priority changes.
     14695   </desc>
     14696     <attribute name="priority" type="unsigned long" readonly="yes">
     14697       <desc>
     14698         The new CPU priority value. (1-100)
     14699       </desc>
     14700     </attribute>
     14701  </interface>
     14702
     14703   <interface
    1467514704     name="IVRDPServerChangedEvent" extends="IEvent"
    1467614705     uuid="726038B6-6279-4A7A-8037-D041693D1915"
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r31220 r31332  
    182182    HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
    183183    HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
     184    HRESULT onCPUPriorityChange(ULONG aCpuPriority);
    184185    HRESULT onVRDPServerChange(BOOL aRestart);
    185186    HRESULT onUSBControllerChange();
  • trunk/src/VBox/Main/include/MachineImpl.h

    r31308 r31332  
    616616    virtual HRESULT onStorageControllerChange() { return S_OK; }
    617617    virtual HRESULT onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
     618    virtual HRESULT onCPUPriorityChange(ULONG /* aCpuPriority */) { return S_OK; }
    618619    virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
    619620    virtual HRESULT onSharedFolderChange() { return S_OK; }
     
    944945    HRESULT onParallelPortChange(IParallelPort *parallelPort);
    945946    HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
     947    HRESULT onCPUPriorityChange(ULONG aCpuPriority);
    946948    HRESULT onVRDPServerChange(BOOL aRestart);
    947949    HRESULT onUSBControllerChange();
  • trunk/src/VBox/Main/include/SessionImpl.h

    r31070 r31332  
    9090    STDMETHOD(OnMediumChange)(IMediumAttachment *aMediumAttachment, BOOL aForce);
    9191    STDMETHOD(OnCPUChange)(ULONG aCPU, BOOL aRemove);
     92    STDMETHOD(OnCPUPriorityChange)(ULONG aCpuPriority);
    9293    STDMETHOD(OnVRDPServerChange)(BOOL aRestart);
    9394    STDMETHOD(OnUSBControllerChange)();
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