VirtualBox

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

Last change on this file since 73768 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
RevLine 
[32370]1/** @file
2 * Internal hard disk format support API for VBoxHDD cache images.
3 */
4
5/*
[69107]6 * Copyright (C) 2006-2017 Oracle Corporation
[32370]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
[63912]26#ifndef ___VBox_vd_cache_backend_h
27#define ___VBox_vd_cache_backend_h
[32370]28
[33567]29#include <VBox/vd.h>
[63905]30#include <VBox/vd-common.h>
[38469]31#include <VBox/vd-ifs-internal.h>
[32370]32
33/**
34 * Cache format backend interface used by VBox HDD Container implementation.
35 */
36typedef struct VDCACHEBACKEND
37{
[63905]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;
[32370]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 */
[63905]58 PCVDCONFIGINFO paConfigInfo;
[32370]59
60 /**
61 * Probes the given image.
62 *
63 * @returns VBox status code.
64 * @param pszFilename Name of the image file.
[32536]65 * @param pVDIfsDisk Pointer to the per-disk VD interface list.
66 * @param pVDIfsImage Pointer to the per-image VD interface list.
[32370]67 */
[32536]68 DECLR3CALLBACKMEMBER(int, pfnProbe, (const char *pszFilename, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage));
[32370]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.
[32536]79 * @param ppBackendData Opaque state data for this image.
[32370]80 */
81 DECLR3CALLBACKMEMBER(int, pfnOpen, (const char *pszFilename, unsigned uOpenFlags,
82 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
[32536]83 void **ppBackendData));
[32370]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.
[32536]101 * @param ppBackendData Opaque state data for this image.
[32370]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,
[32536]110 void **ppBackendData));
[32370]111
112 /**
113 * Close a cache image.
114 *
115 * @returns VBox status code.
[32536]116 * @param pBackendData Opaque state data for this image.
[32370]117 * @param fDelete If true, delete the image from the host disk.
118 */
[32536]119 DECLR3CALLBACKMEMBER(int, pfnClose, (void *pBackendData, bool fDelete));
[32370]120
121 /**
[44412]122 * Start a read request.
[32370]123 *
124 * @returns VBox status code.
[32536]125 * @param pBackendData Opaque state data for this image.
[44412]126 * @param uOffset The offset of the virtual disk to read from.
[64272]127 * @param cbToRead How many bytes to read.
[44412]128 * @param pIoCtx I/O context associated with this request.
[32370]129 * @param pcbActuallyRead Pointer to returned number of bytes read.
130 */
[64272]131 DECLR3CALLBACKMEMBER(int, pfnRead, (void *pBackendData, uint64_t uOffset, size_t cbToRead,
[44412]132 PVDIOCTX pIoCtx, size_t *pcbActuallyRead));
[32370]133
134 /**
[44412]135 * Start a write request.
[32370]136 *
137 * @returns VBox status code.
[32536]138 * @param pBackendData Opaque state data for this image.
[44412]139 * @param uOffset The offset of the virtual disk to write to.
[64272]140 * @param cbToWrite How many bytes to write.
[44412]141 * @param pIoCtx I/O context associated with this request.
[32370]142 * @param pcbWriteProcess Pointer to returned number of bytes that could
[44412]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.
[32370]148 */
[64272]149 DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pBackendData, uint64_t uOffset, size_t cbToWrite,
[44412]150 PVDIOCTX pIoCtx, size_t *pcbWriteProcess));
[32370]151
152 /**
153 * Flush data to disk.
154 *
155 * @returns VBox status code.
[32536]156 * @param pBackendData Opaque state data for this image.
[44412]157 * @param pIoCtx I/O context associated with this request.
[32370]158 */
[44412]159 DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pBackendData, PVDIOCTX pIoCtx));
[32370]160
161 /**
[44412]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 /**
[32370]181 * Get the version of a cache image.
182 *
183 * @returns version of cache image.
[32536]184 * @param pBackendData Opaque state data for this image.
[32370]185 */
[32536]186 DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pBackendData));
[32370]187
188 /**
189 * Get the capacity of a cache image.
190 *
191 * @returns size of cache image in bytes.
[32536]192 * @param pBackendData Opaque state data for this image.
[32370]193 */
[32536]194 DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pBackendData));
[32370]195
196 /**
197 * Get the file size of a cache image.
198 *
199 * @returns size of cache image in bytes.
[32536]200 * @param pBackendData Opaque state data for this image.
[32370]201 */
[32536]202 DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pBackendData));
[32370]203
204 /**
205 * Get the image flags of a cache image.
206 *
207 * @returns image flags of cache image.
[32536]208 * @param pBackendData Opaque state data for this image.
[32370]209 */
[32536]210 DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pBackendData));
[32370]211
212 /**
213 * Get the open flags of a cache image.
214 *
215 * @returns open flags of cache image.
[32536]216 * @param pBackendData Opaque state data for this image.
[32370]217 */
[32536]218 DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pBackendData));
[32370]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.
[32536]225 * @param pBackendData Opaque state data for this image.
[32370]226 * @param uOpenFlags New open flags for this image.
227 */
[32536]228 DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pBackendData, unsigned uOpenFlags));
[32370]229
230 /**
231 * Get comment of a cache image.
232 *
233 * @returns VBox status code.
[32536]234 * @param pBackendData Opaque state data for this image.
[32370]235 * @param pszComment Where to store the comment.
236 * @param cbComment Size of the comment buffer.
237 */
[32536]238 DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pBackendData, char *pszComment, size_t cbComment));
[32370]239
240 /**
241 * Set comment of a cache image.
242 *
243 * @returns VBox status code.
[32536]244 * @param pBackendData Opaque state data for this image.
[32370]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 */
[32536]249 DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pBackendData, const char *pszComment));
[32370]250
251 /**
252 * Get UUID of a cache image.
253 *
254 * @returns VBox status code.
[32536]255 * @param pBackendData Opaque state data for this image.
[32370]256 * @param pUuid Where to store the image UUID.
257 */
[32536]258 DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pBackendData, PRTUUID pUuid));
[32370]259
260 /**
261 * Set UUID of a cache image.
262 *
263 * @returns VBox status code.
[32536]264 * @param pBackendData Opaque state data for this image.
[32370]265 * @param pUuid Where to get the image UUID from.
266 */
[32536]267 DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pBackendData, PCRTUUID pUuid));
[32370]268
269 /**
270 * Get last modification UUID of a cache image.
271 *
272 * @returns VBox status code.
[32536]273 * @param pBackendData Opaque state data for this image.
[32370]274 * @param pUuid Where to store the image modification UUID.
275 */
[32536]276 DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pBackendData, PRTUUID pUuid));
[32370]277
278 /**
279 * Set last modification UUID of a cache image.
280 *
281 * @returns VBox status code.
[32536]282 * @param pBackendData Opaque state data for this image.
[32370]283 * @param pUuid Where to get the image modification UUID from.
284 */
[32536]285 DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pBackendData, PCRTUUID pUuid));
[32370]286
287 /**
288 * Dump information about a cache image.
289 *
[32536]290 * @param pBackendData Opaque state data for this image.
[32370]291 */
[32536]292 DECLR3CALLBACKMEMBER(void, pfnDump, (void *pBackendData));
[32370]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
[63905]307 /** Initialization safty marker. */
308 uint32_t u32VersionEnd;
309
[32370]310} VDCACHEBACKEND;
[50988]311/** Pointer to VD cache backend. */
[32370]312typedef VDCACHEBACKEND *PVDCACHEBACKEND;
313/** Constant pointer to VD backend. */
314typedef const VDCACHEBACKEND *PCVDCACHEBACKEND;
315
[63905]316/** The current version of the VDCACHEBACKEND structure. */
317#define VD_CACHEBACKEND_VERSION VD_VERSION_MAKE(0xff03, 1, 0)
318
[32370]319#endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use