Index: trunk/src/VBox/Devices/Storage/DMGHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/DMGHDDCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/DMGHDDCore.cpp	(revision 33524)
@@ -407,8 +407,8 @@
 
 /** NULL-terminated array of supported file extensions. */
-static const char *const s_apszDmgFileExtensions[] =
-{
-    "dmg",
-    NULL
+static const VDFILEEXTENSION s_aDmgFileExtensions[] =
+{
+    {"dmg", VDTYPE_DVD},
+    {NULL, VDTYPE_INVALID}
 };
 
@@ -1592,7 +1592,8 @@
 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
 static int dmgCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                           PVDINTERFACE pVDIfsImage)
-{
-    LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
+                           PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
+{
+    LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n",
+                 pszFilename, pVDIfsDisk, pVDIfsImage, penmType));
     int rc;
     PVDIOSTORAGE pStorage;
@@ -1639,5 +1640,8 @@
         {
             if (dmgUdifFtrIsValid(&Ftr, offFtr))
+            {
                 rc = VINF_SUCCESS;
+                *penmType = VDTYPE_DVD;
+            }
             else
             {
@@ -1659,5 +1663,5 @@
 static int dmgOpen(const char *pszFilename, unsigned uOpenFlags,
                    PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                   void **ppBackendData)
+                   VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
@@ -2136,17 +2140,16 @@
 {
     LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment));
-    PDMGIMAGE pThis = (PDMGIMAGE)pBackendData;
+    PDMGIMAGE pImage = (PDMGIMAGE)pBackendData;
     int rc;
 
-    AssertPtr(pThis);
-
-    if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-    {
-        rc = VERR_VD_IMAGE_READ_ONLY;
-        goto out;
-    }
-
-    if (pThis)
-        rc = VERR_NOT_SUPPORTED;
+    AssertPtr(pImage);
+
+    if (pImage)
+    {
+        if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
+            rc = VERR_VD_IMAGE_READ_ONLY;
+        else
+            rc = VERR_NOT_SUPPORTED;
+    }
     else
         rc = VERR_VD_NOT_OPENED;
@@ -2346,6 +2349,6 @@
     /* uBackendCaps */
     VD_CAP_FILE | VD_CAP_VFS,
-    /* papszFileExtensions */
-    s_apszDmgFileExtensions,
+    /* paFileExtensions */
+    s_aDmgFileExtensions,
     /* paConfigInfo */
     NULL,
Index: trunk/src/VBox/Devices/Storage/DrvVD.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/DrvVD.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/DrvVD.cpp	(revision 33524)
@@ -2004,4 +2004,5 @@
     unsigned    iLevel = 0;
     PCFGMNODE   pCurNode = pCfg;
+    VDTYPE      enmType = VDTYPE_HDD;
 
     for (;;)
@@ -2017,5 +2018,5 @@
                                           "ReadOnly\0MaybeReadOnly\0TempReadOnly\0Shareable\0HonorZeroWrites\0"
                                           "HostIPStack\0UseNewIo\0BootAcceleration\0BootAccelerationBuffer\0"
-                                          "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0");
+                                          "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0");
         }
         else
@@ -2132,4 +2133,26 @@
             else
                 rc = VINF_SUCCESS;
+
+            char *psz;
+            rc = CFGMR3QueryStringAlloc(pCfg, "Type", &psz);
+            if (RT_FAILURE(rc))
+            {
+                rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type"));
+                break;
+            }
+            else if (!strcmp(psz, "HardDisk"))
+                enmType = VDTYPE_HDD;
+            else if (!strcmp(psz, "DVD"))
+                enmType = VDTYPE_DVD;
+            else if (!strcmp(psz, "Floppy"))
+                enmType = VDTYPE_FLOPPY;
+            else
+            {
+                rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS,
+                                         N_("Unknown type \"%s\""), psz);
+                MMR3HeapFree(psz);
+                break;
+            }
+            MMR3HeapFree(psz); psz = NULL;
         }
 
@@ -2270,5 +2293,5 @@
         if (RT_SUCCESS(rc))
         {
-            rc = VDCreate(pThis->pVDIfsDisk, &pThis->pDisk);
+            rc = VDCreate(pThis->pVDIfsDisk, enmType, &pThis->pDisk);
             /* Error message is already set correctly. */
         }
Index: trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp	(revision 33524)
@@ -4369,5 +4369,5 @@
 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
 static int iscsiCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                             PVDINTERFACE pVDIfsImage)
+                             PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
 {
     LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
@@ -4384,5 +4384,5 @@
 static int iscsiOpen(const char *pszFilename, unsigned uOpenFlags,
                      PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                     void **ppBackendData)
+                     VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
Index: trunk/src/VBox/Devices/Storage/ParallelsHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/ParallelsHDDCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/ParallelsHDDCore.cpp	(revision 33524)
@@ -105,8 +105,8 @@
 
 /** NULL-terminated array of supported file extensions. */
-static const char *const s_apszParallelsFileExtensions[] =
-{
-    "hdd",
-    NULL
+static const VDFILEEXTENSION s_aParallelsFileExtensions[] =
+{
+    {"hdd", VDTYPE_HDD},
+    {NULL, VDTYPE_INVALID}
 };
 
@@ -415,5 +415,5 @@
 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
 static int parallelsCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                 PVDINTERFACE pVDIfsImage)
+                                 PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
 {
     int rc;
@@ -471,4 +471,7 @@
     }
 
+    if (RT_SUCCESS(rc))
+        *penmType = VDTYPE_HDD;
+
     pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage);
     return rc;
@@ -478,5 +481,5 @@
 static int parallelsOpen(const char *pszFilename, unsigned uOpenFlags,
                          PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                         void **ppBackendData)
+                         VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
@@ -1001,12 +1004,11 @@
     AssertPtr(pImage);
 
-    if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-    {
-        rc = VERR_VD_IMAGE_READ_ONLY;
-        goto out;
-    }
-
-    if (pImage)
-        rc = VERR_NOT_SUPPORTED;
+    if (pImage)
+    {
+        if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
+            rc = VERR_VD_IMAGE_READ_ONLY;
+        else
+            rc = VERR_NOT_SUPPORTED;
+    }
     else
         rc = VERR_VD_NOT_OPENED;
@@ -1357,6 +1359,6 @@
     /* uBackendCaps */
     VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS,
-    /* papszFileExtensions */
-    s_apszParallelsFileExtensions,
+    /* paFileExtensions */
+    s_aParallelsFileExtensions,
     /* paConfigInfo */
     NULL,
Index: trunk/src/VBox/Devices/Storage/RawHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/RawHDDCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/RawHDDCore.cpp	(revision 33524)
@@ -26,9 +26,34 @@
 #include <iprt/assert.h>
 #include <iprt/alloc.h>
-
+#include <iprt/path.h>
 
 /*******************************************************************************
 *   Constants And Macros, Structures and Typedefs                              *
 *******************************************************************************/
+/**
+ * ISO volume descriptor.
+ */
+#pragma pack(1)
+typedef struct ISOVOLDESC
+{
+    union
+    {
+        /** Byte view. */
+        uint8_t au8[2048];
+        /** Field view. */
+        struct
+        {
+            /** Descriptor type. */
+            uint8_t u8Type;
+            /** Standard identifier */
+            uint8_t au8Id[5];
+            /** Descriptor version. */
+            uint8_t u8Version;
+            /** Rest depends on the descriptor type. */
+        } fields;
+    };
+} ISOVOLDESC, *PISOVOLDESC;
+#pragma pack()
+AssertCompileSize(ISOVOLDESC, 2048);
 
 /**
@@ -82,10 +107,10 @@
 
 /** NULL-terminated array of supported file extensions. */
-static const char *const s_apszRawFileExtensions[] =
-{
-    /** @todo At the moment this backend doesn't claim any extensions, but it might
-     * be useful to add a few later. However this needs careful testing, as the
-     * CheckIfValid function never returns success. */
-    NULL
+static const VDFILEEXTENSION s_aRawFileExtensions[] =
+{
+    {"iso", VDTYPE_DVD},
+    {"img", VDTYPE_FLOPPY},
+    {"ima", VDTYPE_FLOPPY},
+    {NULL, VDTYPE_INVALID}
 };
 
@@ -484,8 +509,18 @@
 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
 static int rawCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                           PVDINTERFACE pVDIfsImage)
