Index: /trunk/include/VBox/vmm/pdmifs.h
===================================================================
--- /trunk/include/VBox/vmm/pdmifs.h	(revision 35559)
+++ /trunk/include/VBox/vmm/pdmifs.h	(revision 35560)
@@ -1082,7 +1082,8 @@
      * @thread  The emulation thread.
      * @param   fForce          Force the unmount, even for locked media.
-     * @thread  The emulation thread.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface, bool fForce));
+     * @param   fEject          Eject the medium. Only relevant for host drives.
+     * @thread  The emulation thread.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface, bool fForce, bool fEject));
 
     /**
@@ -1125,5 +1126,5 @@
 } PDMIMOUNT;
 /** PDMIMOUNT interface ID. */
-#define PDMIMOUNT_IID                           "8e5a009a-6032-4ca1-9d86-a388d8eaf926"
+#define PDMIMOUNT_IID                           "34fc7a4c-623a-4806-a6bf-5be1be33c99f"
 
 
Index: /trunk/src/VBox/Devices/Storage/ATAController.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/ATAController.cpp	(revision 35559)
+++ /trunk/src/VBox/Devices/Storage/ATAController.cpp	(revision 35560)
@@ -2288,5 +2288,6 @@
                         PDMCritSectLeave(&pCtl->lock);
                         rc = VMR3ReqCallWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY,
-                                             (PFNRT)s->pDrvMount->pfnUnmount, 2, s->pDrvMount, false);
+                                             (PFNRT)s->pDrvMount->pfnUnmount, 3, s->pDrvMount,
+                                             false /*=fForce*/, true /*=fEeject*/);
                         AssertReleaseRC(rc);
                         {
Index: /trunk/src/VBox/Devices/Storage/DevAHCI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 35559)
+++ /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 35560)
@@ -4039,5 +4039,6 @@
 
                             rc2 = VMR3ReqCallWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY,
-                                                  (PFNRT)pAhciPort->pDrvMount->pfnUnmount, 2, pAhciPort->pDrvMount, false);
+                                                  (PFNRT)pAhciPort->pDrvMount->pfnUnmount, 3,
+                                                  pAhciPort->pDrvMount, false/*=fForce*/, true/*=fEject*/);
                             Assert(RT_SUCCESS(rc2) || (rc == VERR_PDM_MEDIA_LOCKED));
                         }
Index: /trunk/src/VBox/Devices/Storage/DevATA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 35559)
+++ /trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 35560)
@@ -2982,5 +2982,6 @@
                         PDMCritSectLeave(&pCtl->lock);
                         rc = VMR3ReqCallWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY,
