VirtualBox

source: vbox/trunk/include/VBox/VBoxHDD.h@ 22151

Last change on this file since 22151 was 21806, checked in by vboxsync, 16 years ago

Storage/VBoxHDD: resurrect the facility to dump information about disk images, and bare minimum fix for creating diff images.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 69.0 KB
Line 
1/** @file
2 * VBox HDD Container API.
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 * 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_VD_h
31#define ___VBox_VD_h
32
33#include <iprt/assert.h>
34#include <iprt/string.h>
35#include <iprt/mem.h>
36#include <VBox/cdefs.h>
37#include <VBox/types.h>
38#include <VBox/err.h>
39#include <VBox/pdmifs.h>
40/** @todo remove this dependency, using PFNVMPROGRESS outside VMM is *WRONG*. */
41#include <VBox/vmapi.h>
42
43RT_C_DECLS_BEGIN
44
45#ifdef IN_RING0
46# error "There are no VBox HDD Container APIs available in Ring-0 Host Context!"
47#endif
48
49/** @defgroup grp_vd VBox HDD Container
50 * @{
51 */
52
53/** Current VMDK image version. */
54#define VMDK_IMAGE_VERSION (0x0001)
55
56/** Current VDI image major version. */
57#define VDI_IMAGE_VERSION_MAJOR (0x0001)
58/** Current VDI image minor version. */
59#define VDI_IMAGE_VERSION_MINOR (0x0001)
60/** Current VDI image version. */
61#define VDI_IMAGE_VERSION ((VDI_IMAGE_VERSION_MAJOR << 16) | VDI_IMAGE_VERSION_MINOR)
62
63/** Get VDI major version from combined version. */
64#define VDI_GET_VERSION_MAJOR(uVer) ((uVer) >> 16)
65/** Get VDI minor version from combined version. */
66#define VDI_GET_VERSION_MINOR(uVer) ((uVer) & 0xffff)
67
68/** Placeholder for specifying the last opened image. */
69#define VD_LAST_IMAGE 0xffffffffU
70
71/** @name VBox HDD container image flags
72 * @{
73 */
74/** No flags. */
75#define VD_IMAGE_FLAGS_NONE (0)
76/** Fixed image. */
77#define VD_IMAGE_FLAGS_FIXED (0x10000)
78/** Diff image. Mutually exclusive with fixed image. */
79#define VD_IMAGE_FLAGS_DIFF (0x20000)
80/** VMDK: Split image into 2GB extents. */
81#define VD_VMDK_IMAGE_FLAGS_SPLIT_2G (0x0001)
82/** VMDK: Raw disk image (giving access to a number of host partitions). */
83#define VD_VMDK_IMAGE_FLAGS_RAWDISK (0x0002)
84/** VMDK: stream optimized image, read only. */
85#define VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED (0x0004)
86/** VMDK: ESX variant, use in addition to other flags. */
87#define VD_VMDK_IMAGE_FLAGS_ESX (0x0008)
88/** VDI: Fill new blocks with zeroes while expanding image file. Only valid
89 * for newly created images, never set for opened existing images. */
90#define VD_VDI_IMAGE_FLAGS_ZERO_EXPAND (0x0100)
91
92/** Mask of valid image flags for VMDK. */
93#define VD_VMDK_IMAGE_FLAGS_MASK ( VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF | VD_IMAGE_FLAGS_NONE \
94 | VD_VMDK_IMAGE_FLAGS_SPLIT_2G | VD_VMDK_IMAGE_FLAGS_RAWDISK \
95 | VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED | VD_VMDK_IMAGE_FLAGS_ESX)
96
97/** Mask of valid image flags for VDI. */
98#define VD_VDI_IMAGE_FLAGS_MASK (VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF | VD_IMAGE_FLAGS_NONE | VD_VDI_IMAGE_FLAGS_ZERO_EXPAND)
99
100/** Mask of all valid image flags for all formats. */
101#define VD_IMAGE_FLAGS_MASK (VD_VMDK_IMAGE_FLAGS_MASK | VD_VDI_IMAGE_FLAGS_MASK)
102
103/** Default image flags. */
104#define VD_IMAGE_FLAGS_DEFAULT (VD_IMAGE_FLAGS_NONE)
105/** @} */
106
107
108/**
109 * Auxiliary type for describing partitions on raw disks.
110 */
111typedef struct VBOXHDDRAWPART
112{
113 /** Device to use for this partition. Can be the disk device if the offset
114 * field is set appropriately. If this is NULL, then this partition will
115 * not be accessible to the guest. The size of the partition must still
116 * be set correctly. */
117 const char *pszRawDevice;
118 /** Offset where the partition data starts in this device. */
119 uint64_t uPartitionStartOffset;
120 /** Offset where the partition data starts in the disk. */
121 uint64_t uPartitionStart;
122 /** Size of the partition. */
123 uint64_t cbPartition;
124 /** Size of the partitioning info to prepend. */
125 uint64_t cbPartitionData;
126 /** Offset where the partitioning info starts in the disk. */
127 uint64_t uPartitionDataStart;
128 /** Pointer to the partitioning info to prepend. */
129 const void *pvPartitionData;
130} VBOXHDDRAWPART, *PVBOXHDDRAWPART;
131
132/**
133 * Auxiliary data structure for creating raw disks.
134 */
135typedef struct VBOXHDDRAW
136{
137 /** Signature for structure. Must be 'R', 'A', 'W', '\0'. Actually a trick
138 * to make logging of the comment string produce sensible results. */
139 char szSignature[4];
140 /** Flag whether access to full disk should be given (ignoring the
141 * partition information below). */
142 bool fRawDisk;
143 /** Filename for the raw disk. Ignored for partitioned raw disks.
144 * For Linux e.g. /dev/sda, and for Windows e.g. \\.\PhysicalDisk0. */
145 const char *pszRawDisk;
146 /** Number of entries in the partitions array. */
147 unsigned cPartitions;
148 /** Pointer to the partitions array. */
149 PVBOXHDDRAWPART pPartitions;
150} VBOXHDDRAW, *PVBOXHDDRAW;
151
152/** @name VBox HDD container image open mode flags
153 * @{
154 */
155/** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
156#define VD_OPEN_FLAGS_NORMAL 0
157/** Open image in read-only mode with sharing access with others. */
158#define VD_OPEN_FLAGS_READONLY RT_BIT(0)
159/** Honor zero block writes instead of ignoring them whenever possible.
160 * This is not supported by all formats. It is silently ignored in this case. */
161#define VD_OPEN_FLAGS_HONOR_ZEROES RT_BIT(1)
162/** Honor writes of the same data instead of ignoring whenever possible.
163 * This is handled generically, and is only meaningful for differential image
164 * formats. It is silently ignored otherwise. */
165#define VD_OPEN_FLAGS_HONOR_SAME RT_BIT(2)
166/** Do not perform the base/diff image check on open. This does NOT imply
167 * opening the image as readonly (would break e.g. adding UUIDs to VMDK files
168 * created by other products). Images opened with this flag should only be
169 * used for querying information, and nothing else. */
170#define VD_OPEN_FLAGS_INFO RT_BIT(3)
171/** Open image for asynchronous access.
172 * Only available if VD_CAP_ASYNC_IO is set
173 * Check with VDIsAsynchonousIoSupported wether
174 * asynchronous I/O is really supported for this file.
175 */
176#define VD_OPEN_FLAGS_ASYNC_IO RT_BIT(4)
177/** Mask of valid flags. */
178#define VD_OPEN_FLAGS_MASK (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES | VD_OPEN_FLAGS_HONOR_SAME | VD_OPEN_FLAGS_INFO | VD_OPEN_FLAGS_ASYNC_IO)
179/** @}*/
180
181
182/** @name VBox HDD container backend capability flags
183 * @{
184 */
185/** Supports UUIDs as expected by VirtualBox code. */
186#define VD_CAP_UUID RT_BIT(0)
187/** Supports creating fixed size images, allocating all space instantly. */
188#define VD_CAP_CREATE_FIXED RT_BIT(1)
189/** Supports creating dynamically growing images, allocating space on demand. */
190#define VD_CAP_CREATE_DYNAMIC RT_BIT(2)
191/** Supports creating images split in chunks of a bit less than 2GBytes. */
192#define VD_CAP_CREATE_SPLIT_2G RT_BIT(3)
193/** Supports being used as differencing image format backend. */
194#define VD_CAP_DIFF RT_BIT(4)
195/** Supports asynchronous I/O operations for at least some configurations. */
196#define VD_CAP_ASYNC RT_BIT(5)
197/** The backend operates on files. The caller needs to know to handle the
198 * location appropriately. */
199#define VD_CAP_FILE RT_BIT(6)
200/** The backend uses the config interface. The caller needs to know how to
201 * provide the mandatory configuration parts this way. */
202#define VD_CAP_CONFIG RT_BIT(7)
203/** The backend uses the network stack interface. The caller has to provide
204 * the appropriate interface. */
205#define VD_CAP_TCPNET RT_BIT(8)
206/** @}*/
207
208/**
209 * Supported interface types.
210 */
211typedef enum VDINTERFACETYPE
212{
213 /** First valid interface. */
214 VDINTERFACETYPE_FIRST = 0,
215 /** Interface to pass error message to upper layers. Per-disk. */
216 VDINTERFACETYPE_ERROR = VDINTERFACETYPE_FIRST,
217 /** Interface for asynchronous I/O operations. Per-disk. */
218 VDINTERFACETYPE_ASYNCIO,
219 /** Interface for progress notification. Per-operation. */
220 VDINTERFACETYPE_PROGRESS,
221 /** Interface for configuration information. Per-image. */
222 VDINTERFACETYPE_CONFIG,
223 /** Interface for TCP network stack. Per-disk. */
224 VDINTERFACETYPE_TCPNET,
225 /** Interface for getting parent image state. Per-operation. */
226 VDINTERFACETYPE_PARENTSTATE,
227 /** invalid interface. */
228 VDINTERFACETYPE_INVALID
229} VDINTERFACETYPE;
230
231/**
232 * Common structure for all interfaces.
233 */
234typedef struct VDINTERFACE
235{
236 /** Human readable interface name. */
237 const char *pszInterfaceName;
238 /** The size of the struct. */
239 uint32_t cbSize;
240 /** Pointer to the next common interface structure. */
241 struct VDINTERFACE *pNext;
242 /** Interface type. */
243 VDINTERFACETYPE enmInterface;
244 /** Opaque user data which is passed on every call. */
245 void *pvUser;
246 /** Pointer to the function call table of the interface.
247 * As this is opaque this must be casted to the right interface
248 * struct defined below based on the interface type in enmInterface. */
249 void *pCallbacks;
250} VDINTERFACE;
251/** Pointer to a VDINTERFACE. */
252typedef VDINTERFACE *PVDINTERFACE;
253/** Pointer to a const VDINTERFACE. */
254typedef const VDINTERFACE *PCVDINTERFACE;
255
256/**
257 * Helper functions to handle interface lists.
258 *
259 * @note These interface lists are used consistently to pass per-disk,
260 * per-image and/or per-operation callbacks. Those three purposes are strictly
261 * separate. See the individual interface declarations for what context they
262 * apply to. The caller is responsible for ensuring that the lifetime of the
263 * interface descriptors is appropriate for the category of interface.
264 */
265
266/**
267 * Get a specific interface from a list of interfaces specified by the type.
268 *
269 * @return Pointer to the matching interface or NULL if none was found.
270 * @param pVDIfs Pointer to the VD interface list.
271 * @param enmInterface Interface to search for.
272 */
273DECLINLINE(PVDINTERFACE) VDInterfaceGet(PVDINTERFACE pVDIfs, VDINTERFACETYPE enmInterface)
274{
275 AssertMsgReturn( (enmInterface >= VDINTERFACETYPE_FIRST)
276 && (enmInterface < VDINTERFACETYPE_INVALID),
277 ("enmInterface=%u", enmInterface), NULL);
278
279 while (pVDIfs)
280 {
281 /* Sanity checks. */
282 AssertMsgBreak(pVDIfs->cbSize == sizeof(VDINTERFACE),
283 ("cbSize=%u\n", pVDIfs->cbSize));
284
285 if (pVDIfs->enmInterface == enmInterface)
286 return pVDIfs;
287 pVDIfs = pVDIfs->pNext;
288 }
289
290 /* No matching interface was found. */
291 return NULL;
292}
293
294/**
295 * Add an interface to a list of interfaces.
296 *
297 * @return VBox status code.
298 * @param pInterface Pointer to an unitialized common interface structure.
299 * @param pszName Name of the interface.
300 * @param enmInterface Type of the interface.
301 * @param pCallbacks The callback table of the interface.
302 * @param pvUser Opaque user data passed on every function call.
303 * @param ppVDIfs Pointer to the VD interface list.
304 */
305DECLINLINE(int) VDInterfaceAdd(PVDINTERFACE pInterface, const char *pszName,
306 VDINTERFACETYPE enmInterface, void *pCallbacks,
307 void *pvUser, PVDINTERFACE *ppVDIfs)
308{
309
310 /** Argument checks. */
311 AssertMsgReturn( (enmInterface >= VDINTERFACETYPE_FIRST)
312 && (enmInterface < VDINTERFACETYPE_INVALID),
313 ("enmInterface=%u", enmInterface), VERR_INVALID_PARAMETER);
314
315 AssertMsgReturn(VALID_PTR(pCallbacks),
316 ("pCallbacks=%#p", pCallbacks),
317 VERR_INVALID_PARAMETER);
318
319 AssertMsgReturn(VALID_PTR(ppVDIfs),
320 ("pInterfaceList=%#p", ppVDIfs),
321 VERR_INVALID_PARAMETER);
322
323 /* Fill out interface descriptor. */
324 pInterface->cbSize = sizeof(VDINTERFACE);
325 pInterface->pszInterfaceName = pszName;
326 pInterface->enmInterface = enmInterface;
327 pInterface->pCallbacks = pCallbacks;
328 pInterface->pvUser = pvUser;
329 pInterface->pNext = *ppVDIfs;
330
331 /* Remember the new start of the list. */
332 *ppVDIfs = pInterface;
333
334 return VINF_SUCCESS;
335}
336
337/**
338 * Interface to deliver error messages (and also informational messages)
339 * to upper layers.
340 *
341 * Per disk interface. Optional, but think twice if you want to miss the
342 * opportunity of reporting better human-readable error messages.
343 */
344typedef struct VDINTERFACEERROR
345{
346 /**
347 * Size of the error interface.
348 */
349 uint32_t cbSize;
350
351 /**
352 * Interface type.
353 */
354 VDINTERFACETYPE enmInterface;
355
356 /**
357 * Error message callback. Must be able to accept special IPRT format
358 * strings.
359 *
360 * @param pvUser The opaque data passed on container creation.
361 * @param rc The VBox error code.
362 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
363 * @param pszFormat Error message format string.
364 * @param va Error message arguments.
365 */
366 DECLR3CALLBACKMEMBER(void, pfnError, (void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
367
368 /**
369 * Informational message callback. May be NULL. Used e.g. in
370 * VDDumpImages(). Must be able to accept special IPRT format strings.
371 *
372 * @return VBox status code.
373 * @param pvUser The opaque data passed on container creation.
374 * @param pszFormat Error message format string.
375 * @param ... Error message arguments.
376 */
377 DECLR3CALLBACKMEMBER(int, pfnMessage, (void *pvUser, const char *pszFormat, ...));
378
379} VDINTERFACEERROR, *PVDINTERFACEERROR;
380
381/**
382 * Get error interface from opaque callback table.
383 *
384 * @return Pointer to the callback table.
385 * @param pInterface Pointer to the interface descriptor.
386 */
387DECLINLINE(PVDINTERFACEERROR) VDGetInterfaceError(PVDINTERFACE pInterface)
388{
389 /* Check that the interface descriptor is a error interface. */
390 AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_ERROR)
391 && (pInterface->cbSize == sizeof(VDINTERFACE)),
392 ("Not an error interface"), NULL);
393
394 PVDINTERFACEERROR pInterfaceError = (PVDINTERFACEERROR)pInterface->pCallbacks;
395
396 /* Do basic checks. */
397 AssertMsgReturn( (pInterfaceError->cbSize == sizeof(VDINTERFACEERROR))
398 && (pInterfaceError->enmInterface == VDINTERFACETYPE_ERROR),
399 ("A non error callback table attached to a error interface descriptor\n"), NULL);
400
401 return pInterfaceError;
402}
403
404/**
405 * Completion callback which is called by the interface owner
406 * to inform the backend that a task finished.
407 *
408 * @return VBox status code.
409 * @param pvUser Opaque user data which is passed on request submission.
410 * @param ppvCaller Where to store the opaque user data the caller of
411 * VDAsyncRead or VDAsyncWrite passed.
412 */
413typedef DECLCALLBACK(int) FNVDCOMPLETED(void *pvUser, void **ppvCaller);
414/** Pointer to FNVDCOMPLETED() */
415typedef FNVDCOMPLETED *PFNVDCOMPLETED;
416
417
418/**
419 * Support interface for asynchronous I/O
420 *
421 * Per-disk. Optional.
422 */
423typedef struct VDINTERFACEASYNCIO
424{
425 /**
426 * Size of the async interface.
427 */
428 uint32_t cbSize;
429
430 /**
431 * Interface type.
432 */
433 VDINTERFACETYPE enmInterface;
434
435 /**
436 * Open callback
437 *
438 * @return VBox status code.
439 * @param pvUser The opaque data passed on container creation.
440 * @param pszLocation Name of the location to open.
441 * @param fReadonly Whether to open the storage medium read only.
442 * @param pfnCompleted The callabck which is called whenever a task
443 * completed. The backend has to pass the user data
444 * of the request initiator (ie the one who calls
445 * VDAsyncRead or VDAsyncWrite) in pvCompletion
446 * if this is NULL.
447 * @param ppStorage Where to store the opaque storage handle.
448 */
449 DECLR3CALLBACKMEMBER(int, pfnOpen, (void *pvUser, const char *pszLocation, bool fReadonly,
450 PFNVDCOMPLETED pfnCompleted, void **ppStorage));
451
452 /**
453 * Close callback.
454 *
455 * @return VBox status code.
456 * @param pvUser The opaque data passed on container creation.
457 * @param pStorage The opaque storage handle to close.
458 */
459 DECLR3CALLBACKMEMBER(int, pfnClose, (void *pvUser, void *pStorage));
460
461 /**
462 * Returns the size of the opened storage backend.
463 *
464 * @return VBox status code.
465 * @param pvUser The opaque data passed on container creation.
466 * @param pStorage The opaque storage handle to close.
467 * @param pcbSize Where to store the size of the storage backend.
468 */
469 DECLR3CALLBACKMEMBER(int, pfnGetSize, (void *pvUser, void *pStorage, uint64_t *pcbSize));
470
471 /**
472 * Synchronous write callback.
473 *
474 * @return VBox status code.
475 * @param pvUser The opaque data passed on container creation.
476 * @param pStorage The storage handle to use.
477 * @param uOffset The offset to start from.
478 * @param cbWrite How many bytes to write.
479 * @param pvBuf Pointer to the bits need to be written.
480 * @param pcbWritten Where to store how many bytes where actually written.
481 */
482 DECLR3CALLBACKMEMBER(int, pfnWriteSync, (void *pvUser, void *pStorage, uint64_t uOffset,
483 size_t cbWrite, const void *pvBuf, size_t *pcbWritten));
484
485 /**
486 * Synchronous read callback.
487 *
488 * @return VBox status code.
489 * @param pvUser The opaque data passed on container creation.
490 * @param pStorage The storage handle to use.
491 * @param uOffset The offset to start from.
492 * @param cbRead How many bytes to read.
493 * @param pvBuf Where to store the read bits.
494 * @param pcbRead Where to store how many bytes where actually read.
495 */
496 DECLR3CALLBACKMEMBER(int, pfnReadSync, (void *pvUser, void *pStorage, uint64_t uOffset,
497 size_t cbRead, void *pvBuf, size_t *pcbRead));
498
499 /**
500 * Flush data to the storage backend.
501 *
502 * @return VBox statis code.
503 * @param pvUser The opaque data passed on container creation.
504 * @param pStorage The storage handle to flush.
505 */
506 DECLR3CALLBACKMEMBER(int, pfnFlushSync, (void *pvUser, void *pStorage));
507
508 /**
509 * Initiate a asynchronous read request.
510 *
511 * @return VBox status code.
512 * @param pvUser The opqaue user data passed on container creation.
513 * @param pStorage The storage handle.
514 * @param uOffset The offset to start reading from.
515 * @param paSegments Scatter gather list to store the data in.
516 * @param cSegments Number of segments in the list.
517 * @param cbRead How many bytes to read.
518 * @param pvCompletion The opaque user data which is returned upon completion.
519 * @param ppTask Where to store the opaque task handle.
520 */
521 DECLR3CALLBACKMEMBER(int, pfnReadAsync, (void *pvUser, void *pStorage, uint64_t uOffset,
522 PCPDMDATASEG paSegments, size_t cSegments,
523 size_t cbRead, void *pvCompletion,
524 void **ppTask));
525
526 /**
527 * Initiate a asynchronous write request.
528 *
529 * @return VBox status code.
530 * @param pvUser The opaque user data passed on conatiner creation.
531 * @param pStorage The storage handle.
532 * @param uOffset The offset to start writing to.
533 * @param paSegments Scatter gather list of the data to write
534 * @param cSegments Number of segments in the list.
535 * @param cbWrite How many bytes to write.
536 * @param pvCompletion The opaque user data which is returned upon completion.
537 * @param ppTask Where to store the opaque task handle.
538 */
539 DECLR3CALLBACKMEMBER(int, pfnWriteAsync, (void *pvUser, void *pStorage, uint64_t uOffset,
540 PCPDMDATASEG paSegments, size_t cSegments,
541 size_t cbWrite, void *pvCompletion,
542 void **ppTask));
543
544 /**
545 * Initiates a async flush request.
546 *
547 * @return VBox statis code.
548 * @param pvUser The opaque data passed on container creation.
549 * @param pStorage The storage handle to flush.
550 * @param pvCompletion The opaque user data which is returned upon completion.
551 * @param ppTask Where to store the opaque task handle.
552 */
553 DECLR3CALLBACKMEMBER(int, pfnFlushAsync, (void *pvUser, void *pStorage,
554 void *pvCompletion, void **ppTask));
555
556} VDINTERFACEASYNCIO, *PVDINTERFACEASYNCIO;
557
558/**
559 * Get async I/O interface from opaque callback table.
560 *
561 * @return Pointer to the callback table.
562 * @param pInterface Pointer to the interface descriptor.
563 */
564DECLINLINE(PVDINTERFACEASYNCIO) VDGetInterfaceAsyncIO(PVDINTERFACE pInterface)
565{
566 /* Check that the interface descriptor is a async I/O interface. */
567 AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_ASYNCIO)
568 && (pInterface->cbSize == sizeof(VDINTERFACE)),
569 ("Not an async I/O interface"), NULL);
570
571 PVDINTERFACEASYNCIO pInterfaceAsyncIO = (PVDINTERFACEASYNCIO)pInterface->pCallbacks;
572
573 /* Do basic checks. */
574 AssertMsgReturn( (pInterfaceAsyncIO->cbSize == sizeof(VDINTERFACEASYNCIO))
575 && (pInterfaceAsyncIO->enmInterface == VDINTERFACETYPE_ASYNCIO),
576 ("A non async I/O callback table attached to a async I/O interface descriptor\n"), NULL);
577
578 return pInterfaceAsyncIO;
579}
580
581/**
582 * Progress notification interface
583 *
584 * Per-operation. Optional.
585 */
586typedef struct VDINTERFACEPROGRESS
587{
588 /**
589 * Size of the progress interface.
590 */
591 uint32_t cbSize;
592
593 /**
594 * Interface type.
595 */
596 VDINTERFACETYPE enmInterface;
597
598 /**
599 * Progress notification callbacks.
600 * @todo r=bird: Why the heck are we using PFNVMPROGRESS here?
601 */
602 PFNVMPROGRESS pfnProgress;
603} VDINTERFACEPROGRESS, *PVDINTERFACEPROGRESS;
604
605/**
606 * Get progress interface from opaque callback table.
607 *
608 * @return Pointer to the callback table.
609 * @param pInterface Pointer to the interface descriptor.
610 */
611DECLINLINE(PVDINTERFACEPROGRESS) VDGetInterfaceProgress(PVDINTERFACE pInterface)
612{
613 /* Check that the interface descriptor is a progress interface. */
614 AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_PROGRESS)
615 && (pInterface->cbSize == sizeof(VDINTERFACE)),
616 ("Not a progress interface"), NULL);
617
618
619 PVDINTERFACEPROGRESS pInterfaceProgress = (PVDINTERFACEPROGRESS)pInterface->pCallbacks;
620
621 /* Do basic checks. */
622 AssertMsgReturn( (pInterfaceProgress->cbSize == sizeof(VDINTERFACEPROGRESS))
623 && (pInterfaceProgress->enmInterface == VDINTERFACETYPE_PROGRESS),
624 ("A non progress callback table attached to a progress interface descriptor\n"), NULL);
625
626 return pInterfaceProgress;
627}
628
629
630/**
631 * Configuration information interface
632 *
633 * Per-image. Optional for most backends, but mandatory for images which do
634 * not operate on files (including standard block or character devices).
635 */
636typedef struct VDINTERFACECONFIG
637{
638 /**
639 * Size of the configuration interface.
640 */
641 uint32_t cbSize;
642
643 /**
644 * Interface type.
645 */
646 VDINTERFACETYPE enmInterface;
647
648 /**
649 * Validates that the keys are within a set of valid names.
650 *
651 * @return true if all key names are found in pszzAllowed.
652 * @return false if not.
653 * @param pvUser The opaque user data associated with this interface.
654 * @param pszzValid List of valid key names separated by '\\0' and ending with
655 * a double '\\0'.
656 */
657 DECLR3CALLBACKMEMBER(bool, pfnAreKeysValid, (void *pvUser, const char *pszzValid));
658
659 /**
660 * Retrieves the length of the string value associated with a key (including
661 * the terminator, for compatibility with CFGMR3QuerySize).
662 *
663 * @return VBox status code.
664 * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known.
665 * @param pvUser The opaque user data associated with this interface.
666 * @param pszName Name of the key to query.
667 * @param pcbValue Where to store the value length. Non-NULL.
668 */
669 DECLR3CALLBACKMEMBER(int, pfnQuerySize, (void *pvUser, const char *pszName, size_t *pcbValue));
670
671 /**
672 * Query the string value associated with a key.
673 *
674 * @return VBox status code.
675 * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known.
676 * VERR_CFGM_NOT_ENOUGH_SPACE means that the buffer is not big enough.
677 * @param pvUser The opaque user data associated with this interface.
678 * @param pszName Name of the key to query.
679 * @param pszValue Pointer to buffer where to store value.
680 * @param cchValue Length of value buffer.
681 */
682 DECLR3CALLBACKMEMBER(int, pfnQuery, (void *pvUser, const char *pszName, char *pszValue, size_t cchValue));
683} VDINTERFACECONFIG, *PVDINTERFACECONFIG;
684
685/**
686 * Get configuration information interface from opaque callback table.
687 *
688 * @return Pointer to the callback table.
689 * @param pInterface Pointer to the interface descriptor.
690 */
691DECLINLINE(PVDINTERFACECONFIG) VDGetInterfaceConfig(PVDINTERFACE pInterface)
692{
693 /* Check that the interface descriptor is a config interface. */
694 AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_CONFIG)
695 && (pInterface->cbSize == sizeof(VDINTERFACE)),
696 ("Not a config interface"), NULL);
697
698 PVDINTERFACECONFIG pInterfaceConfig = (PVDINTERFACECONFIG)pInterface->pCallbacks;
699
700 /* Do basic checks. */
701 AssertMsgReturn( (pInterfaceConfig->cbSize == sizeof(VDINTERFACECONFIG))
702 && (pInterfaceConfig->enmInterface == VDINTERFACETYPE_CONFIG),
703 ("A non config callback table attached to a config interface descriptor\n"), NULL);
704
705 return pInterfaceConfig;
706}
707
708/**
709 * Query configuration, validates that the keys are within a set of valid names.
710 *
711 * @return true if all key names are found in pszzAllowed.
712 * @return false if not.
713 * @param pCfgIf Pointer to configuration callback table.
714 * @param pvUser The opaque user data associated with this interface.
715 * @param pszzValid List of valid names separated by '\\0' and ending with
716 * a double '\\0'.
717 */
718DECLINLINE(bool) VDCFGAreKeysValid(PVDINTERFACECONFIG pCfgIf, void *pvUser,
719 const char *pszzValid)
720{
721 return pCfgIf->pfnAreKeysValid(pvUser, pszzValid);
722}
723
724/**
725 * Query configuration, unsigned 64-bit integer value with default.
726 *
727 * @return VBox status code.
728 * @param pCfgIf Pointer to configuration callback table.
729 * @param pvUser The opaque user data associated with this interface.
730 * @param pszName Name of an integer value
731 * @param pu64 Where to store the value. Set to default on failure.
732 * @param u64Def The default value.
733 */
734DECLINLINE(int) VDCFGQueryU64Def(PVDINTERFACECONFIG pCfgIf, void *pvUser,
735 const char *pszName, uint64_t *pu64,
736 uint64_t u64Def)
737{
738 char aszBuf[32];
739 int rc = pCfgIf->pfnQuery(pvUser, pszName, aszBuf, sizeof(aszBuf));
740 if (RT_SUCCESS(rc))
741 {
742 rc = RTStrToUInt64Full(aszBuf, 0, pu64);
743 }
744 else if (rc == VERR_CFGM_VALUE_NOT_FOUND)
745 {
746 rc = VINF_SUCCESS;
747 *pu64 = u64Def;
748 }
749 return rc;
750}
751
752/**
753 * Query configuration, unsigned 32-bit integer value with default.
754 *
755 * @return VBox status code.
756 * @param pCfgIf Pointer to configuration callback table.
757 * @param pvUser The opaque user data associated with this interface.
758 * @param pszName Name of an integer value
759 * @param pu32 Where to store the value. Set to default on failure.
760 * @param u32Def The default value.
761 */
762DECLINLINE(int) VDCFGQueryU32Def(PVDINTERFACECONFIG pCfgIf, void *pvUser,
763 const char *pszName, uint32_t *pu32,
764 uint32_t u32Def)
765{
766 uint64_t u64;
767 int rc = VDCFGQueryU64Def(pCfgIf, pvUser, pszName, &u64, u32Def);
768 if (RT_SUCCESS(rc))
769 {
770 if (!(u64 & UINT64_C(0xffffffff00000000)))
771 *pu32 = (uint32_t)u64;
772 else
773 rc = VERR_CFGM_INTEGER_TOO_BIG;
774 }
775 return rc;
776}
777
778/**
779 * Query configuration, bool value with default.
780 *
781 * @return VBox status code.
782 * @param pCfgIf Pointer to configuration callback table.
783 * @param pvUser The opaque user data associated with this interface.
784 * @param pszName Name of an integer value
785 * @param pf Where to store the value. Set to default on failure.
786 * @param fDef The default value.
787 */
788DECLINLINE(int) VDCFGQueryBoolDef(PVDINTERFACECONFIG pCfgIf, void *pvUser,
789 const char *pszName, bool *pf,
790 bool fDef)
791{
792 uint64_t u64;
793 int rc = VDCFGQueryU64Def(pCfgIf, pvUser, pszName, &u64, fDef);
794 if (RT_SUCCESS(rc))
795 *pf = u64 ? true : false;
796 return rc;
797}
798
799/**
800 * Query configuration, dynamically allocated (RTMemAlloc) zero terminated
801 * character value.
802 *
803 * @return VBox status code.
804 * @param pCfgIf Pointer to configuration callback table.
805 * @param pvUser The opaque user data associated with this interface.
806 * @param pszName Name of an zero terminated character value
807 * @param ppszString Where to store the string pointer. Not set on failure.
808 * Free this using RTMemFree().
809 */
810DECLINLINE(int) VDCFGQueryStringAlloc(PVDINTERFACECONFIG pCfgIf,
811 void *pvUser, const char *pszName,
812 char **ppszString)
813{
814 size_t cb;
815 int rc = pCfgIf->pfnQuerySize(pvUser, pszName, &cb);
816 if (RT_SUCCESS(rc))
817 {
818 char *pszString = (char *)RTMemAlloc(cb);
819 if (pszString)
820 {
821 rc = pCfgIf->pfnQuery(pvUser, pszName, pszString, cb);
822 if (RT_SUCCESS(rc))
823 *ppszString = pszString;
824 else
825 RTMemFree(pszString);
826 }
827 else
828 rc = VERR_NO_MEMORY;
829 }
830 return rc;
831}
832
833/**
834 * Query configuration, dynamically allocated (RTMemAlloc) zero terminated
835 * character value with default.
836 *
837 * @return VBox status code.
838 * @param pCfgIf Pointer to configuration callback table.
839 * @param pvUser The opaque user data associated with this interface.
840 * @param pszName Name of an zero terminated character value
841 * @param ppszString Where to store the string pointer. Not set on failure.
842 * Free this using RTMemFree().
843 * @param pszDef The default value.
844 */
845DECLINLINE(int) VDCFGQueryStringAllocDef(PVDINTERFACECONFIG pCfgIf,
846 void *pvUser, const char *pszName,
847 char **ppszString,
848 const char *pszDef)
849{
850 size_t cb;
851 int rc = pCfgIf->pfnQuerySize(pvUser, pszName, &cb);
852 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
853 {
854 cb = strlen(pszDef) + 1;
855 rc = VINF_SUCCESS;
856 }
857 if (RT_SUCCESS(rc))
858 {
859 char *pszString = (char *)RTMemAlloc(cb);
860 if (pszString)
861 {
862 rc = pCfgIf->pfnQuery(pvUser, pszName, pszString, cb);
863 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
864 {
865 memcpy(pszString, pszDef, cb);
866 rc = VINF_SUCCESS;
867 }
868 if (RT_SUCCESS(rc))
869 *ppszString = pszString;
870 else
871 RTMemFree(pszString);
872 }
873 else
874 rc = VERR_NO_MEMORY;
875 }
876 return rc;
877}
878
879/**
880 * Query configuration, dynamically allocated (RTMemAlloc) byte string value.
881 *
882 * @return VBox status code.
883 * @param pCfgIf Pointer to configuration callback table.
884 * @param pvUser The opaque user data associated with this interface.
885 * @param pszName Name of an zero terminated character value
886 * @param ppvData Where to store the byte string pointer. Not set on failure.
887 * Free this using RTMemFree().
888 * @param pcbData Where to store the byte string length.
889 */
890DECLINLINE(int) VDCFGQueryBytesAlloc(PVDINTERFACECONFIG pCfgIf,
891 void *pvUser, const char *pszName,
892 void **ppvData, size_t *pcbData)
893{
894 size_t cb;
895 int rc = pCfgIf->pfnQuerySize(pvUser, pszName, &cb);
896 if (RT_SUCCESS(rc))
897 {
898 char *pvData = (char *)RTMemAlloc(cb);
899 if (pvData)
900 {
901 rc = pCfgIf->pfnQuery(pvUser, pszName, pvData, cb);
902 if (RT_SUCCESS(rc))
903 {
904 *ppvData = pvData;
905 *pcbData = cb;
906 }
907 else
908 RTMemFree(pvData);
909 }
910 else
911 rc = VERR_NO_MEMORY;
912 }
913 return rc;
914}
915
916
917/**
918 * TCP network stack interface
919 *
920 * Per-disk. Mandatory for backends which have the VD_CAP_TCPNET bit set.
921 */
922typedef struct VDINTERFACETCPNET
923{
924 /**
925 * Size of the configuration interface.
926 */
927 uint32_t cbSize;
928
929 /**
930 * Interface type.
931 */
932 VDINTERFACETYPE enmInterface;
933
934 /**
935 * Connect as a client to a TCP port.
936 *
937 * @return iprt status code.
938 * @param pszAddress The address to connect to.
939 * @param uPort The port to connect to.
940 * @param pSock Where to store the handle to the established connect
941ion.
942 */
943 DECLR3CALLBACKMEMBER(int, pfnClientConnect, (const char *pszAddress, uint32_t uPort, PRTSOCKET pSock));
944
945 /**
946 * Close a TCP connection.
947 *
948 * @return iprt status code.
949 * @param Sock Socket descriptor.
950ion.
951 */
952 DECLR3CALLBACKMEMBER(int, pfnClientClose, (RTSOCKET Sock));
953
954 /**
955 * Socket I/O multiplexing.
956 * Checks if the socket is ready for reading.
957 *
958 * @return iprt status code.
959 * @param Sock Socket descriptor.
960 * @param cMillies Number of milliseconds to wait for the socket.
961 * Use RT_INDEFINITE_WAIT to wait for ever.
962 */
963 DECLR3CALLBACKMEMBER(int, pfnSelectOne, (RTSOCKET Sock, unsigned cMillies));
964
965 /**
966 * Receive data from a socket.
967 *
968 * @return iprt status code.
969 * @param Sock Socket descriptor.
970 * @param pvBuffer Where to put the data we read.
971 * @param cbBuffer Read buffer size.
972 * @param pcbRead Number of bytes read.
973 * If NULL the entire buffer will be filled upon successful return.
974 * If not NULL a partial read can be done successfully.
975 */
976 DECLR3CALLBACKMEMBER(int, pfnRead, (RTSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead));
977
978 /**
979 * Send data from a socket.
980 *
981 * @return iprt status code.
982 * @param Sock Socket descriptor.
983 * @param pvBuffer Buffer to write data to socket.
984 * @param cbBuffer How much to write.
985 * @param pcbRead Number of bytes read.
986 */
987 DECLR3CALLBACKMEMBER(int, pfnWrite, (RTSOCKET Sock, const void *pvBuffer, size_t cbBuffer));
988
989 /**
990 * Flush socket write buffers.
991 *
992 * @return iprt status code.
993 * @param Sock Socket descriptor.
994 */
995 DECLR3CALLBACKMEMBER(int, pfnFlush, (RTSOCKET Sock));
996
997} VDINTERFACETCPNET, *PVDINTERFACETCPNET;
998
999/**
1000 * Get TCP network stack interface from opaque callback table.
1001 *
1002 * @return Pointer to the callback table.
1003 * @param pInterface Pointer to the interface descriptor.
1004 */
1005DECLINLINE(PVDINTERFACETCPNET) VDGetInterfaceTcpNet(PVDINTERFACE pInterface)
1006{
1007 /* Check that the interface descriptor is a TCP network stack interface. */
1008 AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_TCPNET)
1009 && (pInterface->cbSize == sizeof(VDINTERFACE)),
1010 ("Not a TCP network stack interface"), NULL);
1011
1012 PVDINTERFACETCPNET pInterfaceTcpNet = (PVDINTERFACETCPNET)pInterface->pCallbacks;
1013
1014 /* Do basic checks. */
1015 AssertMsgReturn( (pInterfaceTcpNet->cbSize == sizeof(VDINTERFACETCPNET))
1016 && (pInterfaceTcpNet->enmInterface == VDINTERFACETYPE_TCPNET),
1017 ("A non TCP network stack callback table attached to a TCP network stack interface descriptor\n"), NULL);
1018
1019 return pInterfaceTcpNet;
1020}
1021
1022/**
1023 * Interface to get the parent state.
1024 *
1025 * Per operation interface. Optional, present only if there is a parent, and
1026 * used only internally for compacting.
1027 */
1028typedef struct VDINTERFACEPARENTSTATE
1029{
1030 /**
1031 * Size of the parent state interface.
1032 */
1033 uint32_t cbSize;
1034
1035 /**
1036 * Interface type.
1037 */
1038 VDINTERFACETYPE enmInterface;
1039
1040 /**
1041 * Read data callback.
1042 *
1043 * @return VBox status code.
1044 * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
1045 * @param pvUser The opaque data passed for the operation.
1046 * @param uOffset Offset of first reading byte from start of disk.
1047 * Must be aligned to a sector boundary.
1048 * @param pvBuf Pointer to buffer for reading data.
1049 * @param cbRead Number of bytes to read.
1050 * Must be aligned to a sector boundary.
1051 */
1052 DECLR3CALLBACKMEMBER(int, pfnParentRead, (void *pvUser, uint64_t uOffset, void *pvBuf, size_t cbRead));
1053
1054} VDINTERFACEPARENTSTATE, *PVDINTERFACEPARENTSTATE;
1055
1056
1057/**
1058 * Get parent state interface from opaque callback table.
1059 *
1060 * @return Pointer to the callback table.
1061 * @param pInterface Pointer to the interface descriptor.
1062 */
1063DECLINLINE(PVDINTERFACEPARENTSTATE) VDGetInterfaceParentState(PVDINTERFACE pInterface)
1064{
1065 /* Check that the interface descriptor is a parent state interface. */
1066 AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_PARENTSTATE)
1067 && (pInterface->cbSize == sizeof(VDINTERFACE)),
1068 ("Not a parent state interface"), NULL);
1069
1070 PVDINTERFACEPARENTSTATE pInterfaceParentState = (PVDINTERFACEPARENTSTATE)pInterface->pCallbacks;
1071
1072 /* Do basic checks. */
1073 AssertMsgReturn( (pInterfaceParentState->cbSize == sizeof(VDINTERFACEPARENTSTATE))
1074 && (pInterfaceParentState->enmInterface == VDINTERFACETYPE_PARENTSTATE),
1075 ("A non parent state callback table attached to a parent state interface descriptor\n"), NULL);
1076
1077 return pInterfaceParentState;
1078}
1079
1080
1081/** @name Configuration interface key handling flags.
1082 * @{
1083 */
1084/** Mandatory config key. Not providing a value for this key will cause
1085 * the backend to fail. */
1086#define VD_CFGKEY_MANDATORY RT_BIT(0)
1087/** Expert config key. Not showing it by default in the GUI is is probably
1088 * a good idea, as the average user won't understand it easily. */
1089#define VD_CFGKEY_EXPERT RT_BIT(1)
1090/** @}*/
1091
1092
1093/**
1094 * Configuration value type for configuration information interface.
1095 */
1096typedef enum VDCFGVALUETYPE
1097{
1098 /** Integer value. */
1099 VDCFGVALUETYPE_INTEGER = 1,
1100 /** String value. */
1101 VDCFGVALUETYPE_STRING,
1102 /** Bytestring value. */
1103 VDCFGVALUETYPE_BYTES
1104} VDCFGVALUETYPE;
1105
1106
1107/**
1108 * Structure describing configuration keys required/supported by a backend
1109 * through the config interface.
1110 */
1111typedef struct VDCONFIGINFO
1112{
1113 /** Key name of the configuration. */
1114 const char *pszKey;
1115 /** Pointer to default value (descriptor). NULL if no useful default value
1116 * can be specified. */
1117 const char *pszDefaultValue;
1118 /** Value type for this key. */
1119 VDCFGVALUETYPE enmValueType;
1120 /** Key handling flags (a combination of VD_CFGKEY_* flags). */
1121 uint64_t uKeyFlags;
1122} VDCONFIGINFO;
1123
1124/** Pointer to structure describing configuration keys. */
1125typedef VDCONFIGINFO *PVDCONFIGINFO;
1126
1127/** Pointer to const structure describing configuration keys. */
1128typedef const VDCONFIGINFO *PCVDCONFIGINFO;
1129
1130/**
1131 * Data structure for returning a list of backend capabilities.
1132 */
1133typedef struct VDBACKENDINFO
1134{
1135 /** Name of the backend. Must be unique even with case insensitive comparison. */
1136 const char *pszBackend;
1137 /** Capabilities of the backend (a combination of the VD_CAP_* flags). */
1138 uint64_t uBackendCaps;
1139 /** Pointer to a NULL-terminated array of strings, containing the supported
1140 * file extensions. Note that some backends do not work on files, so this
1141 * pointer may just contain NULL. */
1142 const char * const *papszFileExtensions;
1143 /** Pointer to an array of structs describing each supported config key.
1144 * Terminated by a NULL config key. Note that some backends do not support
1145 * the configuration interface, so this pointer may just contain NULL.
1146 * Mandatory if the backend sets VD_CAP_CONFIG. */
1147 PCVDCONFIGINFO paConfigInfo;
1148 /** Returns a human readable hard disk location string given a
1149 * set of hard disk configuration keys. The returned string is an
1150 * equivalent of the full file path for image-based hard disks.
1151 * Mandatory for backends with no VD_CAP_FILE and NULL otherwise. */
1152 DECLR3CALLBACKMEMBER(int, pfnComposeLocation, (PVDINTERFACE pConfig, char **pszLocation));
1153 /** Returns a human readable hard disk name string given a
1154 * set of hard disk configuration keys. The returned string is an
1155 * equivalent of the file name part in the full file path for
1156 * image-based hard disks. Mandatory for backends with no
1157 * VD_CAP_FILE and NULL otherwise. */
1158 DECLR3CALLBACKMEMBER(int, pfnComposeName, (PVDINTERFACE pConfig, char **pszName));
1159} VDBACKENDINFO, *PVDBACKENDINFO;
1160
1161
1162/**
1163 * VBox HDD Container main structure.
1164 */
1165/* Forward declaration, VBOXHDD structure is visible only inside VBox HDD module. */
1166struct VBOXHDD;
1167typedef struct VBOXHDD VBOXHDD;
1168typedef VBOXHDD *PVBOXHDD;
1169
1170/**
1171 * Initializes HDD backends.
1172 *
1173 * @returns VBox status code.
1174 */
1175VBOXDDU_DECL(int) VDInit(void);
1176
1177/**
1178 * Destroys loaded HDD backends.
1179 *
1180 * @returns VBox status code.
1181 */
1182VBOXDDU_DECL(int) VDShutdown(void);
1183
1184/**
1185 * Lists all HDD backends and their capabilities in a caller-provided buffer.
1186 * Free all returned names with RTStrFree() when you no longer need them.
1187 *
1188 * @return VBox status code.
1189 * VERR_BUFFER_OVERFLOW if not enough space is passed.
1190 * @param cEntriesAlloc Number of list entries available.
1191 * @param pEntries Pointer to array for the entries.
1192 * @param pcEntriesUsed Number of entries returned.
1193 */
1194VBOXDDU_DECL(int) VDBackendInfo(unsigned cEntriesAlloc, PVDBACKENDINFO pEntries,
1195 unsigned *pcEntriesUsed);
1196
1197/**
1198 * Lists the capablities of a backend indentified by its name.
1199 * Free all returned names with RTStrFree() when you no longer need them.
1200 *
1201 * @return VBox status code.
1202 * @param pszBackend The backend name (case insensitive).
1203 * @param pEntries Pointer to an entry.
1204 */
1205VBOXDDU_DECL(int) VDBackendInfoOne(const char *pszBackend, PVDBACKENDINFO pEntry);
1206
1207/**
1208 * Allocates and initializes an empty HDD container.
1209 * No image files are opened.
1210 *
1211 * @return VBox status code.
1212 * @param pVDIfsDisk Pointer to the per-disk VD interface list.
1213 * @param ppDisk Where to store the reference to HDD container.
1214 */
1215VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk);
1216
1217/**
1218 * Destroys HDD container.
1219 * If container has opened image files they will be closed.
1220 *
1221 * @param pDisk Pointer to HDD container.
1222 */
1223VBOXDDU_DECL(void) VDDestroy(PVBOXHDD pDisk);
1224
1225/**
1226 * Try to get the backend name which can use this image.
1227 *
1228 * @return VBox status code.
1229 * @param pszFilename Name of the image file for which the backend is queried.
1230 * @param ppszFormat Receives pointer of the UTF-8 string which contains the format name.
1231 * The returned pointer must be freed using RTStrFree().
1232 */
1233VBOXDDU_DECL(int) VDGetFormat(const char *pszFilename, char **ppszFormat);
1234
1235/**
1236 * Opens an image file.
1237 *
1238 * The first opened image file in HDD container must have a base image type,
1239 * others (next opened images) must be differencing or undo images.
1240 * Linkage is checked for differencing image to be consistent with the previously opened image.
1241 * When another differencing image is opened and the last image was opened in read/write access
1242 * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
1243 * other processes to use images in read-only mode too.
1244 *
1245 * Note that the image is opened in read-only mode if a read/write open is not possible.
1246 * Use VDIsReadOnly to check open mode.
1247 *
1248 * @return VBox status code.
1249 * @param pDisk Pointer to HDD container.
1250 * @param pszBackend Name of the image file backend to use (case insensitive).
1251 * @param pszFilename Name of the image file to open.
1252 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
1253 * @param pVDIfsImage Pointer to the per-image VD interface list.
1254 */
1255VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend,
1256 const char *pszFilename, unsigned uOpenFlags,
1257 PVDINTERFACE pVDIfsImage);
1258
1259/**
1260 * Creates and opens a new base image file.
1261 *
1262 * @return VBox status code.
1263 * @param pDisk Pointer to HDD container.
1264 * @param pszBackend Name of the image file backend to use (case insensitive).
1265 * @param pszFilename Name of the image file to create.
1266 * @param cbSize Image size in bytes.
1267 * @param uImageFlags Flags specifying special image features.
1268 * @param pszComment Pointer to image comment. NULL is ok.
1269 * @param pPCHSGeometry Pointer to physical disk geometry <= (16383,16,63). Not NULL.
1270 * @param pLCHSGeometry Pointer to logical disk geometry <= (x,255,63). Not NULL.
1271 * @param pUuid New UUID of the image. If NULL, a new UUID is created.
1272 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
1273 * @param pVDIfsImage Pointer to the per-image VD interface list.
1274 * @param pVDIfsOperation Pointer to the per-operation VD interface list.
1275 */
1276VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszBackend,
1277 const char *pszFilename, uint64_t cbSize,
1278 unsigned uImageFlags, const char *pszComment,
1279 PCPDMMEDIAGEOMETRY pPCHSGeometry,
1280 PCPDMMEDIAGEOMETRY pLCHSGeometry,
1281 PCRTUUID pUuid, unsigned uOpenFlags,
1282 PVDINTERFACE pVDIfsImage,
1283 PVDINTERFACE pVDIfsOperation);
1284
1285/**
1286 * Creates and opens a new differencing image file in HDD container.
1287 * See comments for VDOpen function about differencing images.
1288 *
1289 * @return VBox status code.
1290 * @param pDisk Pointer to HDD container.
1291 * @param pszBackend Name of the image file backend to use (case insensitive).
1292 * @param pszFilename Name of the differencing image file to create.
1293 * @param uImageFlags Flags specifying special image features.
1294 * @param pszComment Pointer to image comment. NULL is ok.
1295 * @param pUuid New UUID of the image. If NULL, a new UUID is created.
1296 * @param pParentUuid New parent UUID of the image. If NULL, the UUID is queried automatically.
1297 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
1298 * @param pVDIfsImage Pointer to the per-image VD interface list.
1299 * @param pVDIfsOperation Pointer to the per-operation VD interface list.
1300 */
1301VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszBackend,
1302 const char *pszFilename, unsigned uImageFlags,
1303 const char *pszComment, PCRTUUID pUuid,
1304 PCRTUUID pParentUuid, unsigned uOpenFlags,
1305 PVDINTERFACE pVDIfsImage,
1306 PVDINTERFACE pVDIfsOperation);
1307
1308/**
1309 * Merges two images (not necessarily with direct parent/child relationship).
1310 * As a side effect the source image and potentially the other images which
1311 * are also merged to the destination are deleted from both the disk and the
1312 * images in the HDD container.
1313 *
1314 * @return VBox status code.
1315 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1316 * @param pDisk Pointer to HDD container.
1317 * @param nImageFrom Image number to merge from, counts from 0. 0 is always base image of container.
1318 * @param nImageTo Image number to merge to, counts from 0. 0 is always base image of container.
1319 * @param pVDIfsOperation Pointer to the per-operation VD interface list.
1320 */
1321VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom,
1322 unsigned nImageTo, PVDINTERFACE pVDIfsOperation);
1323
1324/**
1325 * Copies an image from one HDD container to another.
1326 * The copy is opened in the target HDD container.
1327 * It is possible to convert between different image formats, because the
1328 * backend for the destination may be different from the source.
1329 * If both the source and destination reference the same HDD container,
1330 * then the image is moved (by copying/deleting or renaming) to the new location.
1331 * The source container is unchanged if the move operation fails, otherwise
1332 * the image at the new location is opened in the same way as the old one was.
1333 *
1334 * @return VBox status code.
1335 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1336 * @param pDiskFrom Pointer to source HDD container.
1337 * @param nImage Image number, counts from 0. 0 is always base image of container.
1338 * @param pDiskTo Pointer to destination HDD container.
1339 * @param pszBackend Name of the image file backend to use (may be NULL to use the same as the source, case insensitive).
1340 * @param pszFilename New name of the image (may be NULL to specify that the
1341 * copy destination is the destination container, or
1342 * if pDiskFrom == pDiskTo, i.e. when moving).
1343 * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored).
1344 * @param cbSize New image size (0 means leave unchanged).
1345 * @param uImageFlags Flags specifying special destination image features.
1346 * @param pDstUuid New UUID of the destination image. If NULL, a new UUID is created.
1347 * This parameter is used if and only if a true copy is created.
1348 * In all rename/move cases or copy to existing image cases the modification UUIDs are copied over.
1349 * @param pVDIfsOperation Pointer to the per-operation VD interface list.
1350 * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the
1351 * destination image.
1352 * @param pDstVDIfsOperation Pointer to the per-operation VD interface list,
1353 * for the destination operation.
1354 */
1355VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
1356 const char *pszBackend, const char *pszFilename,
1357 bool fMoveByRename, uint64_t cbSize,
1358 unsigned uImageFlags, PCRTUUID pDstUuid,
1359 PVDINTERFACE pVDIfsOperation,
1360 PVDINTERFACE pDstVDIfsImage,
1361 PVDINTERFACE pDstVDIfsOperation);
1362
1363/**
1364 * Optimizes the storage consumption of an image. Typically the unused blocks
1365 * have to be wiped with zeroes to achieve a substantial reduced storage use.
1366 * Another optimization done is reordering the image blocks, which can provide
1367 * a significant performance boost, as reads and writes tend to use less random
1368 * file offsets.
1369 *
1370 * @return VBox status code.
1371 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1372 * @return VERR_VD_IMAGE_READ_ONLY if image is not writable.
1373 * @return VERR_NOT_SUPPORTED if this kind of image can be compacted, but
1374 * this isn't supported yet.
1375 * @param pDisk Pointer to HDD container.
1376 * @param nImage Image number, counts from 0. 0 is always base image of container.
1377 * @param pVDIfsOperation Pointer to the per-operation VD interface list.
1378 */
1379VBOXDDU_DECL(int) VDCompact(PVBOXHDD pDisk, unsigned nImage,
1380 PVDINTERFACE pVDIfsOperation);
1381
1382/**
1383 * Closes the last opened image file in HDD container.
1384 * If previous image file was opened in read-only mode (that is normal) and closing image
1385 * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
1386 * will be reopened in read/write mode.
1387 *
1388 * @return VBox status code.
1389 * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
1390 * @param pDisk Pointer to HDD container.
1391 * @param fDelete If true, delete the image from the host disk.
1392 */
1393VBOXDDU_DECL(int) VDClose(PVBOXHDD pDisk, bool fDelete);
1394
1395/**
1396 * Closes all opened image files in HDD container.
1397 *
1398 * @return VBox status code.
1399 * @param pDisk Pointer to HDD container.
1400 */
1401VBOXDDU_DECL(int) VDCloseAll(PVBOXHDD pDisk);
1402
1403/**
1404 * Read data from virtual HDD.
1405 *
1406 * @return VBox status code.
1407 * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
1408 * @param pDisk Pointer to HDD container.
1409 * @param uOffset Offset of first reading byte from start of disk.
1410 * Must be aligned to a sector boundary.
1411 * @param pvBuf Pointer to buffer for reading data.
1412 * @param cbRead Number of bytes to read.
1413 * Must be aligned to a sector boundary.
1414 */
1415VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t uOffset, void *pvBuf, size_t cbRead);
1416
1417/**
1418 * Write data to virtual HDD.
1419 *
1420 * @return VBox status code.
1421 * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
1422 * @param pDisk Pointer to HDD container.
1423 * @param uOffset Offset of first writing byte from start of disk.
1424 * Must be aligned to a sector boundary.
1425 * @param pvBuf Pointer to buffer for writing data.
1426 * @param cbWrite Number of bytes to write.
1427 * Must be aligned to a sector boundary.
1428 */
1429VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t uOffset, const void *pvBuf, size_t cbWrite);
1430
1431/**
1432 * Make sure the on disk representation of a virtual HDD is up to date.
1433 *
1434 * @return VBox status code.
1435 * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
1436 * @param pDisk Pointer to HDD container.
1437 */
1438VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
1439
1440/**
1441 * Get number of opened images in HDD container.
1442 *
1443 * @return Number of opened images for HDD container. 0 if no images have been opened.
1444 * @param pDisk Pointer to HDD container.
1445 */
1446VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
1447
1448/**
1449 * Get read/write mode of HDD container.
1450 *
1451 * @return Virtual disk ReadOnly status.
1452 * @return true if no image is opened in HDD container.
1453 * @param pDisk Pointer to HDD container.
1454 */
1455VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
1456
1457/**
1458 * Get total capacity of an image in HDD container.
1459 *
1460 * @return Virtual disk size in bytes.
1461 * @return 0 if image with specified number was not opened.
1462 * @param pDisk Pointer to HDD container.
1463 * @param nImage Image number, counts from 0. 0 is always base image of container.
1464 */
1465VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk, unsigned nImage);
1466
1467/**
1468 * Get total file size of an image in HDD container.
1469 *
1470 * @return Virtual disk size in bytes.
1471 * @return 0 if image with specified number was not opened.
1472 * @param pDisk Pointer to HDD container.
1473 * @param nImage Image number, counts from 0. 0 is always base image of container.
1474 */
1475VBOXDDU_DECL(uint64_t) VDGetFileSize(PVBOXHDD pDisk, unsigned nImage);
1476
1477/**
1478 * Get virtual disk PCHS geometry of an image in HDD container.
1479 *
1480 * @return VBox status code.
1481 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1482 * @return VERR_VD_GEOMETRY_NOT_SET if no geometry present in the HDD container.
1483 * @param pDisk Pointer to HDD container.
1484 * @param nImage Image number, counts from 0. 0 is always base image of container.
1485 * @param pPCHSGeometry Where to store PCHS geometry. Not NULL.
1486 */
1487VBOXDDU_DECL(int) VDGetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
1488 PPDMMEDIAGEOMETRY pPCHSGeometry);
1489
1490/**
1491 * Store virtual disk PCHS geometry of an image in HDD container.
1492 *
1493 * @return VBox status code.
1494 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1495 * @param pDisk Pointer to HDD container.
1496 * @param nImage Image number, counts from 0. 0 is always base image of container.
1497 * @param pPCHSGeometry Where to load PCHS geometry from. Not NULL.
1498 */
1499VBOXDDU_DECL(int) VDSetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
1500 PCPDMMEDIAGEOMETRY pPCHSGeometry);
1501
1502/**
1503 * Get virtual disk LCHS geometry of an image in HDD container.
1504 *
1505 * @return VBox status code.
1506 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1507 * @return VERR_VD_GEOMETRY_NOT_SET if no geometry present in the HDD container.
1508 * @param pDisk Pointer to HDD container.
1509 * @param nImage Image number, counts from 0. 0 is always base image of container.
1510 * @param pLCHSGeometry Where to store LCHS geometry. Not NULL.
1511 */
1512VBOXDDU_DECL(int) VDGetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
1513 PPDMMEDIAGEOMETRY pLCHSGeometry);
1514
1515/**
1516 * Store virtual disk LCHS geometry of an image in HDD container.
1517 *
1518 * @return VBox status code.
1519 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1520 * @param pDisk Pointer to HDD container.
1521 * @param nImage Image number, counts from 0. 0 is always base image of container.
1522 * @param pLCHSGeometry Where to load LCHS geometry from. Not NULL.
1523 */
1524VBOXDDU_DECL(int) VDSetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
1525 PCPDMMEDIAGEOMETRY pLCHSGeometry);
1526
1527/**
1528 * Get version of image in HDD container.
1529 *
1530 * @return VBox status code.
1531 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1532 * @param pDisk Pointer to HDD container.
1533 * @param nImage Image number, counts from 0. 0 is always base image of container.
1534 * @param puVersion Where to store the image version.
1535 */
1536VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage,
1537 unsigned *puVersion);
1538
1539/**
1540 * List the capabilities of image backend in HDD container.
1541 *
1542 * @return VBox status code.
1543 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1544 * @param pDisk Pointer to the HDD container.
1545 * @param nImage Image number, counts from 0. 0 is always base image of container.
1546 * @param pbackendInfo Where to store the backend information.
1547 */
1548VBOXDDU_DECL(int) VDBackendInfoSingle(PVBOXHDD pDisk, unsigned nImage,
1549 PVDBACKENDINFO pBackendInfo);
1550
1551/**
1552 * Get flags of image in HDD container.
1553 *
1554 * @return VBox status code.
1555 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1556 * @param pDisk Pointer to HDD container.
1557 * @param nImage Image number, counts from 0. 0 is always base image of container.
1558 * @param puImageFlags Where to store the image flags.
1559 */
1560VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
1561
1562/**
1563 * Get open flags of image in HDD container.
1564 *
1565 * @return VBox status code.
1566 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1567 * @param pDisk Pointer to HDD container.
1568 * @param nImage Image number, counts from 0. 0 is always base image of container.
1569 * @param puOpenFlags Where to store the image open flags.
1570 */
1571VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
1572 unsigned *puOpenFlags);
1573
1574/**
1575 * Set open flags of image in HDD container.
1576 * This operation may cause file locking changes and/or files being reopened.
1577 * Note that in case of unrecoverable error all images in HDD container will be closed.
1578 *
1579 * @return VBox status code.
1580 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1581 * @param pDisk Pointer to HDD container.
1582 * @param nImage Image number, counts from 0. 0 is always base image of container.
1583 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
1584 */
1585VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
1586 unsigned uOpenFlags);
1587
1588/**
1589 * Get base filename of image in HDD container. Some image formats use
1590 * other filenames as well, so don't use this for anything but informational
1591 * purposes.
1592 *
1593 * @return VBox status code.
1594 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1595 * @return VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
1596 * @param pDisk Pointer to HDD container.
1597 * @param nImage Image number, counts from 0. 0 is always base image of container.
1598 * @param pszFilename Where to store the image file name.
1599 * @param cbFilename Size of buffer pszFilename points to.
1600 */
1601VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage,
1602 char *pszFilename, unsigned cbFilename);
1603
1604/**
1605 * Get the comment line of image in HDD container.
1606 *
1607 * @return VBox status code.
1608 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1609 * @return VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
1610 * @param pDisk Pointer to HDD container.
1611 * @param nImage Image number, counts from 0. 0 is always base image of container.
1612 * @param pszComment Where to store the comment string of image. NULL is ok.
1613 * @param cbComment The size of pszComment buffer. 0 is ok.
1614 */
1615VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage,
1616 char *pszComment, unsigned cbComment);
1617
1618/**
1619 * Changes the comment line of image in HDD container.
1620 *
1621 * @return VBox status code.
1622 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1623 * @param pDisk Pointer to HDD container.
1624 * @param nImage Image number, counts from 0. 0 is always base image of container.
1625 * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
1626 */
1627VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage,
1628 const char *pszComment);
1629
1630/**
1631 * Get UUID of image in HDD container.
1632 *
1633 * @return VBox status code.
1634 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1635 * @param pDisk Pointer to HDD container.
1636 * @param nImage Image number, counts from 0. 0 is always base image of container.
1637 * @param pUuid Where to store the image UUID.
1638 */
1639VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
1640
1641/**
1642 * Set the image's UUID. Should not be used by normal applications.
1643 *
1644 * @return VBox status code.
1645 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1646 * @param pDisk Pointer to HDD container.
1647 * @param nImage Image number, counts from 0. 0 is always base image of container.
1648 * @param pUuid New UUID of the image. If NULL, a new UUID is created.
1649 */
1650VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
1651
1652/**
1653 * Get last modification UUID of image in HDD container.
1654 *
1655 * @return VBox status code.
1656 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1657 * @param pDisk Pointer to HDD container.
1658 * @param nImage Image number, counts from 0. 0 is always base image of container.
1659 * @param pUuid Where to store the image modification UUID.
1660 */
1661VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
1662 PRTUUID pUuid);
1663
1664/**
1665 * Set the image's last modification UUID. Should not be used by normal applications.
1666 *
1667 * @return VBox status code.
1668 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1669 * @param pDisk Pointer to HDD container.
1670 * @param nImage Image number, counts from 0. 0 is always base image of container.
1671 * @param pUuid New modification UUID of the image. If NULL, a new UUID is created.
1672 */
1673VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
1674 PCRTUUID pUuid);
1675
1676/**
1677 * Get parent UUID of image in HDD container.
1678 *
1679 * @return VBox status code.
1680 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1681 * @param pDisk Pointer to HDD container.
1682 * @param nImage Image number, counts from 0. 0 is always base image of the container.
1683 * @param pUuid Where to store the parent image UUID.
1684 */
1685VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage,
1686 PRTUUID pUuid);
1687
1688/**
1689 * Set the image's parent UUID. Should not be used by normal applications.
1690 *
1691 * @return VBox status code.
1692 * @param pDisk Pointer to HDD container.
1693 * @param nImage Image number, counts from 0. 0 is always base image of container.
1694 * @param pUuid New parent UUID of the image. If NULL, a new UUID is created.
1695 */
1696VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage,
1697 PCRTUUID pUuid);
1698
1699
1700/**
1701 * Debug helper - dumps all opened images in HDD container into the log file.
1702 *
1703 * @param pDisk Pointer to HDD container.
1704 */
1705VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
1706
1707
1708/**
1709 * Query if asynchronous operations are supported for this disk.
1710 *
1711 * @return VBox status code.
1712 * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
1713 * @param pDisk Pointer to the HDD container.
1714 * @param nImage Image number, counts from 0. 0 is always base image of container.
1715 * @param pfAIOSupported Where to store if async IO is supported.
1716 */
1717VBOXDDU_DECL(int) VDImageIsAsyncIOSupported(PVBOXHDD pDisk, unsigned nImage, bool *pfAIOSupported);
1718
1719
1720/**
1721 * Start a asynchronous read request.
1722 *
1723 * @return VBox status code.
1724 * @param pDisk Pointer to the HDD container.
1725 * @param uOffset The offset of the virtual disk to read from.
1726 * @param cbRead How many bytes to read.
1727 * @param paSeg Pointer to an array of segments.
1728 * @param cSeg Number of segments in the array.
1729 * @param pvUser User data which is passed on completion
1730 */
1731VBOXDDU_DECL(int) VDAsyncRead(PVBOXHDD pDisk, uint64_t uOffset, size_t cbRead,
1732 PPDMDATASEG paSeg, unsigned cSeg,
1733 void *pvUser);
1734
1735
1736/**
1737 * Start a asynchronous write request.
1738 *
1739 * @return VBox status code.
1740 * @param pDisk Pointer to the HDD container.
1741 * @param uOffset The offset of the virtual disk to write to.
1742 * @param cbWrtie How many bytes to write.
1743 * @param paSeg Pointer to an array of segments.
1744 * @param cSeg Number of segments in the array.
1745 * @param pvUser User data which is passed on completion.
1746 */
1747VBOXDDU_DECL(int) VDAsyncWrite(PVBOXHDD pDisk, uint64_t uOffset, size_t cbWrite,
1748 PPDMDATASEG paSeg, unsigned cSeg,
1749 void *pvUser);
1750
1751
1752RT_C_DECLS_END
1753
1754/** @} */
1755
1756#endif
Note: See TracBrowser for help on using the repository browser.

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