-{
-    LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
+                           PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
+{
+    LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
+    PVDIOSTORAGE pStorage = NULL;
+    uint64_t cbFile;
     int rc = VINF_SUCCESS;
+    ISOVOLDESC IsoVolDesc;
+    char *pszExtension = NULL;
+
+    /* Get I/O interface. */
+    PVDINTERFACE pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IOINT);
+    AssertPtrReturn(pInterfaceIO, VERR_INVALID_PARAMETER);
+    PVDINTERFACEIOINT pInterfaceIOCallbacks = VDGetInterfaceIOInt(pInterfaceIO);
+    AssertPtrReturn(pInterfaceIOCallbacks, VERR_INVALID_PARAMETER);
 
     if (   !VALID_PTR(pszFilename)
@@ -496,6 +531,67 @@
     }
 
-    /* Always return failure, to avoid opening everything as a raw image. */
-    rc = VERR_VD_RAW_INVALID_HEADER;
+    pszExtension = RTPathExt(pszFilename);
+
+    /*
+     * Open the file and read the footer.
+     */
+    rc = pInterfaceIOCallbacks->pfnOpen(pInterfaceIO->pvUser, pszFilename,
+                                        VDOpenFlagsToFileOpenFlags(VD_OPEN_FLAGS_READONLY,
+                                                                   false /* fCreate */),
+                                        &pStorage);
+    if (RT_SUCCESS(rc))
+        rc = pInterfaceIOCallbacks->pfnGetSize(pInterfaceIO->pvUser, pStorage,
+                                               &cbFile);
+
+    /* Try to guess the image type based on the extension. */
+    if (   RT_SUCCESS(rc)
+        && pszExtension)
+    {
+        if (!strcmp(pszExtension, ".iso")) /* DVD images. */
+        {
+            if (cbFile >= (32768 + sizeof(ISOVOLDESC)))
+            {
+                rc = pInterfaceIOCallbacks->pfnReadSync(pInterfaceIO->pvUser, pStorage,
+                                                        32768, &IsoVolDesc, sizeof(IsoVolDesc), NULL);
+            }
+            else
+                rc = VERR_VD_RAW_INVALID_HEADER;
+
+            if (RT_SUCCESS(rc))
+            {
+                /*
+                 * Do we recognize this stuff?
+                 */
+                if (   !memcmp(IsoVolDesc.fields.au8Id, "BEA01", 5)
+                    || !memcmp(IsoVolDesc.fields.au8Id, "BOOT2", 5)
+                    || !memcmp(IsoVolDesc.fields.au8Id, "CD001", 5)
+                    || !memcmp(IsoVolDesc.fields.au8Id, "CDW02", 5)
+                    || !memcmp(IsoVolDesc.fields.au8Id, "NSR02", 5)
+                    || !memcmp(IsoVolDesc.fields.au8Id, "NSR03", 5)
+                    || !memcmp(IsoVolDesc.fields.au8Id, "TEA01", 5))
+                {
+                    *penmType = VDTYPE_DVD;
+                    rc = VINF_SUCCESS;
+                }
+                else
+                    rc = VERR_VD_RAW_INVALID_HEADER;
+            }
+        }
+        else if (!strcmp(pszExtension, ".img") || !strcmp(pszExtension, ".ima")) /* Floppy images */
+        {
+            if (!(cbFile % 512))
+            {
+                *penmType = VDTYPE_FLOPPY;
+                rc = VINF_SUCCESS;
+            }
+            else
+                rc = VERR_VD_RAW_INVALID_HEADER;
+        }
+    }
+    else
+        rc = VERR_VD_RAW_INVALID_HEADER;
+
+    if (pStorage)
+        pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage);
 
 out:
@@ -507,5 +603,5 @@
 static int rawOpen(const char *pszFilename, unsigned uOpenFlags,
                    PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                   void **ppBackendData)
+                   VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
@@ -1040,12 +1136,11 @@
     AssertPtr(pImage);
 
-    if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-    {
-        rc = VERR_VD_IMAGE_READ_ONLY;
-        goto out;
-    }
-
-    if (pImage)
-        rc = VERR_NOT_SUPPORTED;
+    if (pImage)
+    {
+        if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
+            rc = VERR_VD_IMAGE_READ_ONLY;
+        else
+            rc = VERR_NOT_SUPPORTED;
+    }
     else
         rc = VERR_VD_NOT_OPENED;
