Index: /trunk/src/VBox/Devices/VMMDev/VMMDev.cpp
===================================================================
--- /trunk/src/VBox/Devices/VMMDev/VMMDev.cpp	(revision 81568)
+++ /trunk/src/VBox/Devices/VMMDev/VMMDev.cpp	(revision 81569)
@@ -242,8 +242,8 @@
     {
         /* Filter unsupported events */
-        uint32_t fEvents = pThis->u32HostEventFlags & pThis->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask;
-
-        Log(("vmmdevSetIRQ: fEvents=%#010x, u32HostEventFlags=%#010x, u32GuestEventMask=%#010x.\n",
-             fEvents, pThis->u32HostEventFlags, pThis->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask));
+        uint32_t fEvents = pThis->fHostEventFlags & pThis->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask;
+
+        Log(("vmmdevSetIRQ: fEvents=%#010x, fHostEventFlags=%#010x, u32GuestEventMask=%#010x.\n",
+             fEvents, pThis->fHostEventFlags, pThis->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask));
 
         /* Move event flags to VMMDev RAM */
@@ -254,6 +254,6 @@
         {
             /* Clear host flags which will be delivered to guest. */
-            pThis->u32HostEventFlags &= ~fEvents;
-            Log(("vmmdevSetIRQ: u32HostEventFlags=%#010x\n", pThis->u32HostEventFlags));
+            pThis->fHostEventFlags &= ~fEvents;
+            Log(("vmmdevSetIRQ: fHostEventFlags=%#010x\n", pThis->fHostEventFlags));
             uIRQLevel = 1;
         }
@@ -278,8 +278,8 @@
 static void vmmdevMaybeSetIRQ(PVMMDEV pThis)
 {
-    Log3(("vmmdevMaybeSetIRQ: u32HostEventFlags=%#010x, u32GuestFilterMask=%#010x.\n",
-          pThis->u32HostEventFlags, pThis->u32GuestFilterMask));
-
-    if (pThis->u32HostEventFlags & pThis->u32GuestFilterMask)
+    Log3(("vmmdevMaybeSetIRQ: fHostEventFlags=%#010x, fGuestFilterMask=%#010x.\n",
+          pThis->fHostEventFlags, pThis->fGuestFilterMask));
+
+    if (pThis->fHostEventFlags & pThis->fGuestFilterMask)
     {
         /*
@@ -313,10 +313,10 @@
         if (pThis->fu32AdditionsOk)
         {
-            const bool fHadEvents = (pThis->u32HostEventFlags & pThis->u32GuestFilterMask) != 0;
-
-            Log3(("vmmdevNotifyGuestWorker: fHadEvents=%d, u32HostEventFlags=%#010x, u32GuestFilterMask=%#010x.\n",
-                  fHadEvents, pThis->u32HostEventFlags, pThis->u32GuestFilterMask));
-
-            pThis->u32HostEventFlags |= fAddEvents;
+            const bool fHadEvents = (pThis->fHostEventFlags & pThis->fGuestFilterMask) != 0;
+
+            Log3(("vmmdevNotifyGuestWorker: fHadEvents=%d, fHostEventFlags=%#010x, fGuestFilterMask=%#010x.\n",
+                  fHadEvents, pThis->fHostEventFlags, pThis->fGuestFilterMask));
+
+            pThis->fHostEventFlags |= fAddEvents;
 
             if (!fHadEvents)
@@ -325,5 +325,5 @@
         else
         {
-            pThis->u32HostEventFlags |= fAddEvents;
+            pThis->fHostEventFlags |= fAddEvents;
             Log(("vmmdevNotifyGuestWorker: IRQ is not generated, guest has not yet reported to us.\n"));
         }
@@ -333,5 +333,5 @@
         Log3(("vmmdevNotifyGuestWorker: Old additions detected.\n"));
 
-        pThis->u32HostEventFlags |= fAddEvents;
+        pThis->fHostEventFlags |= fAddEvents;
         vmmdevSetIRQ_Legacy(pThis);
     }
@@ -396,20 +396,20 @@
     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
 
-    const bool fHadEvents = (pThis->u32HostEventFlags & pThis->u32GuestFilterMask) != 0;
+    const bool fHadEvents = (pThis->fHostEventFlags & pThis->fGuestFilterMask) != 0;
 
     Log(("VMMDevCtlSetGuestFilterMask: fOrMask=%#010x, u32NotMask=%#010x, fHadEvents=%d.\n", fOrMask, fNotMask, fHadEvents));
     if (fHadEvents)
     {
-        if (!pThis->fNewGuestFilterMask)
-            pThis->u32NewGuestFilterMask = pThis->u32GuestFilterMask;
-
-        pThis->u32NewGuestFilterMask |= fOrMask;
-        pThis->u32NewGuestFilterMask &= ~fNotMask;
-        pThis->fNewGuestFilterMask = true;
+        if (!pThis->fNewGuestFilterMaskValid)
+            pThis->fNewGuestFilterMask = pThis->fGuestFilterMask;
+
+        pThis->fNewGuestFilterMask |= fOrMask;
+        pThis->fNewGuestFilterMask &= ~fNotMask;
+        pThis->fNewGuestFilterMaskValid = true;
     }
     else
     {
-        pThis->u32GuestFilterMask |= fOrMask;
-        pThis->u32GuestFilterMask &= ~fNotMask;
+        pThis->fGuestFilterMask |= fOrMask;
+        pThis->fGuestFilterMask &= ~fNotMask;
         vmmdevMaybeSetIRQ(pThis);
     }
@@ -975,8 +975,8 @@
     const uint32_t fu32Caps = pReq->caps | VMMDEV_GUEST_SUPPORTS_GRAPHICS;
 
-    if (pThis->guestCaps != fu32Caps)
+    if (pThis->fGuestCaps != fu32Caps)
     {
         /* make a copy of supplied information */
-        pThis->guestCaps = fu32Caps;
+        pThis->fGuestCaps = fu32Caps;
 
         LogRel(("VMMDev: Guest Additions capability report (legacy): (0x%x) seamless: %s, hostWindowMapping: %s, graphics: yes\n",
@@ -1004,15 +1004,15 @@
     AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
 
-    uint32_t fu32Caps = pThis->guestCaps;
+    uint32_t fu32Caps = pThis->fGuestCaps;
     fu32Caps |= pReq->u32OrMask;
     fu32Caps &= ~pReq->u32NotMask;
 
     LogRel(("VMMDev: Guest Additions capability report: (%#x -> %#x) seamless: %s, hostWindowMapping: %s, graphics: %s\n",
-            pThis->guestCaps, fu32Caps,
+            pThis->fGuestCaps, fu32Caps,
             fu32Caps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ? "yes" : "no",
             fu32Caps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no",
             fu32Caps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ? "yes" : "no"));
 
-    pThis->guestCaps = fu32Caps;
+    pThis->fGuestCaps = fu32Caps;
 
     if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
@@ -1035,8 +1035,8 @@
     AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
 
-    pReq->mouseFeatures = pThis->mouseCapabilities
+    pReq->mouseFeatures = pThis->fMouseCapabilities
                         & VMMDEV_MOUSE_MASK;
-    pReq->pointerXPos   = pThis->mouseXAbs;
-    pReq->pointerYPos   = pThis->mouseYAbs;
+    pReq->pointerXPos   = pThis->xMouseAbs;
+    pReq->pointerYPos   = pThis->yMouseAbs;
     LogRel2(("VMMDev: vmmdevReqHandler_GetMouseStatus: mouseFeatures=%#x, xAbs=%d, yAbs=%d\n",
              pReq->mouseFeatures, pReq->pointerXPos, pReq->pointerYPos));
@@ -1061,12 +1061,12 @@
     bool fNotify = false;
     if (   (pReq->mouseFeatures & VMMDEV_MOUSE_NOTIFY_HOST_MASK)
-        != (  pThis->mouseCapabilities
+        != (  pThis->fMouseCapabilities
             & VMMDEV_MOUSE_NOTIFY_HOST_MASK))
         fNotify = true;
 
-    pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
-    pThis->mouseCapabilities |= (pReq->mouseFeatures & VMMDEV_MOUSE_GUEST_MASK);
-
-    LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: New host capabilities: %#x\n", pThis->mouseCapabilities));
+    pThis->fMouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
+    pThis->fMouseCapabilities |= (pReq->mouseFeatures & VMMDEV_MOUSE_GUEST_MASK);
+
+    LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: New host capabilities: %#x\n", pThis->fMouseCapabilities));
 
     /*
@@ -1076,5 +1076,5 @@
     {
         LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: Notifying connector\n"));
-        pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
+        pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);
     }
 
@@ -1673,13 +1673,13 @@
          * Note! This code is duplicated in vmmdevFastRequestIrqAck.
          */
-        if (pThis->fNewGuestFilterMask)
-        {
-            pThis->fNewGuestFilterMask = false;
-            pThis->u32GuestFilterMask = pThis->u32NewGuestFilterMask;
-        }
-
-        pReq->events = pThis->u32HostEventFlags & pThis->u32GuestFilterMask;
-
-        pThis->u32HostEventFlags &= ~pThis->u32GuestFilterMask;
+        if (pThis->fNewGuestFilterMaskValid)
+        {
+            pThis->fNewGuestFilterMaskValid = false;
+            pThis->fGuestFilterMask = pThis->fNewGuestFilterMask;
+        }
+
+        pReq->events = pThis->fHostEventFlags & pThis->fGuestFilterMask;
+
+        pThis->fHostEventFlags &= ~pThis->fGuestFilterMask;
         pThis->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;
 
@@ -2067,11 +2067,11 @@
     Log(("VMMDevReq_GetStatisticsChangeRequest\n"));
     /* just pass on the information */
-    Log(("VMMDev: returning statistics interval %d seconds\n", pThis->u32StatIntervalSize));
-    pReq->u32StatInterval = pThis->u32StatIntervalSize;
+    Log(("VMMDev: returning statistics interval %d seconds\n", pThis->cSecsStatInterval));
+    pReq->u32StatInterval = pThis->cSecsStatInterval;
 
     if (pReq->eventAck == VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST)
     {
         /* Remember which mode the client has queried. */
-        pThis->u32LastStatIntervalSize= pThis->u32StatIntervalSize;
+        pThis->cSecsLastStatInterval = pThis->cSecsStatInterval;
     }
 
@@ -3160,13 +3160,13 @@
                 STAM_REL_COUNTER_INC(&pThis->CTX_SUFF_Z(StatFastIrqAck));
 
-                if (pThis->fNewGuestFilterMask)
+                if (pThis->fNewGuestFilterMaskValid)
                 {
-                    pThis->fNewGuestFilterMask = false;
-                    pThis->u32GuestFilterMask = pThis->u32NewGuestFilterMask;
+                    pThis->fNewGuestFilterMaskValid = false;
+                    pThis->fGuestFilterMask = pThis->fNewGuestFilterMask;
                 }
 
-                *pu32 = pThis->u32HostEventFlags & pThis->u32GuestFilterMask;
-
-                pThis->u32HostEventFlags &= ~pThis->u32GuestFilterMask;
+                *pu32 = pThis->fHostEventFlags & pThis->fGuestFilterMask;
+
+                pThis->fHostEventFlags &= ~pThis->fGuestFilterMask;
                 pThis->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;
 
@@ -3333,21 +3333,24 @@
 
         /* The readable, buffered version. */
+        uint32_t offMsg = RT_MIN(pThis->offMsg, sizeof(pThis->szMsg) - 1);
         if (u32 == '\n' || u32 == '\r')
         {
-            pThis->szMsg[pThis->iMsg] = '\0';
-            if (pThis->iMsg)
-                LogRelIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("VMMDev: Guest Log: %s\n", pThis->szMsg));
-            pThis->iMsg = 0;
+            pThis->szMsg[offMsg] = '\0';
+            if (offMsg)
+                LogRelIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("VMMDev: Guest Log: %.*s\n", offMsg, pThis->szMsg));
+            pThis->offMsg = 0;
         }
         else
         {
-            if (pThis->iMsg >= sizeof(pThis->szMsg)-1)
+            if (offMsg >= sizeof(pThis->szMsg) - 1)
             {
-                pThis->szMsg[pThis->iMsg] = '\0';
-                LogRelIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("VMMDev: Guest Log: %s\n", pThis->szMsg));
-                pThis->iMsg = 0;
+                pThis->szMsg[sizeof(pThis->szMsg) - 1] = '\0';
+                LogRelIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR,
+                         ("VMMDev: Guest Log: %.*s\n", sizeof(pThis->szMsg) - 1, pThis->szMsg));
+                offMsg = 0;
             }
-            pThis->szMsg[pThis->iMsg] = (char )u32;
-            pThis->szMsg[++pThis->iMsg] = '\0';
+            pThis->szMsg[offMsg++] = (char )u32;
+            pThis->szMsg[offMsg]   = '\0';
+            pThis->offMsg = offMsg;
         }
     }
@@ -3396,11 +3399,11 @@
     {
         if (pThis->fTimesyncBackdoorLo)
-            *pu32 = (uint32_t)pThis->hostTime;
+            *pu32 = (uint32_t)pThis->msLatchedHostTime;
         else
         {
             /* Reading the high dword gets and saves the current time. */
             RTTIMESPEC Now;
-            pThis->hostTime = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &Now));
-            *pu32 = (uint32_t)(pThis->hostTime >> 32);
+            pThis->msLatchedHostTime = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &Now));
+            *pu32 = (uint32_t)(pThis->msLatchedHostTime >> 32);
         }
         rc = VINF_SUCCESS;
