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