VirtualBox

Changeset 82483 in vbox


Ignore:
Timestamp:
Dec 7, 2019 1:25:34 AM (5 years ago)
Author:
vboxsync
Message:

VBoxClipboardSvc: More save state cleanup. bugref:9437

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard.h

    r82480 r82483  
    251251/**
    252252 * Shared Clipboard transfer source type.
     253 * @note Part of saved state!
    253254 */
    254255typedef enum SHCLSOURCE
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r81824 r82483  
    9191} SHCLCLIENTPODSTATE, *PSHCLCLIENTPODSTATE;
    9292
     93/** @name SHCLCLIENTSTATE_FLAGS_XXX
     94 * @note Part of saved state! */
    9395/** No Shared Clipboard client flags defined. */
    9496#define SHCLCLIENTSTATE_FLAGS_NONE              0
     
    9799/** Client has a guest write operation active. */
    98100#define SHCLCLIENTSTATE_FLAGS_WRITE_ACTIVE      RT_BIT(1)
     101/** @} */
    99102
    100103/**
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r82482 r82483  
    216216#include <VBox/log.h>
    217217
    218 #include <VBox/AssertGuest.h>
    219218#include <VBox/GuestHost/clipboard-helper.h>
    220219#include <VBox/HostServices/Service.h>
     
    222221#include <VBox/HostServices/VBoxClipboardExt.h>
    223222
    224 #include <iprt/alloc.h>
     223#include <VBox/AssertGuest.h>
     224#include <VBox/err.h>
     225#include <VBox/VMMDev.h>
     226#include <VBox/vmm/ssm.h>
     227
     228#include <iprt/mem.h>
    225229#include <iprt/string.h>
    226230#include <iprt/assert.h>
    227231#include <iprt/critsect.h>
    228232#include <iprt/rand.h>
    229 
    230 #include <VBox/err.h>
    231 #include <VBox/vmm/ssm.h>
    232233
    233234#include "VBoxSharedClipboardSvc-internal.h"
     
    20932094/**
    20942095 * SSM descriptor table for the SHCLCLIENTSTATE structure.
     2096 *
     2097 * @note Saving the session ID not necessary, as they're not persistent across
     2098 *       state save/restore.
    20952099 */
    20962100static SSMFIELD const s_aShClSSMClientState[] =
    20972101{
    2098     /** Note: Saving the session ID not necessary, as they're not persistent across state save/restore. */
    20992102    SSMFIELD_ENTRY(SHCLCLIENTSTATE, fGuestFeatures0),
    21002103    SSMFIELD_ENTRY(SHCLCLIENTSTATE, fGuestFeatures1),
     
    21022105    SSMFIELD_ENTRY(SHCLCLIENTSTATE, enmSource),
    21032106    SSMFIELD_ENTRY(SHCLCLIENTSTATE, fFlags),
     2107    SSMFIELD_ENTRY_TERM()
     2108};
     2109
     2110/**
     2111 * VBox 6.1 Beta 1 version of s_aShClSSMClientState (no flags).
     2112 */
     2113static SSMFIELD const s_aShClSSMClientState61B1[] =
     2114{
     2115    SSMFIELD_ENTRY(SHCLCLIENTSTATE, fGuestFeatures0),
     2116    SSMFIELD_ENTRY(SHCLCLIENTSTATE, fGuestFeatures1),
     2117    SSMFIELD_ENTRY(SHCLCLIENTSTATE, cbChunkSize),
     2118    SSMFIELD_ENTRY(SHCLCLIENTSTATE, enmSource),
    21042119    SSMFIELD_ENTRY_TERM()
    21052120};
     
    22662281        if (lenOrVer >= VBOX_SHCL_SAVED_STATE_VER_6_1RC1)
    22672282        {
    2268             rc = SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */,
    2269                                   &s_aShClSSMClientState[0], NULL);
    2270             AssertRCReturn(rc, rc);
    2271 
    2272             rc = SSMR3GetStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /* fFlags */,
    2273                                   &s_aShClSSMClientPODState[0], NULL);
    2274             AssertRCReturn(rc, rc);
    2275         }
    2276         else /** @todo Remove this block after 6.1 RC; don't annoy team members with broken saved states. */
    2277         {
    2278             rc = SSMR3Skip(pSSM, sizeof(uint32_t));         /* Begin marker */
    2279             AssertRC(rc);
    2280 
    2281             rc = SSMR3GetU64(pSSM, &pClient->State.fGuestFeatures0);
    2282             AssertRC(rc);
    2283 
    2284             rc = SSMR3GetU64(pSSM, &pClient->State.fGuestFeatures1);
    2285             AssertRC(rc);
    2286 
    2287             rc = SSMR3GetU32(pSSM, &pClient->State.cbChunkSize);
    2288             AssertRC(rc);
    2289 
    2290             rc = SSMR3GetU32(pSSM, (uint32_t *)&pClient->State.enmSource);
    2291             AssertRC(rc);
    2292 
    2293             rc = SSMR3Skip(pSSM, sizeof(uint32_t));         /* End marker */
    2294             AssertRC(rc);
    2295         }
    2296 
     2283            SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */, &s_aShClSSMClientState[0], NULL);
     2284            SSMR3GetStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /* fFlags */,
     2285                             &s_aShClSSMClientPODState[0], NULL);
     2286        }
     2287        else
     2288            SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */, &s_aShClSSMClientState61B1[0], NULL);
    22972289        rc = SSMR3GetStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /* fFlags */,
    22982290                              &s_aShClSSMClientTransferState[0], NULL);
     
    23002292
    23012293        /* Load the client's internal message queue. */
    2302         uint64_t cMsg;
    2303         rc = SSMR3GetU64(pSSM, &cMsg);
     2294        uint64_t cMsgs;
     2295        rc = SSMR3GetU64(pSSM, &cMsgs);
    23042296        AssertRCReturn(rc, rc);
    2305 
    2306         for (uint64_t i = 0; i < cMsg; i++)
     2297        AssertLogRelMsgReturn(cMsgs < _16K, ("Too many messages: %u (%x)\n", cMsgs, cMsgs), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     2298
     2299        for (uint64_t i = 0; i < cMsgs; i++)
    23072300        {
    23082301            PSHCLCLIENTMSG pMsg = (PSHCLCLIENTMSG)RTMemAlloc(sizeof(SHCLCLIENTMSG));
    2309             AssertPtrReturn(pMsg, VERR_NO_MEMORY);
    2310 
    2311             rc = SSMR3GetStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
    2312             AssertRCReturn(rc, rc);
    2313 
     2302            AssertReturn(pMsg, VERR_NO_MEMORY);
     2303
     2304            SSMR3GetStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
    23142305            rc = SSMR3GetStructEx(pSSM, &pMsg->Ctx, sizeof(SHCLMSGCTX), 0 /*fFlags*/, &s_aShClSSMClientMsgCtx[0], NULL);
    2315             AssertRCReturn(rc, rc);
     2306            AssertRCReturnStmt(rc, RTMemFree(pMsg), rc);
     2307
     2308            AssertLogRelMsgReturnStmt(pMsg->cParms <= VMMDEV_MAX_HGCM_PARMS,
     2309                                      ("Too many HGCM message parameters: %u (%#x)\n", pMsg->cParms, pMsg->cParms),
     2310                                      RTMemFree(pMsg),
     2311                                      VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    23162312
    23172313            pMsg->paParms = (PVBOXHGCMSVCPARM)RTMemAllocZ(sizeof(VBOXHGCMSVCPARM) * pMsg->cParms);
    2318             AssertPtrReturn(pMsg->paParms, VERR_NO_MEMORY);
     2314            AssertReturnStmt(pMsg->paParms, RTMemFree(pMsg), VERR_NO_MEMORY);
    23192315
    23202316            for (uint32_t p = 0; p < pMsg->cParms; p++)
    23212317            {
    23222318                rc = HGCMSvcSSMR3Get(&pMsg->paParms[p], pSSM);
    2323                 AssertRCReturn(rc, rc);
     2319                AssertRCReturn(rc, rc); /* we'll leak stuff here, oh well... */
    23242320            }
    23252321
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