Index: trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
===================================================================
--- trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp	(revision 50327)
+++ trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp	(revision 50328)
@@ -1795,5 +1795,5 @@
 #include <iprt/mem.h>
 
-static void *vmsvgaFIFOGetCmdBuffer(uint32_t *pFIFO, uint32_t cbCmd, uint32_t *pSize, void **ppfBounceBuffer)
+static void *vmsvgaFIFOGetCmdBuffer(PPDMTHREAD pThread, uint32_t *pFIFO, uint32_t cbCmd, uint32_t *pSize, void **ppfBounceBuffer)
 {
     uint32_t cbLeft;
@@ -1807,5 +1807,5 @@
     *ppfBounceBuffer = NULL;
 
-    while (true)
+    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
     {
         Assert(pFIFO[SVGA_FIFO_NEXT_CMD] != pFIFO[SVGA_FIFO_STOP]);
@@ -1941,5 +1941,5 @@
             case SVGA_CMD_FENCE:
             {                
-                SVGAFifoCmdFence *pCmdFence = (SVGAFifoCmdFence *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdFence), &size, &pBounceBuffer);
+                SVGAFifoCmdFence *pCmdFence = (SVGAFifoCmdFence *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdFence), &size, &pBounceBuffer);
 
                 Log(("vmsvgaFIFOLoop: SVGA_CMD_FENCE %x\n", pCmdFence->fence));
@@ -1962,5 +1962,5 @@
             case SVGA_CMD_UPDATE_VERBOSE:
             {
-                SVGAFifoCmdUpdate *pUpdate = (SVGAFifoCmdUpdate *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdUpdate), &size, &pBounceBuffer);
+                SVGAFifoCmdUpdate *pUpdate = (SVGAFifoCmdUpdate *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdUpdate), &size, &pBounceBuffer);
 
                 Log(("vmsvgaFIFOLoop: UPDATE (%d,%d)(%d,%d)\n", pUpdate->x, pUpdate->y, pUpdate->width, pUpdate->height));
@@ -1972,5 +1972,5 @@
             {
                 /* Followed by bitmap data. */
-                SVGAFifoCmdDefineCursor *pCursor = (SVGAFifoCmdDefineCursor *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdDefineCursor), &size, &pBounceBuffer);
+                SVGAFifoCmdDefineCursor *pCursor = (SVGAFifoCmdDefineCursor *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdDefineCursor), &size, &pBounceBuffer);
 
                 AssertFailed();
@@ -1981,5 +1981,5 @@
             {
                 /* Followed by bitmap data. */
-                SVGAFifoCmdDefineAlphaCursor *pCursor = (SVGAFifoCmdDefineAlphaCursor *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdDefineAlphaCursor), &size, &pBounceBuffer);
+                SVGAFifoCmdDefineAlphaCursor *pCursor = (SVGAFifoCmdDefineAlphaCursor *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdDefineAlphaCursor), &size, &pBounceBuffer);
                 uint32_t cbCursorShape, cbAndMask;
                 uint8_t *pCursorCopy;
@@ -1993,5 +1993,5 @@
                 if (pBounceBuffer)
                     RTMemFree(pBounceBuffer);
-                pCursor = (SVGAFifoCmdDefineAlphaCursor *)vmsvgaFIFOGetCmdBuffer(pFIFO, cbCmd, &size, &pBounceBuffer);
+                pCursor = (SVGAFifoCmdDefineAlphaCursor *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, cbCmd, &size, &pBounceBuffer);
 
                 /* The mouse pointer interface always expects an AND mask followed by the color data (XOR mask). */
@@ -2027,5 +2027,5 @@
             {
                 /* Followed by nsize bytes of data. */
-                SVGAFifoCmdEscape *pEscape = (SVGAFifoCmdEscape *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdEscape), &size, &pBounceBuffer);
+                SVGAFifoCmdEscape *pEscape = (SVGAFifoCmdEscape *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdEscape), &size, &pBounceBuffer);
                 uint32_t cbCmd;
 
@@ -2035,5 +2035,5 @@
                 if (pBounceBuffer)
                     RTMemFree(pBounceBuffer);
