1 | /** @file
|
---|
2 | * VBox HDD Container, Virtual Disk Image (VDI) API.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 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_VBoxHDD_h
|
---|
31 | #define ___VBox_VBoxHDD_h
|
---|
32 |
|
---|
33 | #include <VBox/cdefs.h>
|
---|
34 | #include <VBox/types.h>
|
---|
35 | #include <VBox/param.h>
|
---|
36 | #include <VBox/pdm.h>
|
---|
37 | #include <VBox/vmapi.h>
|
---|
38 |
|
---|
39 | __BEGIN_DECLS
|
---|
40 |
|
---|
41 | #ifdef IN_RING0
|
---|
42 | # error "There are no VDI APIs available in Ring-0 Host Context!"
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | /** @defgroup grp_vbox_hdd VBox HDD Container
|
---|
46 | * @{
|
---|
47 | */
|
---|
48 |
|
---|
49 | /** Image info, not handled anyhow.
|
---|
50 | * Must be less than 64 bytes in length, including the trailing 0.
|
---|
51 | */
|
---|
52 | #define VDI_IMAGE_FILE_INFO "<<< Sun xVM VirtualBox Disk Image >>>\n"
|
---|
53 |
|
---|
54 | /** Current image major version. */
|
---|
55 | #define VDI_IMAGE_VERSION_MAJOR (0x0001)
|
---|
56 | /** Current image minor version. */
|
---|
57 | #define VDI_IMAGE_VERSION_MINOR (0x0001)
|
---|
58 | /** Current image version. */
|
---|
59 | #define VDI_IMAGE_VERSION ((VDI_IMAGE_VERSION_MAJOR << 16) | VDI_IMAGE_VERSION_MINOR)
|
---|
60 |
|
---|
61 | /** Get major version from combined version. */
|
---|
62 | #define VDI_GET_VERSION_MAJOR(uVer) ((uVer) >> 16)
|
---|
63 | /** Get minor version from combined version. */
|
---|
64 | #define VDI_GET_VERSION_MINOR(uVer) ((uVer) & 0xffff)
|
---|
65 |
|
---|
66 | /** @name VDI image types
|
---|
67 | * @{ */
|
---|
68 | typedef enum VDIIMAGETYPE
|
---|
69 | {
|
---|
70 | /** Normal dynamically growing base image file. */
|
---|
71 | VDI_IMAGE_TYPE_NORMAL = 1,
|
---|
72 | /** Preallocated base image file of a fixed size. */
|
---|
73 | VDI_IMAGE_TYPE_FIXED,
|
---|
74 | /** Dynamically growing image file for undo/commit changes support. */
|
---|
75 | VDI_IMAGE_TYPE_UNDO,
|
---|
76 | /** Dynamically growing image file for differencing support. */
|
---|
77 | VDI_IMAGE_TYPE_DIFF,
|
---|
78 |
|
---|
79 | /** First valid image type value. */
|
---|
80 | VDI_IMAGE_TYPE_FIRST = VDI_IMAGE_TYPE_NORMAL,
|
---|
81 | /** Last valid image type value. */
|
---|
82 | VDI_IMAGE_TYPE_LAST = VDI_IMAGE_TYPE_DIFF
|
---|
83 | } VDIIMAGETYPE;
|
---|
84 | /** Pointer to VDI image type. */
|
---|
85 | typedef VDIIMAGETYPE *PVDIIMAGETYPE;
|
---|
86 | /** @} */
|
---|
87 |
|
---|
88 | /** @name VDI image flags
|
---|
89 | * @{ */
|
---|
90 | /** No flags. */
|
---|
91 | #define VDI_IMAGE_FLAGS_NONE (0x00)
|
---|
92 | /** Fill new blocks with zeroes while expanding image file. */
|
---|
93 | #define VDI_IMAGE_FLAGS_ZERO_EXPAND (0x01)
|
---|
94 |
|
---|
95 | /** Mask of valid image flags. */
|
---|
96 | #define VDI_IMAGE_FLAGS_MASK (VDI_IMAGE_FLAGS_NONE | VDI_IMAGE_FLAGS_ZERO_EXPAND)
|
---|
97 |
|
---|
98 | /** Default image flags. */
|
---|
99 | #define VDI_IMAGE_FLAGS_DEFAULT (VDI_IMAGE_FLAGS_NONE)
|
---|
100 | /** @} */
|
---|
101 |
|
---|
102 | /** @name VDI image open mode flags
|
---|
103 | * @{
|
---|
104 | */
|
---|
105 | /** Try to open image in read/write exclusive access mode if possible, or in read-only elsewhere. */
|
---|
106 | #define VDI_OPEN_FLAGS_NORMAL (0)
|
---|
107 | /** Open image in read-only mode with sharing access with others. */
|
---|
108 | #define VDI_OPEN_FLAGS_READONLY (1)
|
---|
109 | /** Mask of valid flags. */
|
---|
110 | #define VDI_OPEN_FLAGS_MASK (VDI_OPEN_FLAGS_NORMAL | VDI_OPEN_FLAGS_READONLY)
|
---|
111 | /** @}*/
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * VBox VDI disk Container main structure.
|
---|
115 | */
|
---|
116 | /* Forward declaration, VDIDISK structure is visible only inside VDI module. */
|
---|
117 | struct VDIDISK;
|
---|
118 | typedef struct VDIDISK VDIDISK;
|
---|
119 | typedef VDIDISK *PVDIDISK;
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Creates a new base image file.
|
---|
123 | *
|
---|
124 | * @returns VBox status code.
|
---|
125 | * @param pszFilename Name of the image file to create.
|
---|
126 | * @param enmType Image type, only base image types are acceptable.
|
---|
127 | * @param cbSize Image size in bytes.
|
---|
128 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
129 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
130 | * @param pvUser User argument for the progress callback.
|
---|
131 | */
|
---|
132 | VBOXDDU_DECL(int) VDICreateBaseImage(const char *pszFilename, VDIIMAGETYPE enmType, uint64_t cbSize, const char *pszComment,
|
---|
133 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Creates a differencing dynamically growing image file for specified parent image.
|
---|
137 | *
|
---|
138 | * @returns VBox status code.
|
---|
139 | * @param pszFilename Name of the differencing image file to create.
|
---|
140 | * @param pszParent Name of the parent image file. May be base or diff image type.
|
---|
141 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
142 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
143 | * @param pvUser User argument for the progress callback.
|
---|
144 | */
|
---|
145 | VBOXDDU_DECL(int) VDICreateDifferenceImage(const char *pszFilename, const char *pszParent, const char *pszComment,
|
---|
146 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * Checks if image is available and not broken, returns some useful image parameters if requested.
|
---|
150 | *
|
---|
151 | * @returns VBox status code.
|
---|
152 | * @param pszFilename Name of the image file to check.
|
---|
153 | * @param puVersion Where to store the version of image. NULL is ok.
|
---|
154 | * @param penmType Where to store the type of image. NULL is ok.
|
---|
155 | * @param pcbSize Where to store the size of image in bytes. NULL is ok.
|
---|
156 | * @param pUuid Where to store the uuid of image creation. NULL is ok.
|
---|
157 | * @param pParentUuid Where to store the uuid of the parent image (if any). NULL is ok.
|
---|
158 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
159 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
160 | */
|
---|
161 | VBOXDDU_DECL(int) VDICheckImage(const char *pszFilename,
|
---|
162 | unsigned *puVersion,
|
---|
163 | PVDIIMAGETYPE penmType,
|
---|
164 | uint64_t *pcbSize,
|
---|
165 | PRTUUID pUuid,
|
---|
166 | PRTUUID pParentUuid,
|
---|
167 | char *pszComment,
|
---|
168 | unsigned cbComment);
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * Changes an image's comment string.
|
---|
172 | *
|
---|
173 | * @returns VBox status code.
|
---|
174 | * @param pszFilename Name of the image file to operate on.
|
---|
175 | * @param pszComment New comment string (UTF-8). NULL is allowed to reset the comment.
|
---|
176 | */
|
---|
177 | VBOXDDU_DECL(int) VDISetImageComment(const char *pszFilename, const char *pszComment);
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Deletes a valid image file. Fails if specified file is not an image.
|
---|
181 | *
|
---|
182 | * @returns VBox status code.
|
---|
183 | * @param pszFilename Name of the image file to check.
|
---|
184 | */
|
---|
185 | VBOXDDU_DECL(int) VDIDeleteImage(const char *pszFilename);
|
---|
186 |
|
---|
187 | /**
|
---|
188 | * Makes a copy of image file with a new (other) creation uuid.
|
---|
189 | *
|
---|
190 | * @returns VBox status code.
|
---|
191 | * @param pszDstFilename Name of the image file to create.
|
---|
192 | * @param pszSrcFilename Name of the image file to copy from.
|
---|
193 | * @param pszComment Pointer to image comment. If NULL, the comment
|
---|
194 | * will be copied from the source image.
|
---|
195 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
196 | * @param pvUser User argument for the progress callback.
|
---|
197 | */
|
---|
198 | VBOXDDU_DECL(int) VDICopyImage(const char *pszDstFilename, const char *pszSrcFilename, const char *pszComment,
|
---|
199 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Converts image file from older VDI formats to current one.
|
---|
203 | *
|
---|
204 | * @returns VBox status code.
|
---|
205 | * @param pszFilename Name of the image file to convert.
|
---|
206 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
207 | * @param pvUser User argument for the progress callback.
|
---|
208 | */
|
---|
209 | VBOXDDU_DECL(int) VDIConvertImage(const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Shrinks growing image file by removing zeroed data blocks.
|
---|
213 | *
|
---|
214 | * @returns VBox status code.
|
---|
215 | * @param pszFilename Name of the image file to shrink.
|
---|
216 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
217 | * @param pvUser User argument for the progress callback.
|
---|
218 | */
|
---|
219 | VBOXDDU_DECL(int) VDIShrinkImage(const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Queries the image's UUID and parent UUIDs.
|
---|
223 | *
|
---|
224 | * @returns VBox status code.
|
---|
225 | * @param pszFilename Name of the image file to operate on.
|
---|
226 | * @param pUuid Where to store image UUID (can be NULL).
|
---|
227 | * @param pModificationUuid Where to store modification UUID (can be NULL).
|
---|
228 | * @param pParentUuuid Where to store parent UUID (can be NULL).
|
---|
229 | * @param pParentModificationUuid Where to store parent modification UUID (can be NULL).
|
---|
230 | */
|
---|
231 | VBOXDDU_DECL(int) VDIGetImageUUIDs(const char *pszFilename,
|
---|
232 | PRTUUID pUuid, PRTUUID pModificationUuid,
|
---|
233 | PRTUUID pParentUuid, PRTUUID pParentModificationUuid);
|
---|
234 |
|
---|
235 |
|
---|
236 | /**
|
---|
237 | * Changes the image's UUID and parent UUIDs.
|
---|
238 | *
|
---|
239 | * @returns VBox status code.
|
---|
240 | * @param pszFilename Name of the image file to operate on.
|
---|
241 | * @param pUuid Optional parameter, new UUID of the image.
|
---|
242 | * @param pModificationUuid Optional parameter, new modification UUID of the image.
|
---|
243 | * @param pParentUuuid Optional parameter, new parent UUID of the image.
|
---|
244 | * @param pParentModificationUuid Optional parameter, new parent modification UUID of the image.
|
---|
245 | */
|
---|
246 | VBOXDDU_DECL(int) VDISetImageUUIDs(const char *pszFilename,
|
---|
247 | PCRTUUID pUuid, PCRTUUID pModificationUuid,
|
---|
248 | PCRTUUID pParentUuid, PCRTUUID pParentModificationUuid);
|
---|
249 |
|
---|
250 | /**
|
---|
251 | * Merges two images having a parent/child relationship (both directions).
|
---|
252 | *
|
---|
253 | * @returns VBox status code.
|
---|
254 | * @param pszFilenameFrom Name of the image file to merge from.
|
---|
255 | * @param pszFilenameTo Name of the image file to merge into.
|
---|
256 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
257 | * @param pvUser User argument for the progress callback.
|
---|
258 | */
|
---|
259 | VBOXDDU_DECL(int) VDIMergeImage(const char *pszFilenameFrom, const char *pszFilenameTo,
|
---|
260 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
261 |
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Allocates and initializes an empty VDI HDD container.
|
---|
265 | * No image files are opened.
|
---|
266 | *
|
---|
267 | * @returns Pointer to newly created empty HDD container.
|
---|
268 | * @returns NULL on failure, typically out of memory.
|
---|
269 | */
|
---|
270 | VBOXDDU_DECL(PVDIDISK) VDIDiskCreate(void);
|
---|
271 |
|
---|
272 | /**
|
---|
273 | * Destroys the VDI HDD container. If container has opened image files they will be closed.
|
---|
274 | *
|
---|
275 | * @param pDisk Pointer to VDI HDD container.
|
---|
276 | */
|
---|
277 | VBOXDDU_DECL(void) VDIDiskDestroy(PVDIDISK pDisk);
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Opens an image file.
|
---|
281 | *
|
---|
282 | * The first opened image file in a HDD container must have a base image type,
|
---|
283 | * others (next opened images) must be a differencing or undo images.
|
---|
284 | * Linkage is checked for differencing image to be in consistence with the previously opened image.
|
---|
285 | * When a next differencing image is opened and the last image was opened in read/write access
|
---|
286 | * mode, then the last image is reopened in read-only with deny write sharing mode. This allows
|
---|
287 | * other processes to use images in read-only mode too.
|
---|
288 | *
|
---|
289 | * Note that the image can be opened in read-only mode if a read/write open is not possible.
|
---|
290 | * Use VDIDiskIsReadOnly to check open mode.
|
---|
291 | *
|
---|
292 | * @returns VBox status code.
|
---|
293 | * @param pDisk Pointer to VDI HDD container.
|
---|
294 | * @param pszFilename Name of the image file to open.
|
---|
295 | * @param fOpen Image file open mode, see VDI_OPEN_FLAGS_* constants.
|
---|
296 | */
|
---|
297 | VBOXDDU_DECL(int) VDIDiskOpenImage(PVDIDISK pDisk, const char *pszFilename, unsigned fOpen);
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Creates and opens a new differencing image file in HDD container.
|
---|
301 | * See comments for VDIDiskOpenImage function about differencing images.
|
---|
302 | *
|
---|
303 | * @returns VBox status code.
|
---|
304 | * @param pDisk Pointer to VDI HDD container.
|
---|
305 | * @param pszFilename Name of the image file to create and open.
|
---|
306 | * @param pszComment Pointer to image comment. NULL is ok.
|
---|
307 | * @param pfnProgress Progress callback. Optional. NULL if not to be used.
|
---|
308 | * @param pvUser User argument for the progress callback.
|
---|
309 | */
|
---|
310 | VBOXDDU_DECL(int) VDIDiskCreateOpenDifferenceImage(PVDIDISK pDisk, const char *pszFilename, const char *pszComment,
|
---|
311 | PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
312 |
|
---|
313 | /**
|
---|
314 | * Closes the last opened image file in the HDD container. Leaves all changes inside it.
|
---|
315 | * If previous image file was opened in read-only mode (that is normal) and closing image
|
---|
316 | * was opened in read-write mode (the whole disk was in read-write mode) - the previous image
|
---|
317 | * will be reopened in read/write mode.
|
---|
318 | *
|
---|
319 | * @param pDisk Pointer to VDI HDD container.
|
---|
320 | */
|
---|
321 | VBOXDDU_DECL(void) VDIDiskCloseImage(PVDIDISK pDisk);
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Closes all opened image files in HDD container.
|
---|
325 | *
|
---|
326 | * @param pDisk Pointer to VDI HDD container.
|
---|
327 | */
|
---|
328 | VBOXDDU_DECL(void) VDIDiskCloseAllImages(PVDIDISK pDisk);
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Commits last opened differencing/undo image file of the HDD container to previous image.
|
---|
332 | * If the previous image file was opened in read-only mode (that must be always so) it is reopened
|
---|
333 | * as read/write to do commit operation.
|
---|
334 | * After successfull commit the previous image file again reopened in read-only mode, last opened
|
---|
335 | * image file is cleared of data and remains open and active in HDD container.
|
---|
336 | * If you want to delete image after commit you must do it manually by VDIDiskCloseImage and
|
---|
337 | * VDIDeleteImage calls.
|
---|
338 | *
|
---|
339 | * Note that in case of unrecoverable error all images of HDD container will be closed.
|
---|
340 | *
|
---|
341 | * @returns VBox status code.
|
---|
342 | * @param pDisk Pointer to VDI HDD container.
|
---|
343 | * @param pfnProgress Progress callback. Optional.
|
---|
344 | * @param pvUser User argument for the progress callback.
|
---|
345 | */
|
---|
346 | VBOXDDU_DECL(int) VDIDiskCommitLastDiff(PVDIDISK pDisk, PFNVMPROGRESS pfnProgress, void *pvUser);
|
---|
347 |
|
---|
348 | /**
|
---|
349 | * Get read/write mode of VDI HDD.
|
---|
350 | *
|
---|
351 | * @returns Disk ReadOnly status.
|
---|
352 | * @returns true if no one VDI image is opened in HDD container.
|
---|
353 | */
|
---|
354 | VBOXDDU_DECL(bool) VDIDiskIsReadOnly(PVDIDISK pDisk);
|
---|
355 |
|
---|
356 | /**
|
---|
357 | * Get total disk size of the VDI HDD container.
|
---|
358 | *
|
---|
359 | * @returns Virtual disk size in bytes.
|
---|
360 | * @returns 0 if no one VDI image is opened in HDD container.
|
---|
361 | */
|
---|
362 | VBOXDDU_DECL(uint64_t) VDIDiskGetSize(PVDIDISK pDisk);
|
---|
363 |
|
---|
364 | /**
|
---|
365 | * Get block size of the VDI HDD container.
|
---|
366 | *
|
---|
367 | * @returns VDI image block size in bytes.
|
---|
368 | * @returns 0 if no one VDI image is opened in HDD container.
|
---|
369 | */
|
---|
370 | VBOXDDU_DECL(unsigned) VDIDiskGetBlockSize(PVDIDISK pDisk);
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Get working buffer size of the VDI HDD container.
|
---|
374 | *
|
---|
375 | * @returns Working buffer size in bytes.
|
---|
376 | */
|
---|
377 | VBOXDDU_DECL(unsigned) VDIDiskGetBufferSize(PVDIDISK pDisk);
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * Get virtual disk PCHS geometry stored in image file.
|
---|
381 | *
|
---|
382 | * @returns VBox status code.
|
---|
383 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
384 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
385 | * @param pDisk Pointer to VDI HDD container.
|
---|
386 | * @param pPCHSGeometry Where to store PCHS geometry. Not NULL.
|
---|
387 | */
|
---|
388 | VBOXDDU_DECL(int) VDIDiskGetPCHSGeometry(PVDIDISK pDisk, PPDMMEDIAGEOMETRY pPCHSGeometry);
|
---|
389 |
|
---|
390 | /**
|
---|
391 | * Store virtual disk PCHS geometry into base image file of HDD container.
|
---|
392 | *
|
---|
393 | * Note that in case of unrecoverable error all images of HDD container will be closed.
|
---|
394 | *
|
---|
395 | * @returns VBox status code.
|
---|
396 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
397 | * @param pDisk Pointer to VDI HDD container.
|
---|
398 | * @param pPCHSGeometry Where to store LCHS geometry. Not NULL.
|
---|
399 | */
|
---|
400 | VBOXDDU_DECL(int) VDIDiskSetPCHSGeometry(PVDIDISK pDisk, PCPDMMEDIAGEOMETRY pPCHSGeometry);
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Get virtual disk LCHS geometry stored in image file.
|
---|
404 | *
|
---|
405 | * @returns VBox status code.
|
---|
406 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
407 | * @returns VERR_VDI_GEOMETRY_NOT_SET if no geometry present in the HDD container.
|
---|
408 | * @param pDisk Pointer to VDI HDD container.
|
---|
409 | * @param pLCHSGeometry Where to store LCHS geometry. Not NULL.
|
---|
410 | */
|
---|
411 | VBOXDDU_DECL(int) VDIDiskGetLCHSGeometry(PVDIDISK pDisk, PPDMMEDIAGEOMETRY pLCHSGeometry);
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * Store virtual disk LCHS geometry into base image file of HDD container.
|
---|
415 | *
|
---|
416 | * Note that in case of unrecoverable error all images of HDD container will be closed.
|
---|
417 | *
|
---|
418 | * @returns VBox status code.
|
---|
419 | * @returns VERR_VDI_NOT_OPENED if no one VDI image is opened in HDD container.
|
---|
420 | * @param pDisk Pointer to VDI HDD container.
|
---|
421 | * @param pLCHSGeometry Where to store LCHS geometry. Not NULL.
|
---|
422 | */
|
---|
423 | VBOXDDU_DECL(int) VDIDiskSetLCHSGeometry(PVDIDISK pDisk, PCPDMMEDIAGEOMETRY pLCHSGeometry);
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * Get number of opened images in HDD container.
|
---|
427 | *
|
---|
428 | * @returns Number of opened images for HDD container. 0 if no images has been opened.
|
---|
429 | * @param pDisk Pointer to VDI HDD container.
|
---|
430 | */
|
---|
431 | VBOXDDU_DECL(int) VDIDiskGetImagesCount(PVDIDISK pDisk);
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Get version of opened image of HDD container.
|
---|
435 | *
|
---|
436 | * @returns VBox status code.
|
---|
437 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
438 | * @param pDisk Pointer to VDI HDD container.
|
---|
439 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
440 | * @param puVersion Where to store the image version.
|
---|
441 | */
|
---|
442 | VBOXDDU_DECL(int) VDIDiskGetImageVersion(PVDIDISK pDisk, int nImage, unsigned *puVersion);
|
---|
443 |
|
---|
444 | /**
|
---|
445 | * Get type of opened image of HDD container.
|
---|
446 | *
|
---|
447 | * @returns VBox status code.
|
---|
448 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
449 | * @param pDisk Pointer to VDI HDD container.
|
---|
450 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
451 | * @param penmType Where to store the image type.
|
---|
452 | */
|
---|
453 | VBOXDDU_DECL(int) VDIDiskGetImageType(PVDIDISK pDisk, int nImage, PVDIIMAGETYPE penmType);
|
---|
454 |
|
---|
455 | /**
|
---|
456 | * Get flags of opened image of HDD container.
|
---|
457 | *
|
---|
458 | * @returns VBox status code.
|
---|
459 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
460 | * @param pDisk Pointer to VDI HDD container.
|
---|
461 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
462 | * @param pfFlags Where to store the image flags.
|
---|
463 | */
|
---|
464 | VBOXDDU_DECL(int) VDIDiskGetImageFlags(PVDIDISK pDisk, int nImage, unsigned *pfFlags);
|
---|
465 |
|
---|
466 | /**
|
---|
467 | * Get filename of opened image of HDD container.
|
---|
468 | *
|
---|
469 | * @returns VBox status code.
|
---|
470 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
471 | * @returns VERR_BUFFER_OVERFLOW if pszFilename buffer too small to hold filename.
|
---|
472 | * @param pDisk Pointer to VDI HDD container.
|
---|
473 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
474 | * @param pszFilename Where to store the image file name.
|
---|
475 | * @param cbFilename Size of buffer pszFilename points to.
|
---|
476 | */
|
---|
477 | VBOXDDU_DECL(int) VDIDiskGetImageFilename(PVDIDISK pDisk, int nImage, char *pszFilename, unsigned cbFilename);
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * Get the comment line of opened image of HDD container.
|
---|
481 | *
|
---|
482 | * @returns VBox status code.
|
---|
483 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
484 | * @returns VERR_BUFFER_OVERFLOW if pszComment buffer too small to hold comment text.
|
---|
485 | * @param pDisk Pointer to VDI HDD container.
|
---|
486 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
487 | * @param pszComment Where to store the comment string of image. NULL is ok.
|
---|
488 | * @param cbComment The size of pszComment buffer. 0 is ok.
|
---|
489 | */
|
---|
490 | VBOXDDU_DECL(int) VDIDiskGetImageComment(PVDIDISK pDisk, int nImage, char *pszComment, unsigned cbComment);
|
---|
491 |
|
---|
492 | /**
|
---|
493 | * Get Uuid of opened image of HDD container.
|
---|
494 | *
|
---|
495 | * @returns VBox status code.
|
---|
496 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
497 | * @param pDisk Pointer to VDI HDD container.
|
---|
498 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
499 | * @param pUuid Where to store the image creation uuid.
|
---|
500 | */
|
---|
501 | VBOXDDU_DECL(int) VDIDiskGetImageUuid(PVDIDISK pDisk, int nImage, PRTUUID pUuid);
|
---|
502 |
|
---|
503 | /**
|
---|
504 | * Get last modification Uuid of opened image of HDD container.
|
---|
505 | *
|
---|
506 | * @returns VBox status code.
|
---|
507 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
508 | * @param pDisk Pointer to VDI HDD container.
|
---|
509 | * @param nImage Image number, counts from 0. 0 is always base image of container.
|
---|
510 | * @param pUuid Where to store the image modification uuid.
|
---|
511 | */
|
---|
512 | VBOXDDU_DECL(int) VDIDiskGetImageModificationUuid(PVDIDISK pDisk, int nImage, PRTUUID pUuid);
|
---|
513 |
|
---|
514 | /**
|
---|
515 | * Get Uuid of opened image's parent image.
|
---|
516 | *
|
---|
517 | * @returns VBox status code.
|
---|
518 | * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
|
---|
519 | * @param pDisk Pointer to VDI HDD container.
|
---|
520 | * @param nImage Image number, counts from 0. 0 is always base image of the container.
|
---|
521 | * @param pUuid Where to store the image creation uuid.
|
---|
522 | */
|
---|
523 | VBOXDDU_DECL(int) VDIDiskGetParentImageUuid(PVDIDISK pDisk, int nImage, PRTUUID pUuid);
|
---|
524 |
|
---|
525 | /**
|
---|
526 | * Read data from virtual HDD.
|
---|
527 | *
|
---|
528 | * @returns VBox status code.
|
---|
529 | * @param pDisk Pointer to VDI HDD container.
|
---|
530 | * @param offStart Offset of first reading byte from start of disk.
|
---|
531 | * @param pvBuf Pointer to buffer for reading data.
|
---|
532 | * @param cbToRead Number of bytes to read.
|
---|
533 | */
|
---|
534 | VBOXDDU_DECL(int) VDIDiskRead(PVDIDISK pDisk, uint64_t offStart, void *pvBuf, size_t cbToRead);
|
---|
535 |
|
---|
536 | /**
|
---|
537 | * Write data to virtual HDD.
|
---|
538 | *
|
---|
539 | * @returns VBox status code.
|
---|
540 | * @param pDisk Pointer to VDI HDD container.
|
---|
541 | * @param offStart Offset of first writing byte from start of HDD.
|
---|
542 | * @param pvBuf Pointer to buffer of writing data.
|
---|
543 | * @param cbToWrite Number of bytes to write.
|
---|
544 | */
|
---|
545 | VBOXDDU_DECL(int) VDIDiskWrite(PVDIDISK pDisk, uint64_t offStart, const void *pvBuf, size_t cbToWrite);
|
---|
546 |
|
---|
547 |
|
---|
548 |
|
---|
549 | /**
|
---|
550 | * Debug helper - dumps all opened images of HDD container into the log file.
|
---|
551 | *
|
---|
552 | * @param pDisk Pointer to VDI HDD container.
|
---|
553 | */
|
---|
554 | VBOXDDU_DECL(void) VDIDiskDumpImages(PVDIDISK pDisk);
|
---|
555 |
|
---|
556 | __END_DECLS
|
---|
557 |
|
---|
558 | /** @} */
|
---|
559 |
|
---|
560 | #endif
|
---|