Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 24726)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 24727)
@@ -2726,4 +2726,6 @@
                         aDevice, aControllerPort, aControllerName);
 
+    ComObjPtr<Medium> oldmedium = pAttach->medium();
+    DeviceType_T mediumType = pAttach->type();
 
     if (pAttach->isImplicit())
@@ -2744,6 +2746,5 @@
         alock.leave();
 
-        ComObjPtr<Medium> hd = pAttach->medium();
-        rc = hd->deleteStorageAndWait();
+        rc = oldmedium->deleteStorageAndWait();
 
         alock.enter();
@@ -2760,4 +2761,8 @@
      * still refers to the original and is not valid for the copy */
     mMediaData->mAttachments.remove(pAttach);
+
+    /* For non-hard disk media, detach straight away. */
+    if (mediumType != DeviceType_HardDisk && !oldmedium.isNull())
+        oldmedium->detachFrom(mData->mUuid);
 
     return S_OK;
