VirtualBox

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


Ignore:
Timestamp:
May 12, 2015 5:52:23 PM (10 years ago)
Author:
vboxsync
Message:

Main/Machine: fix handling of transient guest properties (both on saving config due to machine state change, important for restoring snapshots and for loading config as there might be VM configs out there which have leftovers). Additionally: for restoring snapshots the last machine state change timestamp is not updated when the final machine state is set, to match the snapshot timestamp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r55807 r55833  
    90689068
    90699069#ifdef VBOX_WITH_GUEST_PROPS
     9070        /* Only load transient guest properties for configs which have saved
     9071         * state, because there shouldn't be any for powered off VMs. The same
     9072         * logic applies for snapshots, as offline snapshots shouldn't have
     9073         * any such properties. They confuse the code in various places.
     9074         * Note: can't rely on the machine state, as it isn't set yet. */
     9075        bool fSkipTransientGuestProperties = mSSData->strStateFilePath.isEmpty();
    90709076        /* Guest properties (optional) */
    90719077        for (settings::GuestPropertiesList::const_iterator it = data.llGuestProperties.begin();
     
    90769082            uint32_t fFlags = guestProp::NILFLAG;
    90779083            guestProp::validateFlags(prop.strFlags.c_str(), &fFlags);
     9084            if (   fSkipTransientGuestProperties
     9085                && (   fFlags & guestProp::TRANSIENT
     9086                    || fFlags & guestProp::TRANSRESET))
     9087                continue;
    90789088            HWData::GuestProperty property = { prop.strValue, (LONG64) prop.timestamp, fFlags };
    90799089            mHWData->mGuestProperties[prop.strName] = property;
     
    1036110371
    1036210372            /* Remove transient guest properties at shutdown unless we
    10363              * are saving state */
     10373             * are saving state. Note that restoring snapshot intentionally
     10374             * keeps them, they will be removed if appropriate once the final
     10375             * machine state is set (as crashes etc. need to work). */
    1036410376            if (   (   mData->mMachineState == MachineState_PoweredOff
    1036510377                    || mData->mMachineState == MachineState_Aborted
     
    1448414496    mPeer->i_setMachineState(aMachineState);
    1448514497
    14486     if (   aMachineState == MachineState_PoweredOff
    14487         || aMachineState == MachineState_Teleported
    14488         || aMachineState == MachineState_Aborted
    14489         || aMachineState == MachineState_Saved)
     14498    if (   oldMachineState != MachineState_RestoringSnapshot
     14499        && (   aMachineState == MachineState_PoweredOff
     14500            || aMachineState == MachineState_Teleported
     14501            || aMachineState == MachineState_Aborted
     14502            || aMachineState == MachineState_Saved))
    1449014503    {
    1449114504        /* the machine has stopped execution
     
    1451414527        BOOL fNeedsSaving = mData->mGuestPropertiesModified;
    1451514528
     14529        /* remove it from the settings representation */
    1451614530        settings::GuestPropertiesList &llGuestProperties = mData->pMachineConfigFile->hardwareMachine.llGuestProperties;
    14517         settings::GuestPropertiesList::iterator it = llGuestProperties.begin();
    14518         while (it != llGuestProperties.end())
     14531        for (settings::GuestPropertiesList::iterator it = llGuestProperties.begin();
     14532             it != llGuestProperties.end();
     14533             /*nothing*/)
    1451914534        {
    1452014535            const settings::GuestProperty &prop = *it;
     
    1452314538            {
    1452414539                it = llGuestProperties.erase(it);
     14540                fNeedsSaving = true;
     14541            }
     14542            else
     14543            {
     14544                ++it;
     14545            }
     14546        }
     14547
     14548        /* Additionally remove it from the HWData representation. Required to
     14549         * keep everything in sync, as this is what the API keeps using. */
     14550        HWData::GuestPropertyMap &llHWGuestProperties = mHWData->mGuestProperties;
     14551        for (HWData::GuestPropertyMap::iterator it = llHWGuestProperties.begin();
     14552             it != llHWGuestProperties.end();
     14553             /*nothing*/)
     14554        {
     14555            uint32_t fFlags = it->second.mFlags;
     14556            if (   fFlags & guestProp::TRANSIENT
     14557                || fFlags & guestProp::TRANSRESET)
     14558            {
     14559                /* iterator where we need to continue after the erase call
     14560                 * (C++03 is a fact still, and it doesn't return the iterator
     14561                 * which would allow continuing) */
     14562                HWData::GuestPropertyMap::iterator it2 = it;
     14563                ++it2;
     14564                llHWGuestProperties.erase(it);
     14565                it = it2;
    1452514566                fNeedsSaving = true;
    1452614567            }
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