@@ -1292,11 +1387,11 @@
 {
     /* pszBackendName */
-    "raw",
+    "RAW",
     /* cbSize */
     sizeof(VBOXHDDBACKEND),
     /* uBackendCaps */
     VD_CAP_CREATE_FIXED | VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS,
-    /* papszFileExtensions */
-    s_apszRawFileExtensions,
+    /* paFileExtensions */
+    s_aRawFileExtensions,
     /* paConfigInfo */
     NULL,
Index: trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/VBoxHDD.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/VBoxHDD.cpp	(revision 33524)
@@ -156,4 +156,7 @@
     /** Structure signature (VBOXHDDDISK_SIGNATURE). */
     uint32_t            u32Signature;
+
+    /** Image type. */
+    VDTYPE              enmType;
 
     /** Number of opened images. */
@@ -440,7 +443,5 @@
 extern VBOXHDDBACKEND g_VhdBackend;
 extern VBOXHDDBACKEND g_ParallelsBackend;
-#ifdef VBOX_WITH_DMG
 extern VBOXHDDBACKEND g_DmgBackend;
-#endif
 #ifdef VBOX_WITH_ISCSI
 extern VBOXHDDBACKEND g_ISCSIBackend;
@@ -451,12 +452,10 @@
 static PVBOXHDDBACKEND aStaticBackends[] =
 {
-    &g_RawBackend,
     &g_VmdkBackend,
     &g_VDIBackend,
     &g_VhdBackend,
-    &g_ParallelsBackend
-#ifdef VBOX_WITH_DMG
-    ,&g_DmgBackend
-#endif
+    &g_ParallelsBackend,
+    &g_DmgBackend,
+    &g_RawBackend
 #ifdef VBOX_WITH_ISCSI
     ,&g_ISCSIBackend
@@ -3584,5 +3583,5 @@
         pEntries[i].pszBackend = g_apBackends[i]->pszBackendName;
         pEntries[i].uBackendCaps = g_apBackends[i]->uBackendCaps;
-        pEntries[i].papszFileExtensions = g_apBackends[i]->papszFileExtensions;
+        pEntries[i].paFileExtensions = g_apBackends[i]->paFileExtensions;
         pEntries[i].paConfigInfo = g_apBackends[i]->paConfigInfo;
         pEntries[i].pfnComposeLocation = g_apBackends[i]->pfnComposeLocation;
@@ -3622,5 +3621,5 @@
             pEntry->pszBackend = g_apBackends[i]->pszBackendName;
             pEntry->uBackendCaps = g_apBackends[i]->uBackendCaps;
-            pEntry->papszFileExtensions = g_apBackends[i]->papszFileExtensions;
+            pEntry->paFileExtensions = g_apBackends[i]->paFileExtensions;
             pEntry->paConfigInfo = g_apBackends[i]->paConfigInfo;
             return VINF_SUCCESS;
@@ -3637,7 +3636,8 @@
  * @returns VBox status code.
  * @param   pVDIfsDisk      Pointer to the per-disk VD interface list.
+ * @param   enmType         Type of the image container.
  * @param   ppDisk          Where to store the reference to HDD container.
  */
-VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk)
+VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, VDTYPE enmType, PVBOXHDD *ppDisk)
 {
     int rc = VINF_SUCCESS;
@@ -3656,4 +3656,5 @@
         {
             pDisk->u32Signature = VBOXHDDDISK_SIGNATURE;
+            pDisk->enmType      = enmType;
             pDisk->cImages      = 0;
             pDisk->pBase        = NULL;
@@ -3809,5 +3810,5 @@
  */
 VBOXDDU_DECL(int) VDGetFormat(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                              const char *pszFilename, char **ppszFormat)
+                              const char *pszFilename, char **ppszFormat, VDTYPE *penmType)
 {
     int rc = VERR_NOT_SUPPORTED;
@@ -3825,4 +3826,7 @@
     AssertMsgReturn(VALID_PTR(ppszFormat),
                     ("ppszFormat=%#p\n", ppszFormat),
+                    VERR_INVALID_PARAMETER);
+    AssertMsgReturn(VALID_PTR(ppszFormat),
+                    ("penmType=%#p\n", penmType),
                     VERR_INVALID_PARAMETER);
 
@@ -3886,5 +3890,5 @@
         {
             rc = g_apBackends[i]->pfnCheckIfValid(pszFilename, pVDIfsDisk,
-                                                  pVDIfsImage);
+                                                  pVDIfsImage, penmType);
             if (    RT_SUCCESS(rc)
                 /* The correct backend has been found, but there is a small
@@ -4048,4 +4052,5 @@
                                       pDisk->pVDIfsDisk,
                                       pImage->pVDIfsImage,
+                                      pDisk->enmType,
                                       &pImage->pBackendData);
         /* If the open in read-write mode failed, retry in read-only mode. */
@@ -4063,4 +4068,5 @@
                                                pDisk->pVDIfsDisk,
                                                pImage->pVDIfsImage,
+                                               pDisk->enmType,
                                                &pImage->pBackendData);
             if (RT_FAILURE(rc))
@@ -7186,5 +7192,5 @@
         pBackendInfo->pszBackend = pImage->Backend->pszBackendName;
         pBackendInfo->uBackendCaps = pImage->Backend->uBackendCaps;
-        pBackendInfo->papszFileExtensions = pImage->Backend->papszFileExtensions;
+        pBackendInfo->paFileExtensions = pImage->Backend->paFileExtensions;
         pBackendInfo->paConfigInfo = pImage->Backend->paConfigInfo;
     } while (0);
Index: trunk/src/VBox/Devices/Storage/VCICacheCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/VCICacheCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/VCICacheCore.cpp	(revision 33524)
@@ -1901,12 +1901,11 @@
     AssertPtr(pCache);
 
-    if (pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-    {
-        rc = VERR_VD_IMAGE_READ_ONLY;
-        goto out;
-    }
-
     if (pCache)
-        rc = VERR_NOT_SUPPORTED;
+    {
+        if (pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY)
+            rc = VERR_VD_IMAGE_READ_ONLY;
+        else
+            rc = VERR_NOT_SUPPORTED;
+    }
     else
         rc = VERR_VD_NOT_OPENED;
Index: trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp	(revision 33524)
@@ -38,8 +38,8 @@
 
 /** NULL-terminated array of supported file extensions. */
-static const char *const s_apszVdiFileExtensions[] =
-{
-    "vdi",
-    NULL
+static const VDFILEEXTENSION s_aVdiFileExtensions[] =
+{
+    {"vdi", VDTYPE_HDD},
+    {NULL, VDTYPE_INVALID}
 };
 
@@ -999,5 +999,5 @@
 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
 static int vdiCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                           PVDINTERFACE pVDIfsImage)
+                           PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
 {
     LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
@@ -1028,4 +1028,7 @@
     RTMemFree(pImage);
 
+    if (RT_SUCCESS(rc))
+        *penmType = VDTYPE_HDD;
+
 out:
     LogFlowFunc(("returns %Rrc\n", rc));
@@ -1036,5 +1039,5 @@
 static int vdiOpen(const char *pszFilename, unsigned uOpenFlags,
                    PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                   void **ppBackendData)
+                   VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
@@ -1701,34 +1704,33 @@
     AssertPtr(pImage);
 
-    if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-    {
-        rc = VERR_VD_IMAGE_READ_ONLY;
-        goto out;
-    }
-
     if (pImage)
     {
-        size_t cchComment = pszComment ? strlen(pszComment) : 0;
-        if (cchComment >= VDI_IMAGE_COMMENT_SIZE)
-        {
-            LogFunc(("pszComment is too long, %d bytes!\n", cchComment));
-            rc = VERR_VD_VDI_COMMENT_TOO_LONG;
-            goto out;
-        }
-
-        /* we don't support old style images */
-        if (GET_MAJOR_HEADER_VERSION(&pImage->Header) == 1)
-        {
-            /*
-             * Update the comment field, making sure to zero out all of the previous comment.
-             */
-            memset(pImage->Header.u.v1.szComment, '\0', VDI_IMAGE_COMMENT_SIZE);
-            memcpy(pImage->Header.u.v1.szComment, pszComment, cchComment);
-
-            /* write out new the header */
-            rc = vdiUpdateHeader(pImage);
-        }
+        if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
+            rc = VERR_VD_IMAGE_READ_ONLY;
         else
-            rc = VERR_VD_VDI_UNSUPPORTED_VERSION;
+        {
+            size_t cchComment = pszComment ? strlen(pszComment) : 0;
+            if (cchComment >= VDI_IMAGE_COMMENT_SIZE)
+            {
+                LogFunc(("pszComment is too long, %d bytes!\n", cchComment));
+                rc = VERR_VD_VDI_COMMENT_TOO_LONG;
+                goto out;
+            }
+
+            /* we don't support old style images */
+            if (GET_MAJOR_HEADER_VERSION(&pImage->Header) == 1)
+            {
+                /*
+                 * Update the comment field, making sure to zero out all of the previous comment.
+                 */
+                memset(pImage->Header.u.v1.szComment, '\0', VDI_IMAGE_COMMENT_SIZE);
+                memcpy(pImage->Header.u.v1.szComment, pszComment, cchComment);
+
+                /* write out new the header */
+                rc = vdiUpdateHeader(pImage);
+            }
+            else
+                rc = VERR_VD_VDI_UNSUPPORTED_VERSION;
+        }
     }
     else
@@ -2657,6 +2659,6 @@
       VD_CAP_UUID | VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC
     | VD_CAP_DIFF | VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS,
-    /* papszFileExtensions */
-    s_apszVdiFileExtensions,
+    /* paFileExtensions */
+    s_aVdiFileExtensions,
     /* paConfigInfo */
     NULL,
Index: trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp	(revision 33524)
@@ -241,8 +241,8 @@
 
 /** NULL-terminated array of supported file extensions. */
-static const char *const s_apszVhdFileExtensions[] =
-{
-    "vhd",
-    NULL
+static const VDFILEEXTENSION s_aVhdFileExtensions[] =
+{
+    {"vhd", VDTYPE_HDD},
+    {NULL, VDTYPE_INVALID}
 };
 
@@ -1380,5 +1380,5 @@
 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
 static int vhdCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                           PVDINTERFACE pVDIfsImage)
+                           PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
 {
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
@@ -1416,5 +1416,8 @@
         rc = VERR_VD_VHD_INVALID_HEADER;
     else
+    {
+        *penmType = VDTYPE_HDD;
         rc = VINF_SUCCESS;
+    }
 
     pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage);
@@ -1428,5 +1431,5 @@
 static int vhdOpen(const char *pszFilename, unsigned uOpenFlags,
                    PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                   void **ppBackendData)
+                   VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
@@ -2137,12 +2140,11 @@
     AssertPtr(pImage);
 
-    if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-    {
-        rc = VERR_VD_IMAGE_READ_ONLY;
-        goto out;
-    }
-
     if (pImage)
-        rc = VERR_NOT_SUPPORTED;
+    {
+        if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
+            rc = VERR_VD_IMAGE_READ_ONLY;
+        else
+            rc = VERR_NOT_SUPPORTED;
+    }
     else
         rc = VERR_VD_NOT_OPENED;
@@ -3020,6 +3022,6 @@
     VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC |
     VD_CAP_ASYNC | VD_CAP_VFS,
-    /* papszFileExtensions */
-    s_apszVhdFileExtensions,
+    /* paFileExtensions */
+    s_aVhdFileExtensions,
     /* paConfigInfo */
     NULL,
Index: trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp	(revision 33524)
@@ -514,8 +514,8 @@
 
 /** NULL-terminated array of supported file extensions. */
-static const char *const s_apszVmdkFileExtensions[] =
-{
-    "vmdk",
-    NULL
+static const VDFILEEXTENSION s_aVmdkFileExtensions[] =
+{
+    {"vmdk", VDTYPE_HDD},
+    {NULL, VDTYPE_INVALID}
 };
 
@@ -5704,7 +5704,8 @@
 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
 static int vmdkCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                            PVDINTERFACE pVDIfsImage)
-{
-    LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
+                            PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
+{
+    LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n",
+                 pszFilename, pVDIfsDisk, pVDIfsImage, penmType));
     int rc = VINF_SUCCESS;
     PVMDKIMAGE pImage;
@@ -5738,4 +5739,7 @@
     RTMemFree(pImage);
 
+    if (RT_SUCCESS(rc))
+        *penmType = VDTYPE_HDD;
+
 out:
     LogFlowFunc(("returns %Rrc\n", rc));
@@ -5746,5 +5750,5 @@
 static int vmdkOpen(const char *pszFilename, unsigned uOpenFlags,
                     PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                    void **ppBackendData)
+                    VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
@@ -7322,6 +7326,6 @@
     | VD_CAP_CREATE_SPLIT_2G | VD_CAP_DIFF | VD_CAP_FILE | VD_CAP_ASYNC
     | VD_CAP_VFS,
-    /* papszFileExtensions */
-    s_apszVmdkFileExtensions,
+    /* paFileExtensions */
+    s_aVmdkFileExtensions,
     /* paConfigInfo */
     NULL,
Index: trunk/src/VBox/Devices/Storage/testcase/tstVD-2.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/testcase/tstVD-2.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/testcase/tstVD-2.cpp	(revision 33524)
@@ -86,4 +86,19 @@
 };
 
+static const char *tstVDDeviceType(VDTYPE enmType)
+{
+    switch (enmType)
+    {
+        case VDTYPE_HDD:
+            return "HardDisk";
+        case VDTYPE_DVD:
+            return "DVD";
+        case VDTYPE_FLOPPY:
+            return "Floppy";
+        default:
+            return "Unknown";
+    }
+}
+
 static int tstVDBackendInfo(void)
 {
@@ -108,15 +123,15 @@
         RTPrintf("Backend %u: name=%s capabilities=%#06x extensions=",
                  i, aVDInfo[i].pszBackend, aVDInfo[i].uBackendCaps);
-        if (aVDInfo[i].papszFileExtensions)
-        {
-            const char *const *papsz = aVDInfo[i].papszFileExtensions;
-            while (*papsz != NULL)
-            {
-                if (papsz != aVDInfo[i].papszFileExtensions)
+        if (aVDInfo[i].paFileExtensions)
+        {
+            PCVDFILEEXTENSION pa = aVDInfo[i].paFileExtensions;
+            while (pa->pszExtension != NULL)
+            {
+                if (pa != aVDInfo[i].paFileExtensions)
                     RTPrintf(",");
-                RTPrintf("%s", *papsz);
-                papsz++;
-            }
-            if (papsz == aVDInfo[i].papszFileExtensions)
+                RTPrintf("%s (%s)", pa->pszExtension, tstVDDeviceType(pa->enmType));
+                pa++;
+            }
+            if (pa == aVDInfo[i].paFileExtensions)
                 RTPrintf("<EMPTY>");
         }
Index: trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp	(revision 33524)
@@ -92,5 +92,5 @@
     AssertRC(rc);
 
-    rc = VDCreate(&VDIError, &pVD);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
 
@@ -150,5 +150,5 @@
     AssertRC(rc);
 
-    rc = VDCreate(&VDIError, &pVD);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
 
@@ -505,4 +505,5 @@
     PVBOXHDD pVD = NULL;
     char *pszFormat;
+    VDTYPE enmType = VDTYPE_INVALID;
     VDGEOMETRY PCHS = { 0, 0, 0 };
     VDGEOMETRY LCHS = { 0, 0, 0 };
@@ -539,5 +540,5 @@
 
 
-    rc = VDCreate(&VDIError, &pVD);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
 
@@ -548,5 +549,5 @@
         RTFileClose(File);
         rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                         pszBaseFilename, &pszFormat);
+                         pszBaseFilename, &pszFormat, &enmType);
         RTPrintf("VDGetFormat() pszFormat=%s rc=%Rrc\n", pszFormat, rc);
         if (RT_SUCCESS(rc) && strcmp(pszFormat, pszBackend))
@@ -664,5 +665,5 @@
 
 
-    rc = VDCreate(&VDIError, &pVD);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
 
@@ -738,5 +739,5 @@
     AssertRC(rc);
 
-    rc = VDCreate(&VDIError, &pVD);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
 
@@ -789,5 +790,5 @@
     AssertRC(rc);
 
-    rc = VDCreate(&VDIError, &pVD);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
 
Index: trunk/src/VBox/Devices/Storage/testcase/tstVDCopy.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/testcase/tstVDCopy.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/testcase/tstVDCopy.cpp	(revision 33524)
@@ -70,4 +70,6 @@
     char *pbBuf1 = NULL;
     char *pbBuf2 = NULL;
+    VDTYPE enmTypeVD1 = VDTYPE_INVALID;
+    VDTYPE enmTypeVD2 = VDTYPE_INVALID;
 
 #define CHECK(str) \
@@ -98,15 +100,15 @@
 
     rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                     argv[1], &pszVD1);
+                     argv[1], &pszVD1, &enmTypeVD1);
     CHECK("VDGetFormat() hdd1");
 
     rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                     argv[2], &pszVD2);
