VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/VBoxHDD-newInternal.h@ 11118

Last change on this file since 11118 was 10715, checked in by vboxsync, 16 years ago

Merge async I/O for VMDK backend from private branch

  • Property svn:eol-style set to native
File size: 19.1 KB
Line 
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_newInternal_h__
22
23
24#include <VBox/pdm.h>
25#include <VBox/VBoxHDD-new.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 */
41typedef 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 * Check if a file is valid for the backend.
60 *
61 * @returns VBox status code.
62 * @param pszFilename Name of the image file.
63 */
64 DECLR3CALLBACKMEMBER(int, pfnCheckIfValid, (const char *pszFilename));
65
66 /**
67 * Open a disk image.
68 *
69 * @returns VBox status code.
70 * @param pszFilename Name of the image file to open. Guaranteed to be available and
71 * unchanged during the lifetime of this image.
72 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
73 * @param pInterfaces Pointer to the first element of supported interfaces of the caller.
74 * @param ppvBackendData Opaque state data for this image.
75 */
76 DECLR3CALLBACKMEMBER(int, pfnOpen, (const char *pszFilename, unsigned uOpenFlags,
77 PVDINTERFACE pInterfaces, void **ppvBackendData));
78
79 /**
80 * Create a disk image.
81 *
82 * @returns VBox status code.
83 * @param pszFilename Name of the image file to create. Guaranteed to be available and
84 * unchanged during the lifetime of this image.
85 * @param enmType Image type. Both base and diff image types are valid.
86 * @param cbSize Image size in bytes.
87 * @param uImageFlags Flags specifying special image features.
88 * @param pszComment Pointer to image comment. NULL is ok.
89 * @param pPCHSGeometry Physical drive geometry CHS <= (16383,16,255).
90 * @param pLCHSGeometry Logical drive geometry CHS <= (1024,255,63).
91 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
92 * @param pfnProgress Progress callback. Optional. NULL if not to be used.
93 * @param pvUser User argument for the progress callback.
94 * @param uPercentStart Starting value for progress percentage.
95 * @param uPercentSpan Span for varying progress percentage.
96 * @param pInterfaces Pointer to the supported interfaces of the caller.
97 * @param ppvBackendData Opaque state data for this image.
98 */
99 DECLR3CALLBACKMEMBER(int, pfnCreate, (const char *pszFilename, VDIMAGETYPE enmType, uint64_t cbSize, unsigned uImageFlags, const char *pszComment, PCPDMMEDIAGEOMETRY pPCHSGeometry, PCPDMMEDIAGEOMETRY pLCHSGeometry, unsigned uOpenFlags, PFNVMPROGRESS pfnProgress, void *pvUser, unsigned uPercentStart, unsigned uPercentSpan, PVDINTERFACE pInterfaces, void **ppvBackendData));
100
101 /**
102 * Rename a disk image. Only needs to work as long as the operating
103 * system's rename file functionality is usable. If an attempt is made to
104 * rename an image to a location on another disk/filesystem, this function
105 * may just fail with an appropriate error code (not changing the opened
106 * image data at all). Also works only on images which actually refer to
107 * files (and not for raw disk images).
108 *
109 * @returns VBox status code.
110 * @param pvBackendData Opaque state data for this image.
111 * @param pszFilename New name of the image file. Guaranteed to be available and
112 * unchanged during the lifetime of this image.
113 */
114 DECLR3CALLBACKMEMBER(int, pfnRename, (void *pvBackendData, const char *pszFilename));
115
116 /**
117 * Close a disk image.
118 *
119 * @returns VBox status code.
120 * @param pvBackendData Opaque state data for this image.
121 * @param fDelete If true, delete the image from the host disk.
122 */
123 DECLR3CALLBACKMEMBER(int, pfnClose, (void *pvBackendData, bool fDelete));
124
125 /**
126 * Read data from a disk image. The area read never crosses a block
127 * boundary.
128 *
129 * @returns VBox status code.
130 * @returns VINF_VDI_BLOCK_FREE if this image contains no data for this block.
131 * @returns VINF_VDI_BLOCK_ZERO if this image contains a zero data block.
132 * @param pvBackendData Opaque state data for this image.
133 * @param off Offset to start reading from.
134 * @param pvBuf Where to store the read bits.
135 * @param cbRead Number of bytes to read.
136 * @param pcbActuallyRead Pointer to returned number of bytes read.
137 */
138 DECLR3CALLBACKMEMBER(int, pfnRead, (void *pvBackendData, uint64_t off, void *pvBuf, size_t cbRead, size_t *pcbActuallyRead));
139
140 /**
141 * Write data to a disk image. The area written never crosses a block
142 * boundary.
143 *
144 * @returns VBox status code.
145 * @returns VINF_VDI_BLOCK_FREE if this image contains no data for this block and
146 * this is not a full-block write. The write must be repeated with
147 * the correct amount of prefix/postfix data read from the images below
148 * in the image stack. This might not be the most convenient interface,
149 * but it works with arbitrary block sizes, especially when the image
150 * stack uses different block sizes.
151 * @param pvBackendData Opaque state data for this image.
152 * @param off Offset to start writing to.
153 * @param pvBuf Where to retrieve the written bits.
154 * @param cbWrite Number of bytes to write.
155 * @param pcbWriteProcess Pointer to returned number of bytes that could
156 * be processed. In case the function returned
157 * VINF_VDI_BLOCK_FREE this is the number of bytes
158 * that could be written in a full block write,
159 * when prefixed/postfixed by the appropriate
160 * amount of (previously read) padding data.
161 * @param pcbPreRead Pointer to the returned amount of data that must
162 * be prefixed to perform a full block write.
163 * @param pcbPostRead Pointer to the returned amount of data that must
164 * be postfixed to perform a full block write.
165 * @param fWrite Flags which affect write behavior. Combination
166 * of the VD_WRITE_* flags.
167 */
168 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pvBackendData, uint64_t off, const void *pvBuf, size_t cbWrite, size_t *pcbWriteProcess, size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite));
169
170 /**
171 * Flush data to disk.
172 *
173 * @returns VBox status code.
174 * @param pvBackendData Opaque state data for this image.
175 */
176 DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pvBackendData));
177
178 /**
179 * Get the version of a disk image.
180 *
181 * @returns version of disk image.
182 * @param pvBackendData Opaque state data for this image.
183 */
184 DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pvBackendData));
185
186 /**
187 * Get the type information for a disk image.
188 *
189 * @returns VBox status code.
190 * @param pvBackendData Opaque state data for this image.
191 * @param penmType Image type of this image.
192 */
193 DECLR3CALLBACKMEMBER(int, pfnGetImageType, (void *pvBackendData, PVDIMAGETYPE penmType));
194
195 /**
196 * Get the capacity of a disk image.
197 *
198 * @returns size of disk image in bytes.
199 * @param pvBackendData Opaque state data for this image.
200 */
201 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pvBackendData));
202
203 /**
204 * Get the file size of a disk image.
205 *
206 * @returns size of disk image in bytes.
207 * @param pvBackendData Opaque state data for this image.
208 */
209 DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pvBackendData));
210
211 /**
212 * Get virtual disk PCHS geometry stored in a disk image.
213 *
214 * @returns VBox status code.
215 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the image.
216 * @param pvBackendData Opaque state data for this image.
217 * @param pPCHSGeometry Where to store the geometry. Not NULL.
218 */
219 DECLR3CALLBACKMEMBER(int, pfnGetPCHSGeometry, (void *pvBackendData, PPDMMEDIAGEOMETRY pPCHSGeometry));
220
221 /**
222 * Set virtual disk PCHS geometry stored in a disk image.
223 * Only called if geometry is different than before.
224 *
225 * @returns VBox status code.
226 * @param pvBackendData Opaque state data for this image.
227 * @param pPCHSGeometry Where to load the geometry from. Not NULL.
228 */
229 DECLR3CALLBACKMEMBER(int, pfnSetPCHSGeometry, (void *pvBackendData, PCPDMMEDIAGEOMETRY pPCHSGeometry));
230
231 /**
232 * Get virtual disk LCHS geometry stored in a disk image.
233 *
234 * @returns VBox status code.
235 * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the image.
236 * @param pvBackendData Opaque state data for this image.
237 * @param pLCHSGeometry Where to store the geometry. Not NULL.
238 */
239 DECLR3CALLBACKMEMBER(int, pfnGetLCHSGeometry, (void *pvBackendData, PPDMMEDIAGEOMETRY pLCHSGeometry));
240
241 /**
242 * Set virtual disk LCHS geometry stored in a disk image.
243 * Only called if geometry is different than before.
244 *
245 * @returns VBox status code.
246 * @param pvBackendData Opaque state data for this image.
247 * @param pLCHSGeometry Where to load the geometry from. Not NULL.
248 */
249 DECLR3CALLBACKMEMBER(int, pfnSetLCHSGeometry, (void *pvBackendData, PCPDMMEDIAGEOMETRY pLCHSGeometry));
250
251 /**
252 * Get the image flags of a disk image.
253 *
254 * @returns image flags of disk image.
255 * @param pvBackendData Opaque state data for this image.
256 */
257 DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pvBackendData));
258
259 /**
260 * Get the open flags of a disk image.
261 *
262 * @returns open flags of disk image.
263 * @param pvBackendData Opaque state data for this image.
264 */
265 DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pvBackendData));
266
267 /**
268 * Set the open flags of a disk image. May cause the image to be locked
269 * in a different mode or be reopened (which can fail).
270 *
271 * @returns VBox status code.
272 * @param pvBackendData Opaque state data for this image.
273 * @param uOpenFlags New open flags for this image.
274 */
275 DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pvBackendData, unsigned uOpenFlags));
276
277 /**
278 * Get comment of a disk image.
279 *
280 * @returns VBox status code.
281 * @param pvBackendData Opaque state data for this image.
282 * @param pszComment Where to store the comment.
283 * @param cbComment Size of the comment buffer.
284 */
285 DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pvBackendData, char *pszComment, size_t cbComment));
286
287 /**
288 * Set comment of a disk image.
289 *
290 * @returns VBox status code.
291 * @param pvBackendData Opaque state data for this image.
292 * @param pszComment Where to get the comment from. NULL resets comment.
293 * The comment is silently truncated if the image format
294 * limit is exceeded.
295 */
296 DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pvBackendData, const char *pszComment));
297
298 /**
299 * Get UUID of a disk image.
300 *
301 * @returns VBox status code.
302 * @param pvBackendData Opaque state data for this image.
303 * @param pUuid Where to store the image UUID.
304 */
305 DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pvBackendData, PRTUUID pUuid));
306
307 /**
308 * Set UUID of a disk image.
309 *
310 * @returns VBox status code.
311 * @param pvBackendData Opaque state data for this image.
312 * @param pUuid Where to get the image UUID from.
313 */
314 DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pvBackendData, PCRTUUID pUuid));
315
316 /**
317 * Get last modification UUID of a disk image.
318 *
319 * @returns VBox status code.
320 * @param pvBackendData Opaque state data for this image.
321 * @param pUuid Where to store the image modification UUID.
322 */
323 DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pvBackendData, PRTUUID pUuid));
324
325 /**
326 * Set last modification UUID of a disk image.
327 *
328 * @returns VBox status code.
329 * @param pvBackendData Opaque state data for this image.
330 * @param pUuid Where to get the image modification UUID from.
331 */
332 DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pvBackendData, PCRTUUID pUuid));
333
334 /**
335 * Get parent UUID of a disk image.
336 *
337 * @returns VBox status code.
338 * @param pvBackendData Opaque state data for this image.
339 * @param pUuid Where to store the parent image UUID.
340 */
341 DECLR3CALLBACKMEMBER(int, pfnGetParentUuid, (void *pvBackendData, PRTUUID pUuid));
342
343 /**
344 * Set parent UUID of a disk image.
345 *
346 * @returns VBox status code.
347 * @param pvBackendData Opaque state data for this image.
348 * @param pUuid Where to get the parent image UUID from.
349 */
350 DECLR3CALLBACKMEMBER(int, pfnSetParentUuid, (void *pvBackendData, PCRTUUID pUuid));
351
352 /**
353 * Get parent modification UUID of a disk image.
354 *
355 * @returns VBox status code.
356 * @param pvBackendData Opaque state data for this image.
357 * @param pUuid Where to store the parent image modification UUID.
358 */
359 DECLR3CALLBACKMEMBER(int, pfnGetParentModificationUuid, (void *pvBackendData, PRTUUID pUuid));
360
361 /**
362 * Set parent modification UUID of a disk image.
363 *
364 * @returns VBox status code.
365 * @param pvBackendData Opaque state data for this image.
366 * @param pUuid Where to get the parent image modification UUID from.
367 */
368 DECLR3CALLBACKMEMBER(int, pfnSetParentModificationUuid, (void *pvBackendData, PCRTUUID pUuid));
369
370 /**
371 * Dump information about a disk image.
372 *
373 * @param pvBackendData Opaque state data for this image.
374 */
375 DECLR3CALLBACKMEMBER(void, pfnDump, (void *pvBackendData));
376
377 /**
378 * Get a time stamp of a disk image.
379 *
380 * @returns VBox status code.
381 * @param pvBackendData Opaque state data for this image.
382 * @param pTimeStamp Where to store the time stamp.
383 */
384 DECLR3CALLBACKMEMBER(int, pfnGetTimeStamp, (void *pvBackendData, PRTTIMESPEC pTimeStamp));
385
386 /**
387 * Get the parent time stamp of a disk image.
388 *
389 * @returns VBox status code.
390 * @param pvBackendData Opaque state data for this image.
391 * @param pTimeStamp Where to store the time stamp.
392 */
393 DECLR3CALLBACKMEMBER(int, pfnGetParentTimeStamp, (void *pvBackendData, PRTTIMESPEC pTimeStamp));
394
395 /**
396 * Set the parent time stamp of a disk image.
397 *
398 * @returns VBox status code.
399 * @param pvBackendData Opaque state data for this image.
400 * @param pTimeStamp Where to get the time stamp from.
401 */
402 DECLR3CALLBACKMEMBER(int, pfnSetParentTimeStamp, (void *pvBackendData, PCRTTIMESPEC pTimeStamp));
403
404 /**
405 * Get the relative path to parent image.
406 *
407 * @returns VBox status code.
408 * @param pvBackendData Opaque state data for this image.
409 * @param pszParentFilename Where to store the path.
410 */
411 DECLR3CALLBACKMEMBER(int, pfnGetParentFilename, (void *pvBackendData, char **ppszParentFilename));
412
413 /**
414 * Set the relative path to parent image.
415 *
416 * @returns VBox status code.
417 * @param pvBackendData Opaque state data for this image.
418 * @param pszParentFilename Where to get the path from.
419 */
420 DECLR3CALLBACKMEMBER(int, pfnSetParentFilename, (void *pvBackendData, const char *pszParentFilename));
421
422 /**
423 * Return whether asynchronous I/O operations are supported for this image.
424 *
425 * @returns true if asynchronous I/O is supported
426 * false otherwise.
427 * @param pvBackendData Opaque state data for this image.
428 */
429 DECLR3CALLBACKMEMBER(bool, pfnIsAsyncIOSupported, (void *pvBackendData));
430
431 /**
432 * Start an asynchronous read request.
433 *
434 * @returns VBox status code.
435 * @param pvBackendData Opaque state data for this image.
436 * @param uOffset The offset of the virtual disk to read from.
437 * @param cbRead How many bytes to read.
438 * @param paSeg Pointer to the segment array.
439 * @param cSeg Number of segments.
440 * @param pvUser Opaque user data.
441 */
442 DECLR3CALLBACKMEMBER(int, pfnAsyncRead, (void *pvBackendData, uint64_t uOffset, size_t cbRead,
443 PPDMDATASEG paSeg, unsigned cSeg, void *pvUser));
444
445 /**
446 * Start an asynchronous write request.
447 *
448 * @returns VBox status code.
449 * @param pvBackendData Opaque state data for this image.
450 * @param uOffset The offset of the virtual disk to write to.
451 * @param cbWrite How many bytes to write.
452 * @param paSeg Pointer to the segment array.
453 * @param cSeg Number of segments.
454 * @param pvUser Oaque user data-
455 */
456 DECLR3CALLBACKMEMBER(int, pfnAsyncWrite, (void *pvBackendData, uint64_t uOffset, size_t cbWrite,
457 PPDMDATASEG paSeg, unsigned cSeg, void *pvUser));
458
459} VBOXHDDBACKEND;
460
461/** Pointer to VD backend. */
462typedef VBOXHDDBACKEND *PVBOXHDDBACKEND;
463
464/** Constant pointer to VD backend. */
465typedef const VBOXHDDBACKEND *PCVBOXHDDBACKEND;
466
467/** Initialization entry point. */
468typedef DECLCALLBACK(int) VBOXHDDFORMATLOAD(PVBOXHDDBACKEND *ppBackendTable);
469typedef VBOXHDDFORMATLOAD *PFNVBOXHDDFORMATLOAD;
470#define VBOX_HDDFORMAT_LOAD_NAME "VBoxHDDFormatLoad"
471
472/** The prefix to identify Storage Plugins. */
473#define VBOX_HDDFORMAT_PLUGIN_PREFIX "VBoxHDD"
474/** The size of the prefix excluding the '\0' terminator. */
475#define VBOX_HDDFORMAT_PLUGIN_PREFIX_LENGTH (sizeof(VBOX_HDDFORMAT_PLUGIN_PREFIX)-1)
476
477#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette