- Timestamp:
- Oct 27, 2010 4:44:37 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxHDD-Plugin.h
r32536 r33524 61 61 62 62 /** 63 * Pointer to a NULL-terminated array of strings, containing the supported63 * Pointer to a NULL-terminated array, containing the supported 64 64 * file extensions. Note that some backends do not work on files, so this 65 65 * pointer may just contain NULL. 66 66 */ 67 const char * const *papszFileExtensions;67 PCVDFILEEXTENSION paFileExtensions; 68 68 69 69 /** … … 87 87 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 88 88 * @param pVDIfsImage Pointer to the per-image VD interface list. 89 */ 90 DECLR3CALLBACKMEMBER(int, pfnCheckIfValid, (const char *pszFilename, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage)); 89 * @param penmType Returns the supported device type on success. 90 */ 91 DECLR3CALLBACKMEMBER(int, pfnCheckIfValid, (const char *pszFilename, PVDINTERFACE pVDIfsDisk, 92 PVDINTERFACE pVDIfsImage, VDTYPE *penmType)); 91 93 92 94 /** … … 99 101 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 100 102 * @param pVDIfsImage Pointer to the per-image VD interface list. 103 * @param enmType Requested type of the image. 101 104 * @param ppBackendData Opaque state data for this image. 102 105 */ 103 106 DECLR3CALLBACKMEMBER(int, pfnOpen, (const char *pszFilename, unsigned uOpenFlags, 104 107 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 105 void **ppBackendData));108 VDTYPE enmType, void **ppBackendData)); 106 109 107 110 /** -
trunk/include/VBox/VBoxHDD.h
r33205 r33524 247 247 /** @}*/ 248 248 249 /** @name VBox HDD container type. 250 * @{ 251 */ 252 typedef enum VDTYPE 253 { 254 /** Invalid. */ 255 VDTYPE_INVALID = 0, 256 /** HardDisk */ 257 VDTYPE_HDD, 258 /** CD/DVD */ 259 VDTYPE_DVD, 260 /** Floppy. */ 261 VDTYPE_FLOPPY 262 } VDTYPE; 263 /** @}*/ 264 249 265 /** 250 266 * Supported interface types. … … 1529 1545 1530 1546 /** 1547 * Structure describing a file extension. 1548 */ 1549 typedef struct VDFILEEXTENSION 1550 { 1551 /** Pointer to the NULL-terminated string containing the extension. */ 1552 const char *pszExtension; 1553 /** The device type the extension supports. */ 1554 VDTYPE enmType; 1555 } VDFILEEXTENSION; 1556 1557 /** Pointer to a structure describing a file extension. */ 1558 typedef VDFILEEXTENSION *PVDFILEEXTENSION; 1559 1560 /** Pointer to a const structure describing a file extension. */ 1561 typedef const VDFILEEXTENSION *PCVDFILEEXTENSION; 1562 1563 /** 1531 1564 * Data structure for returning a list of backend capabilities. 1532 1565 */ … … 1540 1573 * file extensions. Note that some backends do not work on files, so this 1541 1574 * pointer may just contain NULL. */ 1542 const char * const *papszFileExtensions;1575 PCVDFILEEXTENSION paFileExtensions; 1543 1576 /** Pointer to an array of structs describing each supported config key. 1544 1577 * Terminated by a NULL config key. Note that some backends do not support … … 2000 2033 * @return VBox status code. 2001 2034 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 2035 * @param enmType Type of the image container. 2002 2036 * @param ppDisk Where to store the reference to HDD container. 2003 2037 */ 2004 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk);2038 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, VDTYPE enmType, PVBOXHDD *ppDisk); 2005 2039 2006 2040 /** … … 2024 2058 * @param ppszFormat Receives pointer of the UTF-8 string which contains the format name. 2025 2059 * The returned pointer must be freed using RTStrFree(). 2060 * @param penmType Where to store the type of the image. 2026 2061 */ 2027 2062 VBOXDDU_DECL(int) VDGetFormat(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 2028 const char *pszFilename, char **ppszFormat );2063 const char *pszFilename, char **ppszFormat, VDTYPE *penmType); 2029 2064 2030 2065 /** -
trunk/include/VBox/settings.h
r33386 r33524 185 185 const USBDeviceFiltersList &ll, 186 186 bool fHostMode); 187 void buildHardDisk(xml::ElementNode &elmMedium, 188 const Medium &m, 189 uint32_t level); 187 void buildMedium(xml::ElementNode &elmMedium, 188 DeviceType_T devType, 189 const Medium &m, 190 uint32_t level); 190 191 void buildMediaRegistry(xml::ElementNode &elmParent, 191 192 const MediaRegistry &mr); -
trunk/src/VBox/Devices/Storage/DMGHDDCore.cpp
r33479 r33524 407 407 408 408 /** NULL-terminated array of supported file extensions. */ 409 static const char *const s_apszDmgFileExtensions[] =410 { 411 "dmg",412 NULL409 static const VDFILEEXTENSION s_aDmgFileExtensions[] = 410 { 411 {"dmg", VDTYPE_DVD}, 412 {NULL, VDTYPE_INVALID} 413 413 }; 414 414 … … 1592 1592 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 1593 1593 static int dmgCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 1594 PVDINTERFACE pVDIfsImage) 1595 { 1596 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage)); 1594 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 1595 { 1596 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n", 1597 pszFilename, pVDIfsDisk, pVDIfsImage, penmType)); 1597 1598 int rc; 1598 1599 PVDIOSTORAGE pStorage; … … 1639 1640 { 1640 1641 if (dmgUdifFtrIsValid(&Ftr, offFtr)) 1642 { 1641 1643 rc = VINF_SUCCESS; 1644 *penmType = VDTYPE_DVD; 1645 } 1642 1646 else 1643 1647 { … … 1659 1663 static int dmgOpen(const char *pszFilename, unsigned uOpenFlags, 1660 1664 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 1661 void **ppBackendData)1665 VDTYPE enmType, void **ppBackendData) 1662 1666 { 1663 1667 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 2136 2140 { 2137 2141 LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment)); 2138 PDMGIMAGE p This= (PDMGIMAGE)pBackendData;2142 PDMGIMAGE pImage = (PDMGIMAGE)pBackendData; 2139 2143 int rc; 2140 2144 2141 AssertPtr(pThis); 2142 2143 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2144 { 2145 rc = VERR_VD_IMAGE_READ_ONLY; 2146 goto out; 2147 } 2148 2149 if (pThis) 2150 rc = VERR_NOT_SUPPORTED; 2145 AssertPtr(pImage); 2146 2147 if (pImage) 2148 { 2149 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2150 rc = VERR_VD_IMAGE_READ_ONLY; 2151 else 2152 rc = VERR_NOT_SUPPORTED; 2153 } 2151 2154 else 2152 2155 rc = VERR_VD_NOT_OPENED; … … 2346 2349 /* uBackendCaps */ 2347 2350 VD_CAP_FILE | VD_CAP_VFS, 2348 /* pa pszFileExtensions */2349 s_a pszDmgFileExtensions,2351 /* paFileExtensions */ 2352 s_aDmgFileExtensions, 2350 2353 /* paConfigInfo */ 2351 2354 NULL, -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r33218 r33524 2004 2004 unsigned iLevel = 0; 2005 2005 PCFGMNODE pCurNode = pCfg; 2006 VDTYPE enmType = VDTYPE_HDD; 2006 2007 2007 2008 for (;;) … … 2017 2018 "ReadOnly\0MaybeReadOnly\0TempReadOnly\0Shareable\0HonorZeroWrites\0" 2018 2019 "HostIPStack\0UseNewIo\0BootAcceleration\0BootAccelerationBuffer\0" 2019 "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0 ");2020 "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0"); 2020 2021 } 2021 2022 else … … 2132 2133 else 2133 2134 rc = VINF_SUCCESS; 2135 2136 char *psz; 2137 rc = CFGMR3QueryStringAlloc(pCfg, "Type", &psz); 2138 if (RT_FAILURE(rc)) 2139 { 2140 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type")); 2141 break; 2142 } 2143 else if (!strcmp(psz, "HardDisk")) 2144 enmType = VDTYPE_HDD; 2145 else if (!strcmp(psz, "DVD")) 2146 enmType = VDTYPE_DVD; 2147 else if (!strcmp(psz, "Floppy")) 2148 enmType = VDTYPE_FLOPPY; 2149 else 2150 { 2151 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS, 2152 N_("Unknown type \"%s\""), psz); 2153 MMR3HeapFree(psz); 2154 break; 2155 } 2156 MMR3HeapFree(psz); psz = NULL; 2134 2157 } 2135 2158 … … 2270 2293 if (RT_SUCCESS(rc)) 2271 2294 { 2272 rc = VDCreate(pThis->pVDIfsDisk, &pThis->pDisk);2295 rc = VDCreate(pThis->pVDIfsDisk, enmType, &pThis->pDisk); 2273 2296 /* Error message is already set correctly. */ 2274 2297 } -
trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp
r33182 r33524 4369 4369 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 4370 4370 static int iscsiCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 4371 PVDINTERFACE pVDIfsImage )4371 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 4372 4372 { 4373 4373 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); … … 4384 4384 static int iscsiOpen(const char *pszFilename, unsigned uOpenFlags, 4385 4385 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 4386 void **ppBackendData)4386 VDTYPE enmType, void **ppBackendData) 4387 4387 { 4388 4388 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); -
trunk/src/VBox/Devices/Storage/ParallelsHDDCore.cpp
r33258 r33524 105 105 106 106 /** NULL-terminated array of supported file extensions. */ 107 static const char *const s_apszParallelsFileExtensions[] =108 { 109 "hdd",110 NULL107 static const VDFILEEXTENSION s_aParallelsFileExtensions[] = 108 { 109 {"hdd", VDTYPE_HDD}, 110 {NULL, VDTYPE_INVALID} 111 111 }; 112 112 … … 415 415 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 416 416 static int parallelsCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 417 PVDINTERFACE pVDIfsImage )417 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 418 418 { 419 419 int rc; … … 471 471 } 472 472 473 if (RT_SUCCESS(rc)) 474 *penmType = VDTYPE_HDD; 475 473 476 pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage); 474 477 return rc; … … 478 481 static int parallelsOpen(const char *pszFilename, unsigned uOpenFlags, 479 482 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 480 void **ppBackendData)483 VDTYPE enmType, void **ppBackendData) 481 484 { 482 485 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 1001 1004 AssertPtr(pImage); 1002 1005 1003 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1004 { 1005 rc = VERR_VD_IMAGE_READ_ONLY; 1006 goto out; 1007 } 1008 1009 if (pImage) 1010 rc = VERR_NOT_SUPPORTED; 1006 if (pImage) 1007 { 1008 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1009 rc = VERR_VD_IMAGE_READ_ONLY; 1010 else 1011 rc = VERR_NOT_SUPPORTED; 1012 } 1011 1013 else 1012 1014 rc = VERR_VD_NOT_OPENED; … … 1357 1359 /* uBackendCaps */ 1358 1360 VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS, 1359 /* pa pszFileExtensions */1360 s_a pszParallelsFileExtensions,1361 /* paFileExtensions */ 1362 s_aParallelsFileExtensions, 1361 1363 /* paConfigInfo */ 1362 1364 NULL, -
trunk/src/VBox/Devices/Storage/RawHDDCore.cpp
r33234 r33524 26 26 #include <iprt/assert.h> 27 27 #include <iprt/alloc.h> 28 28 #include <iprt/path.h> 29 29 30 30 /******************************************************************************* 31 31 * Constants And Macros, Structures and Typedefs * 32 32 *******************************************************************************/ 33 /** 34 * ISO volume descriptor. 35 */ 36 #pragma pack(1) 37 typedef struct ISOVOLDESC 38 { 39 union 40 { 41 /** Byte view. */ 42 uint8_t au8[2048]; 43 /** Field view. */ 44 struct 45 { 46 /** Descriptor type. */ 47 uint8_t u8Type; 48 /** Standard identifier */ 49 uint8_t au8Id[5]; 50 /** Descriptor version. */ 51 uint8_t u8Version; 52 /** Rest depends on the descriptor type. */ 53 } fields; 54 }; 55 } ISOVOLDESC, *PISOVOLDESC; 56 #pragma pack() 57 AssertCompileSize(ISOVOLDESC, 2048); 33 58 34 59 /** … … 82 107 83 108 /** NULL-terminated array of supported file extensions. */ 84 static const char *const s_apszRawFileExtensions[] =85 { 86 /** @todo At the moment this backend doesn't claim any extensions, but it might87 * be useful to add a few later. However this needs careful testing, as the88 * CheckIfValid function never returns success. */89 NULL109 static const VDFILEEXTENSION s_aRawFileExtensions[] = 110 { 111 {"iso", VDTYPE_DVD}, 112 {"img", VDTYPE_FLOPPY}, 113 {"ima", VDTYPE_FLOPPY}, 114 {NULL, VDTYPE_INVALID} 90 115 }; 91 116 … … 484 509 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 485 510 static int rawCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 486 PVDINTERFACE pVDIfsImage) 487 { 488 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); 511 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 512 { 513 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage)); 514 PVDIOSTORAGE pStorage = NULL; 515 uint64_t cbFile; 489 516 int rc = VINF_SUCCESS; 517 ISOVOLDESC IsoVolDesc; 518 char *pszExtension = NULL; 519 520 /* Get I/O interface. */ 521 PVDINTERFACE pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IOINT); 522 AssertPtrReturn(pInterfaceIO, VERR_INVALID_PARAMETER); 523 PVDINTERFACEIOINT pInterfaceIOCallbacks = VDGetInterfaceIOInt(pInterfaceIO); 524 AssertPtrReturn(pInterfaceIOCallbacks, VERR_INVALID_PARAMETER); 490 525 491 526 if ( !VALID_PTR(pszFilename) … … 496 531 } 497 532 498 /* Always return failure, to avoid opening everything as a raw image. */ 499 rc = VERR_VD_RAW_INVALID_HEADER; 533 pszExtension = RTPathExt(pszFilename); 534 535 /* 536 * Open the file and read the footer. 537 */ 538 rc = pInterfaceIOCallbacks->pfnOpen(pInterfaceIO->pvUser, pszFilename, 539 VDOpenFlagsToFileOpenFlags(VD_OPEN_FLAGS_READONLY, 540 false /* fCreate */), 541 &pStorage); 542 if (RT_SUCCESS(rc)) 543 rc = pInterfaceIOCallbacks->pfnGetSize(pInterfaceIO->pvUser, pStorage, 544 &cbFile); 545 546 /* Try to guess the image type based on the extension. */ 547 if ( RT_SUCCESS(rc) 548 && pszExtension) 549 { 550 if (!strcmp(pszExtension, ".iso")) /* DVD images. */ 551 { 552 if (cbFile >= (32768 + sizeof(ISOVOLDESC))) 553 { 554 rc = pInterfaceIOCallbacks->pfnReadSync(pInterfaceIO->pvUser, pStorage, 555 32768, &IsoVolDesc, sizeof(IsoVolDesc), NULL); 556 } 557 else 558 rc = VERR_VD_RAW_INVALID_HEADER; 559 560 if (RT_SUCCESS(rc)) 561 { 562 /* 563 * Do we recognize this stuff? 564 */ 565 if ( !memcmp(IsoVolDesc.fields.au8Id, "BEA01", 5) 566 || !memcmp(IsoVolDesc.fields.au8Id, "BOOT2", 5) 567 || !memcmp(IsoVolDesc.fields.au8Id, "CD001", 5) 568 || !memcmp(IsoVolDesc.fields.au8Id, "CDW02", 5) 569 || !memcmp(IsoVolDesc.fields.au8Id, "NSR02", 5) 570 || !memcmp(IsoVolDesc.fields.au8Id, "NSR03", 5) 571 || !memcmp(IsoVolDesc.fields.au8Id, "TEA01", 5)) 572 { 573 *penmType = VDTYPE_DVD; 574 rc = VINF_SUCCESS; 575 } 576 else 577 rc = VERR_VD_RAW_INVALID_HEADER; 578 } 579 } 580 else if (!strcmp(pszExtension, ".img") || !strcmp(pszExtension, ".ima")) /* Floppy images */ 581 { 582 if (!(cbFile % 512)) 583 { 584 *penmType = VDTYPE_FLOPPY; 585 rc = VINF_SUCCESS; 586 } 587 else 588 rc = VERR_VD_RAW_INVALID_HEADER; 589 } 590 } 591 else 592 rc = VERR_VD_RAW_INVALID_HEADER; 593 594 if (pStorage) 595 pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage); 500 596 501 597 out: … … 507 603 static int rawOpen(const char *pszFilename, unsigned uOpenFlags, 508 604 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 509 void **ppBackendData)605 VDTYPE enmType, void **ppBackendData) 510 606 { 511 607 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 1040 1136 AssertPtr(pImage); 1041 1137 1042 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1043 { 1044 rc = VERR_VD_IMAGE_READ_ONLY; 1045 goto out; 1046 } 1047 1048 if (pImage) 1049 rc = VERR_NOT_SUPPORTED; 1138 if (pImage) 1139 { 1140 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1141 rc = VERR_VD_IMAGE_READ_ONLY; 1142 else 1143 rc = VERR_NOT_SUPPORTED; 1144 } 1050 1145 else 1051 1146 rc = VERR_VD_NOT_OPENED; … … 1292 1387 { 1293 1388 /* pszBackendName */ 1294 " raw",1389 "RAW", 1295 1390 /* cbSize */ 1296 1391 sizeof(VBOXHDDBACKEND), 1297 1392 /* uBackendCaps */ 1298 1393 VD_CAP_CREATE_FIXED | VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS, 1299 /* pa pszFileExtensions */1300 s_a pszRawFileExtensions,1394 /* paFileExtensions */ 1395 s_aRawFileExtensions, 1301 1396 /* paConfigInfo */ 1302 1397 NULL, -
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r33495 r33524 156 156 /** Structure signature (VBOXHDDDISK_SIGNATURE). */ 157 157 uint32_t u32Signature; 158 159 /** Image type. */ 160 VDTYPE enmType; 158 161 159 162 /** Number of opened images. */ … … 440 443 extern VBOXHDDBACKEND g_VhdBackend; 441 444 extern VBOXHDDBACKEND g_ParallelsBackend; 442 #ifdef VBOX_WITH_DMG443 445 extern VBOXHDDBACKEND g_DmgBackend; 444 #endif445 446 #ifdef VBOX_WITH_ISCSI 446 447 extern VBOXHDDBACKEND g_ISCSIBackend; … … 451 452 static PVBOXHDDBACKEND aStaticBackends[] = 452 453 { 453 &g_RawBackend,454 454 &g_VmdkBackend, 455 455 &g_VDIBackend, 456 456 &g_VhdBackend, 457 &g_ParallelsBackend 458 #ifdef VBOX_WITH_DMG 459 ,&g_DmgBackend 460 #endif 457 &g_ParallelsBackend, 458 &g_DmgBackend, 459 &g_RawBackend 461 460 #ifdef VBOX_WITH_ISCSI 462 461 ,&g_ISCSIBackend … … 3584 3583 pEntries[i].pszBackend = g_apBackends[i]->pszBackendName; 3585 3584 pEntries[i].uBackendCaps = g_apBackends[i]->uBackendCaps; 3586 pEntries[i].pa pszFileExtensions = g_apBackends[i]->papszFileExtensions;3585 pEntries[i].paFileExtensions = g_apBackends[i]->paFileExtensions; 3587 3586 pEntries[i].paConfigInfo = g_apBackends[i]->paConfigInfo; 3588 3587 pEntries[i].pfnComposeLocation = g_apBackends[i]->pfnComposeLocation; … … 3622 3621 pEntry->pszBackend = g_apBackends[i]->pszBackendName; 3623 3622 pEntry->uBackendCaps = g_apBackends[i]->uBackendCaps; 3624 pEntry->pa pszFileExtensions = g_apBackends[i]->papszFileExtensions;3623 pEntry->paFileExtensions = g_apBackends[i]->paFileExtensions; 3625 3624 pEntry->paConfigInfo = g_apBackends[i]->paConfigInfo; 3626 3625 return VINF_SUCCESS; … … 3637 3636 * @returns VBox status code. 3638 3637 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 3638 * @param enmType Type of the image container. 3639 3639 * @param ppDisk Where to store the reference to HDD container. 3640 3640 */ 3641 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk)3641 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, VDTYPE enmType, PVBOXHDD *ppDisk) 3642 3642 { 3643 3643 int rc = VINF_SUCCESS; … … 3656 3656 { 3657 3657 pDisk->u32Signature = VBOXHDDDISK_SIGNATURE; 3658 pDisk->enmType = enmType; 3658 3659 pDisk->cImages = 0; 3659 3660 pDisk->pBase = NULL; … … 3809 3810 */ 3810 3811 VBOXDDU_DECL(int) VDGetFormat(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 3811 const char *pszFilename, char **ppszFormat )3812 const char *pszFilename, char **ppszFormat, VDTYPE *penmType) 3812 3813 { 3813 3814 int rc = VERR_NOT_SUPPORTED; … … 3825 3826 AssertMsgReturn(VALID_PTR(ppszFormat), 3826 3827 ("ppszFormat=%#p\n", ppszFormat), 3828 VERR_INVALID_PARAMETER); 3829 AssertMsgReturn(VALID_PTR(ppszFormat), 3830 ("penmType=%#p\n", penmType), 3827 3831 VERR_INVALID_PARAMETER); 3828 3832 … … 3886 3890 { 3887 3891 rc = g_apBackends[i]->pfnCheckIfValid(pszFilename, pVDIfsDisk, 3888 pVDIfsImage );3892 pVDIfsImage, penmType); 3889 3893 if ( RT_SUCCESS(rc) 3890 3894 /* The correct backend has been found, but there is a small … … 4048 4052 pDisk->pVDIfsDisk, 4049 4053 pImage->pVDIfsImage, 4054 pDisk->enmType, 4050 4055 &pImage->pBackendData); 4051 4056 /* If the open in read-write mode failed, retry in read-only mode. */ … … 4063 4068 pDisk->pVDIfsDisk, 4064 4069 pImage->pVDIfsImage, 4070 pDisk->enmType, 4065 4071 &pImage->pBackendData); 4066 4072 if (RT_FAILURE(rc)) … … 7186 7192 pBackendInfo->pszBackend = pImage->Backend->pszBackendName; 7187 7193 pBackendInfo->uBackendCaps = pImage->Backend->uBackendCaps; 7188 pBackendInfo->pa pszFileExtensions = pImage->Backend->papszFileExtensions;7194 pBackendInfo->paFileExtensions = pImage->Backend->paFileExtensions; 7189 7195 pBackendInfo->paConfigInfo = pImage->Backend->paConfigInfo; 7190 7196 } while (0); -
trunk/src/VBox/Devices/Storage/VCICacheCore.cpp
r33522 r33524 1901 1901 AssertPtr(pCache); 1902 1902 1903 if (pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY)1904 {1905 rc = VERR_VD_IMAGE_READ_ONLY;1906 goto out;1907 }1908 1909 1903 if (pCache) 1910 rc = VERR_NOT_SUPPORTED; 1904 { 1905 if (pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1906 rc = VERR_VD_IMAGE_READ_ONLY; 1907 else 1908 rc = VERR_NOT_SUPPORTED; 1909 } 1911 1910 else 1912 1911 rc = VERR_VD_NOT_OPENED; -
trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp
r33478 r33524 38 38 39 39 /** NULL-terminated array of supported file extensions. */ 40 static const char *const s_apszVdiFileExtensions[] =41 { 42 "vdi",43 NULL40 static const VDFILEEXTENSION s_aVdiFileExtensions[] = 41 { 42 {"vdi", VDTYPE_HDD}, 43 {NULL, VDTYPE_INVALID} 44 44 }; 45 45 … … 999 999 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 1000 1000 static int vdiCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 1001 PVDINTERFACE pVDIfsImage )1001 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 1002 1002 { 1003 1003 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); … … 1028 1028 RTMemFree(pImage); 1029 1029 1030 if (RT_SUCCESS(rc)) 1031 *penmType = VDTYPE_HDD; 1032 1030 1033 out: 1031 1034 LogFlowFunc(("returns %Rrc\n", rc)); … … 1036 1039 static int vdiOpen(const char *pszFilename, unsigned uOpenFlags, 1037 1040 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 1038 void **ppBackendData)1041 VDTYPE enmType, void **ppBackendData) 1039 1042 { 1040 1043 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 1701 1704 AssertPtr(pImage); 1702 1705 1703 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)1704 {1705 rc = VERR_VD_IMAGE_READ_ONLY;1706 goto out;1707 }1708 1709 1706 if (pImage) 1710 1707 { 1711 size_t cchComment = pszComment ? strlen(pszComment) : 0; 1712 if (cchComment >= VDI_IMAGE_COMMENT_SIZE) 1713 { 1714 LogFunc(("pszComment is too long, %d bytes!\n", cchComment)); 1715 rc = VERR_VD_VDI_COMMENT_TOO_LONG; 1716 goto out; 1717 } 1718 1719 /* we don't support old style images */ 1720 if (GET_MAJOR_HEADER_VERSION(&pImage->Header) == 1) 1721 { 1722 /* 1723 * Update the comment field, making sure to zero out all of the previous comment. 1724 */ 1725 memset(pImage->Header.u.v1.szComment, '\0', VDI_IMAGE_COMMENT_SIZE); 1726 memcpy(pImage->Header.u.v1.szComment, pszComment, cchComment); 1727 1728 /* write out new the header */ 1729 rc = vdiUpdateHeader(pImage); 1730 } 1708 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 1709 rc = VERR_VD_IMAGE_READ_ONLY; 1731 1710 else 1732 rc = VERR_VD_VDI_UNSUPPORTED_VERSION; 1711 { 1712 size_t cchComment = pszComment ? strlen(pszComment) : 0; 1713 if (cchComment >= VDI_IMAGE_COMMENT_SIZE) 1714 { 1715 LogFunc(("pszComment is too long, %d bytes!\n", cchComment)); 1716 rc = VERR_VD_VDI_COMMENT_TOO_LONG; 1717 goto out; 1718 } 1719 1720 /* we don't support old style images */ 1721 if (GET_MAJOR_HEADER_VERSION(&pImage->Header) == 1) 1722 { 1723 /* 1724 * Update the comment field, making sure to zero out all of the previous comment. 1725 */ 1726 memset(pImage->Header.u.v1.szComment, '\0', VDI_IMAGE_COMMENT_SIZE); 1727 memcpy(pImage->Header.u.v1.szComment, pszComment, cchComment); 1728 1729 /* write out new the header */ 1730 rc = vdiUpdateHeader(pImage); 1731 } 1732 else 1733 rc = VERR_VD_VDI_UNSUPPORTED_VERSION; 1734 } 1733 1735 } 1734 1736 else … … 2657 2659 VD_CAP_UUID | VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC 2658 2660 | VD_CAP_DIFF | VD_CAP_FILE | VD_CAP_ASYNC | VD_CAP_VFS, 2659 /* pa pszFileExtensions */2660 s_a pszVdiFileExtensions,2661 /* paFileExtensions */ 2662 s_aVdiFileExtensions, 2661 2663 /* paConfigInfo */ 2662 2664 NULL, -
trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp
r33495 r33524 241 241 242 242 /** NULL-terminated array of supported file extensions. */ 243 static const char *const s_apszVhdFileExtensions[] =244 { 245 "vhd",246 NULL243 static const VDFILEEXTENSION s_aVhdFileExtensions[] = 244 { 245 {"vhd", VDTYPE_HDD}, 246 {NULL, VDTYPE_INVALID} 247 247 }; 248 248 … … 1380 1380 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 1381 1381 static int vhdCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 1382 PVDINTERFACE pVDIfsImage )1382 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 1383 1383 { 1384 1384 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage)); … … 1416 1416 rc = VERR_VD_VHD_INVALID_HEADER; 1417 1417 else 1418 { 1419 *penmType = VDTYPE_HDD; 1418 1420 rc = VINF_SUCCESS; 1421 } 1419 1422 1420 1423 pInterfaceIOCallbacks->pfnClose(pInterfaceIO->pvUser, pStorage); … … 1428 1431 static int vhdOpen(const char *pszFilename, unsigned uOpenFlags, 1429 1432 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 1430 void **ppBackendData)1433 VDTYPE enmType, void **ppBackendData) 1431 1434 { 1432 1435 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 2137 2140 AssertPtr(pImage); 2138 2141 2139 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)2140 {2141 rc = VERR_VD_IMAGE_READ_ONLY;2142 goto out;2143 }2144 2145 2142 if (pImage) 2146 rc = VERR_NOT_SUPPORTED; 2143 { 2144 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2145 rc = VERR_VD_IMAGE_READ_ONLY; 2146 else 2147 rc = VERR_NOT_SUPPORTED; 2148 } 2147 2149 else 2148 2150 rc = VERR_VD_NOT_OPENED; … … 3020 3022 VD_CAP_CREATE_FIXED | VD_CAP_CREATE_DYNAMIC | 3021 3023 VD_CAP_ASYNC | VD_CAP_VFS, 3022 /* pa pszFileExtensions */3023 s_a pszVhdFileExtensions,3024 /* paFileExtensions */ 3025 s_aVhdFileExtensions, 3024 3026 /* paConfigInfo */ 3025 3027 NULL, -
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r33493 r33524 514 514 515 515 /** NULL-terminated array of supported file extensions. */ 516 static const char *const s_apszVmdkFileExtensions[] =517 { 518 "vmdk",519 NULL516 static const VDFILEEXTENSION s_aVmdkFileExtensions[] = 517 { 518 {"vmdk", VDTYPE_HDD}, 519 {NULL, VDTYPE_INVALID} 520 520 }; 521 521 … … 5704 5704 /** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */ 5705 5705 static int vmdkCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk, 5706 PVDINTERFACE pVDIfsImage) 5707 { 5708 LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename)); 5706 PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 5707 { 5708 LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n", 5709 pszFilename, pVDIfsDisk, pVDIfsImage, penmType)); 5709 5710 int rc = VINF_SUCCESS; 5710 5711 PVMDKIMAGE pImage; … … 5738 5739 RTMemFree(pImage); 5739 5740 5741 if (RT_SUCCESS(rc)) 5742 *penmType = VDTYPE_HDD; 5743 5740 5744 out: 5741 5745 LogFlowFunc(("returns %Rrc\n", rc)); … … 5746 5750 static int vmdkOpen(const char *pszFilename, unsigned uOpenFlags, 5747 5751 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 5748 void **ppBackendData)5752 VDTYPE enmType, void **ppBackendData) 5749 5753 { 5750 5754 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); … … 7322 7326 | VD_CAP_CREATE_SPLIT_2G | VD_CAP_DIFF | VD_CAP_FILE | VD_CAP_ASYNC 7323 7327 | VD_CAP_VFS, 7324 /* pa pszFileExtensions */7325 s_a pszVmdkFileExtensions,7328 /* paFileExtensions */ 7329 s_aVmdkFileExtensions, 7326 7330 /* paConfigInfo */ 7327 7331 NULL, -
trunk/src/VBox/Devices/Storage/testcase/tstVD-2.cpp
r28800 r33524 86 86 }; 87 87 88 static const char *tstVDDeviceType(VDTYPE enmType) 89 { 90 switch (enmType) 91 { 92 case VDTYPE_HDD: 93 return "HardDisk"; 94 case VDTYPE_DVD: 95 return "DVD"; 96 case VDTYPE_FLOPPY: 97 return "Floppy"; 98 default: 99 return "Unknown"; 100 } 101 } 102 88 103 static int tstVDBackendInfo(void) 89 104 { … … 108 123 RTPrintf("Backend %u: name=%s capabilities=%#06x extensions=", 109 124 i, aVDInfo[i].pszBackend, aVDInfo[i].uBackendCaps); 110 if (aVDInfo[i].pa pszFileExtensions)111 { 112 const char *const *papsz = aVDInfo[i].papszFileExtensions;113 while ( *papsz!= NULL)114 { 115 if (pa psz != aVDInfo[i].papszFileExtensions)125 if (aVDInfo[i].paFileExtensions) 126 { 127 PCVDFILEEXTENSION pa = aVDInfo[i].paFileExtensions; 128 while (pa->pszExtension != NULL) 129 { 130 if (pa != aVDInfo[i].paFileExtensions) 116 131 RTPrintf(","); 117 RTPrintf("%s ", *papsz);118 pa psz++;119 } 120 if (pa psz == aVDInfo[i].papszFileExtensions)132 RTPrintf("%s (%s)", pa->pszExtension, tstVDDeviceType(pa->enmType)); 133 pa++; 134 } 135 if (pa == aVDInfo[i].paFileExtensions) 121 136 RTPrintf("<EMPTY>"); 122 137 } -
trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp
r33083 r33524 92 92 AssertRC(rc); 93 93 94 rc = VDCreate(&VDIError, &pVD);94 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 95 95 CHECK("VDCreate()"); 96 96 … … 150 150 AssertRC(rc); 151 151 152 rc = VDCreate(&VDIError, &pVD);152 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 153 153 CHECK("VDCreate()"); 154 154 … … 505 505 PVBOXHDD pVD = NULL; 506 506 char *pszFormat; 507 VDTYPE enmType = VDTYPE_INVALID; 507 508 VDGEOMETRY PCHS = { 0, 0, 0 }; 508 509 VDGEOMETRY LCHS = { 0, 0, 0 }; … … 539 540 540 541 541 rc = VDCreate(&VDIError, &pVD);542 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 542 543 CHECK("VDCreate()"); 543 544 … … 548 549 RTFileClose(File); 549 550 rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 550 pszBaseFilename, &pszFormat );551 pszBaseFilename, &pszFormat, &enmType); 551 552 RTPrintf("VDGetFormat() pszFormat=%s rc=%Rrc\n", pszFormat, rc); 552 553 if (RT_SUCCESS(rc) && strcmp(pszFormat, pszBackend)) … … 664 665 665 666 666 rc = VDCreate(&VDIError, &pVD);667 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 667 668 CHECK("VDCreate()"); 668 669 … … 738 739 AssertRC(rc); 739 740 740 rc = VDCreate(&VDIError, &pVD);741 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 741 742 CHECK("VDCreate()"); 742 743 … … 789 790 AssertRC(rc); 790 791 791 rc = VDCreate(&VDIError, &pVD);792 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 792 793 CHECK("VDCreate()"); 793 794 -
trunk/src/VBox/Devices/Storage/testcase/tstVDCopy.cpp
r32536 r33524 70 70 char *pbBuf1 = NULL; 71 71 char *pbBuf2 = NULL; 72 VDTYPE enmTypeVD1 = VDTYPE_INVALID; 73 VDTYPE enmTypeVD2 = VDTYPE_INVALID; 72 74 73 75 #define CHECK(str) \ … … 98 100 99 101 rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 100 argv[1], &pszVD1 );102 argv[1], &pszVD1, &enmTypeVD1); 101 103 CHECK("VDGetFormat() hdd1"); 102 104 103 105 rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 104 argv[2], &pszVD2 );106 argv[2], &pszVD2, &enmTypeVD2); 105 107 CHECK("VDGetFormat() hdd2"); 106 108 107 rc = VDCreate(&VDIError, &pVD1);109 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD1); 108 110 CHECK("VDCreate() hdd1"); 109 111 110 rc = VDCreate(&VDIError, &pVD2);112 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD2); 111 113 CHECK("VDCreate() hdd1"); 112 114 -
trunk/src/VBox/Devices/Storage/testcase/tstVDShareable.cpp
r32536 r33524 92 92 AssertRC(rc); 93 93 94 rc = VDCreate(&VDIError, &pVD);94 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD); 95 95 CHECK("VDCreate()"); 96 rc = VDCreate(&VDIError, &pVD2);96 rc = VDCreate(&VDIError, VDTYPE_HDD, &pVD2); 97 97 CHECK("VDCreate() #2"); 98 98 -
trunk/src/VBox/Devices/Storage/testcase/tstVDSnap.cpp
r32536 r33524 276 276 277 277 278 rc = VDCreate(pVDIfs, &pVD);278 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pVD); 279 279 CHECK("VDCreate()"); 280 280 -
trunk/src/VBox/Devices/Storage/testcase/vbox-img.cpp
r33288 r33524 124 124 const char *pszFilename = NULL; 125 125 char *pszFormat = NULL; 126 VDTYPE enmType = VDTYPE_INVALID; 126 127 RTUUID imageUuid; 127 128 RTUUID parentUuid; … … 188 189 /* Don't pass error interface, as that would triggers error messages 189 190 * because some backends fail to open the image. */ 190 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat );191 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType); 191 192 if (RT_FAILURE(rc)) 192 193 return errorRuntime("Format autodetect failed: %Rrc\n", rc); … … 194 195 195 196 PVBOXHDD pVD = NULL; 196 rc = VDCreate(pVDIfs, &pVD);197 rc = VDCreate(pVDIfs, enmType, &pVD); 197 198 if (RT_FAILURE(rc)) 198 199 return errorRuntime("Cannot create the virtual disk container: %Rrc\n", rc); … … 625 626 bool fStdOut = false; 626 627 const char *pszSrcFormat = NULL; 628 VDTYPE enmSrcType = VDTYPE_HDD; 627 629 const char *pszDstFormat = NULL; 628 630 const char *pszVariant = NULL; … … 788 790 if (!pszSrcFormat) 789 791 { 790 char *pszFormat; 791 rc = VDGetFormat(NULL, NULL, pszSrcFilename, &pszFormat); 792 char *pszFormat = NULL; 793 VDTYPE enmType = VDTYPE_INVALID; 794 rc = VDGetFormat(NULL, NULL, pszSrcFilename, &pszFormat, &enmType); 792 795 if (RT_FAILURE(rc)) 793 796 { … … 796 799 } 797 800 pszSrcFormat = pszFormat; 798 } 799 800 rc = VDCreate(pVDIfs, &pSrcDisk); 801 enmSrcType = enmType; 802 } 803 804 rc = VDCreate(pVDIfs, enmSrcType, &pSrcDisk); 801 805 if (RT_FAILURE(rc)) 802 806 { … … 814 818 } 815 819 816 rc = VDCreate(pVDIfs, &pDstDisk);820 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDstDisk); 817 821 if (RT_FAILURE(rc)) 818 822 { … … 883 887 /* just try it */ 884 888 char *pszFormat = NULL; 885 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat); 889 VDTYPE enmType = VDTYPE_INVALID; 890 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType); 886 891 if (RT_FAILURE(rc)) 887 892 return errorSyntax("Format autodetect failed: %Rrc\n", rc); 888 893 889 rc = VDCreate(pVDIfs, &pDisk);894 rc = VDCreate(pVDIfs, enmType, &pDisk); 890 895 if (RT_FAILURE(rc)) 891 896 return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc); … … 940 945 /* just try it */ 941 946 char *pszFormat = NULL; 942 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat); 947 VDTYPE enmType = VDTYPE_INVALID; 948 rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType); 943 949 if (RT_FAILURE(rc)) 944 950 return errorSyntax("Format autodetect failed: %Rrc\n", rc); 945 951 946 rc = VDCreate(pVDIfs, &pDisk);952 rc = VDCreate(pVDIfs, enmType, &pDisk); 947 953 if (RT_FAILURE(rc)) 948 954 return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc); -
trunk/src/VBox/Devices/Storage/testcase/vditool.cpp
r32536 r33524 104 104 105 105 PVBOXHDD hdd; 106 rc = VDCreate(NULL, &hdd);106 rc = VDCreate(NULL, VDTYPE_HDD, &hdd); 107 107 if (RT_FAILURE(rc)) 108 108 return PrintDone(rc); -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r33464 r33524 555 555 /* just try it */ 556 556 char *pszFormat = NULL; 557 VDTYPE enmType = VDTYPE_INVALID; 557 558 int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 558 argv[1], &pszFormat );559 argv[1], &pszFormat, &enmType); 559 560 if (RT_FAILURE(rc)) 560 561 { … … 577 578 AssertRC(rc); 578 579 579 rc = VDCreate(pVDIfs, &pDisk);580 rc = VDCreate(pVDIfs, enmType, &pDisk); 580 581 if (RT_FAILURE(rc)) 581 582 { … … 617 618 /* just try it */ 618 619 char *pszFormat = NULL; 620 VDTYPE enmType = VDTYPE_INVALID; 619 621 int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 620 argv[0], &pszFormat );622 argv[0], &pszFormat, &enmType); 621 623 if (RT_FAILURE(rc)) 622 624 { … … 639 641 AssertRC(rc); 640 642 641 rc = VDCreate(pVDIfs, &pDisk);643 rc = VDCreate(pVDIfs, enmType, &pDisk); 642 644 if (RT_FAILURE(rc)) 643 645 { … … 1433 1435 AssertRC(vrc); 1434 1436 1435 vrc = VDCreate(pVDIfs, &pDisk);1437 vrc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); /* Raw VMDK's are harddisk only. */ 1436 1438 if (RT_FAILURE(vrc)) 1437 1439 { … … 1543 1545 AssertRC(vrc); 1544 1546 1545 vrc = VDCreate(pVDIfs, &pDisk);1547 vrc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); 1546 1548 if (RT_FAILURE(vrc)) 1547 1549 { … … 1627 1629 AssertRC(vrc); 1628 1630 1629 vrc = VDCreate(pVDIfs, &pDisk); 1631 /** @todo: Support convert to raw for floppy and DVD images too. */ 1632 vrc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); 1630 1633 if (RT_FAILURE(vrc)) 1631 1634 { … … 1651 1654 { 1652 1655 char *pszFormat = NULL; 1656 VDTYPE enmType = VDTYPE_INVALID; 1653 1657 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 1654 src.c_str(), &pszFormat );1655 if (RT_FAILURE(vrc) )1658 src.c_str(), &pszFormat, &enmType); 1659 if (RT_FAILURE(vrc) || enmType != VDTYPE_HDD) 1656 1660 { 1657 1661 VDCloseAll(pDisk); … … 1661 1665 RTFileDelete(dst.c_str()); 1662 1666 } 1663 RTMsgError("No file format specified and autodetect failed - please specify format: %Rrc", vrc); 1667 if (RT_FAILURE(vrc)) 1668 RTMsgError("No file format specified and autodetect failed - please specify format: %Rrc", vrc); 1669 else 1670 RTMsgError("Only converting harddisk images is supported"); 1664 1671 return 1; 1665 1672 } … … 1739 1746 PVBOXHDD pSrcDisk = NULL; 1740 1747 PVBOXHDD pDstDisk = NULL; 1748 VDTYPE enmSrcType = VDTYPE_INVALID; 1741 1749 1742 1750 /* Parse the arguments. */ … … 1800 1808 char *pszFormat = NULL; 1801 1809 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 1802 src.c_str(), &pszFormat );1810 src.c_str(), &pszFormat, &enmSrcType); 1803 1811 if (RT_FAILURE(vrc)) 1804 1812 { … … 1810 1818 } 1811 1819 1812 vrc = VDCreate(pVDIfs, &pSrcDisk);1820 vrc = VDCreate(pVDIfs, enmSrcType, &pSrcDisk); 1813 1821 if (RT_FAILURE(vrc)) 1814 1822 { … … 1829 1837 dstformat = "VDI"; 1830 1838 1831 vrc = VDCreate(pVDIfs, &pDstDisk);1839 vrc = VDCreate(pVDIfs, enmSrcType, &pDstDisk); 1832 1840 if (RT_FAILURE(vrc)) 1833 1841 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r33456 r33524 888 888 char pszComment[256]; 889 889 RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", srcfilename); 890 rc = VDCreate(pVDIfs, &pDisk);890 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); 891 891 if (RT_FAILURE(rc)) 892 892 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r33386 r33524 62 62 } 63 63 #endif 64 65 static const char*getDeviceTypeText(DeviceType_T enmType) 66 { 67 switch (enmType) 68 { 69 case DeviceType_HardDisk: return "HardDisk"; 70 case DeviceType_DVD: return "DVD"; 71 case DeviceType_Floppy: return "Floppy"; 72 } 73 return "Unknown"; 74 } 64 75 65 76 static void listMedia(const ComPtr<IVirtualBox> aVirtualBox, … … 604 615 /* File extensions */ 605 616 com::SafeArray <BSTR> fileExtensions; 617 com::SafeArray <DeviceType_T> deviceTypes; 606 618 CHECK_ERROR(mediumFormats[i], 607 COMGETTER(FileExtensions)(ComSafeArrayAsOutParam(fileExtensions)));619 DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes))); 608 620 for (size_t j = 0; j < fileExtensions.size(); ++j) 609 621 { 610 RTPrintf("%ls ", Bstr(fileExtensions[j]).raw());622 RTPrintf("%ls (%s)", Bstr(fileExtensions[j]).raw(), getDeviceTypeText(deviceTypes[j])); 611 623 if (j != fileExtensions.size()-1) 612 624 RTPrintf(","); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r33294 r33524 981 981 dir = mVBox.GetHomeFolder(); 982 982 983 QList < QPair <QString, QString> > filterList; 984 QStringList backends; 985 QStringList allPrefix; 986 QString allType; 987 983 988 switch (type) 984 989 { 990 case VBoxDefs::MediumType_DVD: 991 { 992 filterList = vboxGlobal().DVDBackends(); 993 title = tr ("Select a CD/DVD-ROM disk image file"); 994 allType = tr ("CD/DVD-ROM disk"); 995 break; 996 } 985 997 case VBoxDefs::MediumType_HardDisk: 986 998 { 987 QList < QPair <QString, QString> > filterList = vboxGlobal().HDDBackends(); 988 QStringList backends; 989 QStringList allPrefix; 990 for (int i = 0; i < filterList.count(); ++i) 991 { 992 QPair <QString, QString> item = filterList.at (i); 993 /* Create one backend filter string */ 994 backends << QString ("%1 (%2)").arg (item.first). arg (item.second); 995 /* Save the suffix's for the "All" entry */ 996 allPrefix << item.second; 997 } 998 if (!allPrefix.isEmpty()) 999 backends.insert (0, tr ("All hard disk images (%1)").arg (allPrefix.join (" ").trimmed())); 1000 backends << tr ("All files (*)"); 1001 filter = backends.join (";;").trimmed(); 1002 999 filterList = vboxGlobal().HDDBackends(); 1003 1000 title = tr ("Select a hard disk image file"); 1004 break; 1005 } 1006 case VBoxDefs::MediumType_DVD: 1007 { 1008 filter = tr ("CD/DVD-ROM images (*.iso);;All files (*)"); 1009 title = tr ("Select a CD/DVD-ROM disk image file"); 1001 allType = tr ("hard disk"); 1010 1002 break; 1011 1003 } 1012 1004 case VBoxDefs::MediumType_Floppy: 1013 1005 { 1014 filter = tr ("Floppy images (*.img);;All files (*)");1006 filterList = vboxGlobal().FloppyBackends(); 1015 1007 title = tr ("Select a floppy disk image file"); 1008 allType = tr ("floppy disk"); 1016 1009 break; 1017 1010 } … … 1020 1013 break; 1021 1014 } 1015 1016 for (int i = 0; i < filterList.count(); ++i) 1017 { 1018 QPair <QString, QString> item = filterList.at (i); 1019 /* Create one backend filter string */ 1020 backends << QString ("%1 (%2)").arg (item.first). arg (item.second); 1021 /* Save the suffix's for the "All" entry */ 1022 allPrefix << item.second; 1023 } 1024 if (!allPrefix.isEmpty()) 1025 backends.insert (0, tr ("All %1 images (%2)").arg (allType). arg (allPrefix.join (" ").trimmed())); 1026 backends << tr ("All files (*)"); 1027 filter = backends.join (";;").trimmed(); 1022 1028 1023 1029 QStringList files = QIFileDialog::getOpenFileNames (dir, filter, this, title); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r33386 r33524 4060 4060 4061 4061 /** 4062 * Figures out which hard disk formats are currently supported by VirtualBox. 4062 * Figures out which medium formats are currently supported by VirtualBox for 4063 * the given device type. 4063 4064 * Returned is a list of pairs with the form 4064 4065 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. 4065 4066 */ 4066 4067 /* static */ 4067 QList <QPair <QString, QString> > VBoxGlobal:: HDDBackends()4068 QList <QPair <QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType) 4068 4069 { 4069 4070 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); … … 4073 4074 { 4074 4075 /* File extensions */ 4075 QVector <QString> fileExtensions = mediumFormats [i].GetFileExtensions(); 4076 QVector <QString> fileExtensions; 4077 QVector <KDeviceType> deviceTypes; 4078 4079 mediumFormats [i].DescribeFileExtensions(fileExtensions, deviceTypes); 4080 4076 4081 QStringList f; 4077 4082 for (int a = 0; a < fileExtensions.size(); ++ a) 4078 f << QString ("*.%1").arg (fileExtensions [a]); 4083 if (deviceTypes [a] == enmType) 4084 f << QString ("*.%1").arg (fileExtensions [a]); 4079 4085 /* Create a pair out of the backend description and all suffix's. */ 4080 4086 if (!f.isEmpty()) … … 4082 4088 } 4083 4089 return backendPropList; 4090 } 4091 4092 /** 4093 * Figures out which hard disk formats are currently supported by VirtualBox. 4094 * Returned is a list of pairs with the form 4095 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. 4096 */ 4097 /* static */ 4098 QList <QPair <QString, QString> > VBoxGlobal::HDDBackends() 4099 { 4100 return MediumBackends(KDeviceType_HardDisk); 4101 } 4102 4103 /** 4104 * Figures out which CD/DVD disk formats are currently supported by VirtualBox. 4105 * Returned is a list of pairs with the form 4106 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. 4107 */ 4108 /* static */ 4109 QList <QPair <QString, QString> > VBoxGlobal::DVDBackends() 4110 { 4111 return MediumBackends(KDeviceType_DVD); 4112 } 4113 4114 /** 4115 * Figures out which floppy disk formats are currently supported by VirtualBox. 4116 * Returned is a list of pairs with the form 4117 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. 4118 */ 4119 /* static */ 4120 QList <QPair <QString, QString> > VBoxGlobal::FloppyBackends() 4121 { 4122 return MediumBackends(KDeviceType_Floppy); 4084 4123 } 4085 4124 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r33386 r33524 630 630 bool aRecursive = false); 631 631 632 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType); 632 633 static QList <QPair <QString, QString> > HDDBackends(); 634 static QList <QPair <QString, QString> > DVDBackends(); 635 static QList <QPair <QString, QString> > FloppyBackends(); 633 636 634 637 /* Qt 4.2.0 support function */ -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r33307 r33524 3037 3037 } 3038 3038 3039 switch (enmType) 3040 { 3041 case DeviceType_DVD: 3042 InsertConfigString(pCfg, "Type", "DVD"); 3043 break; 3044 case DeviceType_Floppy: 3045 InsertConfigString(pCfg, "Type", "Floppy"); 3046 break; 3047 case DeviceType_HardDisk: 3048 default: 3049 InsertConfigString(pCfg, "Type", "HardDisk"); 3050 } 3051 3039 3052 /* Pass all custom parameters. */ 3040 3053 bool fHostIP = true; -
trunk/src/VBox/Main/MediumFormatImpl.cpp
r32682 r33524 1 1 /* $Id$ */ 2 3 2 /** @file 4 3 * … … 68 67 unconst(m.capabilities) = aVDInfo->uBackendCaps; 69 68 /* Save the supported file extensions in a list */ 70 if (aVDInfo->pa pszFileExtensions)69 if (aVDInfo->paFileExtensions) 71 70 { 72 const char *const *papsz = aVDInfo->papszFileExtensions;73 while ( *papsz!= NULL)71 PCVDFILEEXTENSION papExtension = aVDInfo->paFileExtensions; 72 while (papExtension->pszExtension != NULL) 74 73 { 75 unconst(m.llFileExtensions).push_back(*papsz); 76 ++papsz; 74 DeviceType_T devType; 75 76 unconst(m.llFileExtensions).push_back(papExtension->pszExtension); 77 78 switch(papExtension->enmType) 79 { 80 case VDTYPE_HDD: 81 devType = DeviceType_HardDisk; 82 break; 83 case VDTYPE_DVD: 84 devType = DeviceType_DVD; 85 break; 86 case VDTYPE_FLOPPY: 87 devType = DeviceType_Floppy; 88 break; 89 default: 90 AssertMsgFailed(("Invalid enm type %d!\n", papExtension->enmType)); 91 return E_INVALIDARG; 92 } 93 94 unconst(m.llDeviceTypes).push_back(devType); 95 ++papExtension; 77 96 } 78 97 } … … 162 181 unconst(m.llProperties).clear(); 163 182 unconst(m.llFileExtensions).clear(); 183 unconst(m.llDeviceTypes).clear(); 164 184 unconst(m.capabilities) = 0; 165 185 unconst(m.strName).setNull(); … … 196 216 } 197 217 198 STDMETHODIMP MediumFormat::COMGETTER(FileExtensions)(ComSafeArrayOut(BSTR, aFileExtensions)) 218 STDMETHODIMP MediumFormat::COMGETTER(Capabilities)(ULONG *aCaps) 219 { 220 CheckComArgOutPointerValid(aCaps); 221 222 AutoCaller autoCaller(this); 223 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 224 225 /* m.capabilities is const, no need to lock */ 226 227 /// @todo add COMGETTER(ExtendedCapabilities) when we reach the 32 bit 228 /// limit (or make the argument ULONG64 after checking that COM is capable 229 /// of defining enums (used to represent bit flags) that contain 64-bit 230 /// values) 231 ComAssertRet(m.capabilities == ((ULONG)m.capabilities), E_FAIL); 232 233 *aCaps = (ULONG) m.capabilities; 234 235 return S_OK; 236 } 237 238 STDMETHODIMP MediumFormat::DescribeFileExtensions(ComSafeArrayOut(BSTR, aFileExtensions), 239 ComSafeArrayOut(DeviceType_T, aDeviceTypes)) 199 240 { 200 241 CheckComArgOutSafeArrayPointerValid(aFileExtensions); … … 212 253 fileExtentions.detachTo(ComSafeArrayOutArg(aFileExtensions)); 213 254 214 return S_OK; 215 } 216 217 STDMETHODIMP MediumFormat::COMGETTER(Capabilities)(ULONG *aCaps) 218 { 219 CheckComArgOutPointerValid(aCaps); 220 221 AutoCaller autoCaller(this); 222 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 223 224 /* m.capabilities is const, no need to lock */ 225 226 /// @todo add COMGETTER(ExtendedCapabilities) when we reach the 32 bit 227 /// limit (or make the argument ULONG64 after checking that COM is capable 228 /// of defining enums (used to represent bit flags) that contain 64-bit 229 /// values) 230 ComAssertRet(m.capabilities == ((ULONG)m.capabilities), E_FAIL); 231 232 *aCaps = (ULONG) m.capabilities; 255 com::SafeArray<DeviceType_T> deviceTypes(m.llDeviceTypes.size()); 256 i = 0; 257 for (DeviceTypeList::const_iterator it = m.llDeviceTypes.begin(); 258 it != m.llDeviceTypes.end(); 259 ++it, ++i) 260 deviceTypes[i] = (*it); 261 deviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes)); 233 262 234 263 return S_OK; -
trunk/src/VBox/Main/MediumImpl.cpp
r33433 r33524 1024 1024 m->hddOpenMode = enOpenMode; 1025 1025 1026 if (aDeviceType == DeviceType_HardDisk) 1027 rc = setLocation(aLocation); 1028 else 1029 { 1030 if (aDeviceType == DeviceType_DVD) 1031 m->type = MediumType_Readonly; 1032 else 1033 m->type = MediumType_Writethrough; 1034 rc = setLocation(aLocation, "RAW"); 1035 } 1026 if (aDeviceType == DeviceType_DVD) 1027 m->type = MediumType_Readonly; 1028 else if (aDeviceType == DeviceType_Floppy) 1029 m->type = MediumType_Writethrough; 1030 1031 rc = setLocation(aLocation); 1036 1032 if (FAILED(rc)) return rc; 1037 1038 if ( aDeviceType == DeviceType_DVD1039 || aDeviceType == DeviceType_Floppy)1040 // create new UUID1041 unconst(m->id).create();1042 1033 1043 1034 /* get all the information about the medium from the storage unit */ … … 3660 3651 if (isImport) 3661 3652 { 3653 VDTYPE enmType = VDTYPE_INVALID; 3662 3654 char *backendName = NULL; 3663 3655 … … 3674 3666 { 3675 3667 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 3676 locationFull.c_str(), &backendName );3668 locationFull.c_str(), &backendName, &enmType); 3677 3669 } 3678 3670 else if (vrc != VERR_FILE_NOT_FOUND && vrc != VERR_PATH_NOT_FOUND) … … 3681 3673 locationFull = aLocation; 3682 3674 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 3683 locationFull.c_str(), &backendName );3675 locationFull.c_str(), &backendName, &enmType); 3684 3676 } 3685 3677 … … 3702 3694 } 3703 3695 } 3696 else if (m->devType != convertToDeviceType(enmType)) 3697 { 3698 /* 3699 * The user tried to use a image as a device which is not supported 3700 * by the backend. 3701 */ 3702 return setError(E_FAIL, 3703 tr("The medium '%s' can't be used as the requested device type"), 3704 locationFull.c_str()); 3705 } 3704 3706 else 3705 3707 { … … 3843 3845 3844 3846 PVBOXHDD hdd; 3845 vrc = VDCreate(m->vdDiskIfaces, &hdd);3847 vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 3846 3848 ComAssertRCThrow(vrc, E_FAIL); 3847 3849 … … 4092 4094 { 4093 4095 PVBOXHDD hdd; 4094 vrc = VDCreate(m->vdDiskIfaces, &hdd);4096 vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 4095 4097 ComAssertRCThrow(vrc, E_FAIL); 4096 4098 … … 4207 4209 4208 4210 return rc; 4211 } 4212 4213 /** 4214 * Converts the Medium device type to the VD type. 4215 */ 4216 VDTYPE Medium::convertDeviceType() 4217 { 4218 VDTYPE enmType; 4219 4220 switch (m->devType) 4221 { 4222 case DeviceType_HardDisk: 4223 enmType = VDTYPE_HDD; 4224 break; 4225 case DeviceType_DVD: 4226 enmType = VDTYPE_DVD; 4227 break; 4228 case DeviceType_Floppy: 4229 enmType = VDTYPE_FLOPPY; 4230 break; 4231 default: 4232 ComAssertFailedThrow(E_FAIL); 4233 } 4234 4235 return enmType; 4236 } 4237 4238 /** 4239 * Converts from the VD type to the medium type. 4240 */ 4241 DeviceType_T Medium::convertToDeviceType(VDTYPE enmType) 4242 { 4243 DeviceType_T devType; 4244 4245 switch (enmType) 4246 { 4247 case VDTYPE_HDD: 4248 devType = DeviceType_HardDisk; 4249 break; 4250 case VDTYPE_DVD: 4251 devType = DeviceType_DVD; 4252 break; 4253 case VDTYPE_FLOPPY: 4254 devType = DeviceType_Floppy; 4255 break; 4256 default: 4257 ComAssertFailedThrow(E_FAIL); 4258 } 4259 4260 return devType; 4209 4261 } 4210 4262 … … 5740 5792 { 5741 5793 PVBOXHDD hdd; 5742 int vrc = VDCreate(m->vdDiskIfaces, &hdd);5794 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 5743 5795 ComAssertRCThrow(vrc, E_FAIL); 5744 5796 … … 5881 5933 5882 5934 PVBOXHDD hdd; 5883 int vrc = VDCreate(m->vdDiskIfaces, &hdd);5935 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 5884 5936 ComAssertRCThrow(vrc, E_FAIL); 5885 5937 … … 6018 6070 6019 6071 PVBOXHDD hdd; 6020 int vrc = VDCreate(m->vdDiskIfaces, &hdd);6072 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 6021 6073 ComAssertRCThrow(vrc, E_FAIL); 6022 6074 … … 6187 6239 { 6188 6240 PVBOXHDD hdd; 6189 int vrc = VDCreate(m->vdDiskIfaces, &hdd);6241 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 6190 6242 ComAssertRCThrow(vrc, E_FAIL); 6191 6243 … … 6512 6564 6513 6565 PVBOXHDD hdd; 6514 int vrc = VDCreate(m->vdDiskIfaces, &hdd);6566 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 6515 6567 ComAssertRCThrow(vrc, E_FAIL); 6516 6568 … … 6564 6616 6565 6617 PVBOXHDD targetHdd; 6566 vrc = VDCreate(m->vdDiskIfaces, &targetHdd);6618 vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &targetHdd); 6567 6619 ComAssertRCThrow(vrc, E_FAIL); 6568 6620 … … 6740 6792 6741 6793 PVBOXHDD hdd; 6742 int vrc = VDCreate(m->vdDiskIfaces, &hdd);6794 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 6743 6795 ComAssertRCThrow(vrc, E_FAIL); 6744 6796 … … 6812 6864 6813 6865 PVBOXHDD hdd; 6814 int vrc = VDCreate(m->vdDiskIfaces, &hdd);6866 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 6815 6867 ComAssertRCThrow(vrc, E_FAIL); 6816 6868 … … 6950 7002 { 6951 7003 PVBOXHDD hdd; 6952 int vrc = VDCreate(m->vdDiskIfaces, &hdd);7004 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 6953 7005 ComAssertRCThrow(vrc, E_FAIL); 6954 7006 … … 7047 7099 { 7048 7100 PVBOXHDD hdd; 7049 int vrc = VDCreate(m->vdDiskIfaces, &hdd);7101 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 7050 7102 ComAssertRCThrow(vrc, E_FAIL); 7051 7103 … … 7149 7201 7150 7202 PVBOXHDD hdd; 7151 int vrc = VDCreate(m->vdDiskIfaces, &hdd);7203 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 7152 7204 ComAssertRCThrow(vrc, E_FAIL); 7153 7205 … … 7197 7249 7198 7250 PVBOXHDD targetHdd; 7199 vrc = VDCreate(m->vdDiskIfaces, &targetHdd);7251 vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &targetHdd); 7200 7252 ComAssertRCThrow(vrc, E_FAIL); 7201 7253 … … 7284 7336 7285 7337 PVBOXHDD hdd; 7286 int vrc = VDCreate(m->vdDiskIfaces, &hdd);7338 int vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &hdd); 7287 7339 ComAssertRCThrow(vrc, E_FAIL); 7288 7340 … … 7318 7370 7319 7371 PVBOXHDD targetHdd; 7320 vrc = VDCreate(m->vdDiskIfaces, &targetHdd);7372 vrc = VDCreate(m->vdDiskIfaces, convertDeviceType(), &targetHdd); 7321 7373 ComAssertRCThrow(vrc, E_FAIL); 7322 7374 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r33492 r33524 468 468 <const name="v1_11" value="13"> 469 469 <desc>Settings version "1.11", written by VirtualBox 4.0.x.</desc> 470 <!-- Machine changes: HD Audio controller, per-machine disk registries 470 <!-- Machine changes: HD Audio controller, per-machine disk registries, 471 /@format attribute for DVD and floppy images. 471 472 --> 472 473 </const> … … 10147 10148 <interface 10148 10149 name="IMediumFormat" extends="$unknown" 10149 uuid=" 89f52554-d469-4799-9fad-1705e86a08b1"10150 uuid="4e9a873f-0599-434a-8345-619ef3fb3111" 10150 10151 wsmap="managed" 10151 10152 > … … 10195 10196 </attribute> 10196 10197 10197 <attribute name="fileExtensions" type="wstring" safearray="yes" readonly="yes"> 10198 <desc> 10199 Array of strings containing the supported file extensions. 10200 10201 The first extension in the array is the extension preferred by the 10202 backend. It is recommended to use this extension when specifying a 10203 location of the storage unit for a new medium. 10198 <attribute name="capabilities" type="unsigned long" readonly="yes"> 10199 <desc> 10200 Capabilities of the format as a set of bit flags. 10201 10202 For the meaning of individual capability flags see 10203 <link to="MediumFormatCapabilities"/>. 10204 </desc> 10205 </attribute> 10206 10207 <method name="describeFileExtensions"> 10208 <desc> 10209 Returns two arrays describing the supported file extensions. 10210 10211 The first array contains the supported extensions and the seconds one 10212 the type each extension supports. Both have the same size. 10204 10213 10205 10214 Note that some backends do not work on files, so this array may be … … 10208 10217 <see>IMediumFormat::capabilities</see> 10209 10218 </desc> 10210 </attribute> 10211 10212 <attribute name="capabilities" type="unsigned long" readonly="yes"> 10213 <desc> 10214 Capabilities of the format as a set of bit flags. 10215 10216 For the meaning of individual capability flags see 10217 <link to="MediumFormatCapabilities"/>. 10218 </desc> 10219 </attribute> 10219 <param name="extensions" type="wstring" safearray="yes" dir="out"> 10220 <desc>The array of supported extensions.</desc> 10221 </param> 10222 <param name="type" type="DeviceType" safearray="yes" dir="out"> 10223 <desc>The array which indicates the device type for every given extension.</desc> 10224 </param> 10225 </method> 10220 10226 10221 10227 <method name="describeProperties"> -
trunk/src/VBox/Main/include/MediumFormatImpl.h
r32531 r33524 53 53 }; 54 54 55 typedef std::list<Utf8Str> StrList; 56 typedef std::list<Property> PropertyList; 55 typedef std::list<Utf8Str> StrList; 56 typedef std::list<DeviceType_T> DeviceTypeList; 57 typedef std::list<Property> PropertyList; 57 58 58 59 struct Data … … 60 61 Data() : capabilities(0) {} 61 62 62 const Utf8Str strId; 63 const Utf8Str strName; 64 const StrList llFileExtensions; 65 const uint64_t capabilities; 66 const PropertyList llProperties; 63 const Utf8Str strId; 64 const Utf8Str strName; 65 const StrList llFileExtensions; 66 const DeviceTypeList llDeviceTypes; 67 const uint64_t capabilities; 68 const PropertyList llProperties; 67 69 }; 68 70 … … 91 93 STDMETHOD(COMGETTER(Id))(BSTR *aId); 92 94 STDMETHOD(COMGETTER(Name))(BSTR *aName); 93 STDMETHOD(COMGETTER(FileExtensions))(ComSafeArrayOut(BSTR, aFileExtensions));94 95 STDMETHOD(COMGETTER(Capabilities))(ULONG *aCaps); 95 96 96 97 // IMediumFormat methods 98 STDMETHOD(DescribeFileExtensions)(ComSafeArrayOut(BSTR, aFileExtensions), 99 ComSafeArrayOut(DeviceType_T, aDeviceTypes)); 97 100 STDMETHOD(DescribeProperties)(ComSafeArrayOut(BSTR, aNames), 98 101 ComSafeArrayOut(BSTR, aDescriptions), -
trunk/src/VBox/Main/include/MediumImpl.h
r33339 r33524 300 300 Utf8Str vdError(int aVRC); 301 301 302 VDTYPE convertDeviceType(); 303 DeviceType_T convertToDeviceType(VDTYPE enmType); 304 302 305 static DECLCALLBACK(void) vdErrorCall(void *pvUser, int rc, RT_SRC_POS_DECL, 303 306 const char *pszFormat, va_list va); -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r31539 r33524 164 164 165 165 /** 166 * Special version of the AssertFailed macro to be used within VirtualBoxBase 167 * subclasses that also inherit the VirtualBoxSupportErrorInfoImpl template. 168 * 169 * In the debug build, this macro is equivalent to AssertFailed. 170 * In the release build, this macro uses |setError(E_FAIL, ...)| to set the 171 * error info from the asserted expression. 172 * 173 * @see VirtualBoxSupportErrorInfoImpl::setError 174 * 175 */ 176 #if defined (DEBUG) 177 #define ComAssertFailed() AssertFailed() 178 #else 179 #define ComAssertFailed() \ 180 do { \ 181 setError(E_FAIL, \ 182 "Assertion failed: at '%s' (%d) in %s.\nPlease contact the product vendor!", \ 183 __FILE__, __LINE__, __PRETTY_FUNCTION__); \ 184 } while (0) 185 #endif 186 187 /** 166 188 * Special version of the AssertMsg macro to be used within VirtualBoxBase 167 189 * subclasses that also inherit the VirtualBoxSupportErrorInfoImpl template. … … 280 302 #define ComAssertComRCThrowRC(rc) \ 281 303 if (1) { ComAssertComRC(rc); if (!SUCCEEDED(rc)) { throw rc; } } else do {} while (0) 304 /** Special version of ComAssert that throws eval */ 305 #define ComAssertFailedThrow(eval) \ 306 if (1) { ComAssertFailed(); { throw (eval); } } else do {} while (0) 282 307 283 308 //////////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Main/xml/Settings.cpp
r33504 r33524 671 671 else if (strType == "SHAREABLE") 672 672 med.hdType = MediumType_Shareable; 673 else if (strType == "READONLY") 674 med.hdType = MediumType_Readonly; 673 675 else 674 676 throw ConfigFileError(this, &elmMedium, N_("HardDisk/@type attribute must be one of Normal, Immutable or Writethrough")); 675 677 } 676 678 } 677 else if (m->sv < SettingsVersion_v1_4) 678 { 679 // DVD and floppy images before 1.4 had "src" attribute instead of "location" 680 if (!(elmMedium.getAttributeValue("src", med.strLocation))) 681 throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName()); 682 683 fNeedsLocation = false; 679 else 680 { 681 if (m->sv < SettingsVersion_v1_4) 682 { 683 // DVD and floppy images before 1.4 had "src" attribute instead of "location" 684 if (!(elmMedium.getAttributeValue("src", med.strLocation))) 685 throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName()); 686 687 fNeedsLocation = false; 688 } 689 690 if (!(elmMedium.getAttributeValue("format", med.strFormat))) 691 { 692 // DVD and floppy images before 1.11 had no format attribute. assign the default. 693 med.strFormat = "RAW"; 694 } 684 695 } 685 696 … … 979 990 * @param level 980 991 */ 981 void ConfigFileBase::buildHardDisk(xml::ElementNode &elmMedium, 982 const Medium &mdm, 983 uint32_t level) // 0 for "root" call, incremented with each recursion 984 { 985 xml::ElementNode *pelmHardDisk = elmMedium.createChild("HardDisk"); 986 pelmHardDisk->setAttribute("uuid", mdm.uuid.toStringCurly()); 987 pelmHardDisk->setAttribute("location", mdm.strLocation); 988 pelmHardDisk->setAttribute("format", mdm.strFormat); 992 void ConfigFileBase::buildMedium(xml::ElementNode &elmMedium, 993 DeviceType_T devType, 994 const Medium &mdm, 995 uint32_t level) // 0 for "root" call, incremented with each recursion 996 { 997 xml::ElementNode *pelmMedium; 998 999 if (devType == DeviceType_HardDisk) 1000 pelmMedium = elmMedium.createChild("HardDisk"); 1001 else 1002 pelmMedium = elmMedium.createChild("Image"); 1003 1004 pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly()); 1005 pelmMedium->setAttribute("location", mdm.strLocation); 1006 pelmMedium->setAttribute("format", mdm.strFormat); 989 1007 if (mdm.fAutoReset) 990 pelm HardDisk->setAttribute("autoReset", mdm.fAutoReset);1008 pelmMedium->setAttribute("autoReset", mdm.fAutoReset); 991 1009 if (mdm.strDescription.length()) 992 pelm HardDisk->setAttribute("Description", mdm.strDescription);1010 pelmMedium->setAttribute("Description", mdm.strDescription); 993 1011 994 1012 for (StringsMap::const_iterator it = mdm.properties.begin(); … … 996 1014 ++it) 997 1015 { 998 xml::ElementNode *pelmProp = pelm HardDisk->createChild("Property");1016 xml::ElementNode *pelmProp = pelmMedium->createChild("Property"); 999 1017 pelmProp->setAttribute("name", it->first); 1000 1018 pelmProp->setAttribute("value", it->second); … … 1008 1026 mdm.hdType == MediumType_Immutable ? "Immutable" : 1009 1027 mdm.hdType == MediumType_Writethrough ? "Writethrough" : 1010 mdm.hdType == MediumType_Shareable ? "Shareable" : "INVALID"; 1011 pelmHardDisk->setAttribute("type", pcszType); 1028 mdm.hdType == MediumType_Shareable ? "Shareable" : 1029 mdm.hdType == MediumType_Readonly ? "Readonly" : "INVALID"; 1030 pelmMedium->setAttribute("type", pcszType); 1012 1031 } 1013 1032 … … 1017 1036 { 1018 1037 // recurse for children 1019 buildHardDisk(*pelmHardDisk, // parent 1020 *it, // settings::Medium 1021 ++level); // recursion level 1038 buildMedium(*pelmMedium, // parent 1039 devType, // device type 1040 *it, // settings::Medium 1041 ++level); // recursion level 1022 1042 } 1023 1043 } … … 1044 1064 ++it) 1045 1065 { 1046 build HardDisk(*pelmHardDisks, *it, 0);1066 buildMedium(*pelmHardDisks, DeviceType_HardDisk, *it, 0); 1047 1067 } 1048 1068 … … 1052 1072 ++it) 1053 1073 { 1054 const Medium &mdm = *it; 1055 xml::ElementNode *pelmMedium = pelmDVDImages->createChild("Image"); 1056 pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly()); 1057 pelmMedium->setAttribute("location", mdm.strLocation); 1058 if (mdm.strDescription.length()) 1059 pelmMedium->setAttribute("Description", mdm.strDescription); 1074 buildMedium(*pelmDVDImages, DeviceType_DVD, *it, 0); 1060 1075 } 1061 1076 … … 1065 1080 ++it) 1066 1081 { 1067 const Medium &mdm = *it; 1068 xml::ElementNode *pelmMedium = pelmFloppyImages->createChild("Image"); 1069 pelmMedium->setAttribute("uuid", mdm.uuid.toStringCurly()); 1070 pelmMedium->setAttribute("location", mdm.strLocation); 1071 if (mdm.strDescription.length()) 1072 pelmMedium->setAttribute("Description", mdm.strDescription); 1082 buildMedium(*pelmFloppyImages, DeviceType_Floppy, *it, 0); 1073 1083 } 1074 1084 }
Note:
See TracChangeset
for help on using the changeset viewer.