+                     argv[2], &pszVD2, &enmTypeVD2);
     CHECK("VDGetFormat() hdd2");
 
-    rc = VDCreate(&VDIError, &pVD1);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD1);
     CHECK("VDCreate() hdd1");
 
-    rc = VDCreate(&VDIError, &pVD2);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD2);
     CHECK("VDCreate() hdd1");
 
Index: trunk/src/VBox/Devices/Storage/testcase/tstVDShareable.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/testcase/tstVDShareable.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/testcase/tstVDShareable.cpp	(revision 33524)
@@ -92,7 +92,7 @@
     AssertRC(rc);
 
-    rc = VDCreate(&VDIError, &pVD);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
-    rc = VDCreate(&VDIError, &pVD2);
+    rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD2);
     CHECK("VDCreate() #2");
 
Index: trunk/src/VBox/Devices/Storage/testcase/tstVDSnap.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/testcase/tstVDSnap.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/testcase/tstVDSnap.cpp	(revision 33524)
@@ -276,5 +276,5 @@
 
 
-    rc = VDCreate(pVDIfs, &pVD);
+    rc = VDCreate(pVDIfs, VDTYPE_HDD, &pVD);
     CHECK("VDCreate()");
 
Index: trunk/src/VBox/Devices/Storage/testcase/vbox-img.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/testcase/vbox-img.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/testcase/vbox-img.cpp	(revision 33524)
@@ -124,4 +124,5 @@
     const char *pszFilename = NULL;
     char *pszFormat = NULL;
+    VDTYPE enmType = VDTYPE_INVALID;
     RTUUID imageUuid;
     RTUUID parentUuid;
@@ -188,5 +189,5 @@
         /* Don't pass error interface, as that would triggers error messages
          * because some backends fail to open the image. */
-        rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat);
+        rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
         if (RT_FAILURE(rc))
             return errorRuntime("Format autodetect failed: %Rrc\n", rc);
@@ -194,5 +195,5 @@
 
     PVBOXHDD pVD = NULL;
-    rc = VDCreate(pVDIfs, &pVD);
+    rc = VDCreate(pVDIfs, enmType, &pVD);
     if (RT_FAILURE(rc))
         return errorRuntime("Cannot create the virtual disk container: %Rrc\n", rc);
@@ -625,4 +626,5 @@
     bool fStdOut = false;
     const char *pszSrcFormat = NULL;
+    VDTYPE enmSrcType = VDTYPE_HDD;
     const char *pszDstFormat = NULL;
     const char *pszVariant = NULL;
@@ -788,6 +790,7 @@
         if (!pszSrcFormat)
         {
-            char *pszFormat;
-            rc = VDGetFormat(NULL, NULL, pszSrcFilename, &pszFormat);
+            char *pszFormat = NULL;
+            VDTYPE enmType = VDTYPE_INVALID;
+            rc = VDGetFormat(NULL, NULL, pszSrcFilename, &pszFormat, &enmType);
             if (RT_FAILURE(rc))
             {
@@ -796,7 +799,8 @@
             }
             pszSrcFormat = pszFormat;
-        }
-
-        rc = VDCreate(pVDIfs, &pSrcDisk);
+            enmSrcType = enmType;
+        }
+
+        rc = VDCreate(pVDIfs, enmSrcType, &pSrcDisk);
         if (RT_FAILURE(rc))
         {
@@ -814,5 +818,5 @@
         }
 
-        rc = VDCreate(pVDIfs, &pDstDisk);
+        rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDstDisk);
         if (RT_FAILURE(rc))
         {
@@ -883,9 +887,10 @@
     /* just try it */
     char *pszFormat = NULL;
-    rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat);
+    VDTYPE enmType = VDTYPE_INVALID;
+    rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return errorSyntax("Format autodetect failed: %Rrc\n", rc);
 
-    rc = VDCreate(pVDIfs, &pDisk);
+    rc = VDCreate(pVDIfs, enmType, &pDisk);
     if (RT_FAILURE(rc))
         return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc);
@@ -940,9 +945,10 @@
     /* just try it */
     char *pszFormat = NULL;