@@ -3473,7 +3476,7 @@
      * rules making sure we won't see a halfwritten value. */
     if (pxAbs)
-        *pxAbs = ASMAtomicReadS32(&pThis->mouseXAbs); /* why the atomic read? */
+        *pxAbs = ASMAtomicReadS32(&pThis->xMouseAbs); /* why the atomic read? */
     if (pyAbs)
-        *pyAbs = ASMAtomicReadS32(&pThis->mouseYAbs);
+        *pyAbs = ASMAtomicReadS32(&pThis->yMouseAbs);
 
     return VINF_SUCCESS;
@@ -3488,10 +3491,10 @@
     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
 
-    if (   pThis->mouseXAbs != xAbs
-        || pThis->mouseYAbs != yAbs)
+    if (   pThis->xMouseAbs != xAbs
+        || pThis->yMouseAbs != yAbs)
     {
         Log2(("vmmdevIPort_SetAbsoluteMouse : settings absolute position to x = %d, y = %d\n", xAbs, yAbs));
-        pThis->mouseXAbs = xAbs;
-        pThis->mouseYAbs = yAbs;
+        pThis->xMouseAbs = xAbs;
+        pThis->yMouseAbs = yAbs;
         VMMDevNotifyGuest(pThis, VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
     }
@@ -3509,5 +3512,5 @@
     AssertPtrReturn(pfCapabilities, VERR_INVALID_PARAMETER);
 
-    *pfCapabilities = pThis->mouseCapabilities;
+    *pfCapabilities = pThis->fMouseCapabilities;
     return VINF_SUCCESS;
 }
