Index: /trunk/src/VBox/Main/VirtualBoxImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 33690)
+++ /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 33691)
@@ -1425,12 +1425,25 @@
     /* we don't access non-const data members so no need to lock */
 
+    // check if the device type is correct, and see if a medium for the
+    // given path has already initialized; if so, return that
     switch (deviceType)
     {
         case DeviceType_HardDisk:
+            findHardDiskByLocation(aLocation,
+                                   false, /* aSetError */
+                                   &pMedium);
+        break;
+
         case DeviceType_Floppy:
-        break;
-
         case DeviceType_DVD:
-            accessMode = AccessMode_ReadOnly;
+            findDVDOrFloppyImage(deviceType,
+                                 NULL, /* guid */
+                                 aLocation,
+                                 false, /* aSetError */
+                                 &pMedium);
+
+            // enforce read-only for DVDs even if caller specified ReadWrite
+            if (deviceType == DeviceType_DVD)
+                accessMode = AccessMode_ReadOnly;
         break;
 
@@ -1439,37 +1452,42 @@
     }
 
-    pMedium.createObject();
-    HRESULT rc = pMedium->init(this,
-                               aLocation,
-                               (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly,
-                               deviceType);
-
-    if (SUCCEEDED(rc))
-    {
-        AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
-
-        switch (deviceType)
-        {
-            case DeviceType_HardDisk:
-                rc = registerHardDisk(pMedium,
-                                      &fNeedsGlobalSaveSettings);
-            break;
-
-            case DeviceType_DVD:
-            case DeviceType_Floppy:
-                rc = registerImage(pMedium,
-                                   deviceType,
-                                   &fNeedsGlobalSaveSettings);
-            break;
-        }
-
-        treeLock.release();
-
-        /* Note that it's important to call uninit() on failure to register
-         * because the differencing hard disk would have been already associated
-         * with the parent and this association needs to be broken. */
-
-        if (FAILED(rc))
-            pMedium->uninit();
+    HRESULT rc = S_OK;
+
+    if (pMedium.isNull())
+    {
+        pMedium.createObject();
+        rc = pMedium->init(this,
+                           aLocation,
+                           (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly,
+                           deviceType);
+
+        if (SUCCEEDED(rc))
+        {
+            AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
+
+            switch (deviceType)
+            {
+                case DeviceType_HardDisk:
+                    rc = registerHardDisk(pMedium,
+                                          &fNeedsGlobalSaveSettings);
+                break;
+
+                case DeviceType_DVD:
+                case DeviceType_Floppy:
+                    rc = registerImage(pMedium,
+                                       deviceType,
+                                       &fNeedsGlobalSaveSettings);
+                break;
+            }
+
+            treeLock.release();
+
+            /* Note that it's important to call uninit() on failure to register
+             * because the differencing hard disk would have been already associated
+             * with the parent and this association needs to be broken. */
+
+            if (FAILED(rc))
+                pMedium->uninit();
+        }
     }
 