-                pEscape = (SVGAFifoCmdEscape *)vmsvgaFIFOGetCmdBuffer(pFIFO, cbCmd, &size, &pBounceBuffer);
+                pEscape = (SVGAFifoCmdEscape *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, cbCmd, &size, &pBounceBuffer);
 
                 if (pEscape->nsid == SVGA_ESCAPE_NSID_VMWARE)
@@ -2072,5 +2072,5 @@
             case SVGA_CMD_DEFINE_GMR2:
             {
-                SVGAFifoCmdDefineGMR2 *pCmd = (SVGAFifoCmdDefineGMR2 *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdDefineGMR2), &size, &pBounceBuffer);
+                SVGAFifoCmdDefineGMR2 *pCmd = (SVGAFifoCmdDefineGMR2 *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdDefineGMR2), &size, &pBounceBuffer);
                 Log(("vmsvgaFIFOLoop: SVGA_CMD_DEFINE_GMR2 id=%x %x pages\n", pCmd->gmrId, pCmd->numPages));
 
@@ -2089,5 +2089,5 @@
             {
                 /* Followed by page descriptors. */
-                SVGAFifoCmdRemapGMR2 *pCmd = (SVGAFifoCmdRemapGMR2 *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdRemapGMR2), &size, &pBounceBuffer);
+                SVGAFifoCmdRemapGMR2 *pCmd = (SVGAFifoCmdRemapGMR2 *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdRemapGMR2), &size, &pBounceBuffer);
                 uint32_t cbPageDesc = (pCmd->flags & SVGA_REMAP_GMR2_PPN64) ? sizeof(uint64_t) : sizeof(uint32_t);
                 uint32_t cbCmd;
@@ -2114,5 +2114,5 @@
                 if (pBounceBuffer)
                     RTMemFree(pBounceBuffer);
-                pCmd = (SVGAFifoCmdRemapGMR2 *)vmsvgaFIFOGetCmdBuffer(pFIFO, cbCmd, &size, &pBounceBuffer);
+                pCmd = (SVGAFifoCmdRemapGMR2 *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, cbCmd, &size, &pBounceBuffer);
                 AssertReturn(pCmd, VERR_INTERNAL_ERROR);
 
@@ -2188,5 +2188,5 @@
                 /* @note optional size depending on the capabilities */
                 Assert(!(pThis->svga.pFIFOR3[SVGA_FIFO_CAPABILITIES] & SVGA_FIFO_CAP_SCREEN_OBJECT));
-                SVGAFifoCmdDefineScreen *pCmd = (SVGAFifoCmdDefineScreen *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdDefineScreen), &size, &pBounceBuffer);
+                SVGAFifoCmdDefineScreen *pCmd = (SVGAFifoCmdDefineScreen *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdDefineScreen), &size, &pBounceBuffer);
 
                 Log(("vmsvgaFIFOLoop: SVGA_CMD_DEFINE_SCREEN id=%x flags=%x size=(%d,%d) root=(%d,%d)\n", pCmd->screen.id, pCmd->screen.flags, pCmd->screen.size.width, pCmd->screen.size.height, pCmd->screen.root.x, pCmd->screen.root.y));
@@ -2210,5 +2210,5 @@
             case SVGA_CMD_DESTROY_SCREEN:
             {
-                SVGAFifoCmdDestroyScreen *pCmd = (SVGAFifoCmdDestroyScreen *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdDestroyScreen), &size, &pBounceBuffer);
+                SVGAFifoCmdDestroyScreen *pCmd = (SVGAFifoCmdDestroyScreen *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdDestroyScreen), &size, &pBounceBuffer);
 
                 Log(("vmsvgaFIFOLoop: SVGA_CMD_DESTROY_SCREEN id=%x\n", pCmd->screenId));
