Index: /trunk/src/VBox/Devices/Storage/DevAHCI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 36989)
+++ /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 36990)
@@ -1905,4 +1905,5 @@
     pAhciPort->regIE   = 0;
     pAhciPort->regCMD  = AHCI_PORT_CMD_CPD  | /* Cold presence detection */
+                         AHCI_PORT_CMD_HPCP | /* Hotplugging supported. */
                          AHCI_PORT_CMD_SUD  | /* Device has spun up. */
                          AHCI_PORT_CMD_POD;   /* Port is powered on. */
@@ -7925,4 +7926,19 @@
         ahciMediumRemoved(pAhciPort);
 
+    if (!(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG))
+    {
+        /*
+         * Inform the guest about the removed device.
+         */
+        pAhciPort->regSSTS = 0;
+        ASMAtomicAndU32(&pAhciPort->regCMD, ~AHCI_PORT_CMD_CPS);
+        ASMAtomicOrU32(&pAhciPort->regIS, AHCI_PORT_IS_CPDS | AHCI_PORT_IS_PRCS);
+        ASMAtomicOrU32(&pAhciPort->regSERR, AHCI_PORT_SERR_N);
+        if (   (pAhciPort->regIE & AHCI_PORT_IE_CPDE)
+            || (pAhciPort->regIE & AHCI_PORT_IE_PCE)
+            || (pAhciPort->regIE & AHCI_PORT_IE_PRCE))
+            ahciHbaSetInterrupt(pAhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);
+    }
+
     /*
      * Zero some important members.
@@ -8030,4 +8046,20 @@
             if (RT_SUCCESS(rc) && pAhciPort->fATAPI)
                 ahciMediumInserted(pAhciPort);
+
+            /* Inform the guest about the added device in case of hotplugging. */
+            if (   RT_SUCCESS(rc)
+                && !(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG))
+            {
+                /*
+                 * Initialize registers
+                 */
+                ASMAtomicOrU32(&pAhciPort->regCMD, AHCI_PORT_CMD_CPS);
+                ASMAtomicOrU32(&pAhciPort->regIS, AHCI_PORT_IS_CPDS | AHCI_PORT_IS_PRCS | AHCI_PORT_IS_PCS);
+                ASMAtomicOrU32(&pAhciPort->regSERR, AHCI_PORT_SERR_X | AHCI_PORT_SERR_N);
+                if (   (pAhciPort->regIE & AHCI_PORT_IE_CPDE)
+                    || (pAhciPort->regIE & AHCI_PORT_IE_PCE)
+                    || (pAhciPort->regIE & AHCI_PORT_IE_PRCE))
+                    ahciHbaSetInterrupt(pAhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);
+            }
         }
     }
