Index: trunk/src/VBox/Devices/Serial/UartCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Serial/UartCore.cpp	(revision 74754)
+++ trunk/src/VBox/Devices/Serial/UartCore.cpp	(revision 74919)
@@ -731,4 +731,47 @@
     }
 
+}
+
+
+/**
+ * Tries to copy the specified amount of data from the active TX queue (register or FIFO).
+ *
+ * @returns nothing.
+ * @param   pThis               The serial port instance.
+ * @param   pvBuf               Where to store the data.
+ * @param   cbRead              How much to read from the TX queue.
+ * @param   pcbRead             Where to store the amount of data read.
+ */
+static void uartR3TxQueueCopyFrom(PUARTCORE pThis, void *pvBuf, size_t cbRead, size_t *pcbRead)
+{
+    if (pThis->uRegFcr & UART_REG_FCR_FIFO_EN)
+    {
+        *pcbRead = uartFifoCopyTo(&pThis->FifoXmit, pvBuf, cbRead);
+        if (!pThis->FifoXmit.cbUsed)
+        {
+            UART_REG_SET(pThis->uRegLsr, UART_REG_LSR_THRE);
+            pThis->fThreEmptyPending = true;
+        }
+        if (*pcbRead)
+            UART_REG_CLR(pThis->uRegLsr, UART_REG_LSR_TEMT);
+        uartIrqUpdate(pThis);
+    }
+    else if (!(pThis->uRegLsr & UART_REG_LSR_THRE))
+    {
+        *(uint8_t *)pvBuf = pThis->uRegThr;
+        *pcbRead = 1;
+        UART_REG_SET(pThis->uRegLsr, UART_REG_LSR_THRE);
+        UART_REG_CLR(pThis->uRegLsr, UART_REG_LSR_TEMT);
+        pThis->fThreEmptyPending = true;
+        uartIrqUpdate(pThis);
+    }
+    else
+    {
+        /*
+         * This can happen if there was data in the FIFO when the connection was closed,
+         * indicate this condition to the lower driver by returning 0 bytes.
+         */
+        *pcbRead = 0;
+    }
 }
 #endif
@@ -803,4 +846,6 @@
                         LogRelMax(10, ("Serial#%d: Failed to send data with %Rrc\n", pThis->pDevInsR3->iInstance, rc2));
                 }
+                else
+                    TMTimerSetRelative(pThis->CTX_SUFF(pTimerTxUnconnected), pThis->cSymbolXferTicks, NULL);
 #endif
             }
@@ -1377,4 +1422,21 @@
 }
 
+/**
+ * @callback_method_impl{FNTMTIMERDEV, TX timer function when there is no driver connected for draining the THR/FIFO.}
+ */
+static DECLCALLBACK(void) uartR3TxUnconnectedTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
+{
+    LogFlowFunc(("pDevIns=%#p pTimer=%#p pvUser=%#p\n", pDevIns, pTimer, pvUser));
+    RT_NOREF(pDevIns, pTimer);
+    PUARTCORE pThis = (PUARTCORE)pvUser;
+    PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
+    uint8_t bIgnore = 0;
+    size_t cbRead = 0;
+    uartR3TxQueueCopyFrom(pThis, &bIgnore, sizeof(uint8_t), &cbRead);
+    if (cbRead == 1)
+        TMTimerSetRelative(pThis->CTX_SUFF(pTimerTxUnconnected), pThis->cSymbolXferTicks, NULL);
+    PDMCritSectLeave(&pThis->CritSect);
+}
+
 
 /* -=-=-=-=-=-=-=-=- PDMISERIALPORT on LUN#0 -=-=-=-=-=-=-=-=- */
@@ -1438,33 +1500,5 @@
 
     PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
-    if (pThis->uRegFcr & UART_REG_FCR_FIFO_EN)
-    {
-        *pcbRead = uartFifoCopyTo(&pThis->FifoXmit, pvBuf, cbRead);
-        if (!pThis->FifoXmit.cbUsed)
-        {
-            UART_REG_SET(pThis->uRegLsr, UART_REG_LSR_THRE);
-            pThis->fThreEmptyPending = true;
-        }
-        if (*pcbRead)
-            UART_REG_CLR(pThis->uRegLsr, UART_REG_LSR_TEMT);
-        uartIrqUpdate(pThis);
-    }
-    else if (!(pThis->uRegLsr & UART_REG_LSR_THRE))
-    {
-        *(uint8_t *)pvBuf = pThis->uRegThr;
-        *pcbRead = 1;
-        UART_REG_SET(pThis->uRegLsr, UART_REG_LSR_THRE);
-        UART_REG_CLR(pThis->uRegLsr, UART_REG_LSR_TEMT);
-        pThis->fThreEmptyPending = true;
-        uartIrqUpdate(pThis);
-    }
-    else
-    {
-        /*
-         * This can happen if there was data in the FIFO when the connection was closed,
-         * idicate this condition to the lower driver by returning 0 bytes.
-         */
-        *pcbRead = 0;
-    }
+    uartR3TxQueueCopyFrom(pThis, pvBuf, cbRead, pcbRead);
     PDMCritSectLeave(&pThis->CritSect);
 
@@ -1539,5 +1573,9 @@
     SSMR3PutU8(pSSM,   pThis->FifoRecv.cbItl);
 
