VirtualBox

Changeset 49659 in vbox for trunk/src


Ignore:
Timestamp:
Nov 26, 2013 2:33:07 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Medium enumeration mechanism: Full snapshot-tree update for every medium related to particular VM on machine registration event.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.cpp

    r49647 r49659  
    2828#include "COMEnums.h"
    2929#include "CMachine.h"
     30#include "CSnapshot.h"
    3031#include "CMediumAttachment.h"
    3132
     
    184185    CMediumMap currentCMediums;
    185186    QStringList currentCMediumIDs;
    186     calculateActualUsage(strMachineID, currentCMediums, currentCMediumIDs);
     187    calculateActualUsage(strMachineID, currentCMediums, currentCMediumIDs, true /* take into account current state only */);
    187188    LogRel(("UIMediumEnumerator:  New usage: %s\n",
    188189            currentCMediumIDs.isEmpty() ? "<empty>" : currentCMediumIDs.join(", ").toAscii().constData()));
     
    222223        CMediumMap currentCMediums;
    223224        QStringList currentCMediumIDs;
    224         calculateActualUsage(strMachineID, currentCMediums, currentCMediumIDs);
     225        calculateActualUsage(strMachineID, currentCMediums, currentCMediumIDs, false /* take into account current state only */);
    225226        LogRel(("UIMediumEnumerator:  New usage: %s\n",
    226227                currentCMediumIDs.isEmpty() ? "<empty>" : currentCMediumIDs.join(", ").toAscii().constData()));
     
    259260    CMediumMap currentCMediums;
    260261    QStringList currentCMediumIDs;
    261     calculateActualUsage(strMachineID, currentCMediums, currentCMediumIDs);
     262    calculateActualUsage(strMachineID, currentCMediums, currentCMediumIDs, true /* take into account current state only */);
    262263    LogRel(("UIMediumEnumerator:  New usage: %s\n",
    263264            currentCMediumIDs.isEmpty() ? "<empty>" : currentCMediumIDs.join(", ").toAscii().constData()));
     
    424425 * @param currentCMediums receives CMedium used in actual data.
    425426 * @param currentCMediumIDs receives CMedium IDs used in actual data.
    426  */
    427 void UIMediumEnumerator::calculateActualUsage(const QString &strMachineID, CMediumMap &currentCMediums, QStringList &currentCMediumIDs) const
     427 * @param fTakeIntoAccountCurrentStateOnly defines whether we should take into accound current VM state only.
     428 */
     429void UIMediumEnumerator::calculateActualUsage(const QString &strMachineID, CMediumMap &currentCMediums, QStringList &currentCMediumIDs, bool fTakeIntoAccountCurrentStateOnly) const
    428430{
    429431    /* Search for corresponding machine: */
    430432    CMachine machine = vboxGlobal().virtualBox().FindMachine(strMachineID);
     433    AssertReturnVoid(!machine.isNull());
     434
     435    /* Calculate actual usage starting from root-snapshot if necessary: */
     436    if (!fTakeIntoAccountCurrentStateOnly)
     437        calculateActualUsage(machine.FindSnapshot(QString()), currentCMediums, currentCMediumIDs);
     438    /* Calculate actual usage for current machine state: */
     439    calculateActualUsage(machine, currentCMediums, currentCMediumIDs);
     440}
     441
     442/**
     443 * Calculates new CMedium <i>usage</i> based on actual data.
     444 * @param snapshot is reference we are calculating <i>usage</i> for.
     445 * @param currentCMediums receives CMedium used in actual data.
     446 * @param currentCMediumIDs receives CMedium IDs used in actual data.
     447 */
     448void UIMediumEnumerator::calculateActualUsage(const CSnapshot &snapshot, CMediumMap &currentCMediums, QStringList &currentCMediumIDs) const
     449{
     450    /* Check passed snapshot: */
     451    AssertReturnVoid(!snapshot.isNull());
     452
     453    /* Calculate actual usage for passed snapshot machine: */
     454    calculateActualUsage(snapshot.GetMachine(), currentCMediums, currentCMediumIDs);
     455
     456    /* Iterate through passed snapshot children: */
     457    foreach (const CSnapshot &childSnapshot, snapshot.GetChildren())
     458        calculateActualUsage(childSnapshot, currentCMediums, currentCMediumIDs);
     459}
     460
     461/**
     462 * Calculates new CMedium <i>usage</i> based on actual data.
     463 * @param machine is reference we are calculating <i>usage</i> for.
     464 * @param currentCMediums receives CMedium used in actual data.
     465 * @param currentCMediumIDs receives CMedium IDs used in actual data.
     466 */
     467void UIMediumEnumerator::calculateActualUsage(const CMachine &machine, CMediumMap &currentCMediums, QStringList &currentCMediumIDs) const
     468{
     469    /* Check passed machine: */
    431470    AssertReturnVoid(!machine.isNull());
    432471
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.h

    r49647 r49659  
    8686    /* Helpers: Medium re-caching stuff: */
    8787    void calculateCachedUsage(const QString &strMachineID, QStringList &previousUIMediumIDs, bool fTakeIntoAccountCurrentStateOnly) const;
    88     void calculateActualUsage(const QString &strMachineID, CMediumMap &currentCMediums, QStringList &currentCMediumIDs) const;
     88    void calculateActualUsage(const QString &strMachineID, CMediumMap &currentCMediums, QStringList &currentCMediumIDs, bool fTakeIntoAccountCurrentStateOnly) const;
     89    void calculateActualUsage(const CSnapshot &snapshot, CMediumMap &currentCMediums, QStringList &currentCMediumIDs) const;
     90    void calculateActualUsage(const CMachine &machine, CMediumMap &currentCMediums, QStringList &currentCMediumIDs) const;
    8991    void recacheFromCachedUsage(const QStringList &previousUIMediumIDs);
    9092    void recacheFromActualUsage(const CMediumMap &currentCMediums, const QStringList &currentCMediumIDs);
Note: See TracChangeset for help on using the changeset viewer.

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