@@ -2218,5 +2218,5 @@
             case SVGA_CMD_DEFINE_GMRFB:
             {
-                SVGAFifoCmdDefineGMRFB *pCmd = (SVGAFifoCmdDefineGMRFB *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdDefineGMRFB), &size, &pBounceBuffer);
+                SVGAFifoCmdDefineGMRFB *pCmd = (SVGAFifoCmdDefineGMRFB *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdDefineGMRFB), &size, &pBounceBuffer);
 
                 Log(("vmsvgaFIFOLoop: SVGA_CMD_DEFINE_GMRFB gmr=%x offset=%x bytesPerLine=%x bpp=%d color depth=%d\n", pCmd->ptr.gmrId, pCmd->ptr.offset, pCmd->bytesPerLine, pCmd->format.s.bitsPerPixel, pCmd->format.s.colorDepth));
@@ -2229,5 +2229,5 @@
             case SVGA_CMD_BLIT_GMRFB_TO_SCREEN:
             {
-                SVGAFifoCmdBlitGMRFBToScreen *pCmd = (SVGAFifoCmdBlitGMRFBToScreen *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdBlitGMRFBToScreen), &size, &pBounceBuffer);
+                SVGAFifoCmdBlitGMRFBToScreen *pCmd = (SVGAFifoCmdBlitGMRFBToScreen *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdBlitGMRFBToScreen), &size, &pBounceBuffer);
                 int32_t width, height;
 
@@ -2273,5 +2273,5 @@
             case SVGA_CMD_BLIT_SCREEN_TO_GMRFB:
             {
-                SVGAFifoCmdBlitScreenToGMRFB *pCmd = (SVGAFifoCmdBlitScreenToGMRFB *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdBlitScreenToGMRFB), &size, &pBounceBuffer);
+                SVGAFifoCmdBlitScreenToGMRFB *pCmd = (SVGAFifoCmdBlitScreenToGMRFB *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdBlitScreenToGMRFB), &size, &pBounceBuffer);
 
                 /* @note this can fetch 3d render results as well!! */
@@ -2283,5 +2283,5 @@
             case SVGA_CMD_ANNOTATION_FILL:
             {
-                SVGAFifoCmdAnnotationFill *pCmd = (SVGAFifoCmdAnnotationFill *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdAnnotationFill), &size, &pBounceBuffer);
+                SVGAFifoCmdAnnotationFill *pCmd = (SVGAFifoCmdAnnotationFill *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdAnnotationFill), &size, &pBounceBuffer);
 
                 Log(("vmsvgaFIFOLoop: SVGA_CMD_ANNOTATION_FILL red=%x green=%x blue=%x\n", pCmd->color.s.r, pCmd->color.s.g, pCmd->color.s.b));
@@ -2292,5 +2292,5 @@
             case SVGA_CMD_ANNOTATION_COPY:
             {
-                SVGAFifoCmdAnnotationCopy *pCmd = (SVGAFifoCmdAnnotationCopy*)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGAFifoCmdAnnotationCopy), &size, &pBounceBuffer);
+                SVGAFifoCmdAnnotationCopy *pCmd = (SVGAFifoCmdAnnotationCopy*)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGAFifoCmdAnnotationCopy), &size, &pBounceBuffer);
 
                 Log(("vmsvgaFIFOLoop: SVGA_CMD_ANNOTATION_COPY\n"));
@@ -2305,5 +2305,5 @@
                 {
                     /* All 3d commands start with a common header, which defines the size of the command. */
-                    SVGA3dCmdHeader *pHdr = (SVGA3dCmdHeader *)vmsvgaFIFOGetCmdBuffer(pFIFO, sizeof(SVGA3dCmdHeader), &size, &pBounceBuffer);
+                    SVGA3dCmdHeader *pHdr = (SVGA3dCmdHeader *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, sizeof(SVGA3dCmdHeader), &size, &pBounceBuffer);
                     uint32_t cbCmd;
 
@@ -2313,5 +2313,5 @@
                     if (pBounceBuffer)
                         RTMemFree(pBounceBuffer);
-                    pHdr = (SVGA3dCmdHeader *)vmsvgaFIFOGetCmdBuffer(pFIFO, cbCmd, &size, &pBounceBuffer);
+                    pHdr = (SVGA3dCmdHeader *)vmsvgaFIFOGetCmdBuffer(pThread, pFIFO, cbCmd, &size, &pBounceBuffer);
 
                     switch (pFIFO[u32Cmd])