-    return TMR3TimerSave(pThis->pTimerRcvFifoTimeoutR3, pSSM);
+    int rc = TMR3TimerSave(pThis->pTimerRcvFifoTimeoutR3, pSSM);
+    if (RT_SUCCESS(rc))
+        rc = TMR3TimerSave(pThis->pTimerTxUnconnectedR3, pSSM);
+
+    return rc;
 }
 
@@ -1570,4 +1608,6 @@
 
         TMR3TimerLoad(pThis->pTimerRcvFifoTimeoutR3, pSSM);
+        if (uVersion > UART_SAVED_STATE_VERSION_PRE_UNCONNECTED_TX_TIMER)
+            TMR3TimerLoad(pThis->pTimerTxUnconnectedR3, pSSM);
     }
     else
@@ -1665,4 +1705,5 @@
     pThis->pDevInsRC              = PDMDEVINS_2_RCPTR(pThis->pDevInsR3);
     pThis->pTimerRcvFifoTimeoutRC = TMTimerRCPtr(pThis->pTimerRcvFifoTimeoutR3);
+    pThis->pTimerTxUnconnectedRC  = TMTimerRCPtr(pThis->pTimerTxUnconnectedR3);
 }
 
@@ -1810,4 +1851,18 @@
     pThis->pTimerRcvFifoTimeoutRC = TMTimerRCPtr(pThis->pTimerRcvFifoTimeoutR3);
 
+    /*
+     * Create the transmit timer when no device is connected.
+     */
+    rc = PDMDevHlpTMTimerCreate(pDevInsR3, TMCLOCK_VIRTUAL, uartR3TxUnconnectedTimer, pThis,
+                                TMTIMER_FLAGS_NO_CRIT_SECT, "UART TX uncon. Timer",
+                                &pThis->pTimerTxUnconnectedR3);
+    AssertRCReturn(rc, rc);
+
+    rc = TMR3TimerSetCritSect(pThis->pTimerTxUnconnectedR3, &pThis->CritSect);
+    AssertRCReturn(rc, rc);
+
+    pThis->pTimerTxUnconnectedR0 = TMTimerR0Ptr(pThis->pTimerTxUnconnectedR3);
+    pThis->pTimerTxUnconnectedRC = TMTimerRCPtr(pThis->pTimerTxUnconnectedR3);
+
     uartR3Reset(pThis);
     return VINF_SUCCESS;
Index: trunk/src/VBox/Devices/Serial/UartCore.h
===================================================================
--- trunk/src/VBox/Devices/Serial/UartCore.h	(revision 74754)
+++ trunk/src/VBox/Devices/Serial/UartCore.h	(revision 74919)
@@ -33,11 +33,13 @@
 
 /** The current serial code saved state version. */
-#define UART_SAVED_STATE_VERSION              6
+#define UART_SAVED_STATE_VERSION                                        7
+/** Saved state version before the TX timer for the connected device case was added. */
+#define UART_SAVED_STATE_VERSION_PRE_UNCONNECTED_TX_TIMER               6
 /** Saved state version of the legacy code which got replaced after 5.2. */
-#define UART_SAVED_STATE_VERSION_LEGACY_CODE  5
+#define UART_SAVED_STATE_VERSION_LEGACY_CODE                            5
 /** Includes some missing bits from the previous saved state. */
-#define UART_SAVED_STATE_VERSION_MISSING_BITS 4
+#define UART_SAVED_STATE_VERSION_MISSING_BITS                           4
 /** Saved state version when only the 16450 variant was implemented. */
-#define UART_SAVED_STATE_VERSION_16450        3
+#define UART_SAVED_STATE_VERSION_16450                                  3
 
 /** Maximum size of a FIFO. */
@@ -140,16 +142,24 @@
     UARTTYPE                        enmType;
 
-    /** R3 timer pointer fo the character timeout indication. */
+    /** R3 timer pointer for the character timeout indication. */
     PTMTIMERR3                      pTimerRcvFifoTimeoutR3;
+    /** R3 timer pointer for the send loop if no driver is connected. */
+    PTMTIMERR3                      pTimerTxUnconnectedR3;
     /** R3 interrupt request callback of the owning device. */
     R3PTRTYPE(PFNUARTCOREIRQREQ)    pfnUartIrqReqR3;
     /** R0 timer pointer fo the character timeout indication. */
     PTMTIMERR0                      pTimerRcvFifoTimeoutR0;
+    /** R0 timer pointer for the send loop if no driver is connected. */
+    PTMTIMERR0                      pTimerTxUnconnectedR0;
     /** R0 interrupt request callback of the owning device. */
     R0PTRTYPE(PFNUARTCOREIRQREQ)    pfnUartIrqReqR0;
     /** RC timer pointer fo the character timeout indication. */
     PTMTIMERRC                      pTimerRcvFifoTimeoutRC;
-        /** RC interrupt request callback of the owning device. */
+    /** RC timer pointer for the send loop if no driver is connected. */
+    PTMTIMERRC                      pTimerTxUnconnectedRC;
+    /** RC interrupt request callback of the owning device. */
     RCPTRTYPE(PFNUARTCOREIRQREQ)    pfnUartIrqReqRC;
+    /** Alignment */
+    uint32_t                        u32Alignment;
 
     /** The divisor register (DLAB = 1). */
@@ -187,5 +197,5 @@
     /** Alignment. */
     bool                            afAlignment[2];
-        /** The transmit FIFO. */
+    /** The transmit FIFO. */
     UARTFIFO                        FifoXmit;
     /** The receive FIFO. */
