VirtualBox

source: vbox/trunk/include/VBox/vd-cache-backend.h@ 72101

Last change on this file since 72101 was 69107, checked in by vboxsync, 7 years ago

include/VBox/: (C) year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.3 KB
Line 
1/** @file
2 * Internal hard disk format support API for VBoxHDD cache images.
3 */
4
5/*
6 * Copyright (C) 2006-2017 Oracle Corporation
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
26#ifndef ___VBox_vd_cache_backend_h
27#define ___VBox_vd_cache_backend_h
28
29#include <VBox/vd.h>
30#include <VBox/vd-common.h>
31#include <VBox/vd-ifs-internal.h>
32
33/**
34 * Cache format backend interface used by VBox HDD Container implementation.
35 */
36typedef struct VDCACHEBACKEND
37{
38 /** Structure version. VD_CACHEBACKEND_VERSION defines the current version. */
39 uint32_t u32Version;
40 /** The name of the backend (constant string). */
41 const char *pszBackendName;
42 /** The capabilities of the backend. */
43 uint64_t uBackendCaps;
44
45 /**
46 * Pointer to a NULL-terminated array of strings, containing the supported
47 * file extensions. Note that some backends do not work on files, so this
48 * pointer may just contain NULL.
49 */
50 const char * const *papszFileExtensions;
51
52 /**
53 * Pointer to an array of structs describing each supported config key.
54 * Terminated by a NULL config key. Note that some backends do not support
55 * the configuration interface, so this pointer may just contain NULL.
56 * Mandatory if the backend sets VD_CAP_CONFIG.
57 */
58 PCVDCONFIGINFO paConfigInfo;
59
60 /**
61 * Probes the given image.
62 *
63 * @returns VBox status code.
64 * @param pszFilename Name of the image file.
65 * @param pVDIfsDisk Pointer to the per-disk VD interface list.
66 * @param pVDIfsImage Pointer to the per-image VD interface list.
67 */
68 DECLR3CALLBACKMEMBER(int, pfnProbe, (const char *pszFilename, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage));
69
70 /**
71 * Open a cache image.
72 *
73 * @returns VBox status code.
74 * @param pszFilename Name of the image file to open. Guaranteed to be available and
75 * unchanged during the lifetime of this image.
76 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
77 * @param pVDIfsDisk Pointer to the per-disk VD interface list.
78 * @param pVDIfsImage Pointer to the per-image VD interface list.
79 * @param ppBackendData Opaque state data for this image.
80 */
81 DECLR3CALLBACKMEMBER(int, pfnOpen, (const char *pszFilename, unsigned uOpenFlags,
82 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
83 void **ppBackendData));
84
85 /**
86 * Create a cache image.
87 *
88 * @returns VBox status code.
89 * @param pszFilename Name of the image file to create. Guaranteed to be available and
90 * unchanged during the lifetime of this image.
91 * @param cbSize Image size in bytes.
92 * @param uImageFlags Flags specifying special image features.
93 * @param pszComment Pointer to image comment. NULL is ok.
94 * @param pUuid New UUID of the image. Not NULL.
95 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants.
96 * @param uPercentStart Starting value for progress percentage.
97 * @param uPercentSpan Span for varying progress percentage.
98 * @param pVDIfsDisk Pointer to the per-disk VD interface list.
99 * @param pVDIfsImage Pointer to the per-image VD interface list.
100 * @param pVDIfsOperation Pointer to the per-operation VD interface list.
101 * @param ppBackendData Opaque state data for this image.
102 */
103 DECLR3CALLBACKMEMBER(int, pfnCreate, (const char *pszFilename, uint64_t cbSize,
104 unsigned uImageFlags, const char *pszComment,
105 PCRTUUID pUuid, unsigned uOpenFlags,
106 unsigned uPercentStart, unsigned uPercentSpan,
107 PVDINTERFACE pVDIfsDisk,
108 PVDINTERFACE pVDIfsImage,
109 PVDINTERFACE pVDIfsOperation,
110 void **ppBackendData));
111
112 /**
113 * Close a cache image.
114 *
115 * @returns VBox status code.
116 * @param pBackendData Opaque state data for this image.
117 * @param fDelete If true, delete the image from the host disk.
118 */
119 DECLR3CALLBACKMEMBER(int, pfnClose, (void *pBackendData, bool fDelete));
120
121 /**
122 * Start a read request.
123 *
124 * @returns VBox status code.
125 * @param pBackendData Opaque state data for this image.
126 * @param uOffset The offset of the virtual disk to read from.
127 * @param cbToRead How many bytes to read.
128 * @param pIoCtx I/O context associated with this request.
129 * @param pcbActuallyRead Pointer to returned number of bytes read.
130 */
131 DECLR3CALLBACKMEMBER(int, pfnRead, (void *pBackendData, uint64_t uOffset, size_t cbToRead,
132 PVDIOCTX pIoCtx, size_t *pcbActuallyRead));
133
134 /**
135 * Start a write request.
136 *
137 * @returns VBox status code.
138 * @param pBackendData Opaque state data for this image.
139 * @param uOffset The offset of the virtual disk to write to.
140 * @param cbToWrite How many bytes to write.
141 * @param pIoCtx I/O context associated with this request.
142 * @param pcbWriteProcess Pointer to returned number of bytes that could
143 * be processed. In case the function returned
144 * VERR_VD_BLOCK_FREE this is the number of bytes
145 * that could be written in a full block write,
146 * when prefixed/postfixed by the appropriate
147 * amount of (previously read) padding data.
148 */
149 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pBackendData, uint64_t uOffset, size_t cbToWrite,
150 PVDIOCTX pIoCtx, size_t *pcbWriteProcess));
151
152 /**
153 * Flush data to disk.
154 *
155 * @returns VBox status code.
156 * @param pBackendData Opaque state data for this image.
157 * @param pIoCtx I/O context associated with this request.
158 */
159 DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pBackendData, PVDIOCTX pIoCtx));
160
161 /**
162 * Discards the given amount of bytes from the cache.
163 *
164 * @returns VBox status code.
165 * @retval VERR_VD_DISCARD_ALIGNMENT_NOT_MET if the range doesn't meet the required alignment
166 * for the discard.
167 * @param pBackendData Opaque state data for this image.
168 * @param pIoCtx I/O context associated with this request.
169 * @param uOffset The offset of the first byte to discard.
170 * @param cbDiscard How many bytes to discard.
171 */
172 DECLR3CALLBACKMEMBER(int, pfnDiscard, (void *pBackendData, PVDIOCTX pIoCtx,
173 uint64_t uOffset, size_t cbDiscard,
174 size_t *pcbPreAllocated,
175 size_t *pcbPostAllocated,
176 size_t *pcbActuallyDiscarded,
177 void **ppbmAllocationBitmap,
178 unsigned fDiscard));
179
180 /**
181 * Get the version of a cache image.
182 *
183 * @returns version of cache image.
184 * @param pBackendData Opaque state data for this image.
185 */
186 DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pBackendData));
187
188 /**
189 * Get the capacity of a cache image.
190 *
191 * @returns size of cache image in bytes.
192 * @param pBackendData Opaque state data for this image.
193 */
194 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pBackendData));
195
196 /**
197 * Get the file size of a cache image.
198 *
199 * @returns size of cache image in bytes.
200 * @param pBackendData Opaque state data for this image.
201 */
202 DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pBackendData));
203
204 /**
205 * Get the image flags of a cache image.
206 *
207 * @returns image flags of cache image.
208 * @param pBackendData Opaque state data for this image.
209 */
210 DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pBackendData));
211
212 /**
213 * Get the open flags of a cache image.
214 *
215 * @returns open flags of cache image.
216 * @param pBackendData Opaque state data for this image.
217 */
218 DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pBackendData));
219
220 /**
221 * Set the open flags of a cache image. May cause the image to be locked
222 * in a different mode or be reopened (which can fail).
223 *
224 * @returns VBox status code.
225 * @param pBackendData Opaque state data for this image.
226 * @param uOpenFlags New open flags for this image.
227 */
228 DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pBackendData, unsigned uOpenFlags));
229
230 /**
231 * Get comment of a cache image.
232 *
233 * @returns VBox status code.
234 * @param pBackendData Opaque state data for this image.
235 * @param pszComment Where to store the comment.
236 * @param cbComment Size of the comment buffer.
237 */
238 DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pBackendData, char *pszComment, size_t cbComment));
239
240 /**
241 * Set comment of a cache image.
242 *
243 * @returns VBox status code.
244 * @param pBackendData Opaque state data for this image.
245 * @param pszComment Where to get the comment from. NULL resets comment.
246 * The comment is silently truncated if the image format
247 * limit is exceeded.
248 */
249 DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pBackendData, const char *pszComment));
250
251 /**
252 * Get UUID of a cache image.
253 *
254 * @returns VBox status code.
255 * @param pBackendData Opaque state data for this image.
256 * @param pUuid Where to store the image UUID.
257 */
258 DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pBackendData, PRTUUID pUuid));
259
260 /**
261 * Set UUID of a cache image.
262 *
263 * @returns VBox status code.
264 * @param pBackendData Opaque state data for this image.
265 * @param pUuid Where to get the image UUID from.
266 */
267 DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pBackendData, PCRTUUID pUuid));
268
269 /**
270 * Get last modification UUID of a cache image.
271 *
272 * @returns VBox status code.
273 * @param pBackendData Opaque state data for this image.
274 * @param pUuid Where to store the image modification UUID.
275 */
276 DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pBackendData, PRTUUID pUuid));
277
278 /**
279 * Set last modification UUID of a cache image.
280 *
281 * @returns VBox status code.
282 * @param pBackendData Opaque state data for this image.
283 * @param pUuid Where to get the image modification UUID from.
284 */
285 DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pBackendData, PCRTUUID pUuid));
286
287 /**
288 * Dump information about a cache image.
289 *
290 * @param pBackendData Opaque state data for this image.
291 */
292 DECLR3CALLBACKMEMBER(void, pfnDump, (void *pBackendData));
293
294 /** Returns a human readable hard disk location string given a
295 * set of hard disk configuration keys. The returned string is an
296 * equivalent of the full file path for image-based hard disks.
297 * Mandatory for backends with no VD_CAP_FILE and NULL otherwise. */
298 DECLR3CALLBACKMEMBER(int, pfnComposeLocation, (PVDINTERFACE pConfig, char **pszLocation));
299
300 /** Returns a human readable hard disk name string given a
301 * set of hard disk configuration keys. The returned string is an
302 * equivalent of the file name part in the full file path for
303 * image-based hard disks. Mandatory for backends with no
304 * VD_CAP_FILE and NULL otherwise. */
305 DECLR3CALLBACKMEMBER(int, pfnComposeName, (PVDINTERFACE pConfig, char **pszName));
306
307 /** Initialization safty marker. */
308 uint32_t u32VersionEnd;
309
310} VDCACHEBACKEND;
311/** Pointer to VD cache backend. */
312typedef VDCACHEBACKEND *PVDCACHEBACKEND;
313/** Constant pointer to VD backend. */
314typedef const VDCACHEBACKEND *PCVDCACHEBACKEND;
315
316/** The current version of the VDCACHEBACKEND structure. */
317#define VD_CACHEBACKEND_VERSION VD_VERSION_MAKE(0xff03, 1, 0)
318
319#endif
Note: See TracBrowser for help on using the repository browser.

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