-                                             (PFNRT)s->pDrvMount->pfnUnmount, 2, s->pDrvMount, false);
+                                             (PFNRT)s->pDrvMount->pfnUnmount, 3,
+                                             s->pDrvMount /*=fForce*/, true /*=fEject*/);
                         Assert(RT_SUCCESS(rc) || (rc == VERR_PDM_MEDIA_LOCKED));
                         {
Index: /trunk/src/VBox/Devices/Storage/DrvBlock.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DrvBlock.cpp	(revision 35559)
+++ /trunk/src/VBox/Devices/Storage/DrvBlock.cpp	(revision 35560)
@@ -625,5 +625,5 @@
 
 /** @copydoc PDMIMOUNT::pfnUnmount */
-static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce)
+static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce, bool fEject)
 {
     PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
Index: /trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DrvHostBase.cpp	(revision 35559)
+++ /trunk/src/VBox/Devices/Storage/DrvHostBase.cpp	(revision 35560)
@@ -478,5 +478,5 @@
 
 /** @copydoc PDMIMOUNT::pfnUnmount */
-static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface, bool fForce)
+static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface, bool fForce, bool fEject)
 {
      LogFlow(("drvHostBaseUnmount: returns VERR_NOT_SUPPORTED\n"));
Index: /trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp	(revision 35559)
+++ /trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp	(revision 35560)
@@ -127,99 +127,102 @@
 
 /** @copydoc PDMIMOUNT::pfnUnmount */
-static DECLCALLBACK(int) drvHostDvdUnmount(PPDMIMOUNT pInterface, bool fForce)
-{
-     PDRVHOSTBASE pThis = PDMIMOUNT_2_DRVHOSTBASE(pInterface);
-     RTCritSectEnter(&pThis->CritSect);
-
-     /*
-      * Validate state.
-      */
-     int rc = VINF_SUCCESS;
-     if (!pThis->fLocked || fForce)
-     {
+static DECLCALLBACK(int) drvHostDvdUnmount(PPDMIMOUNT pInterface, bool fForce, bool fEject)
+{
+    PDRVHOSTBASE pThis = PDMIMOUNT_2_DRVHOSTBASE(pInterface);
+    RTCritSectEnter(&pThis->CritSect);
+
+    /*
+     * Validate state.
+     */
+    int rc = VINF_SUCCESS;
+    if (!pThis->fLocked || fForce)
+    {
         /* Unlock drive if necessary. */
         if (pThis->fLocked)
             drvHostDvdDoLock(pThis, false);
 
-         /*
-          * Eject the disc.
-          */
+        if (fEject)
+        {
+            /*
+             * Eject the disc.
+             */
 #if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
-         uint8_t abCmd[16] =
-         {
-             SCSI_START_STOP_UNIT, 0, 0, 0, 2 /*eject+stop*/, 0,
-             0,0,0,0,0,0,0,0,0,0
-         };
-         rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMBLOCKTXDIR_NONE, NULL, NULL, NULL, 0, 0);
+            uint8_t abCmd[16] =
+            {
+                SCSI_START_STOP_UNIT, 0, 0, 0, 2 /*eject+stop*/, 0,
+                0,0,0,0,0,0,0,0,0,0
+            };
+            rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMBLOCKTXDIR_NONE, NULL, NULL, NULL, 0, 0);
 
 #elif defined(RT_OS_LINUX)
-         rc = ioctl(pThis->FileDevice, CDROMEJECT, 0);
-         if (rc < 0)
-         {
-             if (errno == EBUSY)
-                 rc = VERR_PDM_MEDIA_LOCKED;
-             else if (errno == ENOSYS)
-                 rc = VERR_NOT_SUPPORTED;
-             else
-                 rc = RTErrConvertFromErrno(errno);
-         }
+            rc = ioctl(pThis->FileDevice, CDROMEJECT, 0);
+            if (rc < 0)
+            {
+                if (errno == EBUSY)
+                    rc = VERR_PDM_MEDIA_LOCKED;
+                else if (errno == ENOSYS)
+                    rc = VERR_NOT_SUPPORTED;
+                else
+                    rc = RTErrConvertFromErrno(errno);
+            }
 
 #elif defined(RT_OS_SOLARIS)
-        rc = ioctl(pThis->FileRawDevice, DKIOCEJECT, 0);
-        if (rc < 0)
-        {
-            if (errno == EBUSY)
-                rc = VERR_PDM_MEDIA_LOCKED;
-            else if (errno == ENOSYS || errno == ENOTSUP)
-                rc = VERR_NOT_SUPPORTED;
-            else if (errno == ENODEV)
-                rc = VERR_PDM_MEDIA_NOT_MOUNTED;
+            rc = ioctl(pThis->FileRawDevice, DKIOCEJECT, 0);
+            if (rc < 0)
+            {
+                if (errno == EBUSY)
+                    rc = VERR_PDM_MEDIA_LOCKED;
+                else if (errno == ENOSYS || errno == ENOTSUP)
+                    rc = VERR_NOT_SUPPORTED;
+                else if (errno == ENODEV)
+                    rc = VERR_PDM_MEDIA_NOT_MOUNTED;
+                else
+                    rc = RTErrConvertFromErrno(errno);
+            }
+
+#elif defined(RT_OS_WINDOWS)
+            RTFILE FileDevice = pThis->FileDevice;
+            if (FileDevice == NIL_RTFILE) /* obsolete crap */
+                rc = RTFileOpen(&FileDevice, pThis->pszDeviceOpen, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
+            if (RT_SUCCESS(rc))
+            {
+                /* do ioctl */
+                DWORD cbReturned;
+                if (DeviceIoControl((HANDLE)FileDevice, IOCTL_STORAGE_EJECT_MEDIA,
+                                    NULL, 0,
+                                    NULL, 0, &cbReturned,
+                                    NULL))
+                    rc = VINF_SUCCESS;
+                else
+                    rc = RTErrConvertFromWin32(GetLastError());
+
+                /* clean up handle */
+                if (FileDevice != pThis->FileDevice)
+                    RTFileClose(FileDevice);
+            }
             else
-                rc = RTErrConvertFromErrno(errno);
+                AssertMsgFailed(("Failed to open '%s' for ejecting this tray.\n",  rc));
+
+
+#else
+            AssertMsgFailed(("Eject is not implemented!\n"));
+            rc = VINF_SUCCESS;
+#endif
         }
 
-#elif defined(RT_OS_WINDOWS)
-         RTFILE FileDevice = pThis->FileDevice;
-         if (FileDevice == NIL_RTFILE) /* obsolete crap */
-             rc = RTFileOpen(&FileDevice, pThis->pszDeviceOpen, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
-         if (RT_SUCCESS(rc))
-         {
-             /* do ioctl */
-             DWORD cbReturned;
-             if (DeviceIoControl((HANDLE)FileDevice, IOCTL_STORAGE_EJECT_MEDIA,
-                                 NULL, 0,
-                                 NULL, 0, &cbReturned,
-                                 NULL))
-                 rc = VINF_SUCCESS;
-             else
-                 rc = RTErrConvertFromWin32(GetLastError());
-
-             /* clean up handle */
-             if (FileDevice != pThis->FileDevice)
-                 RTFileClose(FileDevice);
-         }
-         else
-             AssertMsgFailed(("Failed to open '%s' for ejecting this tray.\n",  rc));
-
-
-#else
-         AssertMsgFailed(("Eject is not implemented!\n"));
-         rc = VINF_SUCCESS;
-#endif
-
-         /*
-          * Media is no longer present.
-          */
-         DRVHostBaseMediaNotPresent(pThis);  /** @todo This isn't thread safe! */
-     }
-     else
-     {
-         Log(("drvHostDvdUnmount: Locked\n"));
-         rc = VERR_PDM_MEDIA_LOCKED;
-     }
-
-     RTCritSectLeave(&pThis->CritSect);
-     LogFlow(("drvHostDvdUnmount: returns %Rrc\n", rc));
-     return rc;
+        /*
+         * Media is no longer present.
+         */
+        DRVHostBaseMediaNotPresent(pThis);  /** @todo This isn't thread safe! */
+    }
+    else
+    {
+        Log(("drvHostDvdUnmount: Locked\n"));
+        rc = VERR_PDM_MEDIA_LOCKED;
+    }
+
+    RTCritSectLeave(&pThis->CritSect);
+    LogFlow(("drvHostDvdUnmount: returns %Rrc\n", rc));
+    return rc;
 }
 
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 35559)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 35560)
@@ -2711,8 +2711,11 @@
                         AssertReturn(pIMount, VERR_INVALID_POINTER);
 
-                        /* Unmount the media. */
-                        rc = pIMount->pfnUnmount(pIMount, fForceUnmount);
+                        /* Unmount the media (but do not eject the medium!) */
+                        rc = pIMount->pfnUnmount(pIMount, fForceUnmount, false /*=fEject*/);
                         if (rc == VERR_PDM_MEDIA_NOT_MOUNTED)
                             rc = VINF_SUCCESS;
+                        /* for example if the medium is locked */
+                        else if (RT_FAILURE(rc))
+                            return rc;
                     }
                 }