-    rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat);
+    VDTYPE enmType = VDTYPE_INVALID;
+    rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return errorSyntax("Format autodetect failed: %Rrc\n", rc);
 
-    rc = VDCreate(pVDIfs, &pDisk);
+    rc = VDCreate(pVDIfs, enmType, &pDisk);
     if (RT_FAILURE(rc))
         return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc);
Index: trunk/src/VBox/Devices/Storage/testcase/vditool.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/testcase/vditool.cpp	(revision 33523)
+++ trunk/src/VBox/Devices/Storage/testcase/vditool.cpp	(revision 33524)
@@ -104,5 +104,5 @@
 
     PVBOXHDD hdd;
-    rc = VDCreate(NULL, &hdd);
+    rc = VDCreate(NULL, VDTYPE_HDD, &hdd);
     if (RT_FAILURE(rc))
         return PrintDone(rc);
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp	(revision 33523)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp	(revision 33524)
@@ -555,6 +555,7 @@
     /* just try it */
     char *pszFormat = NULL;
+    VDTYPE enmType = VDTYPE_INVALID;
     int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                         argv[1], &pszFormat);
+                         argv[1], &pszFormat, &enmType);
     if (RT_FAILURE(rc))
     {
@@ -577,5 +578,5 @@
     AssertRC(rc);
 
-    rc = VDCreate(pVDIfs, &pDisk);
+    rc = VDCreate(pVDIfs, enmType, &pDisk);
     if (RT_FAILURE(rc))
     {
@@ -617,6 +618,7 @@
     /* just try it */
     char *pszFormat = NULL;
+    VDTYPE enmType = VDTYPE_INVALID;
     int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                         argv[0], &pszFormat);
+                         argv[0], &pszFormat, &enmType);
     if (RT_FAILURE(rc))
     {
@@ -639,5 +641,5 @@
     AssertRC(rc);
 
-    rc = VDCreate(pVDIfs, &pDisk);
+    rc = VDCreate(pVDIfs, enmType, &pDisk);
     if (RT_FAILURE(rc))
     {
@@ -1433,5 +1435,5 @@
     AssertRC(vrc);
 
-    vrc = VDCreate(pVDIfs, &pDisk);
+    vrc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); /* Raw VMDK's are harddisk only. */
     if (RT_FAILURE(vrc))
     {
@@ -1543,5 +1545,5 @@
     AssertRC(vrc);
 
-    vrc = VDCreate(pVDIfs, &pDisk);
+    vrc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk);
     if (RT_FAILURE(vrc))
     {
@@ -1627,5 +1629,6 @@
     AssertRC(vrc);
 
-    vrc = VDCreate(pVDIfs, &pDisk);
+    /** @todo: Support convert to raw for floppy and DVD images too. */
+    vrc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk);
     if (RT_FAILURE(vrc))
     {
@@ -1651,7 +1654,8 @@
     {
         char *pszFormat = NULL;
+        VDTYPE enmType = VDTYPE_INVALID;
         vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                          src.c_str(), &pszFormat);
-        if (RT_FAILURE(vrc))
+                          src.c_str(), &pszFormat, &enmType);
+        if (RT_FAILURE(vrc) || enmType != VDTYPE_HDD)
         {
             VDCloseAll(pDisk);
@@ -1661,5 +1665,8 @@
                 RTFileDelete(dst.c_str());
             }
-            RTMsgError("No file format specified and autodetect failed - please specify format: %Rrc", vrc);
+            if (RT_FAILURE(vrc))
+                RTMsgError("No file format specified and autodetect failed - please specify format: %Rrc", vrc);
+            else
+                RTMsgError("Only converting harddisk images is supported");
             return 1;
         }
@@ -1739,4 +1746,5 @@
     PVBOXHDD pSrcDisk = NULL;
     PVBOXHDD pDstDisk = NULL;
+    VDTYPE enmSrcType = VDTYPE_INVALID;
 
     /* Parse the arguments. */
@@ -1800,5 +1808,5 @@
             char *pszFormat = NULL;
             vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                              src.c_str(), &pszFormat);
+                              src.c_str(), &pszFormat, &enmSrcType);
             if (RT_FAILURE(vrc))
             {
@@ -1810,5 +1818,5 @@
         }
 
-        vrc = VDCreate(pVDIfs, &pSrcDisk);
+        vrc = VDCreate(pVDIfs, enmSrcType, &pSrcDisk);
         if (RT_FAILURE(vrc))
         {
@@ -1829,5 +1837,5 @@
             dstformat = "VDI";
 
-        vrc = VDCreate(pVDIfs, &pDstDisk);
+        vrc = VDCreate(pVDIfs, enmSrcType, &pDstDisk);
         if (RT_FAILURE(vrc))
         {
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp	(revision 33523)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp	(revision 33524)
@@ -888,5 +888,5 @@
     char pszComment[256];
     RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", srcfilename);
-    rc = VDCreate(pVDIfs, &pDisk);
+    rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk);
     if (RT_FAILURE(rc))
     {
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp	(revision 33523)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp	(revision 33524)
@@ -62,4 +62,15 @@
 }
 #endif
+
+static const char*getDeviceTypeText(DeviceType_T enmType)
+{
+    switch (enmType)
+    {
+        case DeviceType_HardDisk: return "HardDisk";
+        case DeviceType_DVD: return "DVD";
+        case DeviceType_Floppy: return "Floppy";
+    }
+    return "Unknown";
+}
 
 static void listMedia(const ComPtr<IVirtualBox> aVirtualBox,
@@ -604,9 +615,10 @@
                 /* File extensions */
                 com::SafeArray <BSTR> fileExtensions;
+                com::SafeArray <DeviceType_T> deviceTypes;
                 CHECK_ERROR(mediumFormats[i],
-                            COMGETTER(FileExtensions)(ComSafeArrayAsOutParam(fileExtensions)));
+                            DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes)));
                 for (size_t j = 0; j < fileExtensions.size(); ++j)
                 {
-                    RTPrintf("%ls", Bstr(fileExtensions[j]).raw());
+                    RTPrintf("%ls (%s)", Bstr(fileExtensions[j]).raw(), getDeviceTypeText(deviceTypes[j]));
                     if (j != fileExtensions.size()-1)
                         RTPrintf(",");
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp	(revision 33523)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp	(revision 33524)
@@ -981,37 +981,30 @@
         dir = mVBox.GetHomeFolder();
 
+    QList < QPair <QString, QString> > filterList;
+    QStringList backends;
+    QStringList allPrefix;
+    QString     allType;
+
     switch (type)
     {
+        case VBoxDefs::MediumType_DVD:
+        {
+            filterList = vboxGlobal().DVDBackends();
+            title = tr ("Select a CD/DVD-ROM disk image file");
+            allType = tr ("CD/DVD-ROM disk");
+            break;
+        }
         case VBoxDefs::MediumType_HardDisk:
         {
-            QList < QPair <QString, QString> > filterList = vboxGlobal().HDDBackends();
-            QStringList backends;
-            QStringList allPrefix;
-            for (int i = 0; i < filterList.count(); ++i)
-            {
-                QPair <QString, QString> item = filterList.at (i);
-                /* Create one backend filter string */
-                backends << QString ("%1 (%2)").arg (item.first). arg (item.second);
-                /* Save the suffix's for the "All" entry */
-                allPrefix << item.second;
-            }
-            if (!allPrefix.isEmpty())
-                backends.insert (0, tr ("All hard disk images (%1)").arg (allPrefix.join (" ").trimmed()));
-            backends << tr ("All files (*)");
-            filter = backends.join (";;").trimmed();
-
+            filterList = vboxGlobal().HDDBackends();
             title = tr ("Select a hard disk image file");
-            break;
-        }
-        case VBoxDefs::MediumType_DVD:
-        {
-            filter = tr ("CD/DVD-ROM images (*.iso);;All files (*)");
-            title = tr ("Select a CD/DVD-ROM disk image file");
+            allType = tr ("hard disk");
             break;
         }
         case VBoxDefs::MediumType_Floppy:
         {
-            filter = tr ("Floppy images (*.img);;All files (*)");
+            filterList = vboxGlobal().FloppyBackends();
             title = tr ("Select a floppy disk image file");
+            allType = tr ("floppy disk");
             break;
         }
@@ -1020,4 +1013,17 @@
             break;
     }
+
+    for (int i = 0; i < filterList.count(); ++i)
+    {
+        QPair <QString, QString> item = filterList.at (i);
+        /* Create one backend filter string */
+        backends << QString ("%1 (%2)").arg (item.first). arg (item.second);
+        /* Save the suffix's for the "All" entry */
+        allPrefix << item.second;
+    }
+    if (!allPrefix.isEmpty())
+        backends.insert (0, tr ("All %1 images (%2)").arg (allType). arg (allPrefix.join (" ").trimmed()));
+    backends << tr ("All files (*)");
+    filter = backends.join (";;").trimmed();
 
     QStringList files = QIFileDialog::getOpenFileNames (dir, filter, this, title);
Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 33523)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 33524)
@@ -4060,10 +4060,11 @@
 
 /**
- * Figures out which hard disk formats are currently supported by VirtualBox.
+ * Figures out which medium formats are currently supported by VirtualBox for
+ * the given device type.
  * Returned is a list of pairs with the form
  *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
  */
 /* static */
