Index: trunk/src/VBox/Devices/Storage/DMGHDDCore.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/DMGHDDCore.cpp	(revision 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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 33522)
+++ 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);
