1 | /** @file
|
---|
2 | * Internal header file for VBox HDD Container.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
17 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
18 | * additional information or have any questions.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef __VBoxHDD_Internal_h__
|
---|
22 |
|
---|
23 |
|
---|
24 | #include <VBox/pdm.h>
|
---|
25 | #include <VBox/VBoxHDD.h>
|
---|
26 |
|
---|
27 |
|
---|
28 | /** @name VBox HDD backend write flags
|
---|
29 | * @{
|
---|
30 | */
|
---|
31 | /** Do not allocate a new block on this write. This is just an advisory
|
---|
32 | * flag. The backend may still decide in some circumstances that it wants
|
---|
33 | * to ignore this flag (which may cause extra dynamic image expansion). */
|
---|
34 | #define VD_WRITE_NO_ALLOC RT_BIT(1)
|
---|
35 | /** @}*/
|
---|
36 |
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Image format backend interface used by VBox HDD Container implementation.
|
---|
40 | */
|
---|
41 | typedef struct VBOXHDDBACKEND
|
---|
42 | {
|
---|
43 | /**
|
---|
44 | * The name of the backend (constant string).
|
---|
45 | */
|
---|
46 | const char *pszBackendName;
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * The size of the structure.
|
---|
50 | */
|
---|
51 | uint32_t cbSize;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * The capabilities of the backend.
|
---|
55 | */
|
---|
56 | uint64_t uBackendCaps;
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Pointer to a NULL-terminated array of strings, containing the supported
|
---|
60 | * file extensions. Note that some backends do not work on files, so this
|
---|
61 | * pointer may just contain NULL.
|
---|
62 | */
|
---|
63 | const char * const *papszFileExtensions;
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Pointer to an array of structs describing each supported config key.
|
---|
67 | * Terminated by a NULL config key. Note that some backends do not support
|
---|
68 | * the configuration interface, so this pointer may just contain NULL.
|
---|
69 | * Mandatory if the backend sets VD_CAP_CONFIG.
|
---|
70 | */
|
---|
71 | PCVDCONFIGINFO paConfigInfo;
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Handle of loaded plugin library, NIL_RTLDRMOD for static backends.
|
---|
75 | */
|
---|
76 | RTLDRMOD hPlugin;
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Check if a file is valid for the backend.
|
---|
80 | *
|
---|
81 | * @returns VBox status code.
|
---|
82 | * @param pszFilename Name of the image file.
|
---|
83 | */
|
---|
84 | DECLR3CALLBACKMEMBER(int, pfnCheckIfValid, (const char *pszFilename));
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Open a disk image.
|
---|
88 | *
|
---|
89 | * @returns VBox status code.
|
---|
90 | * @param pszFilename Name of the image file to open. Guaranteed to be available and
|
---|
91 | * unchanged during the lifetime of this image.
|
---|
92 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
93 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
94 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
95 | * @param ppvBackendData Opaque state data for this image.
|
---|
96 | */
|
---|
97 | DECLR3CALLBACKMEMBER(int, pfnOpen, (const char *pszFilename, unsigned uOpenFlags,
|
---|
98 | PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
|
---|
99 | void **ppvBackendData));
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * Create a disk image.
|
---|
103 | *
|
---|
104 | * @returns VBox status code.
|
---|
105 | * @param pszFilename Name of the image file to create. Guaranteed to be available and
|
---|
106 | * unchanged during the lifetime of this image.
|
---|
107 | * @param cbSize Image size in bytes.
|
---|
108 | * @param uImageFlags Flags specifying special image features.
|
---|
109 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
110 | * @param pPCHSGeometry Physical drive geometry CHS <= (16383,16,255).
|
---|
111 | * @param pLCHSGeometry Logical drive geometry CHS <= (1024,255,63).
|
---|
112 | * @param pUuid New UUID of the image. Not NULL.
|
---|
113 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
114 | * @param uPercentStart Starting value for progress percentage.
|
---|
115 | * @param uPercentSpan Span for varying progress percentage.
|
---|
116 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
117 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
118 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
119 | * @param ppvBackendData Opaque state data for this image.
|
---|
120 | */
|
---|
121 | DECLR3CALLBACKMEMBER(int, pfnCreate, (const char *pszFilename, uint64_t cbSize,
|
---|
122 | unsigned uImageFlags, const char *pszComment,
|
---|
123 | PCPDMMEDIAGEOMETRY pPCHSGeometry,
|
---|
124 | PCPDMMEDIAGEOMETRY pLCHSGeometry,
|
---|
125 | PCRTUUID pUuid, unsigned uOpenFlags,
|
---|
126 | unsigned uPercentStart, unsigned uPercentSpan,
|
---|
127 | PVDINTERFACE pVDIfsDisk,
|
---|
128 | PVDINTERFACE pVDIfsImage,
|
---|
129 | PVDINTERFACE pVDIfsOperation,
|
---|
130 | void **ppvBackendData));
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * Rename a disk image. Only needs to work as long as the operating
|
---|
134 | * system's rename file functionality is usable. If an attempt is made to
|
---|
135 | * rename an image to a location on another disk/filesystem, this function
|
---|
136 | * may just fail with an appropriate error code (not changing the opened
|
---|
137 | * image data at all). Also works only on images which actually refer to
|
---|
138 | * files (and not for raw disk images).
|
---|
139 | *
|
---|
140 | * @returns VBox status code.
|
---|
141 | * @param pvBackendData Opaque state data for this image.
|
---|
142 | * @param pszFilename New name of the image file. Guaranteed to be available and
|
---|
143 | * unchanged during the lifetime of this image.
|
---|
144 | */
|
---|
145 | DECLR3CALLBACKMEMBER(int, pfnRename, (void *pvBackendData, const char *pszFilename));
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * Close a disk image.
|
---|
149 | *
|
---|
150 | * @returns VBox status code.
|
---|
151 | * @param pvBackendData Opaque state data for this image.
|
---|
152 | * @param fDelete If true, delete the image from the host disk.
|
---|
153 | */
|
---|
154 | DECLR3CALLBACKMEMBER(int, pfnClose, (void *pvBackendData, bool fDelete));
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Read data from a disk image. The area read never crosses a block
|
---|
158 | * boundary.
|
---|
159 | *
|
---|
160 | * @returns VBox status code.
|
---|
161 | * @returns VERR_VD_BLOCK_FREE if this image contains no data for this block.
|
---|
162 | * @param pvBackendData Opaque state data for this image.
|
---|
163 | * @param uOffset Offset to start reading from.
|
---|
164 | * @param pvBuf Where to store the read bits.
|
---|
165 | * @param cbRead Number of bytes to read.
|
---|
166 | * @param pcbActuallyRead Pointer to returned number of bytes read.
|
---|
167 | */
|
---|
168 | DECLR3CALLBACKMEMBER(int, pfnRead, (void *pvBackendData, uint64_t uOffset, void *pvBuf,
|
---|
169 | size_t cbRead, size_t *pcbActuallyRead));
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Write data to a disk image. The area written never crosses a block
|
---|
173 | * boundary.
|
---|
174 | *
|
---|
175 | * @returns VBox status code.
|
---|
176 | * @returns VERR_VD_BLOCK_FREE if this image contains no data for this block and
|
---|
177 | * this is not a full-block write. The write must be repeated with
|
---|
178 | * the correct amount of prefix/postfix data read from the images below
|
---|
179 | * in the image stack. This might not be the most convenient interface,
|
---|
180 | * but it works with arbitrary block sizes, especially when the image
|
---|
181 | * stack uses different block sizes.
|
---|
182 | * @param pvBackendData Opaque state data for this image.
|
---|
183 | * @param uOffset Offset to start writing to.
|
---|
184 | * @param pvBuf Where to retrieve the written bits.
|
---|
185 | * @param cbWrite Number of bytes to write.
|
---|
186 | * @param pcbWriteProcess Pointer to returned number of bytes that could
|
---|
187 | * be processed. In case the function returned
|
---|
188 | * VERR_VD_BLOCK_FREE this is the number of bytes
|
---|
189 | * that could be written in a full block write,
|
---|
190 | * when prefixed/postfixed by the appropriate
|
---|
191 | * amount of (previously read) padding data.
|
---|
192 | * @param pcbPreRead Pointer to the returned amount of data that must
|
---|
193 | * be prefixed to perform a full block write.
|
---|
194 | * @param pcbPostRead Pointer to the returned amount of data that must
|
---|
195 | * be postfixed to perform a full block write.
|
---|
196 | * @param fWrite Flags which affect write behavior. Combination
|
---|
197 | * of the VD_WRITE_* flags.
|
---|
198 | */
|
---|
199 | DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pvBackendData, uint64_t uOffset,
|
---|
200 | const void *pvBuf, size_t cbWrite,
|
---|
201 | size_t *pcbWriteProcess, size_t *pcbPreRead,
|
---|
202 | size_t *pcbPostRead, unsigned fWrite));
|
---|
203 |
|
---|
204 | /**
|
---|
205 | * Flush data to disk.
|
---|
206 | *
|
---|
207 | * @returns VBox status code.
|
---|
208 | * @param pvBackendData Opaque state data for this image.
|
---|
209 | */
|
---|
210 | DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pvBackendData));
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * Get the version of a disk image.
|
---|
214 | *
|
---|
215 | * @returns version of disk image.
|
---|
216 | * @param pvBackendData Opaque state data for this image.
|
---|
217 | */
|
---|
218 | DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pvBackendData));
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * Get the capacity of a disk image.
|
---|
222 | *
|
---|
223 | * @returns size of disk image in bytes.
|
---|
224 | * @param pvBackendData Opaque state data for this image.
|
---|
225 | */
|
---|
226 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pvBackendData));
|
---|
227 |
|
---|
228 | /**
|
---|
229 | * Get the file size of a disk image.
|
---|
230 | *
|
---|
231 | * @returns size of disk image in bytes.
|
---|
232 | * @param pvBackendData Opaque state data for this image.
|
---|
233 | */
|
---|
234 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pvBackendData));
|
---|
235 |
|
---|
236 | /**
|
---|
237 | * Get virtual disk PCHS geometry stored in a disk image.
|
---|
238 | *
|
---|
239 | * @returns VBox status code.
|
---|
240 | * @returns VERR_VD_GEOMETRY_NOT_SET if no geometry present in the image.
|
---|
241 | * @param pvBackendData Opaque state data for this image.
|
---|
242 | * @param pPCHSGeometry Where to store the geometry. Not NULL.
|
---|
243 | */
|
---|
244 | DECLR3CALLBACKMEMBER(int, pfnGetPCHSGeometry, (void *pvBackendData, PPDMMEDIAGEOMETRY pPCHSGeometry));
|
---|
245 |
|
---|
246 | /**
|
---|
247 | * Set virtual disk PCHS geometry stored in a disk image.
|
---|
248 | * Only called if geometry is different than before.
|
---|
249 | *
|
---|
250 | * @returns VBox status code.
|
---|
251 | * @param pvBackendData Opaque state data for this image.
|
---|
252 | * @param pPCHSGeometry Where to load the geometry from. Not NULL.
|
---|
253 | */
|
---|
254 | DECLR3CALLBACKMEMBER(int, pfnSetPCHSGeometry, (void *pvBackendData, PCPDMMEDIAGEOMETRY pPCHSGeometry));
|
---|
255 |
|
---|
256 | /**
|
---|
257 | * Get virtual disk LCHS geometry stored in a disk image.
|
---|
258 | *
|
---|
259 | * @returns VBox status code.
|
---|
260 | * @returns VERR_VD_GEOMETRY_NOT_SET if no geometry present in the image.
|
---|
261 | * @param pvBackendData Opaque state data for this image.
|
---|
262 | * @param pLCHSGeometry Where to store the geometry. Not NULL.
|
---|
263 | */
|
---|
264 | DECLR3CALLBACKMEMBER(int, pfnGetLCHSGeometry, (void *pvBackendData, PPDMMEDIAGEOMETRY pLCHSGeometry));
|
---|
265 |
|
---|
266 | /**
|
---|
267 | * Set virtual disk LCHS geometry stored in a disk image.
|
---|
268 | * Only called if geometry is different than before.
|
---|
269 | *
|
---|
270 | * @returns VBox status code.
|
---|
271 | * @param pvBackendData Opaque state data for this image.
|
---|
272 | * @param pLCHSGeometry Where to load the geometry from. Not NULL.
|
---|
273 | */
|
---|
274 | DECLR3CALLBACKMEMBER(int, pfnSetLCHSGeometry, (void *pvBackendData, PCPDMMEDIAGEOMETRY pLCHSGeometry));
|
---|
275 |
|
---|
276 | /**
|
---|
277 | * Get the image flags of a disk image.
|
---|
278 | *
|
---|
279 | * @returns image flags of disk image.
|
---|
280 | * @param pvBackendData Opaque state data for this image.
|
---|
281 | */
|
---|
282 | DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pvBackendData));
|
---|
283 |
|
---|
284 | /**
|
---|
285 | * Get the open flags of a disk image.
|
---|
286 | *
|
---|
287 | * @returns open flags of disk image.
|
---|
288 | * @param pvBackendData Opaque state data for this image.
|
---|
289 | */
|
---|
290 | DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pvBackendData));
|
---|
291 |
|
---|
292 | /**
|
---|
293 | * Set the open flags of a disk image. May cause the image to be locked
|
---|
294 | * in a different mode or be reopened (which can fail).
|
---|
295 | *
|
---|
296 | * @returns VBox status code.
|
---|
297 | * @param pvBackendData Opaque state data for this image.
|
---|
298 | * @param uOpenFlags New open flags for this image.
|
---|
299 | */
|
---|
300 | DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pvBackendData, unsigned uOpenFlags));
|
---|
301 |
|
---|
302 | /**
|
---|
303 | * Get comment of a disk image.
|
---|
304 | *
|
---|
305 | * @returns VBox status code.
|
---|
306 | * @param pvBackendData Opaque state data for this image.
|
---|
307 | * @param pszComment Where to store the comment.
|
---|
308 | * @param cbComment Size of the comment buffer.
|
---|
309 | */
|
---|
310 | DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pvBackendData, char *pszComment, size_t cbComment));
|
---|
311 |
|
---|
312 | /**
|
---|
313 | * Set comment of a disk image.
|
---|
314 | *
|
---|
315 | * @returns VBox status code.
|
---|
316 | * @param pvBackendData Opaque state data for this image.
|
---|
317 | * @param pszComment Where to get the comment from. NULL resets comment.
|
---|
318 | * The comment is silently truncated if the image format
|
---|
319 | * limit is exceeded.
|
---|
320 | */
|
---|
321 | DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pvBackendData, const char *pszComment));
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Get UUID of a disk image.
|
---|
325 | *
|
---|
326 | * @returns VBox status code.
|
---|
327 | * @param pvBackendData Opaque state data for this image.
|
---|
328 | * @param pUuid Where to store the image UUID.
|
---|
329 | */
|
---|
330 | DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pvBackendData, PRTUUID pUuid));
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * Set UUID of a disk image.
|
---|
334 | *
|
---|
335 | * @returns VBox status code.
|
---|
336 | * @param pvBackendData Opaque state data for this image.
|
---|
337 | * @param pUuid Where to get the image UUID from.
|
---|
338 | */
|
---|
339 | DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pvBackendData, PCRTUUID pUuid));
|
---|
340 |
|
---|
341 | /**
|
---|
342 | * Get last modification UUID of a disk image.
|
---|
343 | *
|
---|
344 | * @returns VBox status code.
|
---|
345 | * @param pvBackendData Opaque state data for this image.
|
---|
346 | * @param pUuid Where to store the image modification UUID.
|
---|
347 | */
|
---|
348 | DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pvBackendData, PRTUUID pUuid));
|
---|
349 |
|
---|
350 | /**
|
---|
351 | * Set last modification UUID of a disk image.
|
---|
352 | *
|
---|
353 | * @returns VBox status code.
|
---|
354 | * @param pvBackendData Opaque state data for this image.
|
---|
355 | * @param pUuid Where to get the image modification UUID from.
|
---|
356 | */
|
---|
357 | DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pvBackendData, PCRTUUID pUuid));
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Get parent UUID of a disk image.
|
---|
361 | *
|
---|
362 | * @returns VBox status code.
|
---|
363 | * @param pvBackendData Opaque state data for this image.
|
---|
364 | * @param pUuid Where to store the parent image UUID.
|
---|
365 | */
|
---|
366 | DECLR3CALLBACKMEMBER(int, pfnGetParentUuid, (void *pvBackendData, PRTUUID pUuid));
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Set parent UUID of a disk image.
|
---|
370 | *
|
---|
371 | * @returns VBox status code.
|
---|
372 | * @param pvBackendData Opaque state data for this image.
|
---|
373 | * @param pUuid Where to get the parent image UUID from.
|
---|
374 | */
|
---|
375 | DECLR3CALLBACKMEMBER(int, pfnSetParentUuid, (void *pvBackendData, PCRTUUID pUuid));
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * Get parent modification UUID of a disk image.
|
---|
379 | *
|
---|
380 | * @returns VBox status code.
|
---|
381 | * @param pvBackendData Opaque state data for this image.
|
---|
382 | * @param pUuid Where to store the parent image modification UUID.
|
---|
383 | */
|
---|
384 | DECLR3CALLBACKMEMBER(int, pfnGetParentModificationUuid, (void *pvBackendData, PRTUUID pUuid));
|
---|
385 |
|
---|
386 | /**
|
---|
387 | * Set parent modification UUID of a disk image.
|
---|
388 | *
|
---|
389 | * @returns VBox status code.
|
---|
390 | * @param pvBackendData Opaque state data for this image.
|
---|
391 | * @param pUuid Where to get the parent image modification UUID from.
|
---|
392 | */
|
---|
393 | DECLR3CALLBACKMEMBER(int, pfnSetParentModificationUuid, (void *pvBackendData, PCRTUUID pUuid));
|
---|
394 |
|
---|
395 | /**
|
---|
396 | * Dump information about a disk image.
|
---|
397 | *
|
---|
398 | * @param pvBackendData Opaque state data for this image.
|
---|
399 | */
|
---|
400 | DECLR3CALLBACKMEMBER(void, pfnDump, (void *pvBackendData));
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Get a time stamp of a disk image.
|
---|
404 | *
|
---|
405 | * @returns VBox status code.
|
---|
406 | * @param pvBackendData Opaque state data for this image.
|
---|
407 | * @param pTimeStamp Where to store the time stamp.
|
---|
408 | */
|
---|
409 | DECLR3CALLBACKMEMBER(int, pfnGetTimeStamp, (void *pvBackendData, PRTTIMESPEC pTimeStamp));
|
---|
410 |
|
---|
411 | /**
|
---|
412 | * Get the parent time stamp of a disk image.
|
---|
413 | *
|
---|
414 | * @returns VBox status code.
|
---|
415 | * @param pvBackendData Opaque state data for this image.
|
---|
416 | * @param pTimeStamp Where to store the time stamp.
|
---|
417 | */
|
---|
418 | DECLR3CALLBACKMEMBER(int, pfnGetParentTimeStamp, (void *pvBackendData, PRTTIMESPEC pTimeStamp));
|
---|
419 |
|
---|
420 | /**
|
---|
421 | * Set the parent time stamp of a disk image.
|
---|
422 | *
|
---|
423 | * @returns VBox status code.
|
---|
424 | * @param pvBackendData Opaque state data for this image.
|
---|
425 | * @param pTimeStamp Where to get the time stamp from.
|
---|
426 | */
|
---|
427 | DECLR3CALLBACKMEMBER(int, pfnSetParentTimeStamp, (void *pvBackendData, PCRTTIMESPEC pTimeStamp));
|
---|
428 |
|
---|
429 | /**
|
---|
430 | * Get the relative path to parent image.
|
---|
431 | *
|
---|
432 | * @returns VBox status code.
|
---|
433 | * @param pvBackendData Opaque state data for this image.
|
---|
434 | * @param pszParentFilename Where to store the path.
|
---|
435 | */
|
---|
436 | DECLR3CALLBACKMEMBER(int, pfnGetParentFilename, (void *pvBackendData, char **ppszParentFilename));
|
---|
437 |
|
---|
438 | /**
|
---|
439 | * Set the relative path to parent image.
|
---|
440 | *
|
---|
441 | * @returns VBox status code.
|
---|
442 | * @param pvBackendData Opaque state data for this image.
|
---|
443 | * @param pszParentFilename Where to get the path from.
|
---|
444 | */
|
---|
445 | DECLR3CALLBACKMEMBER(int, pfnSetParentFilename, (void *pvBackendData, const char *pszParentFilename));
|
---|
446 |
|
---|
447 | /**
|
---|
448 | * Return whether asynchronous I/O operations are supported for this image.
|
---|
449 | *
|
---|
450 | * @returns true if asynchronous I/O is supported
|
---|
451 | * false otherwise.
|
---|
452 | * @param pvBackendData Opaque state data for this image.
|
---|
453 | */
|
---|
454 | DECLR3CALLBACKMEMBER(bool, pfnIsAsyncIOSupported, (void *pvBackendData));
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Start an asynchronous read request.
|
---|
458 | *
|
---|
459 | * @returns VBox status code.
|
---|
460 | * @param pvBackendData Opaque state data for this image.
|
---|
461 | * @param uOffset The offset of the virtual disk to read from.
|
---|
462 | * @param cbRead How many bytes to read.
|
---|
463 | * @param paSeg Pointer to the segment array.
|
---|
464 | * @param cSeg Number of segments.
|
---|
465 | * @param pvUser Opaque user data.
|
---|
466 | */
|
---|
467 | DECLR3CALLBACKMEMBER(int, pfnAsyncRead, (void *pvBackendData, uint64_t uOffset, size_t cbRead,
|
---|
468 | PPDMDATASEG paSeg, unsigned cSeg, void *pvUser));
|
---|
469 |
|
---|
470 | /**
|
---|
471 | * Start an asynchronous write request.
|
---|
472 | *
|
---|
473 | * @returns VBox status code.
|
---|
474 | * @param pvBackendData Opaque state data for this image.
|
---|
475 | * @param uOffset The offset of the virtual disk to write to.
|
---|
476 | * @param cbWrite How many bytes to write.
|
---|
477 | * @param paSeg Pointer to the segment array.
|
---|
478 | * @param cSeg Number of segments.
|
---|
479 | * @param pvUser Oaque user data-
|
---|
480 | */
|
---|
481 | DECLR3CALLBACKMEMBER(int, pfnAsyncWrite, (void *pvBackendData, uint64_t uOffset, size_t cbWrite,
|
---|
482 | PPDMDATASEG paSeg, unsigned cSeg, void *pvUser));
|
---|
483 |
|
---|
484 | /** Returns a human readable hard disk location string given a
|
---|
485 | * set of hard disk configuration keys. The returned string is an
|
---|
486 | * equivalent of the full file path for image-based hard disks.
|
---|
487 | * Mandatory for backends with no VD_CAP_FILE and NULL otherwise. */
|
---|
488 | DECLR3CALLBACKMEMBER(int, pfnComposeLocation, (PVDINTERFACE pConfig, char **pszLocation));
|
---|
489 |
|
---|
490 | /** Returns a human readable hard disk name string given a
|
---|
491 | * set of hard disk configuration keys. The returned string is an
|
---|
492 | * equivalent of the file name part in the full file path for
|
---|
493 | * image-based hard disks. Mandatory for backends with no
|
---|
494 | * VD_CAP_FILE and NULL otherwise. */
|
---|
495 | DECLR3CALLBACKMEMBER(int, pfnComposeName, (PVDINTERFACE pConfig, char **pszName));
|
---|
496 |
|
---|
497 | /**
|
---|
498 | * Compact the image. The pointer may be NULL, indicating that this
|
---|
499 | * isn't supported yet (for file-based images) or not necessary.
|
---|
500 | *
|
---|
501 | * @returns VBox status code.
|
---|
502 | * @returns VERR_NOT_SUPPORTED if this image cannot be compacted yet.
|
---|
503 | * @param pvBackendData Opaque state data for this image.
|
---|
504 | * @param uPercentStart Starting value for progress percentage.
|
---|
505 | * @param uPercentSpan Span for varying progress percentage.
|
---|
506 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
507 | */
|
---|
508 | DECLR3CALLBACKMEMBER(int, pfnCompact, (void *pvBackendData,
|
---|
509 | unsigned uPercentStart, unsigned uPercentSpan,
|
---|
510 | PVDINTERFACE pVDIfsOperation));
|
---|
511 |
|
---|
512 | } VBOXHDDBACKEND;
|
---|
513 |
|
---|
514 | /** Pointer to VD backend. */
|
---|
515 | typedef VBOXHDDBACKEND *PVBOXHDDBACKEND;
|
---|
516 |
|
---|
517 | /** Constant pointer to VD backend. */
|
---|
518 | typedef const VBOXHDDBACKEND *PCVBOXHDDBACKEND;
|
---|
519 |
|
---|
520 | /** @copydoc VBOXHDDBACKEND::pfnComposeLocation */
|
---|
521 | DECLINLINE(int) genericFileComposeLocation(PVDINTERFACE pConfig, char **pszLocation)
|
---|
522 | {
|
---|
523 | *pszLocation = NULL;
|
---|
524 | return VINF_SUCCESS;
|
---|
525 | }
|
---|
526 | /** @copydoc VBOXHDDBACKEND::pfnComposeName */
|
---|
527 | DECLINLINE(int) genericFileComposeName(PVDINTERFACE pConfig, char **pszName)
|
---|
528 | {
|
---|
529 | *pszName = NULL;
|
---|
530 | return VINF_SUCCESS;
|
---|
531 | }
|
---|
532 |
|
---|
533 | /** Initialization entry point. */
|
---|
534 | typedef DECLCALLBACK(int) VBOXHDDFORMATLOAD(PVBOXHDDBACKEND *ppBackendTable);
|
---|
535 | typedef VBOXHDDFORMATLOAD *PFNVBOXHDDFORMATLOAD;
|
---|
536 | #define VBOX_HDDFORMAT_LOAD_NAME "VBoxHDDFormatLoad"
|
---|
537 |
|
---|
538 | /** The prefix to identify Storage Plugins. */
|
---|
539 | #define VBOX_HDDFORMAT_PLUGIN_PREFIX "VBoxHDD"
|
---|
540 | /** The size of the prefix excluding the '\0' terminator. */
|
---|
541 | #define VBOX_HDDFORMAT_PLUGIN_PREFIX_LENGTH (sizeof(VBOX_HDDFORMAT_PLUGIN_PREFIX)-1)
|
---|
542 |
|
---|
543 | #endif
|
---|