@@ -3522,9 +3525,9 @@
     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
 
-    uint32_t fOldCaps = pThis->mouseCapabilities;
-    pThis->mouseCapabilities &= ~(fCapsRemoved & VMMDEV_MOUSE_HOST_MASK);
-    pThis->mouseCapabilities |= (fCapsAdded & VMMDEV_MOUSE_HOST_MASK)
+    uint32_t fOldCaps = pThis->fMouseCapabilities;
+    pThis->fMouseCapabilities &= ~(fCapsRemoved & VMMDEV_MOUSE_HOST_MASK);
+    pThis->fMouseCapabilities |= (fCapsAdded & VMMDEV_MOUSE_HOST_MASK)
                               | VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
-    bool fNotify = fOldCaps != pThis->mouseCapabilities;
+    bool fNotify = fOldCaps != pThis->fMouseCapabilities;
 
     LogRelFlow(("VMMDev: vmmdevIPort_UpdateMouseCapabilities: fCapsAdded=0x%x, fCapsRemoved=0x%x, fNotify=%RTbool\n", fCapsAdded,
@@ -3719,12 +3722,12 @@
 
     /* Verify that the new resolution is different and that guest does not yet know about it. */
-    bool fSame = (pThis->u32LastStatIntervalSize == cSecsStatInterval);
-
-    Log(("vmmdevIPort_SetStatisticsInterval: old=%d. new=%d\n", pThis->u32LastStatIntervalSize, cSecsStatInterval));
+    bool fSame = (pThis->cSecsLastStatInterval == cSecsStatInterval);
+
+    Log(("vmmdevIPort_SetStatisticsInterval: old=%d. new=%d\n", pThis->cSecsLastStatInterval, cSecsStatInterval));
 
     if (!fSame)
     {
         /* we could validate the information here but hey, the guest can do that as well! */
-        pThis->u32StatIntervalSize = cSecsStatInterval;
+        pThis->cSecsStatInterval = cSecsStatInterval;
 
         /* IRQ so the guest knows what's going on */
@@ -3884,13 +3887,13 @@
     vmmdevLiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
 
-    SSMR3PutU32(pSSM, pThis->hypervisorSize);
-    SSMR3PutU32(pSSM, pThis->mouseCapabilities);
-    SSMR3PutS32(pSSM, pThis->mouseXAbs);
-    SSMR3PutS32(pSSM, pThis->mouseYAbs);
-
-    SSMR3PutBool(pSSM, pThis->fNewGuestFilterMask);
-    SSMR3PutU32(pSSM, pThis->u32NewGuestFilterMask);
-    SSMR3PutU32(pSSM, pThis->u32GuestFilterMask);
-    SSMR3PutU32(pSSM, pThis->u32HostEventFlags);
+    SSMR3PutU32(pSSM, 0 /*was pThis->hypervisorSize, which was always zero*/);
+    SSMR3PutU32(pSSM, pThis->fMouseCapabilities);
+    SSMR3PutS32(pSSM, pThis->xMouseAbs);
+    SSMR3PutS32(pSSM, pThis->yMouseAbs);
+
+    SSMR3PutBool(pSSM, pThis->fNewGuestFilterMaskValid);
+    SSMR3PutU32(pSSM, pThis->fNewGuestFilterMask);
+    SSMR3PutU32(pSSM, pThis->fGuestFilterMask);
+    SSMR3PutU32(pSSM, pThis->fHostEventFlags);
     /* The following is not strictly necessary as PGM restores MMIO2, keeping it for historical reasons. */
     SSMR3PutMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof(pThis->pVMMDevRAMR3->V));
@@ -3901,5 +3904,5 @@
     SSMR3PutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck);
 
-    SSMR3PutU32(pSSM, pThis->guestCaps);
+    SSMR3PutU32(pSSM, pThis->fGuestCaps);
 
 #ifdef VBOX_WITH_HGCM
@@ -3972,13 +3975,14 @@
 
     /* state */
-    SSMR3GetU32(pSSM, &pThis->hypervisorSize);
-    SSMR3GetU32(pSSM, &pThis->mouseCapabilities);
-    SSMR3GetS32(pSSM, &pThis->mouseXAbs);
-    SSMR3GetS32(pSSM, &pThis->mouseYAbs);
-
-    SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMask);
-    SSMR3GetU32(pSSM, &pThis->u32NewGuestFilterMask);
-    SSMR3GetU32(pSSM, &pThis->u32GuestFilterMask);
-    SSMR3GetU32(pSSM, &pThis->u32HostEventFlags);
+    uint32_t uIgn;
+    SSMR3GetU32(pSSM, &uIgn);
+    SSMR3GetU32(pSSM, &pThis->fMouseCapabilities);
+    SSMR3GetS32(pSSM, &pThis->xMouseAbs);
+    SSMR3GetS32(pSSM, &pThis->yMouseAbs);
+
+    SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMaskValid);
+    SSMR3GetU32(pSSM, &pThis->fNewGuestFilterMask);
+    SSMR3GetU32(pSSM, &pThis->fGuestFilterMask);
+    SSMR3GetU32(pSSM, &pThis->fHostEventFlags);
 
     //SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
