Changeset 7277 in vbox
- Timestamp:
- Mar 4, 2008 2:12:17 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxHDD-new.h
r6291 r7277 202 202 * 203 203 * @returns VBox status code. 204 * @param pszBackend Name of the image file backend to use.205 204 * @param pfnError Callback for setting extended error information. 206 205 * @param pvErrorUser Opaque parameter for pfnError. 207 206 * @param ppDisk Where to store the reference to HDD container. 208 207 */ 209 VBOXDDU_DECL(int) VDCreate( const char *pszBackend, PFNVDERROR pfnError,210 void *pvErrorUser,PVBOXHDD *ppDisk);208 VBOXDDU_DECL(int) VDCreate(PFNVDERROR pfnError, void *pvErrorUser, 209 PVBOXHDD *ppDisk); 211 210 212 211 /** … … 243 242 * @returns VBox status code. 244 243 * @param pDisk Pointer to HDD container. 244 * @param pszBackend Name of the image file backend to use. 245 245 * @param pszFilename Name of the image file to open. 246 246 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 247 247 */ 248 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *psz Filename,249 unsigned uOpenFlags);248 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend, 249 const char *pszFilename, unsigned uOpenFlags); 250 250 251 251 /** … … 254 254 * @returns VBox status code. 255 255 * @param pDisk Pointer to HDD container. 256 * @param pszBackend Name of the image file backend to use. 256 257 * @param pszFilename Name of the image file to create. 257 258 * @param enmType Image type, only base image types are acceptable. … … 265 266 * @param pvUser User argument for the progress callback. 266 267 */ 267 VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszFilename, 268 VDIMAGETYPE enmType, uint64_t cbSize, 269 unsigned uImageFlags, const char *pszComment, 268 VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszBackend, 269 const char *pszFilename, VDIMAGETYPE enmType, 270 uint64_t cbSize, unsigned uImageFlags, 271 const char *pszComment, 270 272 PCPDMMEDIAGEOMETRY pPCHSGeometry, 271 273 PCPDMMEDIAGEOMETRY pLCHSGeometry, … … 279 281 * @returns VBox status code. 280 282 * @param pDisk Pointer to HDD container. 283 * @param pszBackend Name of the image file backend to use. 281 284 * @param pszFilename Name of the differencing image file to create. 282 285 * @param uImageFlags Flags specifying special image features. … … 286 289 * @param pvUser User argument for the progress callback. 287 290 */ 288 VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *psz Filename,289 unsigned uImageFlags, const char *pszComment,290 unsigned uOpenFlags, PFNVMPROGRESS pfnProgress,291 void *pvUser);291 VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszBackend, 292 const char *pszFilename, unsigned uImageFlags, 293 const char *pszComment, unsigned uOpenFlags, 294 PFNVMPROGRESS pfnProgress, void *pvUser); 292 295 293 296 /** … … 313 316 * The copy is opened in the target HDD container. 314 317 * It is possible to convert between different image formats, because the 315 * backend for the destination HDD container may be different from the 316 * source container. 318 * backend for the destination may be different from the source. 317 319 * If both the source and destination reference the same HDD container, 318 320 * then the image is moved (by copying/deleting or renaming) to the new location. … … 325 327 * @param nImage Image number, counts from 0. 0 is always base image of container. 326 328 * @param pDiskTo Pointer to destination HDD container. 329 * @param pszBackend Name of the image file backend to use (may be NULL to use the same as the source). 327 330 * @param pszFilename New name of the image (may be NULL if pDiskFrom == pDiskTo). 328 331 * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored). … … 332 335 */ 333 336 VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo, 334 const char *psz Filename, bool fMoveByRename,335 uint64_t cbSize, PFNVMPROGRESS pfnProgress,336 void *pvUser);337 const char *pszBackend, const char *pszFilename, 338 bool fMoveByRename, uint64_t cbSize, 339 PFNVMPROGRESS pfnProgress, void *pvUser); 337 340 338 341 /** -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r6324 r7277 62 62 /** Pointer to the driver instance. */ 63 63 PPDMDRVINS pDrvIns; 64 /** Name of the image format backend. */65 char szFormat[16];66 64 /** Flag whether suspend has changed image open mode to read only. */ 67 65 bool fTempReadOnly; … … 255 253 PVBOXDISK pData = PDMINS2DATA(pDrvIns, PVBOXDISK); 256 254 int rc = VINF_SUCCESS; 257 char *pszName; /**< The path of the disk image file. */ 255 char *pszName = NULL; /**< The path of the disk image file. */ 256 char *pszFormat = NULL; /**< The format backed to use for this image. */ 258 257 bool fReadOnly; /**< True if the media is readonly. */ 259 258 bool fHonorZeroWrites; /**< True if zero blocks should be written. */ … … 263 262 */ 264 263 pDrvIns->IBase.pfnQueryInterface = drvvdQueryInterface; 265 pData->pDrvIns = pDrvIns; 266 pData->fTempReadOnly = false; 264 pData->pDrvIns = pDrvIns; 265 pData->fTempReadOnly = false; 266 pData->pDisk = NULL; 267 267 268 268 /* IMedia */ … … 290 290 if (pCurNode == pCfgHandle) 291 291 { 292 /* Toplevel configuration contains the format backend name and293 * full image open information. */292 /* Toplevel configuration additionally contains the global image 293 * open flags. Some might be converted to per-image flags later. */ 294 294 fValid = CFGMR3AreValuesValid(pCurNode, 295 "Format\0 "296 " Path\0ReadOnly\0HonorZeroWrites\0");295 "Format\0Path\0" 296 "ReadOnly\0HonorZeroWrites\0"); 297 297 } 298 298 else 299 299 { 300 /* All other image configurations only contain image name. */ 301 fValid = CFGMR3AreValuesValid(pCurNode, "Path\0"); 300 /* All other image configurations only contain image name and 301 * the format information. */ 302 fValid = CFGMR3AreValuesValid(pCurNode, "Format\0Path\0"); 302 303 } 303 304 if (!fValid) … … 320 321 if (VBOX_SUCCESS(rc)) 321 322 { 322 rc = CFGMR3QueryString(pCfgHandle, "Format", &pData->szFormat[0], 323 sizeof(pData->szFormat)); 324 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 325 { 326 /* Default disk image format is VMDK. */ 327 rc = VINF_SUCCESS; 328 strncpy(&pData->szFormat[0], "VMDK", sizeof(pData->szFormat)); 329 pData->szFormat[sizeof(pData->szFormat) - 1] = '\0'; 330 } 331 if (VBOX_SUCCESS(rc)) 332 { 333 rc = VDCreate(pData->szFormat, drvvdErrorCallback, pDrvIns, &pData->pDisk); 334 /* Error message is already set correctly. */ 335 } 336 else 337 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 338 N_("DrvVD: Configuration error: Querying \"Format\" as string failed")); 323 rc = VDCreate(drvvdErrorCallback, pDrvIns, &pData->pDisk); 324 /* Error message is already set correctly. */ 339 325 } 340 326 … … 347 333 if (VBOX_FAILURE(rc)) 348 334 { 349 VDDestroy(pData->pDisk);350 335 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 351 336 N_("DrvVD: Configuration error: Querying \"Path\" as string failed")); 337 break; 338 } 339 340 rc = CFGMR3QueryStringAlloc(pCfgHandle, "Format", &pszFormat); 341 if (VBOX_FAILURE(rc)) 342 { 343 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 344 N_("DrvVD: Configuration error: Querying \"Format\" as string failed")); 352 345 break; 353 346 } … … 360 353 else if (VBOX_FAILURE(rc)) 361 354 { 362 MMR3HeapFree(pszName);363 VDDestroy(pData->pDisk);364 355 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 365 356 N_("DrvVD: Configuration error: Querying \"ReadOnly\" as boolean failed")); … … 372 363 else if (VBOX_FAILURE(rc)) 373 364 { 374 MMR3HeapFree(pszName);375 VDDestroy(pData->pDisk);376 365 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 377 366 N_("DrvVD: Configuration error: Querying \"HonorZeroWrites\" as boolean failed")); … … 395 384 if (fHonorZeroWrites) 396 385 uOpenFlags |= VD_OPEN_FLAGS_HONOR_ZEROES; 397 rc = VDOpen(pData->pDisk, psz Name, uOpenFlags);386 rc = VDOpen(pData->pDisk, pszFormat, pszName, uOpenFlags); 398 387 if (VBOX_SUCCESS(rc)) 399 388 Log(("%s: %d - Opened '%s' in %s mode\n", __FUNCTION__, … … 403 392 { 404 393 AssertMsgFailed(("Failed to open image '%s' rc=%Vrc\n", pszName, rc)); 405 VDDestroy(pData->pDisk);406 394 break; 407 395 } 408 396 MMR3HeapFree(pszName); 397 pszName = NULL; 398 MMR3HeapFree(pszFormat); 399 pszFormat = NULL; 409 400 410 401 /* next */ 411 402 iLevel--; 412 403 pCurNode = CFGMR3GetParent(pCurNode); 404 } 405 406 if (VBOX_FAILURE(rc)) 407 { 408 if (VALID_PTR(pData->pDisk)) 409 { 410 VDDestroy(pData->pDisk); 411 pData->pDisk = NULL; 412 } 413 if (VALID_PTR(pszName)) 414 MMR3HeapFree(pszName); 415 if (VALID_PTR(pszFormat)) 416 MMR3HeapFree(pszFormat); 413 417 } 414 418 -
trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp
r7199 r7277 59 59 * the backends will never ever see). */ 60 60 unsigned uOpenFlags; 61 62 /** Handle for the shared object / DLL. */ 63 RTLDRMOD hPlugin; 64 /** Function pointers for the various backend methods. */ 65 PCVBOXHDDBACKEND Backend; 61 66 } VDIMAGE, *PVDIMAGE; 62 67 … … 101 106 /** Opaque data for error callback. */ 102 107 void *pvErrorUser; 103 104 /** Handle for the shared object / DLL. */105 RTLDRMOD hPlugin;106 /** Function pointers for the various backend methods. */107 PCVBOXHDDBACKEND Backend;108 108 }; 109 109 … … 127 127 128 128 /** 129 * internal: issue early error message.130 */131 static int vdEarlyError(PFNVDERROR pfnError, void *pvErrorUser, int rc,132 RT_SRC_POS_DECL, const char *pszFormat, ...)133 {134 va_list va;135 va_start(va, pszFormat);136 if (pfnError)137 pfnError(pvErrorUser, rc, RT_SRC_POS_ARGS, pszFormat, va);138 va_end(va);139 return rc;140 }141 142 /**143 129 * internal: issue error message. 144 130 */ … … 151 137 pDisk->pfnError(pDisk->pvErrorUser, rc, RT_SRC_POS_ARGS, pszFormat, va); 152 138 va_end(va); 139 return rc; 140 } 141 142 /** 143 * internal: find image format backend. 144 */ 145 static int vdFindBackend(const char *pszBackend, PCVBOXHDDBACKEND *ppBackend, 146 RTLDRMOD *phPlugin) 147 { 148 int rc = VINF_SUCCESS; 149 PCVBOXHDDBACKEND pBackend = NULL; 150 RTLDRMOD hPlugin = NIL_RTLDRMOD; 151 152 for (unsigned i = 0; aBackends[i] != NULL; i++) 153 { 154 if (!strcmp(pszBackend, aBackends[i]->pszBackendName)) 155 { 156 pBackend = aBackends[i]; 157 break; 158 } 159 } 160 161 /* If no static backend is found try loading a shared module with 162 * pszBackend as filename. */ 163 if (!pBackend) 164 { 165 char *pszPluginName; 166 167 /* HDD Format Plugins have VBoxHDD as prefix, prepend it. */ 168 RTStrAPrintf(&pszPluginName, "%s%s", 169 VBOX_HDDFORMAT_PLUGIN_PREFIX, pszBackend); 170 if (!pszPluginName) 171 { 172 rc = VERR_NO_MEMORY; 173 goto out; 174 } 175 176 /* Try to load the plugin (RTldrLoad takes care of the suffix). */ 177 rc = RTLdrLoad(pszPluginName, &hPlugin); 178 if (VBOX_SUCCESS(rc)) 179 { 180 PFNVBOXHDDFORMATLOAD pfnHDDFormatLoad; 181 182 rc = RTLdrGetSymbol(hPlugin, VBOX_HDDFORMAT_LOAD_NAME, 183 (void**)&pfnHDDFormatLoad); 184 if (VBOX_FAILURE(rc) || !pfnHDDFormatLoad) 185 { 186 LogFunc(("error resolving the entry point %s in plugin %s, rc=%Vrc, pfnHDDFormat=%#p\n", VBOX_HDDFORMAT_LOAD_NAME, pszPluginName, rc, pfnHDDFormatLoad)); 187 if (VBOX_SUCCESS(rc)) 188 rc = VERR_SYMBOL_NOT_FOUND; 189 goto out; 190 } 191 192 /* Get the function table. */ 193 PVBOXHDDBACKEND pBE; 194 rc = pfnHDDFormatLoad(&pBE); 195 if (VBOX_FAILURE(rc)) 196 goto out; 197 /* Check if the sizes match. If not this plugin is too old. */ 198 if (pBE->cbSize != sizeof(VBOXHDDBACKEND)) 199 { 200 rc = VERR_VDI_UNSUPPORTED_VERSION; 201 goto out; 202 } 203 pBackend = pBE; 204 } 205 else 206 { 207 /* If the backend plugin doesn't exist, don't treat this as an 208 * error. Just return the NULL pointers. */ 209 rc = VINF_SUCCESS; 210 } 211 212 RTStrFree(pszPluginName); 213 } 214 215 out: 216 if (VBOX_FAILURE(rc)) 217 { 218 if (hPlugin != NIL_RTLDRMOD) 219 RTLdrClose(hPlugin); 220 hPlugin = NIL_RTLDRMOD; 221 pBackend = NULL; 222 } 223 224 *ppBackend = pBackend; 225 *phPlugin = hPlugin; 153 226 return rc; 154 227 } … … 240 313 pCurrImage = pCurrImage->pPrev) 241 314 { 242 rc = pDisk->Backend->pfnRead(pCurrImage->pvBackendData, uOffset, 243 pvBuf, cbThisRead, &cbThisRead); 315 rc = pCurrImage->Backend->pfnRead(pCurrImage->pvBackendData, 316 uOffset, pvBuf, cbThisRead, 317 &cbThisRead); 244 318 } 245 319 … … 272 346 273 347 RTUuidCreate(&Uuid); 274 pDisk-> Backend->pfnSetModificationUuid(pDisk->pLast->pvBackendData,275 &Uuid);348 pDisk->pLast->Backend->pfnSetModificationUuid(pDisk->pLast->pvBackendData, 349 &Uuid); 276 350 } 277 351 … … 294 368 295 369 if (!(pDisk->uModified | VD_IMAGE_MODIFIED_DISABLE_UUID_UPDATE)) 296 pDisk-> Backend->pfnFlush(pDisk->pLast->pvBackendData);370 pDisk->pLast->Backend->pfnFlush(pDisk->pLast->pvBackendData); 297 371 } 298 372 } … … 364 438 365 439 /* Write the full block to the virtual disk. */ 366 rc = p Disk->Backend->pfnWrite(pImage->pvBackendData,367 uOffset - cbPreRead, pvTmp,368 cbPreRead + cbThisWrite + cbPostRead,369 NULL,370 &cbPreRead, &cbPostRead);440 rc = pImage->Backend->pfnWrite(pImage->pvBackendData, 441 uOffset - cbPreRead, pvTmp, 442 cbPreRead + cbThisWrite + cbPostRead, 443 NULL, 444 &cbPreRead, &cbPostRead); 371 445 Assert(rc != VERR_VDI_BLOCK_FREE); 372 446 Assert(cbPreRead == 0); … … 444 518 445 519 /* Write the full block to the virtual disk. */ 446 rc = p Disk->Backend->pfnWrite(pImage->pvBackendData,447 uOffset - cbPreRead, pvTmp,448 cbPreRead + cbThisWrite + cbPostRead,449 NULL,450 &cbPreRead, &cbPostRead);520 rc = pImage->Backend->pfnWrite(pImage->pvBackendData, 521 uOffset - cbPreRead, pvTmp, 522 cbPreRead + cbThisWrite + cbPostRead, 523 NULL, 524 &cbPreRead, &cbPostRead); 451 525 Assert(rc != VERR_VDI_BLOCK_FREE); 452 526 Assert(cbPreRead == 0); … … 475 549 * block if needed. */ 476 550 cbThisWrite = cbWrite; 477 rc = p Disk->Backend->pfnWrite(pImage->pvBackendData, uOffset, pvBuf,478 cbThisWrite, &cbThisWrite, &cbPreRead,479 &cbPostRead);551 rc = pImage->Backend->pfnWrite(pImage->pvBackendData, uOffset, pvBuf, 552 cbThisWrite, &cbThisWrite, &cbPreRead, 553 &cbPostRead); 480 554 if (rc == VERR_VDI_BLOCK_FREE) 481 555 { … … 520 594 * 521 595 * @returns VBox status code. 522 * @param pszBackend Name of the image file backend to use.523 596 * @param pfnError Callback for setting extended error information. 524 597 * @param pvErrorUser Opaque parameter for pfnError. 525 598 * @param ppDisk Where to store the reference to HDD container. 526 599 */ 527 VBOXDDU_DECL(int) VDCreate( const char *pszBackend, PFNVDERROR pfnError,528 void *pvErrorUser,PVBOXHDD *ppDisk)600 VBOXDDU_DECL(int) VDCreate(PFNVDERROR pfnError, void *pvErrorUser, 601 PVBOXHDD *ppDisk) 529 602 { 530 603 int rc = VINF_SUCCESS; 531 PCVBOXHDDBACKEND pBackend = NULL;532 604 PVBOXHDD pDisk = NULL; 533 RTLDRMOD hPlugin = NULL; 534 535 LogFlowFunc(("pszBackend=\"%s\" pfnError=%#p pvErrorUser=%#p\n", 536 pszBackend, pfnError, pvErrorUser)); 605 606 LogFlowFunc(("pfnError=%#p pvErrorUser=%#p\n", pfnError, pvErrorUser)); 537 607 do 538 608 { 539 609 /* Check arguments. */ 540 AssertMsgBreak(VALID_PTR(pszBackend) && *pszBackend,541 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend),542 rc = VERR_INVALID_PARAMETER);543 610 AssertMsgBreak(VALID_PTR(pfnError), 544 611 ("pfnError=%#p\n", pfnError), … … 548 615 rc = VERR_INVALID_PARAMETER); 549 616 550 /* Find backend. */ 551 for (unsigned i = 0; aBackends[i] != NULL; i++) 552 { 553 if (!strcmp(pszBackend, aBackends[i]->pszBackendName)) 554 { 555 pBackend = aBackends[i]; 556 break; 557 } 558 } 559 560 /* If no static backend is found try loading a shared module with 561 * pszBackend as filename. */ 562 if (!pBackend) 563 { 564 char *pszPluginName; 565 566 /* HDD Format Plugins have VBoxHDD as prefix, prepend it. */ 567 RTStrAPrintf(&pszPluginName, "%s%s", 568 VBOX_HDDFORMAT_PLUGIN_PREFIX, pszBackend); 569 if (!pszPluginName) 570 { 571 rc = VERR_NO_MEMORY; 572 break; 573 } 574 575 /* Try to load the plugin (RTldrLoad takes care of the suffix). */ 576 rc = RTLdrLoad(pszPluginName, &hPlugin); 577 if (VBOX_SUCCESS(rc)) 578 { 579 PFNVBOXHDDFORMATLOAD pfnHDDFormatLoad; 580 581 rc = RTLdrGetSymbol(hPlugin, VBOX_HDDFORMAT_LOAD_NAME, 582 (void**)&pfnHDDFormatLoad); 583 if (VBOX_FAILURE(rc) || !pfnHDDFormatLoad) 584 { 585 LogFunc(("error resolving the entry point %s in plugin %s, rc=%Vrc, pfnHDDFormat=%#p\n", VBOX_HDDFORMAT_LOAD_NAME, pszPluginName, rc, pfnHDDFormatLoad)); 586 if (VBOX_SUCCESS(rc)) 587 rc = VERR_SYMBOL_NOT_FOUND; 588 break; 589 } 590 591 /* Get the function table. */ 592 PVBOXHDDBACKEND pBE; 593 rc = pfnHDDFormatLoad(&pBE); 594 if (VBOX_FAILURE(rc)) 595 break; 596 /* Check if the sizes match. If not this plugin is too old. */ 597 if (pBE->cbSize != sizeof(VBOXHDDBACKEND)) 598 { 599 rc = VERR_VDI_UNSUPPORTED_VERSION; 600 break; 601 } 602 pBackend = pBE; 603 } 604 605 RTStrFree(pszPluginName); 606 } 607 608 if (pBackend) 609 { 610 pDisk = (PVBOXHDD)RTMemAllocZ(sizeof(VBOXHDD)); 611 if (pDisk) 612 { 613 pDisk->u32Signature = VBOXHDDDISK_SIGNATURE; 614 pDisk->cImages = 0; 615 pDisk->pBase = NULL; 616 pDisk->pLast = NULL; 617 pDisk->cbSize = 0; 618 pDisk->PCHSGeometry.cCylinders = 0; 619 pDisk->PCHSGeometry.cHeads = 0; 620 pDisk->PCHSGeometry.cSectors = 0; 621 pDisk->LCHSGeometry.cCylinders = 0; 622 pDisk->LCHSGeometry.cHeads = 0; 623 pDisk->LCHSGeometry.cSectors = 0; 624 pDisk->pfnError = pfnError; 625 pDisk->pvErrorUser = pvErrorUser; 626 pDisk->Backend = pBackend; 627 pDisk->hPlugin = hPlugin; 628 *ppDisk = pDisk; 629 } 630 else 631 { 632 rc = VERR_NO_MEMORY; 633 break; 634 } 617 pDisk = (PVBOXHDD)RTMemAllocZ(sizeof(VBOXHDD)); 618 if (pDisk) 619 { 620 pDisk->u32Signature = VBOXHDDDISK_SIGNATURE; 621 pDisk->cImages = 0; 622 pDisk->pBase = NULL; 623 pDisk->pLast = NULL; 624 pDisk->cbSize = 0; 625 pDisk->PCHSGeometry.cCylinders = 0; 626 pDisk->PCHSGeometry.cHeads = 0; 627 pDisk->PCHSGeometry.cSectors = 0; 628 pDisk->LCHSGeometry.cCylinders = 0; 629 pDisk->LCHSGeometry.cHeads = 0; 630 pDisk->LCHSGeometry.cSectors = 0; 631 pDisk->pfnError = pfnError; 632 pDisk->pvErrorUser = pvErrorUser; 633 *ppDisk = pDisk; 635 634 } 636 635 else 637 rc = vdEarlyError(pfnError, pvErrorUser, VERR_INVALID_PARAMETER, 638 RT_SRC_POS, "VD: unknown backend name '%s'", 639 pszBackend); 640 } while (0); 641 642 if (VBOX_FAILURE(rc) && hPlugin) 643 RTLdrClose(hPlugin); 636 { 637 rc = VERR_NO_MEMORY; 638 break; 639 } 640 } while (0); 644 641 645 642 LogFlowFunc(("returns %Vrc (pDisk=%#p)\n", rc, pDisk)); … … 665 662 { 666 663 VDCloseAll(pDisk); 667 if (pDisk->hPlugin != NIL_RTLDRMOD)668 {669 RTLdrClose(pDisk->hPlugin);670 pDisk->hPlugin = NIL_RTLDRMOD;671 }672 664 RTMemFree(pDisk); 673 665 } … … 856 848 * @returns VBox status code. 857 849 * @param pDisk Pointer to HDD container. 850 * @param pszBackend Name of the image file backend to use. 858 851 * @param pszFilename Name of the image file to open. 859 852 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 860 853 */ 861 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *psz Filename,862 unsigned uOpenFlags)854 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend, 855 const char *pszFilename, unsigned uOpenFlags) 863 856 { 864 857 int rc = VINF_SUCCESS; 865 858 PVDIMAGE pImage = NULL; 866 859 867 LogFlowFunc(("pDisk=%#p psz Filename=\"%s\" uOpenFlags=%#x\n",868 p szFilename, uOpenFlags));860 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" uOpenFlags=%#x\n", 861 pDisk, pszBackend, pszFilename, uOpenFlags)); 869 862 do 870 863 { … … 874 867 875 868 /* Check arguments. */ 869 AssertMsgBreak(VALID_PTR(pszBackend) && *pszBackend, 870 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend), 871 rc = VERR_INVALID_PARAMETER); 876 872 AssertMsgBreak(VALID_PTR(pszFilename) && *pszFilename, 877 873 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename), … … 899 895 } 900 896 897 rc = vdFindBackend(pszBackend, &pImage->Backend, &pImage->hPlugin); 898 if (VBOX_FAILURE(rc)) 899 break; 900 if (!pImage->Backend) 901 { 902 rc = vdError(pDisk, VERR_INVALID_PARAMETER, RT_SRC_POS, 903 N_("VD: unknown backend name '%s'"), pszBackend); 904 break; 905 } 906 901 907 pImage->uOpenFlags = uOpenFlags & VD_OPEN_FLAGS_HONOR_SAME; 902 rc = p Disk->Backend->pfnOpen(pImage->pszFilename,903 uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME,904 pDisk->pfnError, pDisk->pvErrorUser,905 &pImage->pvBackendData);908 rc = pImage->Backend->pfnOpen(pImage->pszFilename, 909 uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME, 910 pDisk->pfnError, pDisk->pvErrorUser, 911 &pImage->pvBackendData); 906 912 /* If the open in read-write mode failed, retry in read-only mode. */ 907 913 if (VBOX_FAILURE(rc)) … … 913 919 || rc == VERR_SHARING_VIOLATION 914 920 || rc == VERR_FILE_LOCK_FAILED)) 915 rc = p Disk->Backend->pfnOpen(pImage->pszFilename,916 (uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME)917 | VD_OPEN_FLAGS_READONLY,918 pDisk->pfnError, pDisk->pvErrorUser,919 &pImage->pvBackendData);921 rc = pImage->Backend->pfnOpen(pImage->pszFilename, 922 (uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME) 923 | VD_OPEN_FLAGS_READONLY, 924 pDisk->pfnError, pDisk->pvErrorUser, 925 &pImage->pvBackendData); 920 926 if (VBOX_FAILURE(rc)) 921 927 { … … 927 933 928 934 VDIMAGETYPE enmImageType; 929 rc = p Disk->Backend->pfnGetImageType(pImage->pvBackendData,930 &enmImageType);935 rc = pImage->Backend->pfnGetImageType(pImage->pvBackendData, 936 &enmImageType); 931 937 /* Check image type. As the image itself has no idea whether it's a 932 938 * base image or not, this info is derived here. Image 0 can be fixed … … 946 952 947 953 /* Cache disk information. */ 948 pDisk->cbSize = p Disk->Backend->pfnGetSize(pImage->pvBackendData);954 pDisk->cbSize = pImage->Backend->pfnGetSize(pImage->pvBackendData); 949 955 950 956 /* Cache PCHS geometry. */ 951 rc2 = p Disk->Backend->pfnGetPCHSGeometry(pImage->pvBackendData,952 &pDisk->PCHSGeometry);957 rc2 = pImage->Backend->pfnGetPCHSGeometry(pImage->pvBackendData, 958 &pDisk->PCHSGeometry); 953 959 if (VBOX_FAILURE(rc2)) 954 960 { … … 966 972 967 973 /* Cache LCHS geometry. */ 968 rc2 = p Disk->Backend->pfnGetLCHSGeometry(pImage->pvBackendData,969 &pDisk->LCHSGeometry);974 rc2 = pImage->Backend->pfnGetLCHSGeometry(pImage->pvBackendData, 975 &pDisk->LCHSGeometry); 970 976 if (VBOX_FAILURE(rc2)) 971 977 { … … 986 992 /* Switch previous image to read-only mode. */ 987 993 unsigned uOpenFlagsPrevImg; 988 uOpenFlagsPrevImg = pDisk-> Backend->pfnGetOpenFlags(pDisk->pLast->pvBackendData);994 uOpenFlagsPrevImg = pDisk->pLast->Backend->pfnGetOpenFlags(pDisk->pLast->pvBackendData); 989 995 if (!(uOpenFlagsPrevImg & VD_OPEN_FLAGS_READONLY)) 990 996 { 991 997 uOpenFlagsPrevImg |= VD_OPEN_FLAGS_READONLY; 992 rc = pDisk-> Backend->pfnSetOpenFlags(pDisk->pLast->pvBackendData, uOpenFlagsPrevImg);998 rc = pDisk->pLast->Backend->pfnSetOpenFlags(pDisk->pLast->pvBackendData, uOpenFlagsPrevImg); 993 999 } 994 1000 } … … 1003 1009 /* Error detected, but image opened. Close image. */ 1004 1010 int rc2; 1005 rc2 = p Disk->Backend->pfnClose(pImage->pvBackendData, false);1011 rc2 = pImage->Backend->pfnClose(pImage->pvBackendData, false); 1006 1012 AssertRC(rc2); 1007 1013 pImage->pvBackendData = NULL; … … 1011 1017 if (VBOX_FAILURE(rc)) 1012 1018 { 1019 if (pImage->hPlugin != NIL_RTLDRMOD) 1020 RTLdrClose(pImage->hPlugin); 1021 1013 1022 if (pImage) 1014 1023 { … … 1028 1037 * @returns VBox status code. 1029 1038 * @param pDisk Pointer to HDD container. 1039 * @param pszBackend Name of the image file backend to use. 1030 1040 * @param pszFilename Name of the image file to create. 1031 1041 * @param enmType Image type, only base image types are acceptable. … … 1039 1049 * @param pvUser User argument for the progress callback. 1040 1050 */ 1041 VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszFilename, 1042 VDIMAGETYPE enmType, uint64_t cbSize, 1043 unsigned uImageFlags, const char *pszComment, 1051 VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszBackend, 1052 const char *pszFilename, VDIMAGETYPE enmType, 1053 uint64_t cbSize, unsigned uImageFlags, 1054 const char *pszComment, 1044 1055 PCPDMMEDIAGEOMETRY pPCHSGeometry, 1045 1056 PCPDMMEDIAGEOMETRY pLCHSGeometry, … … 1050 1061 PVDIMAGE pImage = NULL; 1051 1062 1052 LogFlowFunc(("p szFilename=\"%s\" enmType=%#x cbSize=%llu uImageFlags=%#x pszComment=\"%s\" PCHS=%u/%u/%u LCHS=%u/%u/%u uOpenFlags=%#x pfnProgress=%#p pvUser=%#p\n",1053 p szFilename, enmType, cbSize, uImageFlags, pszComment,1063 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" enmType=%#x cbSize=%llu uImageFlags=%#x pszComment=\"%s\" PCHS=%u/%u/%u LCHS=%u/%u/%u uOpenFlags=%#x pfnProgress=%#p pvUser=%#p\n", 1064 pDisk, pszBackend, pszFilename, enmType, cbSize, uImageFlags, pszComment, 1054 1065 pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, 1055 1066 pPCHSGeometry->cSectors, pLCHSGeometry->cCylinders, … … 1063 1074 1064 1075 /* Check arguments. */ 1076 AssertMsgBreak(VALID_PTR(pszBackend) && *pszBackend, 1077 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend), 1078 rc = VERR_INVALID_PARAMETER); 1065 1079 AssertMsgBreak(VALID_PTR(pszFilename) && *pszFilename, 1066 1080 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename), … … 1101 1115 /* Check state. */ 1102 1116 AssertMsgBreak(pDisk->cImages == 0, 1103 1117 ("Create base image cannot be done with other images open\n"), 1104 1118 rc = VERR_VDI_INVALID_STATE); 1105 1119 … … 1118 1132 } 1119 1133 1120 rc = pDisk->Backend->pfnCreate(pImage->pszFilename, enmType, cbSize, 1121 uImageFlags, pszComment, pPCHSGeometry, 1122 pLCHSGeometry, uOpenFlags, pfnProgress, 1123 pvUser, 0, 99, pDisk->pfnError, 1124 pDisk->pvErrorUser, 1125 &pImage->pvBackendData); 1134 rc = vdFindBackend(pszBackend, &pImage->Backend, &pImage->hPlugin); 1135 if (VBOX_FAILURE(rc)) 1136 break; 1137 if (!pImage->Backend) 1138 { 1139 rc = vdError(pDisk, VERR_INVALID_PARAMETER, RT_SRC_POS, 1140 N_("VD: unknown backend name '%s'"), pszBackend); 1141 break; 1142 } 1143 1144 rc = pImage->Backend->pfnCreate(pImage->pszFilename, enmType, cbSize, 1145 uImageFlags, pszComment, pPCHSGeometry, 1146 pLCHSGeometry, uOpenFlags, pfnProgress, 1147 pvUser, 0, 99, pDisk->pfnError, 1148 pDisk->pvErrorUser, 1149 &pImage->pvBackendData); 1126 1150 1127 1151 if (VBOX_SUCCESS(rc)) … … 1132 1156 1133 1157 /* Cache disk information. */ 1134 pDisk->cbSize = p Disk->Backend->pfnGetSize(pImage->pvBackendData);1158 pDisk->cbSize = pImage->Backend->pfnGetSize(pImage->pvBackendData); 1135 1159 1136 1160 /* Cache PCHS geometry. */ 1137 rc2 = p Disk->Backend->pfnGetPCHSGeometry(pImage->pvBackendData,1138 &pDisk->PCHSGeometry);1161 rc2 = pImage->Backend->pfnGetPCHSGeometry(pImage->pvBackendData, 1162 &pDisk->PCHSGeometry); 1139 1163 if (VBOX_FAILURE(rc2)) 1140 1164 { … … 1152 1176 1153 1177 /* Cache LCHS geometry. */ 1154 rc2 = p Disk->Backend->pfnGetLCHSGeometry(pImage->pvBackendData,1155 &pDisk->LCHSGeometry);1178 rc2 = pImage->Backend->pfnGetLCHSGeometry(pImage->pvBackendData, 1179 &pDisk->LCHSGeometry); 1156 1180 if (VBOX_FAILURE(rc2)) 1157 1181 { … … 1178 1202 /* Error detected, but image opened. Close and delete image. */ 1179 1203 int rc2; 1180 rc2 = p Disk->Backend->pfnClose(pImage->pvBackendData, true);1204 rc2 = pImage->Backend->pfnClose(pImage->pvBackendData, true); 1181 1205 AssertRC(rc2); 1182 1206 pImage->pvBackendData = NULL; … … 1186 1210 if (VBOX_FAILURE(rc)) 1187 1211 { 1212 if (pImage->hPlugin != NIL_RTLDRMOD) 1213 RTLdrClose(pImage->hPlugin); 1214 1188 1215 if (pImage) 1189 1216 { … … 1207 1234 * @returns VBox status code. 1208 1235 * @param pDisk Pointer to HDD container. 1236 * @param pszBackend Name of the image file backend to use. 1209 1237 * @param pszFilename Name of the differencing image file to create. 1210 1238 * @param uImageFlags Flags specifying special image features. … … 1214 1242 * @param pvUser User argument for the progress callback. 1215 1243 */ 1216 VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *psz Filename,1217 unsigned uImageFlags, const char *pszComment,1218 unsigned uOpenFlags, PFNVMPROGRESS pfnProgress,1219 void *pvUser)1244 VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszBackend, 1245 const char *pszFilename, unsigned uImageFlags, 1246 const char *pszComment, unsigned uOpenFlags, 1247 PFNVMPROGRESS pfnProgress, void *pvUser) 1220 1248 { 1221 1249 int rc = VINF_SUCCESS; 1222 1250 PVDIMAGE pImage = NULL; 1223 1251 1224 LogFlowFunc(("pDisk=%#p psz Filename=\"%s\" uImageFlags=%#x pszComment=\"%s\" uOpenFlags=%#x pfnProgress=%#p pvUser=%#p\n",1225 pDisk, psz Filename, uImageFlags, pszComment, uOpenFlags,1252 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" uImageFlags=%#x pszComment=\"%s\" uOpenFlags=%#x pfnProgress=%#p pvUser=%#p\n", 1253 pDisk, pszBackend, pszFilename, uImageFlags, pszComment, uOpenFlags, 1226 1254 pfnProgress, pvUser)); 1227 1255 do … … 1232 1260 1233 1261 /* Check arguments. */ 1262 AssertMsgBreak(VALID_PTR(pszBackend) && *pszBackend, 1263 ("pszBackend=%#p \"%s\"\n", pszBackend, pszBackend), 1264 rc = VERR_INVALID_PARAMETER); 1234 1265 AssertMsgBreak(VALID_PTR(pszFilename) && *pszFilename, 1235 1266 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename), … … 1244 1275 /* Check state. */ 1245 1276 AssertMsgBreak(pDisk->cImages != 0, 1246 1277 ("Create diff image cannot be done without other images open\n"), 1247 1278 rc = VERR_VDI_INVALID_STATE); 1248 1279 … … 1261 1292 } 1262 1293 1263 rc = pDisk->Backend->pfnCreate(pImage->pszFilename, 1264 VD_IMAGE_TYPE_NORMAL, pDisk->cbSize, 1265 uImageFlags, pszComment, 1266 &pDisk->PCHSGeometry, 1267 &pDisk->LCHSGeometry, uOpenFlags, 1268 pfnProgress, pvUser, 0, 99, 1269 pDisk->pfnError, pDisk->pvErrorUser, 1270 &pImage->pvBackendData); 1294 rc = vdFindBackend(pszBackend, &pImage->Backend, &pImage->hPlugin); 1295 if (VBOX_FAILURE(rc)) 1296 break; 1297 if (!pImage->Backend) 1298 { 1299 rc = vdError(pDisk, VERR_INVALID_PARAMETER, RT_SRC_POS, 1300 N_("VD: unknown backend name '%s'"), pszBackend); 1301 break; 1302 } 1303 1304 rc = pImage->Backend->pfnCreate(pImage->pszFilename, 1305 VD_IMAGE_TYPE_NORMAL, pDisk->cbSize, 1306 uImageFlags, pszComment, 1307 &pDisk->PCHSGeometry, 1308 &pDisk->LCHSGeometry, uOpenFlags, 1309 pfnProgress, pvUser, 0, 99, 1310 pDisk->pfnError, pDisk->pvErrorUser, 1311 &pImage->pvBackendData); 1271 1312 1272 1313 if (VBOX_SUCCESS(rc)) … … 1284 1325 /* Error detected, but image opened. Close and delete image. */ 1285 1326 int rc2; 1286 rc2 = p Disk->Backend->pfnClose(pImage->pvBackendData, true);1327 rc2 = pImage->Backend->pfnClose(pImage->pvBackendData, true); 1287 1328 AssertRC(rc2); 1288 1329 pImage->pvBackendData = NULL; … … 1292 1333 if (VBOX_FAILURE(rc)) 1293 1334 { 1335 if (pImage->hPlugin != NIL_RTLDRMOD) 1336 RTLdrClose(pImage->hPlugin); 1337 1294 1338 if (pImage) 1295 1339 { … … 1346 1390 1347 1391 /* Check if destination image is writable. */ 1348 unsigned uOpenFlags = p Disk->Backend->pfnGetOpenFlags(pImageTo->pvBackendData);1392 unsigned uOpenFlags = pImageTo->Backend->pfnGetOpenFlags(pImageTo->pvBackendData); 1349 1393 if (uOpenFlags & VD_OPEN_FLAGS_READONLY) 1350 1394 { … … 1354 1398 1355 1399 /* Get size of destination image. */ 1356 uint64_t cbSize = p Disk->Backend->pfnGetSize(pImageTo->pvBackendData);1400 uint64_t cbSize = pImageTo->Backend->pfnGetSize(pImageTo->pvBackendData); 1357 1401 1358 1402 /* Allocate tmp buffer. */ … … 1380 1424 { 1381 1425 size_t cbThisRead = RT_MIN(VD_MERGE_BUFFER_SIZE, cbRemaining); 1382 rc = pDisk->Backend->pfnRead(pImageTo->pvBackendData, uOffset, 1383 pvBuf, cbThisRead, &cbThisRead); 1426 rc = pImageTo->Backend->pfnRead(pImageTo->pvBackendData, 1427 uOffset, pvBuf, cbThisRead, 1428 &cbThisRead); 1384 1429 if (VBOX_FAILURE(rc)) 1385 1430 break; … … 1394 1439 pCurrImage = pCurrImage->pPrev) 1395 1440 { 1396 rc = pDisk->Backend->pfnRead(pCurrImage->pvBackendData, 1397 uOffset, pvBuf, 1398 cbThisRead, &cbThisRead); 1441 rc = pCurrImage->Backend->pfnRead(pCurrImage->pvBackendData, 1442 uOffset, pvBuf, 1443 cbThisRead, 1444 &cbThisRead); 1399 1445 } 1400 1446 if (VBOX_FAILURE(rc)) … … 1432 1478 pCurrImage = pCurrImage->pPrev) 1433 1479 { 1434 rc = p Disk->Backend->pfnRead(pCurrImage->pvBackendData,1435 uOffset, pvBuf,1436 cbThisRead, &cbThisRead);1480 rc = pCurrImage->Backend->pfnRead(pCurrImage->pvBackendData, 1481 uOffset, pvBuf, 1482 cbThisRead, &cbThisRead); 1437 1483 } 1438 1484 if (VBOX_FAILURE(rc)) … … 1458 1504 if (pImageTo->pPrev) 1459 1505 { 1460 rc = p Disk->Backend->pfnGetUuid(pImageTo->pPrev->pvBackendData,1461 &Uuid);1506 rc = pImageTo->Backend->pfnGetUuid(pImageTo->pPrev->pvBackendData, 1507 &Uuid); 1462 1508 AssertRC(rc); 1463 1509 } 1464 1510 else 1465 1511 RTUuidClear(&Uuid); 1466 rc = p Disk->Backend->pfnSetParentUuid(pImageTo->pvBackendData,1467 &Uuid);1512 rc = pImageTo->Backend->pfnSetParentUuid(pImageTo->pvBackendData, 1513 &Uuid); 1468 1514 AssertRC(rc); 1469 1515 } … … 1472 1518 if (pImageFrom->pNext) 1473 1519 { 1474 rc = p Disk->Backend->pfnGetUuid(pImageTo->pvBackendData,1475 &Uuid);1520 rc = pImageTo->Backend->pfnGetUuid(pImageTo->pvBackendData, 1521 &Uuid); 1476 1522 AssertRC(rc); 1477 rc = p Disk->Backend->pfnSetParentUuid(pImageFrom->pNext,1478 &Uuid);1523 rc = pImageFrom->Backend->pfnSetParentUuid(pImageFrom->pNext, 1524 &Uuid); 1479 1525 AssertRC(rc); 1480 1526 } … … 1490 1536 pTmp = pImg->pPrev; 1491 1537 vdRemoveImageFromList(pDisk, pImg); 1492 p Disk->Backend->pfnClose(pImg->pvBackendData, true);1538 pImg->Backend->pfnClose(pImg->pvBackendData, true); 1493 1539 pImg = pTmp; 1494 1540 } … … 1509 1555 * The copy is opened in the target HDD container. 1510 1556 * It is possible to convert between different image formats, because the 1511 * backend for the destination HDD container may be different from the 1512 * source container. 1557 * backend for the destination may be different from the source. 1513 1558 * If both the source and destination reference the same HDD container, 1514 1559 * then the image is moved (by copying/deleting or renaming) to the new location. … … 1521 1566 * @param nImage Image number, counts from 0. 0 is always base image of container. 1522 1567 * @param pDiskTo Pointer to destination HDD container. 1568 * @param pszBackend Name of the image file backend to use. 1523 1569 * @param pszFilename New name of the image (may be NULL if pDiskFrom == pDiskTo). 1524 1570 * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored). … … 1528 1574 */ 1529 1575 VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo, 1530 const char *psz Filename, bool fMoveByRename,1531 uint64_t cbSize, PFNVMPROGRESS pfnProgress,1532 void *pvUser)1576 const char *pszBackend, const char *pszFilename, 1577 bool fMoveByRename, uint64_t cbSize, 1578 PFNVMPROGRESS pfnProgress, void *pvUser) 1533 1579 { 1534 1580 return VERR_NOT_IMPLEMENTED; … … 1550 1596 int rc = VINF_SUCCESS;; 1551 1597 1552 LogFlowFunc((" fDelete=%d\n", fDelete));1598 LogFlowFunc(("pDisk=%#p fDelete=%d\n", pDisk, fDelete)); 1553 1599 do 1554 1600 { … … 1558 1604 1559 1605 PVDIMAGE pImage = pDisk->pLast; 1560 1561 unsigned uOpenFlags = p Disk->Backend->pfnGetOpenFlags(pImage->pvBackendData);1606 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_NOT_OPENED); 1607 unsigned uOpenFlags = pImage->Backend->pfnGetOpenFlags(pImage->pvBackendData); 1562 1608 /* Remove image from list of opened images. */ 1563 1609 vdRemoveImageFromList(pDisk, pImage); 1564 1610 /* Close (and optionally delete) image. */ 1565 rc = p Disk->Backend->pfnClose(pImage->pvBackendData, fDelete);1611 rc = pImage->Backend->pfnClose(pImage->pvBackendData, fDelete); 1566 1612 /* Free remaining resources related to the image. */ 1613 if (pImage->hPlugin != NIL_RTLDRMOD) 1614 { 1615 RTLdrClose(pImage->hPlugin); 1616 pImage->hPlugin = NIL_RTLDRMOD; 1617 } 1567 1618 RTStrFree(pImage->pszFilename); 1568 1619 RTMemFree(pImage); … … 1577 1628 if (!(uOpenFlags & VD_OPEN_FLAGS_READONLY)) 1578 1629 { 1579 uOpenFlags = p Disk->Backend->pfnGetOpenFlags(pImage->pvBackendData);1630 uOpenFlags = pImage->Backend->pfnGetOpenFlags(pImage->pvBackendData); 1580 1631 uOpenFlags &= ~ VD_OPEN_FLAGS_READONLY; 1581 rc = p Disk->Backend->pfnSetOpenFlags(pImage->pvBackendData, uOpenFlags);1632 rc = pImage->Backend->pfnSetOpenFlags(pImage->pvBackendData, uOpenFlags); 1582 1633 } 1583 1634 … … 1585 1636 1586 1637 /* Cache disk information. */ 1587 pDisk->cbSize = p Disk->Backend->pfnGetSize(pImage->pvBackendData);1638 pDisk->cbSize = pImage->Backend->pfnGetSize(pImage->pvBackendData); 1588 1639 1589 1640 /* Cache PCHS geometry. */ 1590 rc2 = p Disk->Backend->pfnGetPCHSGeometry(pImage->pvBackendData,1641 rc2 = pImage->Backend->pfnGetPCHSGeometry(pImage->pvBackendData, 1591 1642 &pDisk->PCHSGeometry); 1592 1643 if (VBOX_FAILURE(rc2)) … … 1605 1656 1606 1657 /* Cache LCHS geometry. */ 1607 rc2 = p Disk->Backend->pfnGetLCHSGeometry(pImage->pvBackendData,1608 &pDisk->LCHSGeometry);1658 rc2 = pImage->Backend->pfnGetLCHSGeometry(pImage->pvBackendData, 1659 &pDisk->LCHSGeometry); 1609 1660 if (VBOX_FAILURE(rc2)) 1610 1661 { … … 1650 1701 vdRemoveImageFromList(pDisk, pImage); 1651 1702 /* Close image. */ 1652 int rc2 = p Disk->Backend->pfnClose(pImage->pvBackendData, false);1703 int rc2 = pImage->Backend->pfnClose(pImage->pvBackendData, false); 1653 1704 if (VBOX_FAILURE(rc2) && VBOX_SUCCESS(rc)) 1654 1705 rc = rc2; 1655 1706 /* Free remaining resources related to the image. */ 1707 if (pImage->hPlugin != NIL_RTLDRMOD) 1708 { 1709 RTLdrClose(pImage->hPlugin); 1710 pImage->hPlugin = NIL_RTLDRMOD; 1711 } 1656 1712 RTStrFree(pImage->pszFilename); 1657 1713 RTMemFree(pImage); … … 1778 1834 1779 1835 vdResetModifiedFlag(pDisk); 1780 rc = p Disk->Backend->pfnFlush(pImage->pvBackendData);1836 rc = pImage->Backend->pfnFlush(pImage->pvBackendData); 1781 1837 } while (0); 1782 1838 … … 1831 1887 1832 1888 unsigned uOpenFlags; 1833 uOpenFlags = pDisk-> Backend->pfnGetOpenFlags(pDisk->pLast->pvBackendData);1889 uOpenFlags = pDisk->pLast->Backend->pfnGetOpenFlags(pDisk->pLast->pvBackendData); 1834 1890 fReadOnly = !!(uOpenFlags & VD_OPEN_FLAGS_READONLY); 1835 1891 } while (0); … … 1860 1916 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1861 1917 AssertBreak(VALID_PTR(pImage), cbSize = 0); 1862 cbSize = p Disk->Backend->pfnGetSize(pImage->pvBackendData);1918 cbSize = pImage->Backend->pfnGetSize(pImage->pvBackendData); 1863 1919 } while (0); 1864 1920 … … 1888 1944 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 1889 1945 AssertBreak(VALID_PTR(pImage), cbSize = 0); 1890 cbSize = p Disk->Backend->pfnGetFileSize(pImage->pvBackendData);1946 cbSize = pImage->Backend->pfnGetFileSize(pImage->pvBackendData); 1891 1947 } while (0); 1892 1948 … … 1935 1991 } 1936 1992 else 1937 rc = p Disk->Backend->pfnGetPCHSGeometry(pImage->pvBackendData,1938 pPCHSGeometry);1993 rc = pImage->Backend->pfnGetPCHSGeometry(pImage->pvBackendData, 1994 pPCHSGeometry); 1939 1995 } while (0); 1940 1996 … … 1998 2054 * of updating an image which could be opened in read-only mode 1999 2055 * right now. */ 2000 rc = p Disk->Backend->pfnSetPCHSGeometry(pImage->pvBackendData,2001 pPCHSGeometry);2056 rc = pImage->Backend->pfnSetPCHSGeometry(pImage->pvBackendData, 2057 pPCHSGeometry); 2002 2058 2003 2059 /* Cache new geometry values in any case. */ 2004 int rc2 = p Disk->Backend->pfnGetPCHSGeometry(pImage->pvBackendData,2005 &pDisk->PCHSGeometry);2060 int rc2 = pImage->Backend->pfnGetPCHSGeometry(pImage->pvBackendData, 2061 &pDisk->PCHSGeometry); 2006 2062 if (VBOX_FAILURE(rc2)) 2007 2063 { … … 2022 2078 { 2023 2079 PDMMEDIAGEOMETRY PCHS; 2024 rc = p Disk->Backend->pfnGetPCHSGeometry(pImage->pvBackendData,2025 &PCHS);2080 rc = pImage->Backend->pfnGetPCHSGeometry(pImage->pvBackendData, 2081 &PCHS); 2026 2082 if ( VBOX_FAILURE(rc) 2027 2083 || pPCHSGeometry->cCylinders != PCHS.cCylinders … … 2034 2090 * of updating an image which could be opened in read-only mode 2035 2091 * right now. */ 2036 rc = p Disk->Backend->pfnSetPCHSGeometry(pImage->pvBackendData,2037 pPCHSGeometry);2092 rc = pImage->Backend->pfnSetPCHSGeometry(pImage->pvBackendData, 2093 pPCHSGeometry); 2038 2094 } 2039 2095 } … … 2084 2140 } 2085 2141 else 2086 rc = p Disk->Backend->pfnGetLCHSGeometry(pImage->pvBackendData,2087 pLCHSGeometry);2142 rc = pImage->Backend->pfnGetLCHSGeometry(pImage->pvBackendData, 2143 pLCHSGeometry); 2088 2144 } while (0); 2089 2145 … … 2144 2200 * of updating an image which could be opened in read-only mode 2145 2201 * right now. */ 2146 rc = p Disk->Backend->pfnSetLCHSGeometry(pImage->pvBackendData,2147 pLCHSGeometry);2202 rc = pImage->Backend->pfnSetLCHSGeometry(pImage->pvBackendData, 2203 pLCHSGeometry); 2148 2204 2149 2205 /* Cache new geometry values in any case. */ 2150 int rc2 = p Disk->Backend->pfnGetLCHSGeometry(pImage->pvBackendData,2151 &pDisk->LCHSGeometry);2206 int rc2 = pImage->Backend->pfnGetLCHSGeometry(pImage->pvBackendData, 2207 &pDisk->LCHSGeometry); 2152 2208 if (VBOX_FAILURE(rc2)) 2153 2209 { … … 2168 2224 { 2169 2225 PDMMEDIAGEOMETRY LCHS; 2170 rc = p Disk->Backend->pfnGetLCHSGeometry(pImage->pvBackendData,2171 &LCHS);2226 rc = pImage->Backend->pfnGetLCHSGeometry(pImage->pvBackendData, 2227 &LCHS); 2172 2228 if ( VBOX_FAILURE(rc) 2173 2229 || pLCHSGeometry->cCylinders != LCHS.cCylinders … … 2180 2236 * of updating an image which could be opened in read-only mode 2181 2237 * right now. */ 2182 rc = p Disk->Backend->pfnSetLCHSGeometry(pImage->pvBackendData,2183 pLCHSGeometry);2238 rc = pImage->Backend->pfnSetLCHSGeometry(pImage->pvBackendData, 2239 pLCHSGeometry); 2184 2240 } 2185 2241 } … … 2220 2276 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2221 2277 2222 *puVersion = p Disk->Backend->pfnGetVersion(pImage->pvBackendData);2278 *puVersion = pImage->Backend->pfnGetVersion(pImage->pvBackendData); 2223 2279 } while (0); 2224 2280 … … 2257 2313 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2258 2314 2259 rc = p Disk->Backend->pfnGetImageType(pImage->pvBackendData,2260 penmType);2315 rc = pImage->Backend->pfnGetImageType(pImage->pvBackendData, 2316 penmType); 2261 2317 } while (0); 2262 2318 … … 2295 2351 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2296 2352 2297 *puImageFlags = p Disk->Backend->pfnGetImageFlags(pImage->pvBackendData);2353 *puImageFlags = pImage->Backend->pfnGetImageFlags(pImage->pvBackendData); 2298 2354 } while (0); 2299 2355 … … 2332 2388 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2333 2389 2334 *puOpenFlags = p Disk->Backend->pfnGetOpenFlags(pImage->pvBackendData);2390 *puOpenFlags = pImage->Backend->pfnGetOpenFlags(pImage->pvBackendData); 2335 2391 } while (0); 2336 2392 … … 2370 2426 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2371 2427 2372 rc = p Disk->Backend->pfnSetOpenFlags(pImage->pvBackendData,2373 uOpenFlags);2428 rc = pImage->Backend->pfnSetOpenFlags(pImage->pvBackendData, 2429 uOpenFlags); 2374 2430 } while (0); 2375 2431 … … 2468 2524 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2469 2525 2470 rc = p Disk->Backend->pfnGetComment(pImage->pvBackendData, pszComment,2471 cbComment);2526 rc = pImage->Backend->pfnGetComment(pImage->pvBackendData, pszComment, 2527 cbComment); 2472 2528 } while (0); 2473 2529 … … 2506 2562 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2507 2563 2508 rc = p Disk->Backend->pfnSetComment(pImage->pvBackendData, pszComment);2564 rc = pImage->Backend->pfnSetComment(pImage->pvBackendData, pszComment); 2509 2565 } while (0); 2510 2566 … … 2542 2598 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2543 2599 2544 rc = p Disk->Backend->pfnGetUuid(pImage->pvBackendData, pUuid);2600 rc = pImage->Backend->pfnGetUuid(pImage->pvBackendData, pUuid); 2545 2601 } while (0); 2546 2602 … … 2583 2639 pUuid = &Uuid; 2584 2640 } 2585 rc = p Disk->Backend->pfnSetUuid(pImage->pvBackendData, pUuid);2641 rc = pImage->Backend->pfnSetUuid(pImage->pvBackendData, pUuid); 2586 2642 } while (0); 2587 2643 … … 2618 2674 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2619 2675 2620 rc = p Disk->Backend->pfnGetModificationUuid(pImage->pvBackendData,2621 pUuid);2676 rc = pImage->Backend->pfnGetModificationUuid(pImage->pvBackendData, 2677 pUuid); 2622 2678 } while (0); 2623 2679 … … 2661 2717 pUuid = &Uuid; 2662 2718 } 2663 rc = p Disk->Backend->pfnSetModificationUuid(pImage->pvBackendData,2664 pUuid);2719 rc = pImage->Backend->pfnSetModificationUuid(pImage->pvBackendData, 2720 pUuid); 2665 2721 } while (0); 2666 2722 … … 2698 2754 AssertBreak(VALID_PTR(pImage), rc = VERR_VDI_IMAGE_NOT_FOUND); 2699 2755 2700 rc = p Disk->Backend->pfnGetParentUuid(pImage->pvBackendData, pUuid);2756 rc = pImage->Backend->pfnGetParentUuid(pImage->pvBackendData, pUuid); 2701 2757 } while (0); 2702 2758 … … 2740 2796 pUuid = &Uuid; 2741 2797 } 2742 rc = p Disk->Backend->pfnSetParentUuid(pImage->pvBackendData, pUuid);2798 rc = pImage->Backend->pfnSetParentUuid(pImage->pvBackendData, pUuid); 2743 2799 } while (0); 2744 2800 … … 2761 2817 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 2762 2818 2763 RTLogPrintf("--- Dumping VD Disk, Backend=%s, Images=%u\n", 2764 pDisk->Backend->pszBackendName, pDisk->cImages); 2819 RTLogPrintf("--- Dumping VD Disk, Images=%u\n", pDisk->cImages); 2765 2820 for (PVDIMAGE pImage = pDisk->pBase; pImage; pImage = pImage->pNext) 2766 2821 { 2767 RTLogPrintf("Dumping VD image \"%s\"\n", pImage->pszFilename); 2768 pDisk->Backend->pfnDump(pImage->pvBackendData); 2769 } 2770 } while (0); 2771 } 2772 2822 RTLogPrintf("Dumping VD image \"%s\" (Backend=%s)\n", 2823 pImage->Backend->pszBackendName, pImage->pszFilename); 2824 pImage->Backend->pfnDump(pImage->pvBackendData); 2825 } 2826 } while (0); 2827 } 2828 -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r7207 r7277 760 760 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK(); 761 761 STR_FREE(); 762 rc = CFGMR3InsertString(pCfg, "Format", "VMDK"); RC_CHECK(); 762 763 } 763 764 else if (hddType == HardDiskStorageType_CustomHardDisk) -
trunk/src/VBox/Main/HardDiskImpl.cpp
r7207 r7277 3381 3381 3382 3382 /* initialize the container */ 3383 int vrc = VDCreate ( "VMDK",VDError, this, &mContainer);3383 int vrc = VDCreate (VDError, this, &mContainer); 3384 3384 ComAssertRCRet (vrc, E_FAIL); 3385 3385 … … 4049 4049 /// obviously. This of course changes locking behavior, but for now 4050 4050 /// this is acceptable. A better solution needs to be found later. 4051 vrc = VDOpen (mContainer, filePath, VD_OPEN_FLAGS_NORMAL);4051 vrc = VDOpen (mContainer, "VMDK", filePath, VD_OPEN_FLAGS_NORMAL); 4052 4052 if (VBOX_FAILURE (vrc)) 4053 4053 break; … … 4316 4316 4317 4317 /* initialize the container */ 4318 vrc = VDCreate ( Utf8Str (mFormat),VDError, this, &mContainer);4318 vrc = VDCreate (VDError, this, &mContainer); 4319 4319 if (VBOX_FAILURE (vrc)) 4320 4320 { … … 4417 4417 break; 4418 4418 } 4419 mFormat = Bstr (pszFormat); 4420 RTStrFree (pszFormat); 4419 4421 4420 4422 /* Create the corresponding container. */ 4421 vrc = VDCreate (pszFormat, VDError, this, &mContainer); 4422 4423 if (VBOX_SUCCESS(vrc)) 4424 mFormat = Bstr (pszFormat); 4425 4426 RTStrFree (pszFormat); 4423 vrc = VDCreate (VDError, this, &mContainer); 4427 4424 4428 4425 /* the format has been already checked for presence at this point */ … … 4885 4882 Guid id, parentId; 4886 4883 4887 vrc = VDOpen (mContainer, location, VD_OPEN_FLAGS_INFO);4884 vrc = VDOpen (mContainer, Utf8Str (mFormat), location, VD_OPEN_FLAGS_INFO); 4888 4885 if (VBOX_FAILURE (vrc)) 4889 4886 break; … … 5083 5080 5084 5081 /* initialize the container */ 5085 int vrc = VDCreate ( "VHD",VDError, this, &mContainer);5082 int vrc = VDCreate (VDError, this, &mContainer); 5086 5083 ComAssertRCRet (vrc, E_FAIL); 5087 5084 … … 5749 5746 /// obviously. This of course changes locking behavior, but for now 5750 5747 /// this is acceptable. A better solution needs to be found later. 5751 vrc = VDOpen (mContainer, filePath, VD_OPEN_FLAGS_NORMAL);5748 vrc = VDOpen (mContainer, "VHD", filePath, VD_OPEN_FLAGS_NORMAL); 5752 5749 if (VBOX_FAILURE (vrc)) 5753 5750 break;
Note:
See TracChangeset
for help on using the changeset viewer.