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 |
|
---|
43 | RT_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 | */
|
---|
111 | typedef 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 | */
|
---|
135 | typedef 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 | */
|
---|
211 | typedef 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 | */
|
---|
234 | typedef 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. */
|
---|
252 | typedef VDINTERFACE *PVDINTERFACE;
|
---|
253 | /** Pointer to a const VDINTERFACE. */
|
---|
254 | typedef 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 | */
|
---|
273 | DECLINLINE(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 | */
|
---|
305 | DECLINLINE(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 to upper layers.
|
---|
339 | *
|
---|
340 | * Per disk interface. Optional, but think twice if you want to miss the
|
---|
341 | * opportunity of reporting better human-readable error messages.
|
---|
342 | */
|
---|
343 | typedef struct VDINTERFACEERROR
|
---|
344 | {
|
---|
345 | /**
|
---|
346 | * Size of the error interface.
|
---|
347 | */
|
---|
348 | uint32_t cbSize;
|
---|
349 |
|
---|
350 | /**
|
---|
351 | * Interface type.
|
---|
352 | */
|
---|
353 | VDINTERFACETYPE enmInterface;
|
---|
354 |
|
---|
355 | /**
|
---|
356 | * Error message callback.
|
---|
357 | *
|
---|
358 | * @param pvUser The opaque data passed on container creation.
|
---|
359 | * @param rc The VBox error code.
|
---|
360 | * @param RT_SRC_POS_DECL Use RT_SRC_POS.
|
---|
361 | * @param pszFormat Error message format string.
|
---|
362 | * @param va Error message arguments.
|
---|
363 | */
|
---|
364 | DECLR3CALLBACKMEMBER(void, pfnError, (void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
|
---|
365 |
|
---|
366 | } VDINTERFACEERROR, *PVDINTERFACEERROR;
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Get error interface from opaque callback table.
|
---|
370 | *
|
---|
371 | * @return Pointer to the callback table.
|
---|
372 | * @param pInterface Pointer to the interface descriptor.
|
---|
373 | */
|
---|
374 | DECLINLINE(PVDINTERFACEERROR) VDGetInterfaceError(PVDINTERFACE pInterface)
|
---|
375 | {
|
---|
376 | /* Check that the interface descriptor is a error interface. */
|
---|
377 | AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_ERROR)
|
---|
378 | && (pInterface->cbSize == sizeof(VDINTERFACE)),
|
---|
379 | ("Not an error interface"), NULL);
|
---|
380 |
|
---|
381 | PVDINTERFACEERROR pInterfaceError = (PVDINTERFACEERROR)pInterface->pCallbacks;
|
---|
382 |
|
---|
383 | /* Do basic checks. */
|
---|
384 | AssertMsgReturn( (pInterfaceError->cbSize == sizeof(VDINTERFACEERROR))
|
---|
385 | && (pInterfaceError->enmInterface == VDINTERFACETYPE_ERROR),
|
---|
386 | ("A non error callback table attached to a error interface descriptor\n"), NULL);
|
---|
387 |
|
---|
388 | return pInterfaceError;
|
---|
389 | }
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Completion callback which is called by the interface owner
|
---|
393 | * to inform the backend that a task finished.
|
---|
394 | *
|
---|
395 | * @return VBox status code.
|
---|
396 | * @param pvUser Opaque user data which is passed on request submission.
|
---|
397 | * @param ppvCaller Where to store the opaque user data the caller of
|
---|
398 | * VDAsyncRead or VDAsyncWrite passed.
|
---|
399 | */
|
---|
400 | typedef DECLCALLBACK(int) FNVDCOMPLETED(void *pvUser, void **ppvCaller);
|
---|
401 | /** Pointer to FNVDCOMPLETED() */
|
---|
402 | typedef FNVDCOMPLETED *PFNVDCOMPLETED;
|
---|
403 |
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * Support interface for asynchronous I/O
|
---|
407 | *
|
---|
408 | * Per-disk. Optional.
|
---|
409 | */
|
---|
410 | typedef struct VDINTERFACEASYNCIO
|
---|
411 | {
|
---|
412 | /**
|
---|
413 | * Size of the async interface.
|
---|
414 | */
|
---|
415 | uint32_t cbSize;
|
---|
416 |
|
---|
417 | /**
|
---|
418 | * Interface type.
|
---|
419 | */
|
---|
420 | VDINTERFACETYPE enmInterface;
|
---|
421 |
|
---|
422 | /**
|
---|
423 | * Open callback
|
---|
424 | *
|
---|
425 | * @return VBox status code.
|
---|
426 | * @param pvUser The opaque data passed on container creation.
|
---|
427 | * @param pszLocation Name of the location to open.
|
---|
428 | * @param fReadonly Whether to open the storage medium read only.
|
---|
429 | * @param pfnCompleted The callabck which is called whenever a task
|
---|
430 | * completed. The backend has to pass the user data
|
---|
431 | * of the request initiator (ie the one who calls
|
---|
432 | * VDAsyncRead or VDAsyncWrite) in pvCompletion
|
---|
433 | * if this is NULL.
|
---|
434 | * @param ppStorage Where to store the opaque storage handle.
|
---|
435 | */
|
---|
436 | DECLR3CALLBACKMEMBER(int, pfnOpen, (void *pvUser, const char *pszLocation, bool fReadonly,
|
---|
437 | PFNVDCOMPLETED pfnCompleted, void **ppStorage));
|
---|
438 |
|
---|
439 | /**
|
---|
440 | * Close callback.
|
---|
441 | *
|
---|
442 | * @return VBox status code.
|
---|
443 | * @param pvUser The opaque data passed on container creation.
|
---|
444 | * @param pStorage The opaque storage handle to close.
|
---|
445 | */
|
---|
446 | DECLR3CALLBACKMEMBER(int, pfnClose, (void *pvUser, void *pStorage));
|
---|
447 |
|
---|
448 | /**
|
---|
449 | * Returns the size of the opened storage backend.
|
---|
450 | *
|
---|
451 | * @return VBox status code.
|
---|
452 | * @param pvUser The opaque data passed on container creation.
|
---|
453 | * @param pStorage The opaque storage handle to close.
|
---|
454 | * @param pcbSize Where to store the size of the storage backend.
|
---|
455 | */
|
---|
456 | DECLR3CALLBACKMEMBER(int, pfnGetSize, (void *pvUser, void *pStorage, uint64_t *pcbSize));
|
---|
457 |
|
---|
458 | /**
|
---|
459 | * Synchronous write callback.
|
---|
460 | *
|
---|
461 | * @return VBox status code.
|
---|
462 | * @param pvUser The opaque data passed on container creation.
|
---|
463 | * @param pStorage The storage handle to use.
|
---|
464 | * @param uOffset The offset to start from.
|
---|
465 | * @param cbWrite How many bytes to write.
|
---|
466 | * @param pvBuf Pointer to the bits need to be written.
|
---|
467 | * @param pcbWritten Where to store how many bytes where actually written.
|
---|
468 | */
|
---|
469 | DECLR3CALLBACKMEMBER(int, pfnWriteSync, (void *pvUser, void *pStorage, uint64_t uOffset,
|
---|
470 | size_t cbWrite, const void *pvBuf, size_t *pcbWritten));
|
---|
471 |
|
---|
472 | /**
|
---|
473 | * Synchronous read callback.
|
---|
474 | *
|
---|
475 | * @return VBox status code.
|
---|
476 | * @param pvUser The opaque data passed on container creation.
|
---|
477 | * @param pStorage The storage handle to use.
|
---|
478 | * @param uOffset The offset to start from.
|
---|
479 | * @param cbRead How many bytes to read.
|
---|
480 | * @param pvBuf Where to store the read bits.
|
---|
481 | * @param pcbRead Where to store how many bytes where actually read.
|
---|
482 | */
|
---|
483 | DECLR3CALLBACKMEMBER(int, pfnReadSync, (void *pvUser, void *pStorage, uint64_t uOffset,
|
---|
484 | size_t cbRead, void *pvBuf, size_t *pcbRead));
|
---|
485 |
|
---|
486 | /**
|
---|
487 | * Flush data to the storage backend.
|
---|
488 | *
|
---|
489 | * @return VBox statis code.
|
---|
490 | * @param pvUser The opaque data passed on container creation.
|
---|
491 | * @param pStorage The storage handle to flush.
|
---|
492 | */
|
---|
493 | DECLR3CALLBACKMEMBER(int, pfnFlushSync, (void *pvUser, void *pStorage));
|
---|
494 |
|
---|
495 | /**
|
---|
496 | * Initiate a asynchronous read request.
|
---|
497 | *
|
---|
498 | * @return VBox status code.
|
---|
499 | * @param pvUser The opqaue user data passed on container creation.
|
---|
500 | * @param pStorage The storage handle.
|
---|
501 | * @param uOffset The offset to start reading from.
|
---|
502 | * @param paSegments Scatter gather list to store the data in.
|
---|
503 | * @param cSegments Number of segments in the list.
|
---|
504 | * @param cbRead How many bytes to read.
|
---|
505 | * @param pvCompletion The opaque user data which is returned upon completion.
|
---|
506 | * @param ppTask Where to store the opaque task handle.
|
---|
507 | */
|
---|
508 | DECLR3CALLBACKMEMBER(int, pfnReadAsync, (void *pvUser, void *pStorage, uint64_t uOffset,
|
---|
509 | PCPDMDATASEG paSegments, size_t cSegments,
|
---|
510 | size_t cbRead, void *pvCompletion,
|
---|
511 | void **ppTask));
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * Initiate a asynchronous write request.
|
---|
515 | *
|
---|
516 | * @return VBox status code.
|
---|
517 | * @param pvUser The opaque user data passed on conatiner creation.
|
---|
518 | * @param pStorage The storage handle.
|
---|
519 | * @param uOffset The offset to start writing to.
|
---|
520 | * @param paSegments Scatter gather list of the data to write
|
---|
521 | * @param cSegments Number of segments in the list.
|
---|
522 | * @param cbWrite How many bytes to write.
|
---|
523 | * @param pvCompletion The opaque user data which is returned upon completion.
|
---|
524 | * @param ppTask Where to store the opaque task handle.
|
---|
525 | */
|
---|
526 | DECLR3CALLBACKMEMBER(int, pfnWriteAsync, (void *pvUser, void *pStorage, uint64_t uOffset,
|
---|
527 | PCPDMDATASEG paSegments, size_t cSegments,
|
---|
528 | size_t cbWrite, void *pvCompletion,
|
---|
529 | void **ppTask));
|
---|
530 |
|
---|
531 | /**
|
---|
532 | * Initiates a async flush request.
|
---|
533 | *
|
---|
534 | * @return VBox statis code.
|
---|
535 | * @param pvUser The opaque data passed on container creation.
|
---|
536 | * @param pStorage The storage handle to flush.
|
---|
537 | * @param pvCompletion The opaque user data which is returned upon completion.
|
---|
538 | * @param ppTask Where to store the opaque task handle.
|
---|
539 | */
|
---|
540 | DECLR3CALLBACKMEMBER(int, pfnFlushAsync, (void *pvUser, void *pStorage,
|
---|
541 | void *pvCompletion, void **ppTask));
|
---|
542 |
|
---|
543 | } VDINTERFACEASYNCIO, *PVDINTERFACEASYNCIO;
|
---|
544 |
|
---|
545 | /**
|
---|
546 | * Get async I/O interface from opaque callback table.
|
---|
547 | *
|
---|
548 | * @return Pointer to the callback table.
|
---|
549 | * @param pInterface Pointer to the interface descriptor.
|
---|
550 | */
|
---|
551 | DECLINLINE(PVDINTERFACEASYNCIO) VDGetInterfaceAsyncIO(PVDINTERFACE pInterface)
|
---|
552 | {
|
---|
553 | /* Check that the interface descriptor is a async I/O interface. */
|
---|
554 | AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_ASYNCIO)
|
---|
555 | && (pInterface->cbSize == sizeof(VDINTERFACE)),
|
---|
556 | ("Not an async I/O interface"), NULL);
|
---|
557 |
|
---|
558 | PVDINTERFACEASYNCIO pInterfaceAsyncIO = (PVDINTERFACEASYNCIO)pInterface->pCallbacks;
|
---|
559 |
|
---|
560 | /* Do basic checks. */
|
---|
561 | AssertMsgReturn( (pInterfaceAsyncIO->cbSize == sizeof(VDINTERFACEASYNCIO))
|
---|
562 | && (pInterfaceAsyncIO->enmInterface == VDINTERFACETYPE_ASYNCIO),
|
---|
563 | ("A non async I/O callback table attached to a async I/O interface descriptor\n"), NULL);
|
---|
564 |
|
---|
565 | return pInterfaceAsyncIO;
|
---|
566 | }
|
---|
567 |
|
---|
568 | /**
|
---|
569 | * Progress notification interface
|
---|
570 | *
|
---|
571 | * Per-operation. Optional.
|
---|
572 | */
|
---|
573 | typedef struct VDINTERFACEPROGRESS
|
---|
574 | {
|
---|
575 | /**
|
---|
576 | * Size of the progress interface.
|
---|
577 | */
|
---|
578 | uint32_t cbSize;
|
---|
579 |
|
---|
580 | /**
|
---|
581 | * Interface type.
|
---|
582 | */
|
---|
583 | VDINTERFACETYPE enmInterface;
|
---|
584 |
|
---|
585 | /**
|
---|
586 | * Progress notification callbacks.
|
---|
587 | * @todo r=bird: Why the heck are we using PFNVMPROGRESS here?
|
---|
588 | */
|
---|
589 | PFNVMPROGRESS pfnProgress;
|
---|
590 | } VDINTERFACEPROGRESS, *PVDINTERFACEPROGRESS;
|
---|
591 |
|
---|
592 | /**
|
---|
593 | * Get progress interface from opaque callback table.
|
---|
594 | *
|
---|
595 | * @return Pointer to the callback table.
|
---|
596 | * @param pInterface Pointer to the interface descriptor.
|
---|
597 | */
|
---|
598 | DECLINLINE(PVDINTERFACEPROGRESS) VDGetInterfaceProgress(PVDINTERFACE pInterface)
|
---|
599 | {
|
---|
600 | /* Check that the interface descriptor is a progress interface. */
|
---|
601 | AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_PROGRESS)
|
---|
602 | && (pInterface->cbSize == sizeof(VDINTERFACE)),
|
---|
603 | ("Not a progress interface"), NULL);
|
---|
604 |
|
---|
605 |
|
---|
606 | PVDINTERFACEPROGRESS pInterfaceProgress = (PVDINTERFACEPROGRESS)pInterface->pCallbacks;
|
---|
607 |
|
---|
608 | /* Do basic checks. */
|
---|
609 | AssertMsgReturn( (pInterfaceProgress->cbSize == sizeof(VDINTERFACEPROGRESS))
|
---|
610 | && (pInterfaceProgress->enmInterface == VDINTERFACETYPE_PROGRESS),
|
---|
611 | ("A non progress callback table attached to a progress interface descriptor\n"), NULL);
|
---|
612 |
|
---|
613 | return pInterfaceProgress;
|
---|
614 | }
|
---|
615 |
|
---|
616 |
|
---|
617 | /**
|
---|
618 | * Configuration information interface
|
---|
619 | *
|
---|
620 | * Per-image. Optional for most backends, but mandatory for images which do
|
---|
621 | * not operate on files (including standard block or character devices).
|
---|
622 | */
|
---|
623 | typedef struct VDINTERFACECONFIG
|
---|
624 | {
|
---|
625 | /**
|
---|
626 | * Size of the configuration interface.
|
---|
627 | */
|
---|
628 | uint32_t cbSize;
|
---|
629 |
|
---|
630 | /**
|
---|
631 | * Interface type.
|
---|
632 | */
|
---|
633 | VDINTERFACETYPE enmInterface;
|
---|
634 |
|
---|
635 | /**
|
---|
636 | * Validates that the keys are within a set of valid names.
|
---|
637 | *
|
---|
638 | * @return true if all key names are found in pszzAllowed.
|
---|
639 | * @return false if not.
|
---|
640 | * @param pvUser The opaque user data associated with this interface.
|
---|
641 | * @param pszzValid List of valid key names separated by '\\0' and ending with
|
---|
642 | * a double '\\0'.
|
---|
643 | */
|
---|
644 | DECLR3CALLBACKMEMBER(bool, pfnAreKeysValid, (void *pvUser, const char *pszzValid));
|
---|
645 |
|
---|
646 | /**
|
---|
647 | * Retrieves the length of the string value associated with a key (including
|
---|
648 | * the terminator, for compatibility with CFGMR3QuerySize).
|
---|
649 | *
|
---|
650 | * @return VBox status code.
|
---|
651 | * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known.
|
---|
652 | * @param pvUser The opaque user data associated with this interface.
|
---|
653 | * @param pszName Name of the key to query.
|
---|
654 | * @param pcbValue Where to store the value length. Non-NULL.
|
---|
655 | */
|
---|
656 | DECLR3CALLBACKMEMBER(int, pfnQuerySize, (void *pvUser, const char *pszName, size_t *pcbValue));
|
---|
657 |
|
---|
658 | /**
|
---|
659 | * Query the string value associated with a key.
|
---|
660 | *
|
---|
661 | * @return VBox status code.
|
---|
662 | * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known.
|
---|
663 | * VERR_CFGM_NOT_ENOUGH_SPACE means that the buffer is not big enough.
|
---|
664 | * @param pvUser The opaque user data associated with this interface.
|
---|
665 | * @param pszName Name of the key to query.
|
---|
666 | * @param pszValue Pointer to buffer where to store value.
|
---|
667 | * @param cchValue Length of value buffer.
|
---|
668 | */
|
---|
669 | DECLR3CALLBACKMEMBER(int, pfnQuery, (void *pvUser, const char *pszName, char *pszValue, size_t cchValue));
|
---|
670 | } VDINTERFACECONFIG, *PVDINTERFACECONFIG;
|
---|
671 |
|
---|
672 | /**
|
---|
673 | * Get configuration information interface from opaque callback table.
|
---|
674 | *
|
---|
675 | * @return Pointer to the callback table.
|
---|
676 | * @param pInterface Pointer to the interface descriptor.
|
---|
677 | */
|
---|
678 | DECLINLINE(PVDINTERFACECONFIG) VDGetInterfaceConfig(PVDINTERFACE pInterface)
|
---|
679 | {
|
---|
680 | /* Check that the interface descriptor is a config interface. */
|
---|
681 | AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_CONFIG)
|
---|
682 | && (pInterface->cbSize == sizeof(VDINTERFACE)),
|
---|
683 | ("Not a config interface"), NULL);
|
---|
684 |
|
---|
685 | PVDINTERFACECONFIG pInterfaceConfig = (PVDINTERFACECONFIG)pInterface->pCallbacks;
|
---|
686 |
|
---|
687 | /* Do basic checks. */
|
---|
688 | AssertMsgReturn( (pInterfaceConfig->cbSize == sizeof(VDINTERFACECONFIG))
|
---|
689 | && (pInterfaceConfig->enmInterface == VDINTERFACETYPE_CONFIG),
|
---|
690 | ("A non config callback table attached to a config interface descriptor\n"), NULL);
|
---|
691 |
|
---|
692 | return pInterfaceConfig;
|
---|
693 | }
|
---|
694 |
|
---|
695 | /**
|
---|
696 | * Query configuration, validates that the keys are within a set of valid names.
|
---|
697 | *
|
---|
698 | * @return true if all key names are found in pszzAllowed.
|
---|
699 | * @return false if not.
|
---|
700 | * @param pCfgIf Pointer to configuration callback table.
|
---|
701 | * @param pvUser The opaque user data associated with this interface.
|
---|
702 | * @param pszzValid List of valid names separated by '\\0' and ending with
|
---|
703 | * a double '\\0'.
|
---|
704 | */
|
---|
705 | DECLINLINE(bool) VDCFGAreKeysValid(PVDINTERFACECONFIG pCfgIf, void *pvUser,
|
---|
706 | const char *pszzValid)
|
---|
707 | {
|
---|
708 | return pCfgIf->pfnAreKeysValid(pvUser, pszzValid);
|
---|
709 | }
|
---|
710 |
|
---|
711 | /**
|
---|
712 | * Query configuration, unsigned 64-bit integer value with default.
|
---|
713 | *
|
---|
714 | * @return VBox status code.
|
---|
715 | * @param pCfgIf Pointer to configuration callback table.
|
---|
716 | * @param pvUser The opaque user data associated with this interface.
|
---|
717 | * @param pszName Name of an integer value
|
---|
718 | * @param pu64 Where to store the value. Set to default on failure.
|
---|
719 | * @param u64Def The default value.
|
---|
720 | */
|
---|
721 | DECLINLINE(int) VDCFGQueryU64Def(PVDINTERFACECONFIG pCfgIf, void *pvUser,
|
---|
722 | const char *pszName, uint64_t *pu64,
|
---|
723 | uint64_t u64Def)
|
---|
724 | {
|
---|
725 | char aszBuf[32];
|
---|
726 | int rc = pCfgIf->pfnQuery(pvUser, pszName, aszBuf, sizeof(aszBuf));
|
---|
727 | if (RT_SUCCESS(rc))
|
---|
728 | {
|
---|
729 | rc = RTStrToUInt64Full(aszBuf, 0, pu64);
|
---|
730 | }
|
---|
731 | else if (rc == VERR_CFGM_VALUE_NOT_FOUND)
|
---|
732 | {
|
---|
733 | rc = VINF_SUCCESS;
|
---|
734 | *pu64 = u64Def;
|
---|
735 | }
|
---|
736 | return rc;
|
---|
737 | }
|
---|
738 |
|
---|
739 | /**
|
---|
740 | * Query configuration, unsigned 32-bit integer value with default.
|
---|
741 | *
|
---|
742 | * @return VBox status code.
|
---|
743 | * @param pCfgIf Pointer to configuration callback table.
|
---|
744 | * @param pvUser The opaque user data associated with this interface.
|
---|
745 | * @param pszName Name of an integer value
|
---|
746 | * @param pu32 Where to store the value. Set to default on failure.
|
---|
747 | * @param u32Def The default value.
|
---|
748 | */
|
---|
749 | DECLINLINE(int) VDCFGQueryU32Def(PVDINTERFACECONFIG pCfgIf, void *pvUser,
|
---|
750 | const char *pszName, uint32_t *pu32,
|
---|
751 | uint32_t u32Def)
|
---|
752 | {
|
---|
753 | uint64_t u64;
|
---|
754 | int rc = VDCFGQueryU64Def(pCfgIf, pvUser, pszName, &u64, u32Def);
|
---|
755 | if (RT_SUCCESS(rc))
|
---|
756 | {
|
---|
757 | if (!(u64 & UINT64_C(0xffffffff00000000)))
|
---|
758 | *pu32 = (uint32_t)u64;
|
---|
759 | else
|
---|
760 | rc = VERR_CFGM_INTEGER_TOO_BIG;
|
---|
761 | }
|
---|
762 | return rc;
|
---|
763 | }
|
---|
764 |
|
---|
765 | /**
|
---|
766 | * Query configuration, bool value with default.
|
---|
767 | *
|
---|
768 | * @return VBox status code.
|
---|
769 | * @param pCfgIf Pointer to configuration callback table.
|
---|
770 | * @param pvUser The opaque user data associated with this interface.
|
---|
771 | * @param pszName Name of an integer value
|
---|
772 | * @param pf Where to store the value. Set to default on failure.
|
---|
773 | * @param fDef The default value.
|
---|
774 | */
|
---|
775 | DECLINLINE(int) VDCFGQueryBoolDef(PVDINTERFACECONFIG pCfgIf, void *pvUser,
|
---|
776 | const char *pszName, bool *pf,
|
---|
777 | bool fDef)
|
---|
778 | {
|
---|
779 | uint64_t u64;
|
---|
780 | int rc = VDCFGQueryU64Def(pCfgIf, pvUser, pszName, &u64, fDef);
|
---|
781 | if (RT_SUCCESS(rc))
|
---|
782 | *pf = u64 ? true : false;
|
---|
783 | return rc;
|
---|
784 | }
|
---|
785 |
|
---|
786 | /**
|
---|
787 | * Query configuration, dynamically allocated (RTMemAlloc) zero terminated
|
---|
788 | * character value.
|
---|
789 | *
|
---|
790 | * @return VBox status code.
|
---|
791 | * @param pCfgIf Pointer to configuration callback table.
|
---|
792 | * @param pvUser The opaque user data associated with this interface.
|
---|
793 | * @param pszName Name of an zero terminated character value
|
---|
794 | * @param ppszString Where to store the string pointer. Not set on failure.
|
---|
795 | * Free this using RTMemFree().
|
---|
796 | */
|
---|
797 | DECLINLINE(int) VDCFGQueryStringAlloc(PVDINTERFACECONFIG pCfgIf,
|
---|
798 | void *pvUser, const char *pszName,
|
---|
799 | char **ppszString)
|
---|
800 | {
|
---|
801 | size_t cb;
|
---|
802 | int rc = pCfgIf->pfnQuerySize(pvUser, pszName, &cb);
|
---|
803 | if (RT_SUCCESS(rc))
|
---|
804 | {
|
---|
805 | char *pszString = (char *)RTMemAlloc(cb);
|
---|
806 | if (pszString)
|
---|
807 | {
|
---|
808 | rc = pCfgIf->pfnQuery(pvUser, pszName, pszString, cb);
|
---|
809 | if (RT_SUCCESS(rc))
|
---|
810 | *ppszString = pszString;
|
---|
811 | else
|
---|
812 | RTMemFree(pszString);
|
---|
813 | }
|
---|
814 | else
|
---|
815 | rc = VERR_NO_MEMORY;
|
---|
816 | }
|
---|
817 | return rc;
|
---|
818 | }
|
---|
819 |
|
---|
820 | /**
|
---|
821 | * Query configuration, dynamically allocated (RTMemAlloc) zero terminated
|
---|
822 | * character value with default.
|
---|
823 | *
|
---|
824 | * @return VBox status code.
|
---|
825 | * @param pCfgIf Pointer to configuration callback table.
|
---|
826 | * @param pvUser The opaque user data associated with this interface.
|
---|
827 | * @param pszName Name of an zero terminated character value
|
---|
828 | * @param ppszString Where to store the string pointer. Not set on failure.
|
---|
829 | * Free this using RTMemFree().
|
---|
830 | * @param pszDef The default value.
|
---|
831 | */
|
---|
832 | DECLINLINE(int) VDCFGQueryStringAllocDef(PVDINTERFACECONFIG pCfgIf,
|
---|
833 | void *pvUser, const char *pszName,
|
---|
834 | char **ppszString,
|
---|
835 | const char *pszDef)
|
---|
836 | {
|
---|
837 | size_t cb;
|
---|
838 | int rc = pCfgIf->pfnQuerySize(pvUser, pszName, &cb);
|
---|
839 | if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
|
---|
840 | {
|
---|
841 | cb = strlen(pszDef) + 1;
|
---|
842 | rc = VINF_SUCCESS;
|
---|
843 | }
|
---|
844 | if (RT_SUCCESS(rc))
|
---|
845 | {
|
---|
846 | char *pszString = (char *)RTMemAlloc(cb);
|
---|
847 | if (pszString)
|
---|
848 | {
|
---|
849 | rc = pCfgIf->pfnQuery(pvUser, pszName, pszString, cb);
|
---|
850 | if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
|
---|
851 | {
|
---|
852 | memcpy(pszString, pszDef, cb);
|
---|
853 | rc = VINF_SUCCESS;
|
---|
854 | }
|
---|
855 | if (RT_SUCCESS(rc))
|
---|
856 | *ppszString = pszString;
|
---|
857 | else
|
---|
858 | RTMemFree(pszString);
|
---|
859 | }
|
---|
860 | else
|
---|
861 | rc = VERR_NO_MEMORY;
|
---|
862 | }
|
---|
863 | return rc;
|
---|
864 | }
|
---|
865 |
|
---|
866 | /**
|
---|
867 | * Query configuration, dynamically allocated (RTMemAlloc) byte string value.
|
---|
868 | *
|
---|
869 | * @return VBox status code.
|
---|
870 | * @param pCfgIf Pointer to configuration callback table.
|
---|
871 | * @param pvUser The opaque user data associated with this interface.
|
---|
872 | * @param pszName Name of an zero terminated character value
|
---|
873 | * @param ppvData Where to store the byte string pointer. Not set on failure.
|
---|
874 | * Free this using RTMemFree().
|
---|
875 | * @param pcbData Where to store the byte string length.
|
---|
876 | */
|
---|
877 | DECLINLINE(int) VDCFGQueryBytesAlloc(PVDINTERFACECONFIG pCfgIf,
|
---|
878 | void *pvUser, const char *pszName,
|
---|
879 | void **ppvData, size_t *pcbData)
|
---|
880 | {
|
---|
881 | size_t cb;
|
---|
882 | int rc = pCfgIf->pfnQuerySize(pvUser, pszName, &cb);
|
---|
883 | if (RT_SUCCESS(rc))
|
---|
884 | {
|
---|
885 | char *pvData = (char *)RTMemAlloc(cb);
|
---|
886 | if (pvData)
|
---|
887 | {
|
---|
888 | rc = pCfgIf->pfnQuery(pvUser, pszName, pvData, cb);
|
---|
889 | if (RT_SUCCESS(rc))
|
---|
890 | {
|
---|
891 | *ppvData = pvData;
|
---|
892 | *pcbData = cb;
|
---|
893 | }
|
---|
894 | else
|
---|
895 | RTMemFree(pvData);
|
---|
896 | }
|
---|
897 | else
|
---|
898 | rc = VERR_NO_MEMORY;
|
---|
899 | }
|
---|
900 | return rc;
|
---|
901 | }
|
---|
902 |
|
---|
903 |
|
---|
904 | /**
|
---|
905 | * TCP network stack interface
|
---|
906 | *
|
---|
907 | * Per-disk. Mandatory for backends which have the VD_CAP_TCPNET bit set.
|
---|
908 | */
|
---|
909 | typedef struct VDINTERFACETCPNET
|
---|
910 | {
|
---|
911 | /**
|
---|
912 | * Size of the configuration interface.
|
---|
913 | */
|
---|
914 | uint32_t cbSize;
|
---|
915 |
|
---|
916 | /**
|
---|
917 | * Interface type.
|
---|
918 | */
|
---|
919 | VDINTERFACETYPE enmInterface;
|
---|
920 |
|
---|
921 | /**
|
---|
922 | * Connect as a client to a TCP port.
|
---|
923 | *
|
---|
924 | * @return iprt status code.
|
---|
925 | * @param pszAddress The address to connect to.
|
---|
926 | * @param uPort The port to connect to.
|
---|
927 | * @param pSock Where to store the handle to the established connect
|
---|
928 | ion.
|
---|
929 | */
|
---|
930 | DECLR3CALLBACKMEMBER(int, pfnClientConnect, (const char *pszAddress, uint32_t uPort, PRTSOCKET pSock));
|
---|
931 |
|
---|
932 | /**
|
---|
933 | * Close a TCP connection.
|
---|
934 | *
|
---|
935 | * @return iprt status code.
|
---|
936 | * @param Sock Socket descriptor.
|
---|
937 | ion.
|
---|
938 | */
|
---|
939 | DECLR3CALLBACKMEMBER(int, pfnClientClose, (RTSOCKET Sock));
|
---|
940 |
|
---|
941 | /**
|
---|
942 | * Socket I/O multiplexing.
|
---|
943 | * Checks if the socket is ready for reading.
|
---|
944 | *
|
---|
945 | * @return iprt status code.
|
---|
946 | * @param Sock Socket descriptor.
|
---|
947 | * @param cMillies Number of milliseconds to wait for the socket.
|
---|
948 | * Use RT_INDEFINITE_WAIT to wait for ever.
|
---|
949 | */
|
---|
950 | DECLR3CALLBACKMEMBER(int, pfnSelectOne, (RTSOCKET Sock, unsigned cMillies));
|
---|
951 |
|
---|
952 | /**
|
---|
953 | * Receive data from a socket.
|
---|
954 | *
|
---|
955 | * @return iprt status code.
|
---|
956 | * @param Sock Socket descriptor.
|
---|
957 | * @param pvBuffer Where to put the data we read.
|
---|
958 | * @param cbBuffer Read buffer size.
|
---|
959 | * @param pcbRead Number of bytes read.
|
---|
960 | * If NULL the entire buffer will be filled upon successful return.
|
---|
961 | * If not NULL a partial read can be done successfully.
|
---|
962 | */
|
---|
963 | DECLR3CALLBACKMEMBER(int, pfnRead, (RTSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead));
|
---|
964 |
|
---|
965 | /**
|
---|
966 | * Send data from a socket.
|
---|
967 | *
|
---|
968 | * @return iprt status code.
|
---|
969 | * @param Sock Socket descriptor.
|
---|
970 | * @param pvBuffer Buffer to write data to socket.
|
---|
971 | * @param cbBuffer How much to write.
|
---|
972 | * @param pcbRead Number of bytes read.
|
---|
973 | */
|
---|
974 | DECLR3CALLBACKMEMBER(int, pfnWrite, (RTSOCKET Sock, const void *pvBuffer, size_t cbBuffer));
|
---|
975 |
|
---|
976 | /**
|
---|
977 | * Flush socket write buffers.
|
---|
978 | *
|
---|
979 | * @return iprt status code.
|
---|
980 | * @param Sock Socket descriptor.
|
---|
981 | */
|
---|
982 | DECLR3CALLBACKMEMBER(int, pfnFlush, (RTSOCKET Sock));
|
---|
983 |
|
---|
984 | } VDINTERFACETCPNET, *PVDINTERFACETCPNET;
|
---|
985 |
|
---|
986 | /**
|
---|
987 | * Get TCP network stack interface from opaque callback table.
|
---|
988 | *
|
---|
989 | * @return Pointer to the callback table.
|
---|
990 | * @param pInterface Pointer to the interface descriptor.
|
---|
991 | */
|
---|
992 | DECLINLINE(PVDINTERFACETCPNET) VDGetInterfaceTcpNet(PVDINTERFACE pInterface)
|
---|
993 | {
|
---|
994 | /* Check that the interface descriptor is a TCP network stack interface. */
|
---|
995 | AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_TCPNET)
|
---|
996 | && (pInterface->cbSize == sizeof(VDINTERFACE)),
|
---|
997 | ("Not a TCP network stack interface"), NULL);
|
---|
998 |
|
---|
999 | PVDINTERFACETCPNET pInterfaceTcpNet = (PVDINTERFACETCPNET)pInterface->pCallbacks;
|
---|
1000 |
|
---|
1001 | /* Do basic checks. */
|
---|
1002 | AssertMsgReturn( (pInterfaceTcpNet->cbSize == sizeof(VDINTERFACETCPNET))
|
---|
1003 | && (pInterfaceTcpNet->enmInterface == VDINTERFACETYPE_TCPNET),
|
---|
1004 | ("A non TCP network stack callback table attached to a TCP network stack interface descriptor\n"), NULL);
|
---|
1005 |
|
---|
1006 | return pInterfaceTcpNet;
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | /**
|
---|
1010 | * Interface to get the parent state.
|
---|
1011 | *
|
---|
1012 | * Per operation interface. Optional, present only if there is a parent, and
|
---|
1013 | * used only internally for compacting.
|
---|
1014 | */
|
---|
1015 | typedef struct VDINTERFACEPARENTSTATE
|
---|
1016 | {
|
---|
1017 | /**
|
---|
1018 | * Size of the parent state interface.
|
---|
1019 | */
|
---|
1020 | uint32_t cbSize;
|
---|
1021 |
|
---|
1022 | /**
|
---|
1023 | * Interface type.
|
---|
1024 | */
|
---|
1025 | VDINTERFACETYPE enmInterface;
|
---|
1026 |
|
---|
1027 | /**
|
---|
1028 | * Read data callback.
|
---|
1029 | *
|
---|
1030 | * @return VBox status code.
|
---|
1031 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
1032 | * @param pvUser The opaque data passed for the operation.
|
---|
1033 | * @param uOffset Offset of first reading byte from start of disk.
|
---|
1034 | * Must be aligned to a sector boundary.
|
---|
1035 | * @param pvBuf Pointer to buffer for reading data.
|
---|
1036 | * @param cbRead Number of bytes to read.
|
---|
1037 | * Must be aligned to a sector boundary.
|
---|
1038 | */
|
---|
1039 | DECLR3CALLBACKMEMBER(int, pfnParentRead, (void *pvUser, uint64_t uOffset, void *pvBuf, size_t cbRead));
|
---|
1040 |
|
---|
1041 | } VDINTERFACEPARENTSTATE, *PVDINTERFACEPARENTSTATE;
|
---|
1042 |
|
---|
1043 |
|
---|
1044 | /**
|
---|
1045 | * Get parent state interface from opaque callback table.
|
---|
1046 | *
|
---|
1047 | * @return Pointer to the callback table.
|
---|
1048 | * @param pInterface Pointer to the interface descriptor.
|
---|
1049 | */
|
---|
1050 | DECLINLINE(PVDINTERFACEPARENTSTATE) VDGetInterfaceParentState(PVDINTERFACE pInterface)
|
---|
1051 | {
|
---|
1052 | /* Check that the interface descriptor is a parent state interface. */
|
---|
1053 | AssertMsgReturn( (pInterface->enmInterface == VDINTERFACETYPE_PARENTSTATE)
|
---|
1054 | && (pInterface->cbSize == sizeof(VDINTERFACE)),
|
---|
1055 | ("Not a parent state interface"), NULL);
|
---|
1056 |
|
---|
1057 | PVDINTERFACEPARENTSTATE pInterfaceParentState = (PVDINTERFACEPARENTSTATE)pInterface->pCallbacks;
|
---|
1058 |
|
---|
1059 | /* Do basic checks. */
|
---|
1060 | AssertMsgReturn( (pInterfaceParentState->cbSize == sizeof(VDINTERFACEPARENTSTATE))
|
---|
1061 | && (pInterfaceParentState->enmInterface == VDINTERFACETYPE_PARENTSTATE),
|
---|
1062 | ("A non parent state callback table attached to a parent state interface descriptor\n"), NULL);
|
---|
1063 |
|
---|
1064 | return pInterfaceParentState;
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 |
|
---|
1068 | /** @name Configuration interface key handling flags.
|
---|
1069 | * @{
|
---|
1070 | */
|
---|
1071 | /** Mandatory config key. Not providing a value for this key will cause
|
---|
1072 | * the backend to fail. */
|
---|
1073 | #define VD_CFGKEY_MANDATORY RT_BIT(0)
|
---|
1074 | /** Expert config key. Not showing it by default in the GUI is is probably
|
---|
1075 | * a good idea, as the average user won't understand it easily. */
|
---|
1076 | #define VD_CFGKEY_EXPERT RT_BIT(1)
|
---|
1077 | /** @}*/
|
---|
1078 |
|
---|
1079 |
|
---|
1080 | /**
|
---|
1081 | * Configuration value type for configuration information interface.
|
---|
1082 | */
|
---|
1083 | typedef enum VDCFGVALUETYPE
|
---|
1084 | {
|
---|
1085 | /** Integer value. */
|
---|
1086 | VDCFGVALUETYPE_INTEGER = 1,
|
---|
1087 | /** String value. */
|
---|
1088 | VDCFGVALUETYPE_STRING,
|
---|
1089 | /** Bytestring value. */
|
---|
1090 | VDCFGVALUETYPE_BYTES
|
---|
1091 | } VDCFGVALUETYPE;
|
---|
1092 |
|
---|
1093 |
|
---|
1094 | /**
|
---|
1095 | * Structure describing configuration keys required/supported by a backend
|
---|
1096 | * through the config interface.
|
---|
1097 | */
|
---|
1098 | typedef struct VDCONFIGINFO
|
---|
1099 | {
|
---|
1100 | /** Key name of the configuration. */
|
---|
1101 | const char *pszKey;
|
---|
1102 | /** Pointer to default value (descriptor). NULL if no useful default value
|
---|
1103 | * can be specified. */
|
---|
1104 | const char *pszDefaultValue;
|
---|
1105 | /** Value type for this key. */
|
---|
1106 | VDCFGVALUETYPE enmValueType;
|
---|
1107 | /** Key handling flags (a combination of VD_CFGKEY_* flags). */
|
---|
1108 | uint64_t uKeyFlags;
|
---|
1109 | } VDCONFIGINFO;
|
---|
1110 |
|
---|
1111 | /** Pointer to structure describing configuration keys. */
|
---|
1112 | typedef VDCONFIGINFO *PVDCONFIGINFO;
|
---|
1113 |
|
---|
1114 | /** Pointer to const structure describing configuration keys. */
|
---|
1115 | typedef const VDCONFIGINFO *PCVDCONFIGINFO;
|
---|
1116 |
|
---|
1117 | /**
|
---|
1118 | * Data structure for returning a list of backend capabilities.
|
---|
1119 | */
|
---|
1120 | typedef struct VDBACKENDINFO
|
---|
1121 | {
|
---|
1122 | /** Name of the backend. Must be unique even with case insensitive comparison. */
|
---|
1123 | const char *pszBackend;
|
---|
1124 | /** Capabilities of the backend (a combination of the VD_CAP_* flags). */
|
---|
1125 | uint64_t uBackendCaps;
|
---|
1126 | /** Pointer to a NULL-terminated array of strings, containing the supported
|
---|
1127 | * file extensions. Note that some backends do not work on files, so this
|
---|
1128 | * pointer may just contain NULL. */
|
---|
1129 | const char * const *papszFileExtensions;
|
---|
1130 | /** Pointer to an array of structs describing each supported config key.
|
---|
1131 | * Terminated by a NULL config key. Note that some backends do not support
|
---|
1132 | * the configuration interface, so this pointer may just contain NULL.
|
---|
1133 | * Mandatory if the backend sets VD_CAP_CONFIG. */
|
---|
1134 | PCVDCONFIGINFO paConfigInfo;
|
---|
1135 | /** Returns a human readable hard disk location string given a
|
---|
1136 | * set of hard disk configuration keys. The returned string is an
|
---|
1137 | * equivalent of the full file path for image-based hard disks.
|
---|
1138 | * Mandatory for backends with no VD_CAP_FILE and NULL otherwise. */
|
---|
1139 | DECLR3CALLBACKMEMBER(int, pfnComposeLocation, (PVDINTERFACE pConfig, char **pszLocation));
|
---|
1140 | /** Returns a human readable hard disk name string given a
|
---|
1141 | * set of hard disk configuration keys. The returned string is an
|
---|
1142 | * equivalent of the file name part in the full file path for
|
---|
1143 | * image-based hard disks. Mandatory for backends with no
|
---|
1144 | * VD_CAP_FILE and NULL otherwise. */
|
---|
1145 | DECLR3CALLBACKMEMBER(int, pfnComposeName, (PVDINTERFACE pConfig, char **pszName));
|
---|
1146 | } VDBACKENDINFO, *PVDBACKENDINFO;
|
---|
1147 |
|
---|
1148 |
|
---|
1149 | /**
|
---|
1150 | * VBox HDD Container main structure.
|
---|
1151 | */
|
---|
1152 | /* Forward declaration, VBOXHDD structure is visible only inside VBox HDD module. */
|
---|
1153 | struct VBOXHDD;
|
---|
1154 | typedef struct VBOXHDD VBOXHDD;
|
---|
1155 | typedef VBOXHDD *PVBOXHDD;
|
---|
1156 |
|
---|
1157 | /**
|
---|
1158 | * Initializes HDD backends.
|
---|
1159 | *
|
---|
1160 | * @returns VBox status code.
|
---|
1161 | */
|
---|
1162 | VBOXDDU_DECL(int) VDInit(void);
|
---|
1163 |
|
---|
1164 | /**
|
---|
1165 | * Destroys loaded HDD backends.
|
---|
1166 | *
|
---|
1167 | * @returns VBox status code.
|
---|
1168 | */
|
---|
1169 | VBOXDDU_DECL(int) VDShutdown(void);
|
---|
1170 |
|
---|
1171 | /**
|
---|
1172 | * Lists all HDD backends and their capabilities in a caller-provided buffer.
|
---|
1173 | * Free all returned names with RTStrFree() when you no longer need them.
|
---|
1174 | *
|
---|
1175 | * @return VBox status code.
|
---|
1176 | * VERR_BUFFER_OVERFLOW if not enough space is passed.
|
---|
1177 | * @param cEntriesAlloc Number of list entries available.
|
---|
1178 | * @param pEntries Pointer to array for the entries.
|
---|
1179 | * @param pcEntriesUsed Number of entries returned.
|
---|
1180 | */
|
---|
1181 | VBOXDDU_DECL(int) VDBackendInfo(unsigned cEntriesAlloc, PVDBACKENDINFO pEntries,
|
---|
1182 | unsigned *pcEntriesUsed);
|
---|
1183 |
|
---|
1184 | /**
|
---|
1185 | * Lists the capablities of a backend indentified by its name.
|
---|
1186 | * Free all returned names with RTStrFree() when you no longer need them.
|
---|
1187 | *
|
---|
1188 | * @return VBox status code.
|
---|
1189 | * @param pszBackend The backend name (case insensitive).
|
---|
1190 | * @param pEntries Pointer to an entry.
|
---|
1191 | */
|
---|
1192 | VBOXDDU_DECL(int) VDBackendInfoOne(const char *pszBackend, PVDBACKENDINFO pEntry);
|
---|
1193 |
|
---|
1194 | /**
|
---|
1195 | * Allocates and initializes an empty HDD container.
|
---|
1196 | * No image files are opened.
|
---|
1197 | *
|
---|
1198 | * @return VBox status code.
|
---|
1199 | * @param pVDIfsDisk Pointer to the per-disk VD interface list.
|
---|
1200 | * @param ppDisk Where to store the reference to HDD container.
|
---|
1201 | */
|
---|
1202 | VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk);
|
---|
1203 |
|
---|
1204 | /**
|
---|
1205 | * Destroys HDD container.
|
---|
1206 | * If container has opened image files they will be closed.
|
---|
1207 | *
|
---|
1208 | * @param pDisk Pointer to HDD container.
|
---|
1209 | */
|
---|
1210 | VBOXDDU_DECL(void) VDDestroy(PVBOXHDD pDisk);
|
---|
1211 |
|
---|
1212 | /**
|
---|
1213 | * Try to get the backend name which can use this image.
|
---|
1214 | *
|
---|
1215 | * @return VBox status code.
|
---|
1216 | * @param pszFilename Name of the image file for which the backend is queried.
|
---|
1217 | * @param ppszFormat Receives pointer of the UTF-8 string which contains the format name.
|
---|
1218 | * The returned pointer must be freed using RTStrFree().
|
---|
1219 | */
|
---|
1220 | VBOXDDU_DECL(int) VDGetFormat(const char *pszFilename, char **ppszFormat);
|
---|
1221 |
|
---|
1222 | /**
|
---|
1223 | * Opens an image file.
|
---|
1224 | *
|
---|
1225 | * The first opened image file in HDD container must have a base image type,
|
---|
1226 | * others (next opened images) must be differencing or undo images.
|
---|
1227 | * Linkage is checked for differencing image to be consistent with the previously opened image.
|
---|
1228 | * When another differencing image is opened and the last image was opened in read/write access
|
---|
1229 | * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
|
---|
1230 | * other processes to use images in read-only mode too.
|
---|
1231 | *
|
---|
1232 | * Note that the image is opened in read-only mode if a read/write open is not possible.
|
---|
1233 | * Use VDIsReadOnly to check open mode.
|
---|
1234 | *
|
---|
1235 | * @return VBox status code.
|
---|
1236 | * @param pDisk Pointer to HDD container.
|
---|
1237 | * @param pszBackend Name of the image file backend to use (case insensitive).
|
---|
1238 | * @param pszFilename Name of the image file to open.
|
---|
1239 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
1240 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
1241 | */
|
---|
1242 | VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend,
|
---|
1243 | const char *pszFilename, unsigned uOpenFlags,
|
---|
1244 | PVDINTERFACE pVDIfsImage);
|
---|
1245 |
|
---|
1246 | /**
|
---|
1247 | * Creates and opens a new base image file.
|
---|
1248 | *
|
---|
1249 | * @return VBox status code.
|
---|
1250 | * @param pDisk Pointer to HDD container.
|
---|
1251 | * @param pszBackend Name of the image file backend to use (case insensitive).
|
---|
1252 | * @param pszFilename Name of the image file to create.
|
---|
1253 | * @param cbSize Image size in bytes.
|
---|
1254 | * @param uImageFlags Flags specifying special image features.
|
---|
1255 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
1256 | * @param pPCHSGeometry Pointer to physical disk geometry <= (16383,16,63). Not NULL.
|
---|
1257 | * @param pLCHSGeometry Pointer to logical disk geometry <= (x,255,63). Not NULL.
|
---|
1258 | * @param pUuid New UUID of the image. If NULL, a new UUID is created.
|
---|
1259 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
1260 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
1261 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
1262 | */
|
---|
1263 | VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszBackend,
|
---|
1264 | const char *pszFilename, uint64_t cbSize,
|
---|
1265 | unsigned uImageFlags, const char *pszComment,
|
---|
1266 | PCPDMMEDIAGEOMETRY pPCHSGeometry,
|
---|
1267 | PCPDMMEDIAGEOMETRY pLCHSGeometry,
|
---|
1268 | PCRTUUID pUuid, unsigned uOpenFlags,
|
---|
1269 | PVDINTERFACE pVDIfsImage,
|
---|
1270 | PVDINTERFACE pVDIfsOperation);
|
---|
1271 |
|
---|
1272 | /**
|
---|
1273 | * Creates and opens a new differencing image file in HDD container.
|
---|
1274 | * See comments for VDOpen function about differencing images.
|
---|
1275 | *
|
---|
1276 | * @return VBox status code.
|
---|
1277 | * @param pDisk Pointer to HDD container.
|
---|
1278 | * @param pszBackend Name of the image file backend to use (case insensitive).
|
---|
1279 | * @param pszFilename Name of the differencing image file to create.
|
---|
1280 | * @param uImageFlags Flags specifying special image features.
|
---|
1281 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
1282 | * @param pUuid New UUID of the image. If NULL, a new UUID is created.
|
---|
1283 | * @param pParentUuid New parent UUID of the image. If NULL, the UUID is queried automatically.
|
---|
1284 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
1285 | * @param pVDIfsImage Pointer to the per-image VD interface list.
|
---|
1286 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
1287 | */
|
---|
1288 | VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszBackend,
|
---|
1289 | const char *pszFilename, unsigned uImageFlags,
|
---|
1290 | const char *pszComment, PCRTUUID pUuid,
|
---|
1291 | PCRTUUID pParentUuid, unsigned uOpenFlags,
|
---|
1292 | PVDINTERFACE pVDIfsImage,
|
---|
1293 | PVDINTERFACE pVDIfsOperation);
|
---|
1294 |
|
---|
1295 | /**
|
---|
1296 | * Merges two images (not necessarily with direct parent/child relationship).
|
---|
1297 | * As a side effect the source image and potentially the other images which
|
---|
1298 | * are also merged to the destination are deleted from both the disk and the
|
---|
1299 | * images in the HDD container.
|
---|
1300 | *
|
---|
1301 | * @return VBox status code.
|
---|
1302 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1303 | * @param pDisk Pointer to HDD container.
|
---|
1304 | * @param nImageFrom Image number to merge from, counts from 0. 0 is always base image of container.
|
---|
1305 | * @param nImageTo Image number to merge to, counts from 0. 0 is always base image of container.
|
---|
1306 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
1307 | */
|
---|
1308 | VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom,
|
---|
1309 | unsigned nImageTo, PVDINTERFACE pVDIfsOperation);
|
---|
1310 |
|
---|
1311 | /**
|
---|
1312 | * Copies an image from one HDD container to another.
|
---|
1313 | * The copy is opened in the target HDD container.
|
---|
1314 | * It is possible to convert between different image formats, because the
|
---|
1315 | * backend for the destination may be different from the source.
|
---|
1316 | * If both the source and destination reference the same HDD container,
|
---|
1317 | * then the image is moved (by copying/deleting or renaming) to the new location.
|
---|
1318 | * The source container is unchanged if the move operation fails, otherwise
|
---|
1319 | * the image at the new location is opened in the same way as the old one was.
|
---|
1320 | *
|
---|
1321 | * @return VBox status code.
|
---|
1322 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1323 | * @param pDiskFrom Pointer to source HDD container.
|
---|
1324 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1325 | * @param pDiskTo Pointer to destination HDD container.
|
---|
1326 | * @param pszBackend Name of the image file backend to use (may be NULL to use the same as the source, case insensitive).
|
---|
1327 | * @param pszFilename New name of the image (may be NULL to specify that the
|
---|
1328 | * copy destination is the destination container, or
|
---|
1329 | * if pDiskFrom == pDiskTo, i.e. when moving).
|
---|
1330 | * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored).
|
---|
1331 | * @param cbSize New image size (0 means leave unchanged).
|
---|
1332 | * @param uImageFlags Flags specifying special destination image features.
|
---|
1333 | * @param pDstUuid New UUID of the destination image. If NULL, a new UUID is created.
|
---|
1334 | * This parameter is used if and only if a true copy is created.
|
---|
1335 | * In all rename/move cases or copy to existing image cases the modification UUIDs are copied over.
|
---|
1336 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
1337 | * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the
|
---|
1338 | * destination image.
|
---|
1339 | * @param pDstVDIfsOperation Pointer to the per-operation VD interface list,
|
---|
1340 | * for the destination operation.
|
---|
1341 | */
|
---|
1342 | VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo,
|
---|
1343 | const char *pszBackend, const char *pszFilename,
|
---|
1344 | bool fMoveByRename, uint64_t cbSize,
|
---|
1345 | unsigned uImageFlags, PCRTUUID pDstUuid,
|
---|
1346 | PVDINTERFACE pVDIfsOperation,
|
---|
1347 | PVDINTERFACE pDstVDIfsImage,
|
---|
1348 | PVDINTERFACE pDstVDIfsOperation);
|
---|
1349 |
|
---|
1350 | /**
|
---|
1351 | * Optimizes the storage consumption of an image. Typically the unused blocks
|
---|
1352 | * have to be wiped with zeroes to achieve a substantial reduced storage use.
|
---|
1353 | * Another optimization done is reordering the image blocks, which can provide
|
---|
1354 | * a significant performance boost, as reads and writes tend to use less random
|
---|
1355 | * file offsets.
|
---|
1356 | *
|
---|
1357 | * @return VBox status code.
|
---|
1358 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1359 | * @return VERR_VD_IMAGE_READ_ONLY if image is not writable.
|
---|
1360 | * @return VERR_NOT_SUPPORTED if this kind of image can be compacted, but
|
---|
1361 | * this isn't supported yet.
|
---|
1362 | * @param pDisk Pointer to HDD container.
|
---|
1363 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1364 | * @param pVDIfsOperation Pointer to the per-operation VD interface list.
|
---|
1365 | */
|
---|
1366 | VBOXDDU_DECL(int) VDCompact(PVBOXHDD pDisk, unsigned nImage,
|
---|
1367 | PVDINTERFACE pVDIfsOperation);
|
---|
1368 |
|
---|
1369 | /**
|
---|
1370 | * Closes the last opened image file in HDD container.
|
---|
1371 | * If previous image file was opened in read-only mode (that is normal) and closing image
|
---|
1372 | * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
|
---|
1373 | * will be reopened in read/write mode.
|
---|
1374 | *
|
---|
1375 | * @return VBox status code.
|
---|
1376 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
1377 | * @param pDisk Pointer to HDD container.
|
---|
1378 | * @param fDelete If true, delete the image from the host disk.
|
---|
1379 | */
|
---|
1380 | VBOXDDU_DECL(int) VDClose(PVBOXHDD pDisk, bool fDelete);
|
---|
1381 |
|
---|
1382 | /**
|
---|
1383 | * Closes all opened image files in HDD container.
|
---|
1384 | *
|
---|
1385 | * @return VBox status code.
|
---|
1386 | * @param pDisk Pointer to HDD container.
|
---|
1387 | */
|
---|
1388 | VBOXDDU_DECL(int) VDCloseAll(PVBOXHDD pDisk);
|
---|
1389 |
|
---|
1390 | /**
|
---|
1391 | * Read data from virtual HDD.
|
---|
1392 | *
|
---|
1393 | * @return VBox status code.
|
---|
1394 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
1395 | * @param pDisk Pointer to HDD container.
|
---|
1396 | * @param uOffset Offset of first reading byte from start of disk.
|
---|
1397 | * Must be aligned to a sector boundary.
|
---|
1398 | * @param pvBuf Pointer to buffer for reading data.
|
---|
1399 | * @param cbRead Number of bytes to read.
|
---|
1400 | * Must be aligned to a sector boundary.
|
---|
1401 | */
|
---|
1402 | VBOXDDU_DECL(int) VDRead(PVBOXHDD pDisk, uint64_t uOffset, void *pvBuf, size_t cbRead);
|
---|
1403 |
|
---|
1404 | /**
|
---|
1405 | * Write data to virtual HDD.
|
---|
1406 | *
|
---|
1407 | * @return VBox status code.
|
---|
1408 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
1409 | * @param pDisk Pointer to HDD container.
|
---|
1410 | * @param uOffset Offset of first writing byte from start of disk.
|
---|
1411 | * Must be aligned to a sector boundary.
|
---|
1412 | * @param pvBuf Pointer to buffer for writing data.
|
---|
1413 | * @param cbWrite Number of bytes to write.
|
---|
1414 | * Must be aligned to a sector boundary.
|
---|
1415 | */
|
---|
1416 | VBOXDDU_DECL(int) VDWrite(PVBOXHDD pDisk, uint64_t uOffset, const void *pvBuf, size_t cbWrite);
|
---|
1417 |
|
---|
1418 | /**
|
---|
1419 | * Make sure the on disk representation of a virtual HDD is up to date.
|
---|
1420 | *
|
---|
1421 | * @return VBox status code.
|
---|
1422 | * @return VERR_VD_NOT_OPENED if no image is opened in HDD container.
|
---|
1423 | * @param pDisk Pointer to HDD container.
|
---|
1424 | */
|
---|
1425 | VBOXDDU_DECL(int) VDFlush(PVBOXHDD pDisk);
|
---|
1426 |
|
---|
1427 | /**
|
---|
1428 | * Get number of opened images in HDD container.
|
---|
1429 | *
|
---|
1430 | * @return Number of opened images for HDD container. 0 if no images have been opened.
|
---|
1431 | * @param pDisk Pointer to HDD container.
|
---|
1432 | */
|
---|
1433 | VBOXDDU_DECL(unsigned) VDGetCount(PVBOXHDD pDisk);
|
---|
1434 |
|
---|
1435 | /**
|
---|
1436 | * Get read/write mode of HDD container.
|
---|
1437 | *
|
---|
1438 | * @return Virtual disk ReadOnly status.
|
---|
1439 | * @return true if no image is opened in HDD container.
|
---|
1440 | * @param pDisk Pointer to HDD container.
|
---|
1441 | */
|
---|
1442 | VBOXDDU_DECL(bool) VDIsReadOnly(PVBOXHDD pDisk);
|
---|
1443 |
|
---|
1444 | /**
|
---|
1445 | * Get total capacity of an image in HDD container.
|
---|
1446 | *
|
---|
1447 | * @return Virtual disk size in bytes.
|
---|
1448 | * @return 0 if image with specified number was not opened.
|
---|
1449 | * @param pDisk Pointer to HDD container.
|
---|
1450 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1451 | */
|
---|
1452 | VBOXDDU_DECL(uint64_t) VDGetSize(PVBOXHDD pDisk, unsigned nImage);
|
---|
1453 |
|
---|
1454 | /**
|
---|
1455 | * Get total file size of an image in HDD container.
|
---|
1456 | *
|
---|
1457 | * @return Virtual disk size in bytes.
|
---|
1458 | * @return 0 if image with specified number was not opened.
|
---|
1459 | * @param pDisk Pointer to HDD container.
|
---|
1460 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1461 | */
|
---|
1462 | VBOXDDU_DECL(uint64_t) VDGetFileSize(PVBOXHDD pDisk, unsigned nImage);
|
---|
1463 |
|
---|
1464 | /**
|
---|
1465 | * Get virtual disk PCHS geometry of an image in HDD container.
|
---|
1466 | *
|
---|
1467 | * @return VBox status code.
|
---|
1468 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1469 | * @return VERR_VD_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
1470 | * @param pDisk Pointer to HDD container.
|
---|
1471 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1472 | * @param pPCHSGeometry Where to store PCHS geometry. Not NULL.
|
---|
1473 | */
|
---|
1474 | VBOXDDU_DECL(int) VDGetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
1475 | PPDMMEDIAGEOMETRY pPCHSGeometry);
|
---|
1476 |
|
---|
1477 | /**
|
---|
1478 | * Store 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 | * @param pDisk Pointer to HDD container.
|
---|
1483 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1484 | * @param pPCHSGeometry Where to load PCHS geometry from. Not NULL.
|
---|
1485 | */
|
---|
1486 | VBOXDDU_DECL(int) VDSetPCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
1487 | PCPDMMEDIAGEOMETRY pPCHSGeometry);
|
---|
1488 |
|
---|
1489 | /**
|
---|
1490 | * Get virtual disk LCHS geometry of an image in HDD container.
|
---|
1491 | *
|
---|
1492 | * @return VBox status code.
|
---|
1493 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1494 | * @return VERR_VD_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
1495 | * @param pDisk Pointer to HDD container.
|
---|
1496 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1497 | * @param pLCHSGeometry Where to store LCHS geometry. Not NULL.
|
---|
1498 | */
|
---|
1499 | VBOXDDU_DECL(int) VDGetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
1500 | PPDMMEDIAGEOMETRY pLCHSGeometry);
|
---|
1501 |
|
---|
1502 | /**
|
---|
1503 | * Store 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 | * @param pDisk Pointer to HDD container.
|
---|
1508 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1509 | * @param pLCHSGeometry Where to load LCHS geometry from. Not NULL.
|
---|
1510 | */
|
---|
1511 | VBOXDDU_DECL(int) VDSetLCHSGeometry(PVBOXHDD pDisk, unsigned nImage,
|
---|
1512 | PCPDMMEDIAGEOMETRY pLCHSGeometry);
|
---|
1513 |
|
---|
1514 | /**
|
---|
1515 | * Get version of image in HDD container.
|
---|
1516 | *
|
---|
1517 | * @return VBox status code.
|
---|
1518 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1519 | * @param pDisk Pointer to HDD container.
|
---|
1520 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1521 | * @param puVersion Where to store the image version.
|
---|
1522 | */
|
---|
1523 | VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage,
|
---|
1524 | unsigned *puVersion);
|
---|
1525 |
|
---|
1526 | /**
|
---|
1527 | * List the capabilities of image backend in HDD container.
|
---|
1528 | *
|
---|
1529 | * @return VBox status code.
|
---|
1530 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1531 | * @param pDisk Pointer to the HDD container.
|
---|
1532 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1533 | * @param pbackendInfo Where to store the backend information.
|
---|
1534 | */
|
---|
1535 | VBOXDDU_DECL(int) VDBackendInfoSingle(PVBOXHDD pDisk, unsigned nImage,
|
---|
1536 | PVDBACKENDINFO pBackendInfo);
|
---|
1537 |
|
---|
1538 | /**
|
---|
1539 | * Get flags of image in HDD container.
|
---|
1540 | *
|
---|
1541 | * @return VBox status code.
|
---|
1542 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1543 | * @param pDisk Pointer to HDD container.
|
---|
1544 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1545 | * @param puImageFlags Where to store the image flags.
|
---|
1546 | */
|
---|
1547 | VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags);
|
---|
1548 |
|
---|
1549 | /**
|
---|
1550 | * Get open flags of image in HDD container.
|
---|
1551 | *
|
---|
1552 | * @return VBox status code.
|
---|
1553 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1554 | * @param pDisk Pointer to HDD container.
|
---|
1555 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1556 | * @param puOpenFlags Where to store the image open flags.
|
---|
1557 | */
|
---|
1558 | VBOXDDU_DECL(int) VDGetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
|
---|
1559 | unsigned *puOpenFlags);
|
---|
1560 |
|
---|
1561 | /**
|
---|
1562 | * Set open flags of image in HDD container.
|
---|
1563 | * This operation may cause file locking changes and/or files being reopened.
|
---|
1564 | * Note that in case of unrecoverable error all images in HDD container will be closed.
|
---|
1565 | *
|
---|
1566 | * @return VBox status code.
|
---|
1567 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1568 | * @param pDisk Pointer to HDD container.
|
---|
1569 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1570 | * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
|
---|
1571 | */
|
---|
1572 | VBOXDDU_DECL(int) VDSetOpenFlags(PVBOXHDD pDisk, unsigned nImage,
|
---|
1573 | unsigned uOpenFlags);
|
---|
1574 |
|
---|
1575 | /**
|
---|
1576 | * Get base filename of image in HDD container. Some image formats use
|
---|
1577 | * other filenames as well, so don't use this for anything but informational
|
---|
1578 | * purposes.
|
---|
1579 | *
|
---|
1580 | * @return VBox status code.
|
---|
1581 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1582 | * @return VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
|
---|
1583 | * @param pDisk Pointer to HDD container.
|
---|
1584 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1585 | * @param pszFilename Where to store the image file name.
|
---|
1586 | * @param cbFilename Size of buffer pszFilename points to.
|
---|
1587 | */
|
---|
1588 | VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage,
|
---|
1589 | char *pszFilename, unsigned cbFilename);
|
---|
1590 |
|
---|
1591 | /**
|
---|
1592 | * Get the comment line of image in HDD container.
|
---|
1593 | *
|
---|
1594 | * @return VBox status code.
|
---|
1595 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1596 | * @return VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
|
---|
1597 | * @param pDisk Pointer to HDD container.
|
---|
1598 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1599 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
1600 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
1601 | */
|
---|
1602 | VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage,
|
---|
1603 | char *pszComment, unsigned cbComment);
|
---|
1604 |
|
---|
1605 | /**
|
---|
1606 | * Changes the comment line of image in HDD container.
|
---|
1607 | *
|
---|
1608 | * @return VBox status code.
|
---|
1609 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
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 New comment string (UTF-8). NULL is allowed to reset the comment.
|
---|
1613 | */
|
---|
1614 | VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage,
|
---|
1615 | const char *pszComment);
|
---|
1616 |
|
---|
1617 | /**
|
---|
1618 | * Get UUID of image in HDD container.
|
---|
1619 | *
|
---|
1620 | * @return VBox status code.
|
---|
1621 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1622 | * @param pDisk Pointer to HDD container.
|
---|
1623 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1624 | * @param pUuid Where to store the image UUID.
|
---|
1625 | */
|
---|
1626 | VBOXDDU_DECL(int) VDGetUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid);
|
---|
1627 |
|
---|
1628 | /**
|
---|
1629 | * Set the image's UUID. Should not be used by normal applications.
|
---|
1630 | *
|
---|
1631 | * @return VBox status code.
|
---|
1632 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1633 | * @param pDisk Pointer to HDD container.
|
---|
1634 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1635 | * @param pUuid New UUID of the image. If NULL, a new UUID is created.
|
---|
1636 | */
|
---|
1637 | VBOXDDU_DECL(int) VDSetUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid);
|
---|
1638 |
|
---|
1639 | /**
|
---|
1640 | * Get last modification UUID of image in HDD container.
|
---|
1641 | *
|
---|
1642 | * @return VBox status code.
|
---|
1643 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1644 | * @param pDisk Pointer to HDD container.
|
---|
1645 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1646 | * @param pUuid Where to store the image modification UUID.
|
---|
1647 | */
|
---|
1648 | VBOXDDU_DECL(int) VDGetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1649 | PRTUUID pUuid);
|
---|
1650 |
|
---|
1651 | /**
|
---|
1652 | * Set the image's last modification UUID. Should not be used by normal applications.
|
---|
1653 | *
|
---|
1654 | * @return VBox status code.
|
---|
1655 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1656 | * @param pDisk Pointer to HDD container.
|
---|
1657 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1658 | * @param pUuid New modification UUID of the image. If NULL, a new UUID is created.
|
---|
1659 | */
|
---|
1660 | VBOXDDU_DECL(int) VDSetModificationUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1661 | PCRTUUID pUuid);
|
---|
1662 |
|
---|
1663 | /**
|
---|
1664 | * Get parent UUID of image in HDD container.
|
---|
1665 | *
|
---|
1666 | * @return VBox status code.
|
---|
1667 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1668 | * @param pDisk Pointer to HDD container.
|
---|
1669 | * @param nImage Image number, counts from 0. 0 is always base image of the container.
|
---|
1670 | * @param pUuid Where to store the parent image UUID.
|
---|
1671 | */
|
---|
1672 | VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1673 | PRTUUID pUuid);
|
---|
1674 |
|
---|
1675 | /**
|
---|
1676 | * Set the image's parent UUID. Should not be used by normal applications.
|
---|
1677 | *
|
---|
1678 | * @return VBox status code.
|
---|
1679 | * @param pDisk Pointer to HDD container.
|
---|
1680 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1681 | * @param pUuid New parent UUID of the image. If NULL, a new UUID is created.
|
---|
1682 | */
|
---|
1683 | VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage,
|
---|
1684 | PCRTUUID pUuid);
|
---|
1685 |
|
---|
1686 |
|
---|
1687 | /**
|
---|
1688 | * Debug helper - dumps all opened images in HDD container into the log file.
|
---|
1689 | *
|
---|
1690 | * @param pDisk Pointer to HDD container.
|
---|
1691 | */
|
---|
1692 | VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
|
---|
1693 |
|
---|
1694 |
|
---|
1695 | /**
|
---|
1696 | * Query if asynchronous operations are supported for this disk.
|
---|
1697 | *
|
---|
1698 | * @return VBox status code.
|
---|
1699 | * @return VERR_VD_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
1700 | * @param pDisk Pointer to the HDD container.
|
---|
1701 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
1702 | * @param pfAIOSupported Where to store if async IO is supported.
|
---|
1703 | */
|
---|
1704 | VBOXDDU_DECL(int) VDImageIsAsyncIOSupported(PVBOXHDD pDisk, unsigned nImage, bool *pfAIOSupported);
|
---|
1705 |
|
---|
1706 |
|
---|
1707 | /**
|
---|
1708 | * Start a asynchronous read request.
|
---|
1709 | *
|
---|
1710 | * @return VBox status code.
|
---|
1711 | * @param pDisk Pointer to the HDD container.
|
---|
1712 | * @param uOffset The offset of the virtual disk to read from.
|
---|
1713 | * @param cbRead How many bytes to read.
|
---|
1714 | * @param paSeg Pointer to an array of segments.
|
---|
1715 | * @param cSeg Number of segments in the array.
|
---|
1716 | * @param pvUser User data which is passed on completion
|
---|
1717 | */
|
---|
1718 | VBOXDDU_DECL(int) VDAsyncRead(PVBOXHDD pDisk, uint64_t uOffset, size_t cbRead,
|
---|
1719 | PPDMDATASEG paSeg, unsigned cSeg,
|
---|
1720 | void *pvUser);
|
---|
1721 |
|
---|
1722 |
|
---|
1723 | /**
|
---|
1724 | * Start a asynchronous write request.
|
---|
1725 | *
|
---|
1726 | * @return VBox status code.
|
---|
1727 | * @param pDisk Pointer to the HDD container.
|
---|
1728 | * @param uOffset The offset of the virtual disk to write to.
|
---|
1729 | * @param cbWrtie How many bytes to write.
|
---|
1730 | * @param paSeg Pointer to an array of segments.
|
---|
1731 | * @param cSeg Number of segments in the array.
|
---|
1732 | * @param pvUser User data which is passed on completion.
|
---|
1733 | */
|
---|
1734 | VBOXDDU_DECL(int) VDAsyncWrite(PVBOXHDD pDisk, uint64_t uOffset, size_t cbWrite,
|
---|
1735 | PPDMDATASEG paSeg, unsigned cSeg,
|
---|
1736 | void *pvUser);
|
---|
1737 |
|
---|
1738 |
|
---|
1739 | RT_C_DECLS_END
|
---|
1740 |
|
---|
1741 | /** @} */
|
---|
1742 |
|
---|
1743 | #endif
|
---|