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