-QList <QPair <QString, QString> > VBoxGlobal::HDDBackends()
+QList <QPair <QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType)
 {
     CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
@@ -4073,8 +4074,13 @@
     {
         /* File extensions */
-        QVector <QString> fileExtensions = mediumFormats [i].GetFileExtensions();
+        QVector <QString> fileExtensions;
+        QVector <KDeviceType> deviceTypes;
+
+        mediumFormats [i].DescribeFileExtensions(fileExtensions, deviceTypes);
+
         QStringList f;
         for (int a = 0; a < fileExtensions.size(); ++ a)
-            f << QString ("*.%1").arg (fileExtensions [a]);
+            if (deviceTypes [a] == enmType)
+                f << QString ("*.%1").arg (fileExtensions [a]);
         /* Create a pair out of the backend description and all suffix's. */
         if (!f.isEmpty())
@@ -4082,4 +4088,37 @@
     }
     return backendPropList;
+}
+
+/**
+ * Figures out which hard disk formats are currently supported by VirtualBox.
+ * Returned is a list of pairs with the form
+ *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
+ */
+/* static */
+QList <QPair <QString, QString> > VBoxGlobal::HDDBackends()
+{
+    return MediumBackends(KDeviceType_HardDisk);
+}
+
+/**
+ * Figures out which CD/DVD disk formats are currently supported by VirtualBox.
+ * Returned is a list of pairs with the form
+ *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
+ */
+/* static */
+QList <QPair <QString, QString> > VBoxGlobal::DVDBackends()
+{
+    return MediumBackends(KDeviceType_DVD);
+}
+
+/**
+ * Figures out which floppy disk formats are currently supported by VirtualBox.
+ * Returned is a list of pairs with the form
+ *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
+ */
+/* static */
+QList <QPair <QString, QString> > VBoxGlobal::FloppyBackends()
+{
+    return MediumBackends(KDeviceType_Floppy);
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 33523)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 33524)
@@ -630,5 +630,8 @@
                                 bool aRecursive = false);
 
+    static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);
     static QList <QPair <QString, QString> > HDDBackends();
+    static QList <QPair <QString, QString> > DVDBackends();
+    static QList <QPair <QString, QString> > FloppyBackends();
 
     /* Qt 4.2.0 support function */
Index: trunk/src/VBox/Main/ConsoleImpl2.cpp
===================================================================
--- trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 33523)
+++ trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 33524)
@@ -3037,4 +3037,17 @@
                 }
 
+                switch (enmType)
+                {
+                    case DeviceType_DVD:
+                        InsertConfigString(pCfg, "Type", "DVD");
+                        break;
+                    case DeviceType_Floppy:
+                        InsertConfigString(pCfg, "Type", "Floppy");
+                        break;
+                    case DeviceType_HardDisk:
+                    default:
+                        InsertConfigString(pCfg, "Type", "HardDisk");
+                }
+
                 /* Pass all custom parameters. */
                 bool fHostIP = true;
Index: trunk/src/VBox/Main/MediumFormatImpl.cpp
===================================================================
--- trunk/src/VBox/Main/MediumFormatImpl.cpp	(revision 33523)
+++ trunk/src/VBox/Main/MediumFormatImpl.cpp	(revision 33524)
@@ -1,4 +1,3 @@
 /* $Id$ */
-
 /** @file
  *
@@ -68,11 +67,31 @@
     unconst(m.capabilities) = aVDInfo->uBackendCaps;
     /* Save the supported file extensions in a list */
-    if (aVDInfo->papszFileExtensions)
+    if (aVDInfo->paFileExtensions)
     {
-        const char *const *papsz = aVDInfo->papszFileExtensions;
-        while (*papsz != NULL)
+        PCVDFILEEXTENSION papExtension = aVDInfo->paFileExtensions;
+        while (papExtension->pszExtension != NULL)
         {
-            unconst(m.llFileExtensions).push_back(*papsz);
-            ++papsz;
+            DeviceType_T devType;
+
+            unconst(m.llFileExtensions).push_back(papExtension->pszExtension);
+
+            switch(papExtension->enmType)
+            {
+                case VDTYPE_HDD:
+                    devType = DeviceType_HardDisk;
+                    break;
+                case VDTYPE_DVD:
+                    devType = DeviceType_DVD;
+                    break;
+                case VDTYPE_FLOPPY:
+                    devType = DeviceType_Floppy;
+                    break;
+                default:
+                    AssertMsgFailed(("Invalid enm type %d!\n", papExtension->enmType));
+                    return E_INVALIDARG;
+            }
+
+            unconst(m.llDeviceTypes).push_back(devType);
+            ++papExtension;
         }
     }
@@ -162,4 +181,5 @@
     unconst(m.llProperties).clear();
     unconst(m.llFileExtensions).clear();
+    unconst(m.llDeviceTypes).clear();
     unconst(m.capabilities) = 0;
     unconst(m.strName).setNull();
@@ -196,5 +216,26 @@
 }
 
-STDMETHODIMP MediumFormat::COMGETTER(FileExtensions)(ComSafeArrayOut(BSTR, aFileExtensions))
+STDMETHODIMP MediumFormat::COMGETTER(Capabilities)(ULONG *aCaps)
+{
+    CheckComArgOutPointerValid(aCaps);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    /* m.capabilities is const, no need to lock */
+
+    /// @todo add COMGETTER(ExtendedCapabilities) when we reach the 32 bit
+    /// limit (or make the argument ULONG64 after checking that COM is capable
+    /// of defining enums (used to represent bit flags) that contain 64-bit
+    /// values)
+    ComAssertRet(m.capabilities == ((ULONG)m.capabilities), E_FAIL);
+
+    *aCaps = (ULONG) m.capabilities;
+
+    return S_OK;
+}
+
+STDMETHODIMP MediumFormat::DescribeFileExtensions(ComSafeArrayOut(BSTR, aFileExtensions),
+                                                  ComSafeArrayOut(DeviceType_T, aDeviceTypes))
 {
     CheckComArgOutSafeArrayPointerValid(aFileExtensions);
@@ -212,23 +253,11 @@
     fileExtentions.detachTo(ComSafeArrayOutArg(aFileExtensions));
 
-    return S_OK;
-}
-
-STDMETHODIMP MediumFormat::COMGETTER(Capabilities)(ULONG *aCaps)
-{
-    CheckComArgOutPointerValid(aCaps);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* m.capabilities is const, no need to lock */
-
-    /// @todo add COMGETTER(ExtendedCapabilities) when we reach the 32 bit
-    /// limit (or make the argument ULONG64 after checking that COM is capable
-    /// of defining enums (used to represent bit flags) that contain 64-bit
-    /// values)
-    ComAssertRet(m.capabilities == ((ULONG)m.capabilities), E_FAIL);
-
-    *aCaps = (ULONG) m.capabilities;
+    com::SafeArray<DeviceType_T> deviceTypes(m.llDeviceTypes.size());
+    i = 0;
+    for (DeviceTypeList::const_iterator it = m.llDeviceTypes.begin();
+         it != m.llDeviceTypes.end();
+         ++it, ++i)
+        deviceTypes[i] = (*it);
+    deviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
 
     return S_OK;
Index: trunk/src/VBox/Main/MediumImpl.cpp
===================================================================
--- trunk/src/VBox/Main/MediumImpl.cpp	(revision 33523)
+++ trunk/src/VBox/Main/MediumImpl.cpp	(revision 33524)
@@ -1024,20 +1024,11 @@
     m->hddOpenMode = enOpenMode;
 
-    if (aDeviceType == DeviceType_HardDisk)
-        rc = setLocation(aLocation);
-    else
-    {
-        if (aDeviceType == DeviceType_DVD)
-            m->type = MediumType_Readonly;
-        else
-            m->type = MediumType_Writethrough;
-        rc = setLocation(aLocation, "RAW");
-    }
+    if (aDeviceType == DeviceType_DVD)
+        m->type = MediumType_Readonly;
+    else if (aDeviceType == DeviceType_Floppy)
+        m->type = MediumType_Writethrough;
+
+    rc = setLocation(aLocation);
     if (FAILED(rc)) return rc;
-
-    if (    aDeviceType == DeviceType_DVD
-         || aDeviceType == DeviceType_Floppy)
-        // create new UUID
-        unconst(m->id).create();
 
     /* get all the information about the medium from the storage unit */
@@ -3660,4 +3651,5 @@
         if (isImport)
         {
+            VDTYPE enmType = VDTYPE_INVALID;
             char *backendName = NULL;
 
@@ -3674,5 +3666,5 @@
             {
                 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                                  locationFull.c_str(), &backendName);
+                                  locationFull.c_str(), &backendName, &enmType);
             }
             else if (vrc != VERR_FILE_NOT_FOUND && vrc != VERR_PATH_NOT_FOUND)
