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