@@ -3992,5 +3996,5 @@
         SSMR3GetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck);
 
-    rc = SSMR3GetU32(pSSM, &pThis->guestCaps);
+    rc = SSMR3GetU32(pSSM, &pThis->fGuestCaps);
 
     /* Attributes which were temporarily introduced in r30072 */
@@ -4068,8 +4072,8 @@
      * that listeners can sync their state again
      */
-    Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
+    Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pThis->fMouseCapabilities));
     if (pThis->pDrv)
     {
-        pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
+        pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);
         if (uVersion >= 10)
             pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
@@ -4106,5 +4110,5 @@
     }
     if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
-        pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
+        pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->fGuestCaps);
 
     return VINF_SUCCESS;
@@ -4167,14 +4171,12 @@
      * Reset the mouse integration feature bits
      */
-    if (pThis->mouseCapabilities & VMMDEV_MOUSE_GUEST_MASK)
-    {
-        pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
+    if (pThis->fMouseCapabilities & VMMDEV_MOUSE_GUEST_MASK)
+    {
+        pThis->fMouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
         /* notify the connector */
-        Log(("vmmdevReset: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
-        pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
+        Log(("vmmdevReset: capabilities changed (%x), informing connector\n", pThis->fMouseCapabilities));
+        pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);
     }
     pThis->fHostCursorRequested = false;
-
-    pThis->hypervisorSize = 0;
 
     /* re-initialize the VMMDev memory */
@@ -4203,6 +4205,6 @@
     memset (&pThis->guestInfo, 0, sizeof (pThis->guestInfo));
     RT_ZERO(pThis->guestInfo2);
-    const bool fCapsChanged = pThis->guestCaps != 0; /* Report transition to 0. */
-    pThis->guestCaps = 0;
+    const bool fCapsChanged = pThis->fGuestCaps != 0; /* Report transition to 0. */
+    pThis->fGuestCaps = 0;
 
     /* Clear facilities. No need to tell Main as it will get a
@@ -4233,5 +4235,5 @@
 
     /* disabled statistics updating */
-    pThis->u32LastStatIntervalSize = 0;
+    pThis->cSecsLastStatInterval = 0;
 
 #ifdef VBOX_WITH_HGCM
@@ -4253,13 +4255,13 @@
      * Clear the event variables.
      *
-     * XXX By design we should NOT clear pThis->u32HostEventFlags because it is designed
+     * XXX By design we should NOT clear pThis->fHostEventFlags because it is designed
      *     that way so host events do not depend on guest resets. However, the pending
      *     event flags actually _were_ cleared since ages so we mask out events from
      *     clearing which we really need to survive the reset. See xtracker 5767.
      */
-    pThis->u32HostEventFlags    &= VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
-    pThis->u32GuestFilterMask    = 0;
-    pThis->u32NewGuestFilterMask = 0;
-    pThis->fNewGuestFilterMask   = 0;
+    pThis->fHostEventFlags    &= VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
+    pThis->fGuestFilterMask    = 0;
+    pThis->fNewGuestFilterMask = 0;
+    pThis->fNewGuestFilterMaskValid   = 0;
 
     /*
@@ -4269,5 +4271,5 @@
         pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
     if (fCapsChanged && pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
-        pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
+        pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->fGuestCaps);
 
     /*
@@ -4704,5 +4706,5 @@
      * changes.
      */
-    pThis->mouseCapabilities |= VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
+    pThis->fMouseCapabilities |= VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
 
     /*
Index: /trunk/src/VBox/Devices/VMMDev/VMMDevState.h
===================================================================
--- /trunk/src/VBox/Devices/VMMDev/VMMDevState.h	(revision 81568)
+++ /trunk/src/VBox/Devices/VMMDev/VMMDevState.h	(revision 81569)
@@ -127,33 +127,26 @@
     PDMCRITSECT         CritSect;
 
-    /** hypervisor address space size */
-    uint32_t hypervisorSize;
-
     /** mouse capabilities of host and guest */
-    uint32_t mouseCapabilities;
-    /** absolute mouse position in pixels */
-    int32_t mouseXAbs;
-    int32_t mouseYAbs;
+    uint32_t            fMouseCapabilities;
+    /** @name Absolute mouse position in pixels
+     * @{ */
+    int32_t             xMouseAbs;
+    int32_t             yMouseAbs;
+    /** @} */
     /** Does the guest currently want the host pointer to be shown? */
-    uint32_t fHostCursorRequested;
-
-#ifdef VBOX_WITH_RAW_MODE_KEEP
-    /** Pointer to device instance - RC pointer. */
-    PPDMDEVINSRC pDevInsRC;
-#else
-    uint32_t u32Alignment0;
-#endif
+    uint32_t            fHostCursorRequested;
+
     /** Pointer to device instance - R3 poitner. */
-    PPDMDEVINSR3 pDevInsR3;
+    PPDMDEVINSR3        pDevInsR3;
     /** Pointer to device instance - R0 pointer. */
-    PPDMDEVINSR0 pDevInsR0;
+    PPDMDEVINSR0        pDevInsR0;
 
     /** LUN\#0 + Status: VMMDev port base interface. */
-    PDMIBASE IBase;
+    PDMIBASE            IBase;
     /** LUN\#0: VMMDev port interface. */
-    PDMIVMMDEVPORT IPort;
+    PDMIVMMDEVPORT      IPort;
 #ifdef VBOX_WITH_HGCM
     /** LUN\#0: HGCM port interface. */
-    PDMIHGCMPORT IHGCMPort;
+    PDMIHGCMPORT        IHGCMPort;
 //# if HC_ARCH_BITS == 32
 //    RTR3PTR      R3PtrAlignment1;
@@ -169,30 +162,28 @@
 #endif
     /** message buffer for backdoor logging. */
-    char szMsg[512];
+    char                szMsg[512];
     /** message buffer index. */
-    uint32_t iMsg;
+    uint32_t            offMsg;
     /** Alignment padding. */
-    uint32_t u32Alignment2;
+    uint32_t            u32Alignment2;
 
     /** Statistics counter for slow IRQ ACK. */
-    STAMCOUNTER StatSlowIrqAck;
+    STAMCOUNTER         StatSlowIrqAck;
     /** Statistics counter for fast IRQ ACK - R3. */
-    STAMCOUNTER StatFastIrqAckR3;
+    STAMCOUNTER         StatFastIrqAckR3;
     /** Statistics counter for fast IRQ ACK - R0 / RC. */
-    STAMCOUNTER StatFastIrqAckRZ;
-    /** IRQ number assigned to the device */
-    uint32_t irq;
-    /** Current host side event flags */
-    uint32_t u32HostEventFlags;
-    /** Mask of events guest is interested in.
+    STAMCOUNTER         StatFastIrqAckRZ;
+    /** Current host side event flags - VMMDEV_EVENT_XXX. */
+    uint32_t            fHostEventFlags;
+    /** Mask of events guest is interested in - VMMDEV_EVENT_XXX.
      * @note The HGCM events are enabled automatically by the VMMDev device when
      *       guest issues HGCM commands. */
-    uint32_t u32GuestFilterMask;
-    /** Delayed mask of guest events */
-    uint32_t u32NewGuestFilterMask;
-    /** Flag whether u32NewGuestFilterMask is valid */
-    bool fNewGuestFilterMask;
+    uint32_t            fGuestFilterMask;
+    /** Delayed mask of guest events - VMMDEV_EVENT_XXX. */
+    uint32_t            fNewGuestFilterMask;
+    /** Flag whether fNewGuestFilterMask is valid */
+    bool                fNewGuestFilterMaskValid;
     /** Alignment padding. */
-    bool afAlignment3[3];
+    bool                afAlignment3[7];
 
     /** GC physical address of VMMDev RAM area */
@@ -211,26 +202,26 @@
     R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3;
     /** GC physical address of VMMDev Heap RAM area */
-    RTGCPHYS32 GCPhysVMMDevHeap;
+    RTGCPHYS32          GCPhysVMMDevHeap;
 
     /** Information reported by guest via VMMDevReportGuestInfo generic request.
      * Until this information is reported the VMMDev refuses any other requests.
      */
-    VBoxGuestInfo guestInfo;
+    VBoxGuestInfo       guestInfo;
     /** Information report \#2, chewed a little. */
     struct
     {
-        uint32_t uFullVersion; /**< non-zero if info is present. */
-        uint32_t uRevision;
-        uint32_t fFeatures;
-        char     szName[128];
-    } guestInfo2;
+        uint32_t            uFullVersion; /**< non-zero if info is present. */
+        uint32_t            uRevision;
+        uint32_t            fFeatures;
+        char                szName[128];
+    }                   guestInfo2;
 
     /** Array of guest facility statuses. */
-    VMMDEVFACILITYSTATUSENTRY   aFacilityStatuses[32];
+    VMMDEVFACILITYSTATUSENTRY aFacilityStatuses[32];
     /** The number of valid entries in the facility status array. */
-    uint32_t                    cFacilityStatuses;
-
-    /** Information reported by guest via VMMDevReportGuestCapabilities. */
-    uint32_t      guestCaps;
+    uint32_t            cFacilityStatuses;
+
+    /** Information reported by guest via VMMDevReportGuestCapabilities - VMMDEV_GUEST_SUPPORTS_XXX. */
+    uint32_t            fGuestCaps;
 
     /** "Additions are Ok" indicator, set to true after processing VMMDevReportGuestInfo,
@@ -238,10 +229,10 @@
      * of the version in guestInfo.
      */
-    uint32_t fu32AdditionsOk;
+    uint32_t            fu32AdditionsOk;
 
     /** Video acceleration status set by guest. */
-    uint32_t u32VideoAccelEnabled;
-
-    DISPLAYCHANGEDATA displayChangeData;
+    uint32_t            u32VideoAccelEnabled;
+
+    DISPLAYCHANGEDATA   displayChangeData;
 
     /** Pointer to the credentials. */
@@ -249,74 +240,74 @@
 
 #if HC_ARCH_BITS == 32
-    uint32_t uAlignment4;
-#endif
-
-    /* memory balloon change request */
-    uint32_t    cMbMemoryBalloon;
+    uint32_t            uAlignment4;
+#endif
+
+    /** memory balloon change request */
+    uint32_t            cMbMemoryBalloon;
     /** The last balloon size queried by the guest additions. */
-    uint32_t    cMbMemoryBalloonLast;
-
-    /* guest ram size */
-    uint64_t    cbGuestRAM;
-
-    /* unique session id; the id will be different after each start, reset or restore of the VM. */
-    uint64_t    idSession;
-
-    /* statistics interval change request */
-    uint32_t    u32StatIntervalSize, u32LastStatIntervalSize;
-
-    /* seamless mode change request */
-    bool fLastSeamlessEnabled, fSeamlessEnabled;
-    bool afAlignment5[1];
-
-    bool fVRDPEnabled;
-    uint32_t uVRDPExperienceLevel;
+    uint32_t            cMbMemoryBalloonLast;
+
+    /** guest ram size */
+    uint64_t            cbGuestRAM;
+
+    /** unique session id; the id will be different after each start, reset or restore of the VM. */
+    uint64_t            idSession;
+
+    /** Statistics interval in seconds.  */
+    uint32_t            cSecsStatInterval;
+    /** The statistics interval last returned to the guest. */
+    uint32_t            cSecsLastStatInterval;
+
+    /** Whether seamless is enabled or not. */
+    bool                fSeamlessEnabled;
+    /** The last fSeamlessEnabled state returned to the guest. */
+    bool                fLastSeamlessEnabled;
+    bool                afAlignment5[1];
+
+    bool                fVRDPEnabled;
+    uint32_t            uVRDPExperienceLevel;
 
 #ifdef VMMDEV_WITH_ALT_TIMESYNC
-    uint64_t hostTime;
-    bool fTimesyncBackdoorLo;
-    bool afAlignment6[2];
+    uint64_t            msLatchedHostTime;
+    bool                fTimesyncBackdoorLo;
+    bool                afAlignment6[2];
 #else
-    bool afAlignment6[1+2];
-#endif
+    bool                afAlignment6[1+2];
+#endif
+
     /** Set if GetHostTime should fail.
      * Loaded from the GetHostTimeDisabled configuration value. */
-    bool fGetHostTimeDisabled;
-
+    bool                fGetHostTimeDisabled;
     /** Set if backdoor logging should be disabled (output will be ignored then) */
-    bool fBackdoorLogDisabled;
-
+    bool                fBackdoorLogDisabled;
     /** Don't clear credentials */
-    bool fKeepCredentials;
-
+    bool                fKeepCredentials;
     /** Heap enabled. */
-    bool fHeapEnabled;
+    bool                fHeapEnabled;
 
     /** Guest Core Dumping enabled. */
-    bool fGuestCoreDumpEnabled;
-
+    bool                fGuestCoreDumpEnabled;
     /** Guest Core Dump location. */
-    char szGuestCoreDumpDir[RTPATH_MAX];
-
+    char                szGuestCoreDumpDir[RTPATH_MAX];
     /** Number of additional cores to keep around. */
-    uint32_t cGuestCoreDumps;
+    uint32_t            cGuestCoreDumps;
 
 #ifdef VBOX_WITH_HGCM
     /** List of pending HGCM requests (VBOXHGCMCMD). */
-    RTLISTANCHORR3 listHGCMCmd;
+    RTLISTANCHORR3      listHGCMCmd;
     /** Critical section to protect the list. */
-    RTCRITSECT critsectHGCMCmdList;
+    RTCRITSECT          critsectHGCMCmdList;
     /** Whether the HGCM events are already automatically enabled. */
-    uint32_t u32HGCMEnabled;
+    uint32_t            u32HGCMEnabled;
     /** Saved state version of restored commands. */
-    uint32_t u32SSMVersion;
-    RTMEMCACHE  hHgcmCmdCache;
-    STAMPROFILE StatHgcmCmdArrival;
-    STAMPROFILE StatHgcmCmdCompletion;
-    STAMPROFILE StatHgcmCmdTotal;
-    STAMCOUNTER StatHgcmLargeCmdAllocs;
-    STAMCOUNTER StatHgcmFailedPageListLocking;
+    uint32_t            u32SSMVersion;
+    RTMEMCACHE          hHgcmCmdCache;
+    STAMPROFILE         StatHgcmCmdArrival;
+    STAMPROFILE         StatHgcmCmdCompletion;
+    STAMPROFILE         StatHgcmCmdTotal;
+    STAMCOUNTER         StatHgcmLargeCmdAllocs;
+    STAMCOUNTER         StatHgcmFailedPageListLocking;
 #endif /* VBOX_WITH_HGCM */
-    STAMCOUNTER StatReqBufAllocs;
+    STAMCOUNTER         StatReqBufAllocs;
 
     /** Per CPU request 4K sized buffers, allocated as needed. */