@@ -3681,5 +3673,5 @@
                 locationFull = aLocation;
                 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                                  locationFull.c_str(), &backendName);
+                                  locationFull.c_str(), &backendName, &enmType);
             }
 
@@ -3702,4 +3694,14 @@
                 }
             }
+            else if (m->devType != convertToDeviceType(enmType))
+            {
+                /*
+                 * The user tried to use a image as a device which is not supported
+                 * by the backend.
+                 */
+                return setError(E_FAIL,
+                                tr("The medium '%s' can't be used as the requested device type"),
+                                locationFull.c_str());
+            }
             else
             {
@@ -3843,5 +3845,5 @@
 
         PVBOXHDD hdd;
-        vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -4092,5 +4094,5 @@
         {
             PVBOXHDD hdd;
-            vrc = VDCreate(m->vdDiskIfaces, &hdd);
+            vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
             ComAssertRCThrow(vrc, E_FAIL);
 
@@ -4207,4 +4209,54 @@
 
     return rc;
+}
+
+/**
+ * Converts the Medium device type to the VD type.
+ */
+VDTYPE Medium::convertDeviceType()
+{
+    VDTYPE enmType;
+
+    switch (m->devType)
+    {
+        case DeviceType_HardDisk:
+            enmType = VDTYPE_HDD;
+            break;
+        case DeviceType_DVD:
+            enmType = VDTYPE_DVD;
+            break;
+        case DeviceType_Floppy:
+            enmType = VDTYPE_FLOPPY;
+            break;
+        default:
+            ComAssertFailedThrow(E_FAIL);
+    }
+
+    return enmType;
+}
+
+/**
+ * Converts from the VD type to the medium type.
+ */
+DeviceType_T Medium::convertToDeviceType(VDTYPE enmType)
+{
+    DeviceType_T devType;
+
+    switch (enmType)
+    {
+        case VDTYPE_HDD:
+            devType = DeviceType_HardDisk;
+            break;
+        case VDTYPE_DVD:
+            devType = DeviceType_DVD;
+            break;
+        case VDTYPE_FLOPPY:
+            devType = DeviceType_Floppy;
+            break;
+        default:
+            ComAssertFailedThrow(E_FAIL);
+    }
+
+    return devType;
 }
 
@@ -5740,5 +5792,5 @@
     {
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -5881,5 +5933,5 @@
 
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -6018,5 +6070,5 @@
 
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -6187,5 +6239,5 @@
     {
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -6512,5 +6564,5 @@
 
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -6564,5 +6616,5 @@
 
             PVBOXHDD targetHdd;
-            vrc = VDCreate(m->vdDiskIfaces, &targetHdd);
+            vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &targetHdd);
             ComAssertRCThrow(vrc, E_FAIL);
 
@@ -6740,5 +6792,5 @@
 
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -6812,5 +6864,5 @@
 
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -6950,5 +7002,5 @@
     {
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -7047,5 +7099,5 @@
     {
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -7149,5 +7201,5 @@
 
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -7197,5 +7249,5 @@
 
             PVBOXHDD targetHdd;
-            vrc = VDCreate(m->vdDiskIfaces, &targetHdd);
+            vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &targetHdd);
             ComAssertRCThrow(vrc, E_FAIL);
 
@@ -7284,5 +7336,5 @@
 
         PVBOXHDD hdd;
-        int vrc = VDCreate(m->vdDiskIfaces, &hdd);
+        int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd);
         ComAssertRCThrow(vrc, E_FAIL);
 
@@ -7318,5 +7370,5 @@
 
             PVBOXHDD targetHdd;
-            vrc = VDCreate(m->vdDiskIfaces, &targetHdd);
+            vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &targetHdd);
             ComAssertRCThrow(vrc, E_FAIL);
 
Index: trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 33523)
+++ trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 33524)
@@ -468,5 +468,6 @@
     <const name="v1_11"     value="13">
       <desc>Settings version "1.11", written by VirtualBox 4.0.x.</desc>
-      <!-- Machine changes: HD Audio controller, per-machine disk registries
+      <!-- Machine changes: HD Audio controller, per-machine disk registries,
+           /@format attribute for DVD and floppy images.
            -->
     </const>
@@ -10147,5 +10148,5 @@
   <interface
      name="IMediumFormat" extends="$unknown"
-     uuid="89f52554-d469-4799-9fad-1705e86a08b1"
+     uuid="4e9a873f-0599-434a-8345-619ef3fb3111"
      wsmap="managed"
      >
@@ -10195,11 +10196,19 @@
     </attribute>
 
-    <attribute name="fileExtensions" type="wstring" safearray="yes" readonly="yes">
-      <desc>
-        Array of strings containing the supported file extensions.
-
-        The first extension in the array is the extension preferred by the
-        backend. It is recommended to use this extension when specifying a
-        location of the storage unit for a new medium.
+    <attribute name="capabilities" type="unsigned long" readonly="yes">
+      <desc>
+        Capabilities of the format as a set of bit flags.
+
+        For the meaning of individual capability flags see
+        <link to="MediumFormatCapabilities"/>.
+      </desc>
+    </attribute>
+
+    <method name="describeFileExtensions">
+      <desc>
+        Returns two arrays describing the supported file extensions.
+
+        The first array contains the supported extensions and the seconds one
+        the type each extension supports. Both have the same size.
 
         Note that some backends do not work on files, so this array may be
@@ -10208,14 +10217,11 @@
         <see>IMediumFormat::capabilities</see>
       </desc>
-    </attribute>
-
-    <attribute name="capabilities" type="unsigned long" readonly="yes">
-      <desc>
-        Capabilities of the format as a set of bit flags.
-
-        For the meaning of individual capability flags see
-        <link to="MediumFormatCapabilities"/>.
-      </desc>
-    </attribute>
+      <param  name="extensions" type="wstring" safearray="yes" dir="out">
+        <desc>The array of supported extensions.</desc>
+      </param>
+      <param  name="type" type="DeviceType" safearray="yes" dir="out">
+        <desc>The array which indicates the device type for every given extension.</desc>
+      </param>
+    </method>
 
     <method name="describeProperties">
Index: trunk/src/VBox/Main/include/MediumFormatImpl.h
===================================================================
--- trunk/src/VBox/Main/include/MediumFormatImpl.h	(revision 33523)
+++ trunk/src/VBox/Main/include/MediumFormatImpl.h	(revision 33524)
@@ -53,6 +53,7 @@
     };
 
-    typedef std::list<Utf8Str>  StrList;
-    typedef std::list<Property> PropertyList;
+    typedef std::list<Utf8Str>      StrList;
+    typedef std::list<DeviceType_T> DeviceTypeList;
+    typedef std::list<Property>     PropertyList;
 
     struct Data
@@ -60,9 +61,10 @@
         Data() : capabilities(0) {}
 
-        const Utf8Str       strId;
-        const Utf8Str       strName;
-        const StrList       llFileExtensions;
-        const uint64_t      capabilities;
-        const PropertyList  llProperties;
+        const Utf8Str        strId;
+        const Utf8Str        strName;
+        const StrList        llFileExtensions;
+        const DeviceTypeList llDeviceTypes;
+        const uint64_t       capabilities;
+        const PropertyList   llProperties;
     };
 
@@ -91,8 +93,9 @@
     STDMETHOD(COMGETTER(Id))(BSTR *aId);
     STDMETHOD(COMGETTER(Name))(BSTR *aName);
