VirtualBox

Changeset 36178 in vbox for trunk/src


Ignore:
Timestamp:
Mar 7, 2011 9:45:24 AM (14 years ago)
Author:
vboxsync
Message:

Main/VBoxManage/Guest Additions: Added support for "TRANSIENT_RESET" guest properties which are only present until a VM reset.

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServicePropCache.cpp

    r34406 r36178  
    105105                 * gets deleted when the property cache did not have the chance to
    106106                 * gracefully clean it up (due to a hard VM reset etc), so set this
    107                  * guest property using the TRANSIENT flag.
     107                 * guest property using the TRANSIENT and TRANSIENT_RESET flags.
    108108                 */
    109                 rc = VbglR3GuestPropWrite(u32ClientId, pszName, pszValue, "TRANSIENT");
     109                rc = VbglR3GuestPropWrite(u32ClientId, pszName, pszValue, "TRANSIENT,TRANSIENT_RESET");
     110                if (rc == VERR_PARSE_ERROR)
     111                {
     112                    /* Host does not support the "TRANSIENT_RESET" flag, so only
     113                     * use the "TRANSIENT" flag* -- better than nothing :-). */
     114                    rc = VbglR3GuestPropWrite(u32ClientId, pszName, pszValue, "TRANSIENT");
     115                }
    110116            }
    111117            else
     
    377383            /*
    378384             * When destroying the cache and we have a temporary value, remove the
    379              * (eventually) set TRANSIENT flag from it so that it doesn't get deleted
     385             * (eventually) set TRANSIENT_RESET flag from it so that it doesn't get deleted
    380386             * by the host side in order to put the actual reset value in it.
    381387             */
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServicePropCache.h

    r31925 r36178  
    2121#include "VBoxServiceInternal.h"
    2222
    23 #ifdef VBOX_WITH_GUEST_PROPS
     23# ifdef VBOX_WITH_GUEST_PROPS
    2424
     25/** Indicates wheter a guest property is temporary and either should
     26 *  get deleted when
     27 *  - a) the property cache gets destroyed, or
     28 *  - b) the VM gets a hard reset / shutdown
     29 *  or gets a default "reset" value (if specified via VBoxServicePropCacheUpdateEntry)
     30 *  when the property cache gets properly destroyed.
     31 */
    2532#define VBOXSERVICEPROPCACHEFLAG_TEMPORARY          RT_BIT(1)
     33/** Indicates whether a property every time needs to be updated, regardless
     34 *  if its real value changed or not. */
    2635#define VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE      RT_BIT(2)
    2736
     
    3241int VBoxServicePropCacheFlush(PVBOXSERVICEVEPROPCACHE pCache);
    3342void VBoxServicePropCacheDestroy(PVBOXSERVICEVEPROPCACHE pCache);
    34 #endif
     43# endif /* VBOX_WITH_GUEST_PROPS */
    3544
    36 #endif
     45#endif  /* ___VBoxServicePropCache_h */
    3746
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r36041 r36178  
    619619                                                           ComSafeArrayOut(BSTR, aFlags));
    620620
    621     bool enabledGuestPropertiesVRDP(void);
    622     void updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
    623     void updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId);
     621    void guestPropertiesHandleVMReset(void);
     622    bool guestPropertiesVRDPEnabled(void);
     623    void guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
     624    void guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
    624625#endif
    625626
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r36074 r36178  
    673673#ifdef VBOX_WITH_GUEST_PROPS
    674674
    675 bool Console::enabledGuestPropertiesVRDP(void)
     675/**
     676 * Handles guest properties on a VM reset.
     677 * At the moment we only delete properties which have the flag
     678 * "TRARESET".
     679 */
     680void Console::guestPropertiesHandleVMReset(void)
     681{
     682    com::SafeArray<BSTR>   arrNames;
     683    com::SafeArray<BSTR>   arrValues;
     684    com::SafeArray<LONG64> arrTimestamps;
     685    com::SafeArray<BSTR>   arrFlags;
     686    HRESULT hrc = enumerateGuestProperties(Bstr("*").raw(),
     687                                           ComSafeArrayAsOutParam(arrNames),
     688                                           ComSafeArrayAsOutParam(arrValues),
     689                                           ComSafeArrayAsOutParam(arrTimestamps),
     690                                           ComSafeArrayAsOutParam(arrFlags));
     691    if (SUCCEEDED(hrc))
     692    {
     693        for (size_t i = 0; i < arrFlags.size(); i++)
     694        {
     695            /* Delete all properties which have the flag "TRARESET". */
     696            if (Utf8Str(arrFlags[i]).contains("TRANSIENT_RESET", Utf8Str::CaseInsensitive))
     697            {
     698                hrc = mMachine->SetGuestProperty(arrNames[i], Bstr("").raw() /* Value */,
     699                                                 Bstr("").raw() /* Flags */);
     700                if (FAILED(hrc))
     701                    LogRel(("RESET: Could not delete transient property \"%ls\", rc=%Rhrc\n",
     702                            arrNames[i], hrc));
     703            }
     704        }
     705    }
     706    else
     707        LogRel(("RESET: Unable to enumerate guest properties, rc=%Rhrc\n", hrc));
     708}
     709
     710bool Console::guestPropertiesVRDPEnabled(void)
    676711{
    677712    Bstr value;
    678713    HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/EnableGuestPropertiesVRDP").raw(),
    679714                                         value.asOutParam());
    680     if (hrc == S_OK)
    681     {
    682         if (value == "1")
    683         {
    684             return true;
    685         }
    686     }
     715    if (   hrc   == S_OK
     716        && value == "1")
     717        return true;
    687718    return false;
    688719}
    689720
    690 void Console::updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
    691 {
    692     if (!enabledGuestPropertiesVRDP())
    693     {
     721void Console::guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
     722{
     723    if (!guestPropertiesVRDPEnabled())
    694724        return;
    695     }
    696725
    697726    char szPropNm[256];
     
    725754}
    726755
    727 void Console::updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId)
    728 {
    729     if (!enabledGuestPropertiesVRDP())
     756void Console::guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId)
     757{
     758    if (!guestPropertiesVRDPEnabled())
    730759        return;
    731760
     
    961990
    962991#ifdef VBOX_WITH_GUEST_PROPS
    963     updateGuestPropertiesVRDPLogon(u32ClientId, pszUser, pszDomain);
     992    guestPropertiesVRDPUpdateLogon(u32ClientId, pszUser, pszDomain);
    964993#endif /* VBOX_WITH_GUEST_PROPS */
    965994
     
    10961125
    10971126#ifdef VBOX_WITH_GUEST_PROPS
    1098     updateGuestPropertiesVRDPDisconnect(u32ClientId);
     1127    guestPropertiesVRDPUpdateDisconnect(u32ClientId);
    10991128#endif /* VBOX_WITH_GUEST_PROPS */
    11001129
     
    67686797                    break;
    67696798            }
     6799            break;
     6800        }
     6801
     6802        case VMSTATE_RESETTING:
     6803        {
     6804    #ifdef VBOX_WITH_GUEST_PROPS
     6805            /* Do not take any read/write locks here! */
     6806            that->guestPropertiesHandleVMReset();
     6807    #endif
    67706808            break;
    67716809        }
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r36168 r36178  
    50095009                      /** @todo Fix when adding DeleteGuestProperty(),
    50105010                                   see defect. */
    5011                       *aValue ? aValue : NULL, aFlags, true /* isSetter */,
     5011                      *aValue ? aValue : NULL, *aFlags ? aFlags : NULL,
     5012                      true /* isSetter */,
    50125013                      &dummy, &dummy64, &dummy);
    50135014    }
     
    86528653                    || mData->mMachineState == MachineState_Aborted
    86538654                    || mData->mMachineState == MachineState_Teleported)
    8654                 && property.mFlags & guestProp::TRANSIENT)
     8655                && (   property.mFlags & guestProp::TRANSIENT
     8656                    || property.mFlags & guestProp::TRANSIENT_RESET))
    86558657                continue;
    86568658            settings::GuestProperty prop;
     
    1221712219            for (it = mHWData->mGuestProperties.begin();
    1221812220                 it != mHWData->mGuestProperties.end(); ++it)
    12219                 if (it->mFlags & guestProp::TRANSIENT)
     12221                if (   (it->mFlags & guestProp::TRANSIENT)
     12222                    || (it->mFlags & guestProp::TRANSIENT_RESET))
    1222012223                {
    1222112224                    fNeedsSaving = true;
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