[23266] | 1 | /** @file
|
---|
[50988] | 2 | * VD: Image backend interface.
|
---|
[23266] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[50988] | 6 | * Copyright (C) 2006-2014 Oracle Corporation
|
---|
[23266] | 7 | *
|
---|
| 8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
| 11 | * General Public License (GPL) as published by the Free Software
|
---|
| 12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
| 15 | *
|
---|
| 16 | * The contents of this file may alternatively be used under the terms
|
---|
| 17 | * of the Common Development and Distribution License Version 1.0
|
---|
| 18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
| 19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
| 20 | * CDDL are applicable instead of those of the GPL.
|
---|
| 21 | *
|
---|
| 22 | * You may elect to license modified versions of this file under the
|
---|
| 23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
| 24 | */
|
---|
| 25 |
|
---|
[50988] | 26 | #ifndef __vd_image_backend_h__
|
---|
| 27 | #define __vd_image_backend_h__
|
---|
[23266] | 28 |
|
---|
[33567] | 29 | #include <VBox/vd.h>
|
---|
[38469] | 30 | #include <VBox/vd-ifs-internal.h>
|
---|
[23266] | 31 |
|
---|
| 32 |
|
---|
| 33 | /** @name VBox HDD backend write flags
|
---|
| 34 | * @{
|
---|
| 35 | */
|
---|
| 36 | /** Do not allocate a new block on this write. This is just an advisory
|
---|
| 37 | * flag. The backend may still decide in some circumstances that it wants
|
---|
| 38 | * to ignore this flag (which may cause extra dynamic image expansion). */
|
---|
| 39 | #define VD_WRITE_NO_ALLOC RT_BIT(1)
|
---|
| 40 | /** @}*/
|
---|
| 41 |
|
---|
[38621] | 42 | /** @name VBox HDD backend discard flags
|
---|
| 43 | * @{
|
---|
| 44 | */
|
---|
| 45 | /** Don't discard block but mark the given range as unused
|
---|
| 46 | * (usually by writing 0's to it).
|
---|
| 47 | * This doesn't require the range to be aligned on a block boundary but
|
---|
| 48 | * the image size might not be decreased. */
|
---|
| 49 | #define VD_DISCARD_MARK_UNUSED RT_BIT(0)
|
---|
| 50 | /** @}*/
|
---|
[23266] | 51 |
|
---|
[50988] | 52 | /** @name VBox HDD backend metadata traverse flags
|
---|
| 53 | * @{
|
---|
| 54 | */
|
---|
| 55 | /** Include per block metadata while traversing the metadata.
|
---|
| 56 | * This might take much longer instead of traversing just global metadata. */
|
---|
| 57 | #define VD_TRAVERSE_METADATA_INCLUDE_PER_BLOCK_METADATA RT_BIT(0)
|
---|
| 58 | /** @}*/
|
---|
[38621] | 59 |
|
---|
[23266] | 60 | /**
|
---|
| 61 | * Image format backend interface used by VBox HDD Container implementation.
|
---|
| 62 | */
|
---|
| 63 | typedef struct VBOXHDDBACKEND
|
---|
| 64 | {
|
---|
| 65 | /**
|
---|
| 66 | * The name of the backend (constant string).
|
---|
| 67 | */
|
---|
| 68 | const char *pszBackendName;
|
---|
| 69 |
|
---|
| 70 | /**
|
---|
| 71 | * The size of the structure.
|
---|
| 72 | */
|
---|
| 73 | uint32_t cbSize;
|
---|
| 74 |
|
---|
| 75 | /**
|
---|
| 76 | * The capabilities of the backend.
|
---|
| 77 | */
|
---|
| 78 | uint64_t uBackendCaps;
|
---|
| 79 |
|
---|
| 80 | /**
|
---|
[33524] | 81 | * Pointer to a NULL-terminated array, containing the supported
|
---|
[23266] | 82 | * file extensions. Note that some backends do not work on files, so this
|
---|
| 83 | * pointer may just contain NULL.
|
---|
| 84 | */
|
---|
[33524] | 85 | PCVDFILEEXTENSION paFileExtensions;
|
---|
[23266] | 86 |
|
---|
| 87 | /**
|
---|
| 88 | * Pointer to an array of structs describing each supported config key.
|
---|
| 89 | * Terminated by a NULL config key. Note that some backends do not support
|
---|
| 90 | * the configuration interface, so this pointer may just contain NULL.
|
---|
| 91 | * Mandatory if the backend sets VD_CAP_CONFIG.
|
---|
| 92 | */
|
---|
| 93 | PCVDCONFIGINFO paConfigInfo;
|
---|
| 94 |
|
---|
| 95 | /**
|
---|
| 96 | * Check if a file is valid for the backend.
|
---|
| 97 | *
|
---|
| 98 | * @returns VBox status code.
|
---|
| 99 | * @param pszFilename Name of the image file.
|
---|
| 100 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
[32536] | 101 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
[33524] | 102 | * @param penmType Returns the supported device type on success.
|
---|
[23266] | 103 | */
|
---|
[33524] | 104 | DECLR3CALLBACKMEMBER(int, pfnCheckIfValid, (const char *pszFilename, PVDINTERFACE pVDIfsDisk,
|
---|
| 105 | PVDINTERFACE pVDIfsImage, VDTYPE *penmType));
|
---|
[23266] | 106 |
|
---|
| 107 | /**
|
---|
| 108 | * Open a disk image.
|
---|
| 109 | *
|
---|
| 110 | * @returns VBox status code.
|
---|
| 111 | * @param pszFilename Name of the image file to open. Guaranteed to be available and
|
---|
| 112 | * unchanged during the lifetime of this image.
|
---|
| 113 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
| 114 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
| 115 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
[33524] | 116 | * @param enmType Requested type of the image.
|
---|
[32536] | 117 | * @param ppBackendData Opaque state data for this image.
|
---|
[23266] | 118 | */
|
---|
| 119 | DECLR3CALLBACKMEMBER(int, pfnOpen, (const char *pszFilename, unsigned uOpenFlags,
|
---|
| 120 | PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
|
---|
[33524] | 121 | VDTYPE enmType, void **ppBackendData));
|
---|
[23266] | 122 |
|
---|
| 123 | /**
|
---|
| 124 | * Create a disk image.
|
---|
| 125 | *
|
---|
| 126 | * @returns VBox status code.
|
---|
| 127 | * @param pszFilename Name of the image file to create. Guaranteed to be available and
|
---|
| 128 | * unchanged during the lifetime of this image.
|
---|
| 129 | * @param cbSize Image size in bytes.
|
---|
| 130 | * @param uImageFlags Flags specifying special image features.
|
---|
| 131 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
| 132 | * @param pPCHSGeometry Physical drive geometry CHS <= (16383,16,255).
|
---|
| 133 | * @param pLCHSGeometry Logical drive geometry CHS <= (1024,255,63).
|
---|
| 134 | * @param pUuid New UUID of the image. Not NULL.
|
---|
| 135 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
| 136 | * @param uPercentStart Starting value for progress percentage.
|
---|
| 137 | * @param uPercentSpan Span for varying progress percentage.
|
---|
| 138 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
| 139 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
| 140 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
[32536] | 141 | * @param ppBackendData Opaque state data for this image.
|
---|
[23266] | 142 | */
|
---|
| 143 | DECLR3CALLBACKMEMBER(int, pfnCreate, (const char *pszFilename, uint64_t cbSize,
|
---|
| 144 | unsigned uImageFlags, const char *pszComment,
|
---|
[32536] | 145 | PCVDGEOMETRY pPCHSGeometry,
|
---|
| 146 | PCVDGEOMETRY pLCHSGeometry,
|
---|
[23266] | 147 | PCRTUUID pUuid, unsigned uOpenFlags,
|
---|
| 148 | unsigned uPercentStart, unsigned uPercentSpan,
|
---|
| 149 | PVDINTERFACE pVDIfsDisk,
|
---|
| 150 | PVDINTERFACE pVDIfsImage,
|
---|
| 151 | PVDINTERFACE pVDIfsOperation,
|
---|
[32536] | 152 | void **ppBackendData));
|
---|
[23266] | 153 |
|
---|
| 154 | /**
|
---|
| 155 | * Rename a disk image. Only needs to work as long as the operating
|
---|
| 156 | * system's rename file functionality is usable. If an attempt is made to
|
---|
| 157 | * rename an image to a location on another disk/filesystem, this function
|
---|
| 158 | * may just fail with an appropriate error code (not changing the opened
|
---|
| 159 | * image data at all). Also works only on images which actually refer to
|
---|
[32536] | 160 | * regular files. May be NULL.
|
---|
[23266] | 161 | *
|
---|
| 162 | * @returns VBox status code.
|
---|
[32536] | 163 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 164 | * @param pszFilename New name of the image file. Guaranteed to be available and
|
---|
| 165 | * unchanged during the lifetime of this image.
|
---|
| 166 | */
|
---|
[32536] | 167 | DECLR3CALLBACKMEMBER(int, pfnRename, (void *pBackendData, const char *pszFilename));
|
---|
[23266] | 168 |
|
---|
| 169 | /**
|
---|
| 170 | * Close a disk image.
|
---|
| 171 | *
|
---|
| 172 | * @returns VBox status code.
|
---|
[32536] | 173 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 174 | * @param fDelete If true, delete the image from the host disk.
|
---|
| 175 | */
|
---|
[32536] | 176 | DECLR3CALLBACKMEMBER(int, pfnClose, (void *pBackendData, bool fDelete));
|
---|
[23266] | 177 |
|
---|
| 178 | /**
|
---|
[44253] | 179 | * Start a read request.
|
---|
[23266] | 180 | *
|
---|
| 181 | * @returns VBox status code.
|
---|
[32536] | 182 | * @param pBackendData Opaque state data for this image.
|
---|
[44253] | 183 | * @param uOffset The offset of the virtual disk to read from.
|
---|
| 184 | * @param cbRead How many bytes to read.
|
---|
| 185 | * @param pIoCtx I/O context associated with this request.
|
---|
[23266] | 186 | * @param pcbActuallyRead Pointer to returned number of bytes read.
|
---|
| 187 | */
|
---|
[44253] | 188 | DECLR3CALLBACKMEMBER(int, pfnRead, (void *pBackendData, uint64_t uOffset, size_t cbRead,
|
---|
| 189 | PVDIOCTX pIoCtx, size_t *pcbActuallyRead));
|
---|
[23266] | 190 |
|
---|
| 191 | /**
|
---|
[44253] | 192 | * Start a write request.
|
---|
[23266] | 193 | *
|
---|
| 194 | * @returns VBox status code.
|
---|
[32536] | 195 | * @param pBackendData Opaque state data for this image.
|
---|
[44253] | 196 | * @param uOffset The offset of the virtual disk to write to.
|
---|
| 197 | * @param cbWrite How many bytes to write.
|
---|
| 198 | * @param pIoCtx I/O context associated with this request.
|
---|
[23266] | 199 | * @param pcbWriteProcess Pointer to returned number of bytes that could
|
---|
| 200 | * be processed. In case the function returned
|
---|
| 201 | * VERR_VD_BLOCK_FREE this is the number of bytes
|
---|
| 202 | * that could be written in a full block write,
|
---|
| 203 | * when prefixed/postfixed by the appropriate
|
---|
| 204 | * amount of (previously read) padding data.
|
---|
| 205 | * @param pcbPreRead Pointer to the returned amount of data that must
|
---|
| 206 | * be prefixed to perform a full block write.
|
---|
| 207 | * @param pcbPostRead Pointer to the returned amount of data that must
|
---|
| 208 | * be postfixed to perform a full block write.
|
---|
| 209 | * @param fWrite Flags which affect write behavior. Combination
|
---|
| 210 | * of the VD_WRITE_* flags.
|
---|
| 211 | */
|
---|
[44253] | 212 | DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pBackendData, uint64_t uOffset, size_t cbWrite,
|
---|
| 213 | PVDIOCTX pIoCtx,
|
---|
[23266] | 214 | size_t *pcbWriteProcess, size_t *pcbPreRead,
|
---|
| 215 | size_t *pcbPostRead, unsigned fWrite));
|
---|
| 216 |
|
---|
| 217 | /**
|
---|
| 218 | * Flush data to disk.
|
---|
| 219 | *
|
---|
| 220 | * @returns VBox status code.
|
---|
[32536] | 221 | * @param pBackendData Opaque state data for this image.
|
---|
[44253] | 222 | * @param pIoCtx I/O context associated with this request.
|
---|
[23266] | 223 | */
|
---|
[44253] | 224 | DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pBackendData, PVDIOCTX pIoCtx));
|
---|
[23266] | 225 |
|
---|
| 226 | /**
|
---|
[44253] | 227 | * Discards the given amount of bytes decreasing the size of the image if possible
|
---|
| 228 | *
|
---|
| 229 | * @returns VBox status code.
|
---|
| 230 | * @retval VERR_VD_DISCARD_ALIGNMENT_NOT_MET if the range doesn't meet the required alignment
|
---|
| 231 | * for the discard.
|
---|
| 232 | * @param pBackendData Opaque state data for this image.
|
---|
| 233 | * @param pIoCtx I/O context associated with this request.
|
---|
| 234 | * @param uOffset The offset of the first byte to discard.
|
---|
| 235 | * @param cbDiscard How many bytes to discard.
|
---|
| 236 | * @param pcbPreAllocated Pointer to the returned amount of bytes that must
|
---|
| 237 | * be discarded before the range to perform a full
|
---|
| 238 | * block discard.
|
---|
| 239 | * @param pcbPostAllocated Pointer to the returned amount of bytes that must
|
---|
| 240 | * be discarded after the range to perform a full
|
---|
| 241 | * block discard.
|
---|
| 242 | * @param pcbActuallyDiscarded Pointer to the returned amount of bytes which
|
---|
| 243 | * could be actually discarded.
|
---|
| 244 | * @param ppbmAllocationBitmap Where to store the pointer to the allocation bitmap
|
---|
| 245 | * if VERR_VD_DISCARD_ALIGNMENT_NOT_MET is returned or NULL
|
---|
| 246 | * if the allocation bitmap should be returned.
|
---|
| 247 | * @param fDiscard Flags which affect discard behavior. Combination
|
---|
| 248 | * of the VD_DISCARD_* flags.
|
---|
| 249 | */
|
---|
| 250 | DECLR3CALLBACKMEMBER(int, pfnDiscard, (void *pBackendData, PVDIOCTX pIoCtx,
|
---|
| 251 | uint64_t uOffset, size_t cbDiscard,
|
---|
| 252 | size_t *pcbPreAllocated,
|
---|
| 253 | size_t *pcbPostAllocated,
|
---|
| 254 | size_t *pcbActuallyDiscarded,
|
---|
| 255 | void **ppbmAllocationBitmap,
|
---|
| 256 | unsigned fDiscard));
|
---|
| 257 |
|
---|
| 258 | /**
|
---|
[23266] | 259 | * Get the version of a disk image.
|
---|
| 260 | *
|
---|
| 261 | * @returns version of disk image.
|
---|
[32536] | 262 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 263 | */
|
---|
[32536] | 264 | DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pBackendData));
|
---|
[23266] | 265 |
|
---|
| 266 | /**
|
---|
[48743] | 267 | * Get the sector size of a disk image.
|
---|
| 268 | *
|
---|
| 269 | * @returns size of disk image in bytes.
|
---|
| 270 | * @param pBackendData Opaque state data for this image.
|
---|
| 271 | */
|
---|
| 272 | DECLR3CALLBACKMEMBER(uint32_t, pfnGetSectorSize, (void *pBackendData));
|
---|
| 273 |
|
---|
| 274 | /**
|
---|
[23266] | 275 | * Get the capacity of a disk image.
|
---|
| 276 | *
|
---|
| 277 | * @returns size of disk image in bytes.
|
---|
[32536] | 278 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 279 | */
|
---|
[32536] | 280 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pBackendData));
|
---|
[23266] | 281 |
|
---|
| 282 | /**
|
---|
| 283 | * Get the file size of a disk image.
|
---|
| 284 | *
|
---|
| 285 | * @returns size of disk image in bytes.
|
---|
[32536] | 286 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 287 | */
|
---|
[32536] | 288 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pBackendData));
|
---|
[23266] | 289 |
|
---|
| 290 | /**
|
---|
| 291 | * Get virtual disk PCHS geometry stored in a disk image.
|
---|
| 292 | *
|
---|
| 293 | * @returns VBox status code.
|
---|
| 294 | * @returns VERR_VD_GEOMETRY_NOT_SET if no geometry present in the image.
|
---|
[32536] | 295 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 296 | * @param pPCHSGeometry Where to store the geometry. Not NULL.
|
---|
| 297 | */
|
---|
[32536] | 298 | DECLR3CALLBACKMEMBER(int, pfnGetPCHSGeometry, (void *pBackendData, PVDGEOMETRY pPCHSGeometry));
|
---|
[23266] | 299 |
|
---|
| 300 | /**
|
---|
| 301 | * Set virtual disk PCHS geometry stored in a disk image.
|
---|
| 302 | * Only called if geometry is different than before.
|
---|
| 303 | *
|
---|
| 304 | * @returns VBox status code.
|
---|
[32536] | 305 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 306 | * @param pPCHSGeometry Where to load the geometry from. Not NULL.
|
---|
| 307 | */
|
---|
[32536] | 308 | DECLR3CALLBACKMEMBER(int, pfnSetPCHSGeometry, (void *pBackendData, PCVDGEOMETRY pPCHSGeometry));
|
---|
[23266] | 309 |
|
---|
| 310 | /**
|
---|
| 311 | * Get virtual disk LCHS geometry stored in a disk image.
|
---|
| 312 | *
|
---|
| 313 | * @returns VBox status code.
|
---|
| 314 | * @returns VERR_VD_GEOMETRY_NOT_SET if no geometry present in the image.
|
---|
[32536] | 315 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 316 | * @param pLCHSGeometry Where to store the geometry. Not NULL.
|
---|
| 317 | */
|
---|
[32536] | 318 | DECLR3CALLBACKMEMBER(int, pfnGetLCHSGeometry, (void *pBackendData, PVDGEOMETRY pLCHSGeometry));
|
---|
[23266] | 319 |
|
---|
| 320 | /**
|
---|
| 321 | * Set virtual disk LCHS geometry stored in a disk image.
|
---|
| 322 | * Only called if geometry is different than before.
|
---|
| 323 | *
|
---|
| 324 | * @returns VBox status code.
|
---|
[32536] | 325 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 326 | * @param pLCHSGeometry Where to load the geometry from. Not NULL.
|
---|
| 327 | */
|
---|
[32536] | 328 | DECLR3CALLBACKMEMBER(int, pfnSetLCHSGeometry, (void *pBackendData, PCVDGEOMETRY pLCHSGeometry));
|
---|
[23266] | 329 |
|
---|
| 330 | /**
|
---|
| 331 | * Get the image flags of a disk image.
|
---|
| 332 | *
|
---|
| 333 | * @returns image flags of disk image.
|
---|
[32536] | 334 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 335 | */
|
---|
[32536] | 336 | DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pBackendData));
|
---|
[23266] | 337 |
|
---|
| 338 | /**
|
---|
| 339 | * Get the open flags of a disk image.
|
---|
| 340 | *
|
---|
| 341 | * @returns open flags of disk image.
|
---|
[32536] | 342 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 343 | */
|
---|
[32536] | 344 | DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pBackendData));
|
---|
[23266] | 345 |
|
---|
| 346 | /**
|
---|
| 347 | * Set the open flags of a disk image. May cause the image to be locked
|
---|
| 348 | * in a different mode or be reopened (which can fail).
|
---|
| 349 | *
|
---|
| 350 | * @returns VBox status code.
|
---|
[32536] | 351 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 352 | * @param uOpenFlags New open flags for this image.
|
---|
| 353 | */
|
---|
[32536] | 354 | DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pBackendData, unsigned uOpenFlags));
|
---|
[23266] | 355 |
|
---|
| 356 | /**
|
---|
| 357 | * Get comment of a disk image.
|
---|
| 358 | *
|
---|
| 359 | * @returns VBox status code.
|
---|
[32536] | 360 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 361 | * @param pszComment Where to store the comment.
|
---|
| 362 | * @param cbComment Size of the comment buffer.
|
---|
| 363 | */
|
---|
[32536] | 364 | DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pBackendData, char *pszComment, size_t cbComment));
|
---|
[23266] | 365 |
|
---|
| 366 | /**
|
---|
| 367 | * Set comment of a disk image.
|
---|
| 368 | *
|
---|
| 369 | * @returns VBox status code.
|
---|
[32536] | 370 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 371 | * @param pszComment Where to get the comment from. NULL resets comment.
|
---|
| 372 | * The comment is silently truncated if the image format
|
---|
| 373 | * limit is exceeded.
|
---|
| 374 | */
|
---|
[32536] | 375 | DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pBackendData, const char *pszComment));
|
---|
[23266] | 376 |
|
---|
| 377 | /**
|
---|
| 378 | * Get UUID of a disk image.
|
---|
| 379 | *
|
---|
| 380 | * @returns VBox status code.
|
---|
[32536] | 381 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 382 | * @param pUuid Where to store the image UUID.
|
---|
| 383 | */
|
---|
[32536] | 384 | DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pBackendData, PRTUUID pUuid));
|
---|
[23266] | 385 |
|
---|
| 386 | /**
|
---|
| 387 | * Set UUID of a disk image.
|
---|
| 388 | *
|
---|
| 389 | * @returns VBox status code.
|
---|
[32536] | 390 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 391 | * @param pUuid Where to get the image UUID from.
|
---|
| 392 | */
|
---|
[32536] | 393 | DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pBackendData, PCRTUUID pUuid));
|
---|
[23266] | 394 |
|
---|
| 395 | /**
|
---|
| 396 | * Get last modification UUID of a disk image.
|
---|
| 397 | *
|
---|
| 398 | * @returns VBox status code.
|
---|
[32536] | 399 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 400 | * @param pUuid Where to store the image modification UUID.
|
---|
| 401 | */
|
---|
[32536] | 402 | DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pBackendData, PRTUUID pUuid));
|
---|
[23266] | 403 |
|
---|
| 404 | /**
|
---|
| 405 | * Set last modification UUID of a disk image.
|
---|
| 406 | *
|
---|
| 407 | * @returns VBox status code.
|
---|
[32536] | 408 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 409 | * @param pUuid Where to get the image modification UUID from.
|
---|
| 410 | */
|
---|
[32536] | 411 | DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pBackendData, PCRTUUID pUuid));
|
---|
[23266] | 412 |
|
---|
| 413 | /**
|
---|
| 414 | * Get parent UUID of a disk image.
|
---|
| 415 | *
|
---|
| 416 | * @returns VBox status code.
|
---|
[32536] | 417 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 418 | * @param pUuid Where to store the parent image UUID.
|
---|
| 419 | */
|
---|
[32536] | 420 | DECLR3CALLBACKMEMBER(int, pfnGetParentUuid, (void *pBackendData, PRTUUID pUuid));
|
---|
[23266] | 421 |
|
---|
| 422 | /**
|
---|
| 423 | * Set parent UUID of a disk image.
|
---|
| 424 | *
|
---|
| 425 | * @returns VBox status code.
|
---|
[32536] | 426 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 427 | * @param pUuid Where to get the parent image UUID from.
|
---|
| 428 | */
|
---|
[32536] | 429 | DECLR3CALLBACKMEMBER(int, pfnSetParentUuid, (void *pBackendData, PCRTUUID pUuid));
|
---|
[23266] | 430 |
|
---|
| 431 | /**
|
---|
| 432 | * Get parent modification UUID of a disk image.
|
---|
| 433 | *
|
---|
| 434 | * @returns VBox status code.
|
---|
[32536] | 435 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 436 | * @param pUuid Where to store the parent image modification UUID.
|
---|
| 437 | */
|
---|
[32536] | 438 | DECLR3CALLBACKMEMBER(int, pfnGetParentModificationUuid, (void *pBackendData, PRTUUID pUuid));
|
---|
[23266] | 439 |
|
---|
| 440 | /**
|
---|
| 441 | * Set parent modification UUID of a disk image.
|
---|
| 442 | *
|
---|
| 443 | * @returns VBox status code.
|
---|
[32536] | 444 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 445 | * @param pUuid Where to get the parent image modification UUID from.
|
---|
| 446 | */
|
---|
[32536] | 447 | DECLR3CALLBACKMEMBER(int, pfnSetParentModificationUuid, (void *pBackendData, PCRTUUID pUuid));
|
---|
[23266] | 448 |
|
---|
| 449 | /**
|
---|
| 450 | * Dump information about a disk image.
|
---|
| 451 | *
|
---|
[32536] | 452 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 453 | */
|
---|
[32536] | 454 | DECLR3CALLBACKMEMBER(void, pfnDump, (void *pBackendData));
|
---|
[23266] | 455 |
|
---|
| 456 | /**
|
---|
[32536] | 457 | * Get a time stamp of a disk image. May be NULL.
|
---|
[23266] | 458 | *
|
---|
| 459 | * @returns VBox status code.
|
---|
[32536] | 460 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 461 | * @param pTimeStamp Where to store the time stamp.
|
---|
| 462 | */
|
---|
[32536] | 463 | DECLR3CALLBACKMEMBER(int, pfnGetTimeStamp, (void *pBackendData, PRTTIMESPEC pTimeStamp));
|
---|
[23266] | 464 |
|
---|
| 465 | /**
|
---|
[32536] | 466 | * Get the parent time stamp of a disk image. May be NULL.
|
---|
[23266] | 467 | *
|
---|
| 468 | * @returns VBox status code.
|
---|
[32536] | 469 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 470 | * @param pTimeStamp Where to store the time stamp.
|
---|
| 471 | */
|
---|
[32536] | 472 | DECLR3CALLBACKMEMBER(int, pfnGetParentTimeStamp, (void *pBackendData, PRTTIMESPEC pTimeStamp));
|
---|
[23266] | 473 |
|
---|
| 474 | /**
|
---|
[32536] | 475 | * Set the parent time stamp of a disk image. May be NULL.
|
---|
[23266] | 476 | *
|
---|
| 477 | * @returns VBox status code.
|
---|
[32536] | 478 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 479 | * @param pTimeStamp Where to get the time stamp from.
|
---|
| 480 | */
|
---|
[32536] | 481 | DECLR3CALLBACKMEMBER(int, pfnSetParentTimeStamp, (void *pBackendData, PCRTTIMESPEC pTimeStamp));
|
---|
[23266] | 482 |
|
---|
| 483 | /**
|
---|
[32536] | 484 | * Get the relative path to parent image. May be NULL.
|
---|
[23266] | 485 | *
|
---|
| 486 | * @returns VBox status code.
|
---|
[32536] | 487 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 488 | * @param pszParentFilename Where to store the path.
|
---|
| 489 | */
|
---|
[32536] | 490 | DECLR3CALLBACKMEMBER(int, pfnGetParentFilename, (void *pBackendData, char **ppszParentFilename));
|
---|
[23266] | 491 |
|
---|
| 492 | /**
|
---|
[32536] | 493 | * Set the relative path to parent image. May be NULL.
|
---|
[23266] | 494 | *
|
---|
| 495 | * @returns VBox status code.
|
---|
[32536] | 496 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 497 | * @param pszParentFilename Where to get the path from.
|
---|
| 498 | */
|
---|
[32536] | 499 | DECLR3CALLBACKMEMBER(int, pfnSetParentFilename, (void *pBackendData, const char *pszParentFilename));
|
---|
[23266] | 500 |
|
---|
| 501 | /** Returns a human readable hard disk location string given a
|
---|
| 502 | * set of hard disk configuration keys. The returned string is an
|
---|
| 503 | * equivalent of the full file path for image-based hard disks.
|
---|
| 504 | * Mandatory for backends with no VD_CAP_FILE and NULL otherwise. */
|
---|
| 505 | DECLR3CALLBACKMEMBER(int, pfnComposeLocation, (PVDINTERFACE pConfig, char **pszLocation));
|
---|
| 506 |
|
---|
| 507 | /** Returns a human readable hard disk name string given a
|
---|
| 508 | * set of hard disk configuration keys. The returned string is an
|
---|
| 509 | * equivalent of the file name part in the full file path for
|
---|
| 510 | * image-based hard disks. Mandatory for backends with no
|
---|
| 511 | * VD_CAP_FILE and NULL otherwise. */
|
---|
| 512 | DECLR3CALLBACKMEMBER(int, pfnComposeName, (PVDINTERFACE pConfig, char **pszName));
|
---|
| 513 |
|
---|
| 514 | /**
|
---|
| 515 | * Compact the image. The pointer may be NULL, indicating that this
|
---|
| 516 | * isn't supported yet (for file-based images) or not necessary.
|
---|
| 517 | *
|
---|
| 518 | * @returns VBox status code.
|
---|
| 519 | * @returns VERR_NOT_SUPPORTED if this image cannot be compacted yet.
|
---|
[32536] | 520 | * @param pBackendData Opaque state data for this image.
|
---|
[23266] | 521 | * @param uPercentStart Starting value for progress percentage.
|
---|
| 522 | * @param uPercentSpan Span for varying progress percentage.
|
---|
[27232] | 523 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
| 524 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
[23266] | 525 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
| 526 | */
|
---|
[32536] | 527 | DECLR3CALLBACKMEMBER(int, pfnCompact, (void *pBackendData,
|
---|
[23266] | 528 | unsigned uPercentStart, unsigned uPercentSpan,
|
---|
[27232] | 529 | PVDINTERFACE pVDIfsDisk,
|
---|
| 530 | PVDINTERFACE pVDIfsImage,
|
---|
[23266] | 531 | PVDINTERFACE pVDIfsOperation));
|
---|
| 532 |
|
---|
[31776] | 533 | /**
|
---|
| 534 | * Resize the image. The pointer may be NULL, indicating that this
|
---|
| 535 | * isn't supported yet (for file-based images) or not necessary.
|
---|
| 536 | *
|
---|
| 537 | * @returns VBox status code.
|
---|
[38621] | 538 | * @returns VERR_NOT_SUPPORTED if this image cannot be resized yet.
|
---|
[32536] | 539 | * @param pBackendData Opaque state data for this image.
|
---|
[31776] | 540 | * @param cbSize New size of the image.
|
---|
| 541 | * @param pPCHSGeometry Pointer to the new physical disk geometry <= (16383,16,63). Not NULL.
|
---|
| 542 | * @param pLCHSGeometry Pointer to the new logical disk geometry <= (x,255,63). Not NULL.
|
---|
| 543 | * @param uPercentStart Starting value for progress percentage.
|
---|
| 544 | * @param uPercentSpan Span for varying progress percentage.
|
---|
| 545 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
| 546 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
| 547 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
| 548 | */
|
---|
[32536] | 549 | DECLR3CALLBACKMEMBER(int, pfnResize, (void *pBackendData,
|
---|
[31776] | 550 | uint64_t cbSize,
|
---|
[32536] | 551 | PCVDGEOMETRY pPCHSGeometry,
|
---|
| 552 | PCVDGEOMETRY pLCHSGeometry,
|
---|
[31776] | 553 | unsigned uPercentStart, unsigned uPercentSpan,
|
---|
| 554 | PVDINTERFACE pVDIfsDisk,
|
---|
| 555 | PVDINTERFACE pVDIfsImage,
|
---|
| 556 | PVDINTERFACE pVDIfsOperation));
|
---|
| 557 |
|
---|
[38621] | 558 | /**
|
---|
[39519] | 559 | * Try to repair the given image.
|
---|
| 560 | *
|
---|
| 561 | * @returns VBox status code.
|
---|
| 562 | * @param pszFilename Name of the image file.
|
---|
| 563 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
| 564 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
| 565 | * @param fFlags Combination of the VD_REPAIR_* flags.
|
---|
| 566 | */
|
---|
| 567 | DECLR3CALLBACKMEMBER(int, pfnRepair, (const char *pszFilename, PVDINTERFACE pVDIfsDisk,
|
---|
| 568 | PVDINTERFACE pVDIfsImage, uint32_t fFlags));
|
---|
| 569 |
|
---|
[50988] | 570 | /**
|
---|
| 571 | * Traverse all metadata of the opened image.
|
---|
| 572 | *
|
---|
| 573 | * @returns VBox status code.
|
---|
| 574 | * @param pBackendData Opaque state data for this image.
|
---|
| 575 | * @param fFlags Traverse flags, combination of VD_TRAVERSE_METDATA_* defines.
|
---|
| 576 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
| 577 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
| 578 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
| 579 | */
|
---|
| 580 | DECLR3CALLBACKMEMBER(int, pfnTraverseMetadata, (void *pBackendData, uint32_t fFlags,
|
---|
| 581 | PVDINTERFACE pVDIfsDisk,
|
---|
| 582 | PVDINTERFACE pVDIfsImage,
|
---|
| 583 | PVDINTERFACE pVDIfsOperation));
|
---|
| 584 |
|
---|
[23266] | 585 | } VBOXHDDBACKEND;
|
---|
| 586 |
|
---|
| 587 | /** Pointer to VD backend. */
|
---|
| 588 | typedef VBOXHDDBACKEND *PVBOXHDDBACKEND;
|
---|
| 589 | /** Constant pointer to VD backend. */
|
---|
| 590 | typedef const VBOXHDDBACKEND *PCVBOXHDDBACKEND;
|
---|
| 591 |
|
---|
| 592 | /** @copydoc VBOXHDDBACKEND::pfnComposeLocation */
|
---|
| 593 | DECLINLINE(int) genericFileComposeLocation(PVDINTERFACE pConfig, char **pszLocation)
|
---|
| 594 | {
|
---|
| 595 | *pszLocation = NULL;
|
---|
| 596 | return VINF_SUCCESS;
|
---|
| 597 | }
|
---|
| 598 | /** @copydoc VBOXHDDBACKEND::pfnComposeName */
|
---|
| 599 | DECLINLINE(int) genericFileComposeName(PVDINTERFACE pConfig, char **pszName)
|
---|
| 600 | {
|
---|
| 601 | *pszName = NULL;
|
---|
| 602 | return VINF_SUCCESS;
|
---|
| 603 | }
|
---|
| 604 |
|
---|
| 605 | #endif
|
---|