-    STDMETHOD(COMGETTER(FileExtensions))(ComSafeArrayOut(BSTR, aFileExtensions));
     STDMETHOD(COMGETTER(Capabilities))(ULONG *aCaps);
 
     // IMediumFormat methods
+    STDMETHOD(DescribeFileExtensions)(ComSafeArrayOut(BSTR, aFileExtensions),
+                                      ComSafeArrayOut(DeviceType_T, aDeviceTypes));
     STDMETHOD(DescribeProperties)(ComSafeArrayOut(BSTR, aNames),
                                   ComSafeArrayOut(BSTR, aDescriptions),
Index: trunk/src/VBox/Main/include/MediumImpl.h
===================================================================
--- trunk/src/VBox/Main/include/MediumImpl.h	(revision 33523)
+++ trunk/src/VBox/Main/include/MediumImpl.h	(revision 33524)
@@ -300,4 +300,7 @@
     Utf8Str vdError(int aVRC);
 
+    VDTYPE convertDeviceType();
+    DeviceType_T convertToDeviceType(VDTYPE enmType);
+
     static DECLCALLBACK(void) vdErrorCall(void *pvUser, int rc, RT_SRC_POS_DECL,
                                           const char *pszFormat, va_list va);
Index: trunk/src/VBox/Main/include/VirtualBoxBase.h
===================================================================
--- trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 33523)
+++ trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 33524)
@@ -164,4 +164,26 @@
 
 /**
+ *  Special version of the AssertFailed macro to be used within VirtualBoxBase
+ *  subclasses that also inherit the VirtualBoxSupportErrorInfoImpl template.
+ *
+ *  In the debug build, this macro is equivalent to AssertFailed.
+ *  In the release build, this macro uses |setError(E_FAIL, ...)| to set the
+ *  error info from the asserted expression.
+ *
+ *  @see VirtualBoxSupportErrorInfoImpl::setError
+ *
+ */
+#if defined (DEBUG)
+#define ComAssertFailed()    AssertFailed()
+#else
+#define ComAssertFailed()    \
+    do { \
+        setError(E_FAIL, \
+                 "Assertion failed: at '%s' (%d) in %s.\nPlease contact the product vendor!", \
+                 __FILE__, __LINE__, __PRETTY_FUNCTION__); \
+    } while (0)
+#endif
+
+/**
  *  Special version of the AssertMsg macro to be used within VirtualBoxBase
  *  subclasses that also inherit the VirtualBoxSupportErrorInfoImpl template.
@@ -280,4 +302,7 @@
 #define ComAssertComRCThrowRC(rc)                 \
     if (1)  { ComAssertComRC(rc); if (!SUCCEEDED(rc)) { throw rc; } } else do {} while (0)
+/** Special version of ComAssert that throws eval */
+#define ComAssertFailedThrow(eval)                \
+    if (1) { ComAssertFailed(); { throw (eval); } } else do {} while (0)
 
 ////////////////////////////////////////////////////////////////////////////////
Index: trunk/src/VBox/Main/xml/Settings.cpp
===================================================================
--- trunk/src/VBox/Main/xml/Settings.cpp	(revision 33523)
+++ trunk/src/VBox/Main/xml/Settings.cpp	(revision 33524)
@@ -671,15 +671,26 @@
             else if (strType == "SHAREABLE")
                 med.hdType = MediumType_Shareable;
+            else if (strType == "READONLY")
+                med.hdType = MediumType_Readonly;
             else
                 throw ConfigFileError(this, &elmMedium, N_("HardDisk/@type attribute must be one of Normal, Immutable or Writethrough"));
         }
     }
-    else if (m->sv < SettingsVersion_v1_4)
-    {
-        // DVD and floppy images before 1.4 had "src" attribute instead of "location"
-        if (!(elmMedium.getAttributeValue("src", med.strLocation)))
-            throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName());
-
-        fNeedsLocation = false;
+    else
+    {
+        if (m->sv < SettingsVersion_v1_4)
+        {
+            // DVD and floppy images before 1.4 had "src" attribute instead of "location"
+            if (!(elmMedium.getAttributeValue("src", med.strLocation)))
+                throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName());
+
+            fNeedsLocation = false;
+        }
+
+        if (!(elmMedium.getAttributeValue("format", med.strFormat)))
+        {
+            // DVD and floppy images before 1.11 had no format attribute. assign the default.
+            med.strFormat = "RAW";
+        }
     }
 
@@ -979,16 +990,23 @@
  * @param level
  */
-void ConfigFileBase::buildHardDisk(xml::ElementNode &elmMedium,
-                                   const Medium &mdm,
-                                   uint32_t level)          // 0 for "root" call, incremented with each recursion
-{
-    xml::ElementNode *pelmHardDisk = elmMedium.createChild("HardDisk");
-    pelmHardDisk->setAttribute("uuid", mdm.uuid.toStringCurly());
-    pelmHardDisk->setAttribute("location", mdm.strLocation);
-    pelmHardDisk->setAttribute("format", mdm.strFormat);
+void ConfigFileBase::buildMedium(xml::ElementNode &elmMedium,
+                                 DeviceType_T devType,
+                                 const Medium &mdm,
+                                 uint32_t level)          // 0 for "root" call, incremented with each recursion
+{
+    xml::ElementNode *pelmMedium;
+
+    if (devType == DeviceType_HardDisk)
+        pelmMedium = elmMedium.createChild("HardDisk");
+    else
+        pelmMedium = elmMedium.createChild("Image");
+
+    pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly());
+    pelmMedium->setAttribute("location", mdm.strLocation);
+    pelmMedium->setAttribute("format", mdm.strFormat);
     if (mdm.fAutoReset)
-        pelmHardDisk->setAttribute("autoReset", mdm.fAutoReset);
+        pelmMedium->setAttribute("autoReset", mdm.fAutoReset);
     if (mdm.strDescription.length())
-        pelmHardDisk->setAttribute("Description", mdm.strDescription);
+        pelmMedium->setAttribute("Description", mdm.strDescription);
 
     for (StringsMap::const_iterator it = mdm.properties.begin();
@@ -996,5 +1014,5 @@
          ++it)
     {
-        xml::ElementNode *pelmProp = pelmHardDisk->createChild("Property");
+        xml::ElementNode *pelmProp = pelmMedium->createChild("Property");
         pelmProp->setAttribute("name", it->first);
         pelmProp->setAttribute("value", it->second);
@@ -1008,6 +1026,7 @@
             mdm.hdType == MediumType_Immutable ? "Immutable" :
             mdm.hdType == MediumType_Writethrough ? "Writethrough" :
-            mdm.hdType == MediumType_Shareable ? "Shareable" : "INVALID";
-        pelmHardDisk->setAttribute("type", pcszType);
+            mdm.hdType == MediumType_Shareable ? "Shareable" :
+            mdm.hdType == MediumType_Readonly ? "Readonly" : "INVALID";
+        pelmMedium->setAttribute("type", pcszType);
     }
 
@@ -1017,7 +1036,8 @@
     {
         // recurse for children
-        buildHardDisk(*pelmHardDisk, // parent
-                      *it,           // settings::Medium
-                      ++level);      // recursion level
+        buildMedium(*pelmMedium, // parent
+                    devType,     // device type
+                    *it,         // settings::Medium
+                    ++level);    // recursion level
     }
 }
@@ -1044,5 +1064,5 @@
          ++it)
     {
-        buildHardDisk(*pelmHardDisks, *it, 0);
+        buildMedium(*pelmHardDisks, DeviceType_HardDisk, *it, 0);
     }
 
@@ -1052,10 +1072,5 @@
          ++it)
     {
-        const Medium &mdm = *it;
-        xml::ElementNode *pelmMedium = pelmDVDImages->createChild("Image");
-        pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly());
-        pelmMedium->setAttribute("location", mdm.strLocation);
-        if (mdm.strDescription.length())
-            pelmMedium->setAttribute("Description", mdm.strDescription);
+        buildMedium(*pelmDVDImages, DeviceType_DVD, *it, 0);
     }
 
@@ -1065,10 +1080,5 @@
          ++it)
     {
-        const Medium &mdm = *it;
-        xml::ElementNode *pelmMedium = pelmFloppyImages->createChild("Image");
-        pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly());
-        pelmMedium->setAttribute("location", mdm.strLocation);
-        if (mdm.strDescription.length())
-            pelmMedium->setAttribute("Description", mdm.strDescription);
+        buildMedium(*pelmFloppyImages, DeviceType_Floppy, *it, 0);
     }
 }
