Index: /trunk/src/VBox/Devices/Graphics/DevVGA.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 24052)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 24053)
@@ -458,4 +458,5 @@
 int      VBVAUpdateDisplay (PVGASTATE pVGAState);
 void     VBVAReset (PVGASTATE pVGAState);
+void     HGSMIReset (PHGSMIINSTANCE pIns);
 
 # ifdef VBOX_WITH_VIDEOHWACCEL
@@ -463,4 +464,5 @@
 int vbvaVHWAConstruct (PVGASTATE pVGAState);
 int vbvaVHWADisable (PVGASTATE pVGAState);
+int vbvaVHWAReset (PVGASTATE pVGAState);
 
 int vboxVBVASaveStatePrep (PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
Index: /trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp	(revision 24052)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp	(revision 24053)
@@ -945,4 +945,24 @@
 }
 
+int vbvaVHWAReset (PVGASTATE pVGAState)
+{
+    /* ensure we have all pending cmds processed and h->g cmds disabled */
+    VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(pVGAState, VBOXVHWACMD_TYPE_DISABLE, 0);
+    Assert(pCmd);
+    if(pCmd)
+    {
+        int rc = vbvaVHWAHHCommandPost(pVGAState, pCmd);
+        Assert(RT_SUCCESS(rc));
+        if(RT_SUCCESS(rc))
+        {
+            rc = pCmd->rc;
+            Assert(RT_SUCCESS(rc));
+            vbvaVHWAHHCommandRelease(pCmd);
+        }
+        return rc;
+    }
+    return VERR_OUT_OF_RESOURCES;
+}
+
 /* @todo call this also on reset? */
 int vbvaVHWADisable (PVGASTATE pVGAState)
@@ -1346,4 +1366,10 @@
     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
 
+#ifdef VBOX_WITH_VIDEOHWACCEL
+    vbvaVHWAReset (pVGAState);
+#endif
+
+    HGSMIReset (pVGAState->pHGSMI);
+
     if (pCtx)
     {
@@ -1357,4 +1383,5 @@
         }
     }
+
 }
 
Index: /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp	(revision 24052)
+++ /trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp	(revision 24053)
@@ -346,14 +346,8 @@
 }
 
-
-/* The the guest has finished processing of a buffer previously submitted by the host.
- * Called from HGSMI_IO_HOST write handler.
- * @thread EMT
- */
-void HGSMIHostWrite (HGSMIINSTANCE *pIns,
-                     HGSMIOFFSET offBuffer)
-{
-    LogFlowFunc(("pIns %p offBuffer 0x%x\n", pIns, offBuffer));
-
+static bool hgsmiProcessHostCmdCompletion (HGSMIINSTANCE *pIns,
+                     HGSMIOFFSET offBuffer,
+                     bool bCompleteFirst)
+{
     VM_ASSERT_EMT(pIns->pVM);
 
@@ -369,5 +363,5 @@
             Assert(pEntry->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_READ));
 
-            if (pEntry->offBuffer == offBuffer)
+            if (bCompleteFirst || pEntry->offBuffer == offBuffer)
             {
                 break;
@@ -386,5 +380,5 @@
         LogFlowFunc(("read list entry: %p.\n", pEntry));
 
-        Assert(pEntry);
+        Assert(pEntry || bCompleteFirst);
 
         if (pEntry)
@@ -409,11 +403,24 @@
             hgsmiHostCommandFreeCallback(pEntry);
 #endif
-        }
-        else
-        {
-            hgsmiFIFOUnlock(pIns);
+            return true;
+        }
+
+        hgsmiFIFOUnlock(pIns);
+        if(!bCompleteFirst)
             LogRel(("HGSMI[%s]: ignored invalid write to the host FIFO: 0x%08X!!!\n", pIns->pszName, offBuffer));
-        }
-    }
+    }
+    return false;
+}
+
+/* The the guest has finished processing of a buffer previously submitted by the host.
+ * Called from HGSMI_IO_HOST write handler.
+ * @thread EMT
+ */
+void HGSMIHostWrite (HGSMIINSTANCE *pIns,
+                     HGSMIOFFSET offBuffer)
+{
+    LogFlowFunc(("pIns %p offBuffer 0x%x\n", pIns, offBuffer));
+
+    hgsmiProcessHostCmdCompletion (pIns, offBuffer, false);
 }
 
@@ -1531,4 +1538,11 @@
 }
 
+void HGSMIReset (PHGSMIINSTANCE pIns)
+{
+    while(hgsmiProcessHostCmdCompletion (pIns, 0, true)) {}
+
+    HGSMIHeapSetupUnitialized (&pIns->hostHeap);
+}
+
 void HGSMIDestroy (PHGSMIINSTANCE pIns)
 {
