vd-ifs.h revision 7cb5e5e023bd9dc218e5b159d4a421245101edb2
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VD Container API - interfaces.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Copyright (C) 2011-2012 Oracle Corporation
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This file is part of VirtualBox Open Source Edition (OSE), as
c869993e79c1eafbec61a56bf6cea848fe754c71xy * available from http://www.virtualbox.org. This file is free software;
c869993e79c1eafbec61a56bf6cea848fe754c71xy * you can redistribute it and/or modify it under the terms of the GNU
c869993e79c1eafbec61a56bf6cea848fe754c71xy * General Public License (GPL) as published by the Free Software
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Foundation, in version 2 as it comes in the "COPYING" file of the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The contents of this file may alternatively be used under the terms
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of the Common Development and Distribution License Version 1.0
c869993e79c1eafbec61a56bf6cea848fe754c71xy * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VirtualBox OSE distribution, in which case the provisions of the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * CDDL are applicable instead of those of the GPL.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * You may elect to license modified versions of this file under the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * terms and conditions of either the GPL or the CDDL or both.
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Interface header magic. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Supported interface types.
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** First valid interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface to pass error message to upper layers. Per-disk. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for I/O operations. Per-image. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for progress notification. Per-operation. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for configuration information. Per-image. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for TCP network stack. Per-image. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for getting parent image state. Per-operation. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for synchronizing accesses from several threads. Per-disk. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for I/O between the generic VBoxHDD code and the backend. Per-image (internal).
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This interface is completely internal and must not be used elsewhere. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface to query the use of block ranges on the disk. Per-operation. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for the metadata traverse callback. Per-operation. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface for crypto operations. Per-filter. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** invalid interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common structure for all interfaces and at the beginning of all types.
c869993e79c1eafbec61a56bf6cea848fe754c71xytypedef struct VDINTERFACE
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Human readable interface name. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Pointer to the next common interface structure. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Interface type. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Size of the interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /** Opaque user data which is passed on every call. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Pointer to a VDINTERFACE. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Pointer to a const VDINTERFACE. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Helper functions to handle interface lists.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @note These interface lists are used consistently to pass per-disk,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * per-image and/or per-operation callbacks. Those three purposes are strictly
c869993e79c1eafbec61a56bf6cea848fe754c71xy * separate. See the individual interface declarations for what context they
c869993e79c1eafbec61a56bf6cea848fe754c71xy * apply to. The caller is responsible for ensuring that the lifetime of the
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * interface descriptors is appropriate for the category of interface.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Get a specific interface from a list of interfaces specified by the type.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the matching interface or NULL if none was found.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the VD interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param enmInterface Interface to search for.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACE) VDInterfaceGet(PVDINTERFACE pVDIfs, VDINTERFACETYPE enmInterface)
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* No matching interface was found. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Add an interface to a list of interfaces.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pInterface Pointer to an unitialized common interface structure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of the interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param enmInterface Type of the interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser Opaque user data passed on every function call.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppVDIfs Pointer to the VD interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDInterfaceAdd(PVDINTERFACE pInterface, const char *pszName,
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Argument checks. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy ("enmInterface=%u", enmInterface), VERR_INVALID_PARAMETER);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Fill out interface descriptor. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Remember the new start of the list. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Removes an interface from a list of interfaces.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pInterface Pointer to an initialized common interface structure to remove.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppVDIfs Pointer to the VD interface list to remove from.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDInterfaceRemove(PVDINTERFACE pInterface, PVDINTERFACE *ppVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Argument checks. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* First interface */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Interface to deliver error messages (and also informational messages)
c869993e79c1eafbec61a56bf6cea848fe754c71xy * to upper layers.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Per-disk interface. Optional, but think twice if you want to miss the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * opportunity of reporting better human-readable error messages.
c869993e79c1eafbec61a56bf6cea848fe754c71xytypedef struct VDINTERFACEERROR
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common interface header.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Error message callback. Must be able to accept special IPRT format
c869993e79c1eafbec61a56bf6cea848fe754c71xy * strings.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param rc The VBox error code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param RT_SRC_POS_DECL Use RT_SRC_POS.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszFormat Error message format string.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param va Error message arguments.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(void, pfnError, (void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Informational message callback. May be NULL. Used e.g. in
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VDDumpImages(). Must be able to accept special IPRT format strings.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszFormat Message format string.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param va Message arguments.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnMessage, (void *pvUser, const char *pszFormat, va_list va));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get error interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first error interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACEERROR) VDIfErrorGet(PVDINTERFACE pVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_ERROR);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a progress interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Signal an error to the frontend.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @returns VBox status code.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param pIfError The error interface.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param rc The status code.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param RT_SRC_POS_DECL The position in the source code.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param pszFormat The format string to pass.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param ... Arguments to the format string.
8bb4b220fdb894543e41a5f9037898cf3c3f312bglDECLINLINE(int) vdIfError(PVDINTERFACEERROR pIfError, int rc, RT_SRC_POS_DECL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy const char *pszFormat, ...)
c869993e79c1eafbec61a56bf6cea848fe754c71xy pIfError->pfnError(pIfError->Core.pvUser, rc, RT_SRC_POS_ARGS, pszFormat, va);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Signal an informational message to the frontend.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @returns VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pIfError The error interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszFormat The format string to pass.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ... Arguments to the format string.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfErrorMessage(PVDINTERFACEERROR pIfError, const char *pszFormat, ...)
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = pIfError->pfnMessage(pIfError->Core.pvUser, pszFormat, va);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Completion callback which is called by the interface owner
c869993e79c1eafbec61a56bf6cea848fe754c71xy * to inform the backend that a task finished.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser Opaque user data which is passed on request submission.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param rcReq Status code of the completed request.
c869993e79c1eafbec61a56bf6cea848fe754c71xytypedef DECLCALLBACK(int) FNVDCOMPLETED(void *pvUser, int rcReq);
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Pointer to FNVDCOMPLETED() */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Support interface for I/O
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Per-image. Optional as input.
c869993e79c1eafbec61a56bf6cea848fe754c71xytypedef struct VDINTERFACEIO
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common interface header.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Open callback
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszLocation Name of the location to open.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param fOpen Flags for opening the backend.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * See RTFILE_O_* #defines, inventing another set
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of open flags is not worth the mapping effort.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pfnCompleted The callback which is called whenever a task
c869993e79c1eafbec61a56bf6cea848fe754c71xy * completed. The backend has to pass the user data
c869993e79c1eafbec61a56bf6cea848fe754c71xy * of the request initiator (ie the one who calls
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VDAsyncRead or VDAsyncWrite) in pvCompletion
c869993e79c1eafbec61a56bf6cea848fe754c71xy * if this is NULL.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppStorage Where to store the opaque storage handle.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnOpen, (void *pvUser, const char *pszLocation,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Close callback.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The opaque storage handle to close.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnClose, (void *pvUser, void *pStorage));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Delete callback.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcszFilename Name of the file to delete.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnDelete, (void *pvUser, const char *pcszFilename));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Move callback.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcszSrc The path to the source file.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcszDst The path to the destination file.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This file will be created.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param fMove A combination of the RTFILEMOVE_* flags.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnMove, (void *pvUser, const char *pcszSrc, const char *pcszDst, unsigned fMove));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Returns the free space on a disk.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcszFilename Name of a file to identify the disk.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbFreeSpace Where to store the free space of the disk.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnGetFreeSpace, (void *pvUser, const char *pcszFilename, int64_t *pcbFreeSpace));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Returns the last modification timestamp of a file.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcszFilename Name of a file to identify the disk.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pModificationTime Where to store the timestamp of the file.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnGetModificationTime, (void *pvUser, const char *pcszFilename, PRTTIMESPEC pModificationTime));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Returns the size of the opened storage backend.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The opaque storage handle to close.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbSize Where to store the size of the storage backend.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnGetSize, (void *pvUser, void *pStorage, uint64_t *pcbSize));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Sets the size of the opened storage backend if possible.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @retval VERR_NOT_SUPPORTED if the backend does not support this operation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The opaque storage handle to close.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbSize The new size of the image.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnSetSize, (void *pvUser, void *pStorage, uint64_t cbSize));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Synchronous write callback.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The storage handle to use.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param uOffset The offset to start from.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvBuffer Pointer to the bits need to be written.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbBuffer How many bytes to write.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbWritten Where to store how many bytes were actually written.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnWriteSync, (void *pvUser, void *pStorage, uint64_t uOffset,
c869993e79c1eafbec61a56bf6cea848fe754c71xy const void *pvBuffer, size_t cbBuffer, size_t *pcbWritten));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Synchronous read callback.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The storage handle to use.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param uOffset The offset to start from.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvBuffer Where to store the read bits.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbBuffer How many bytes to read.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbRead Where to store how many bytes were actually read.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnReadSync, (void *pvUser, void *pStorage, uint64_t uOffset,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Flush data to the storage backend.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The storage handle to flush.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnFlushSync, (void *pvUser, void *pStorage));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initiate an asynchronous read request.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The storage handle.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param uOffset The offset to start reading from.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param paSegments Scatter gather list to store the data in.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cSegments Number of segments in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbRead How many bytes to read.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvCompletion The opaque user data which is returned upon completion.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppTask Where to store the opaque task handle.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnReadAsync, (void *pvUser, void *pStorage, uint64_t uOffset,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initiate an asynchronous write request.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data passed on conatiner creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The storage handle.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param uOffset The offset to start writing to.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param paSegments Scatter gather list of the data to write
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cSegments Number of segments in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbWrite How many bytes to write.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvCompletion The opaque user data which is returned upon completion.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppTask Where to store the opaque task handle.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnWriteAsync, (void *pvUser, void *pStorage, uint64_t uOffset,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Initiates an async flush request.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque data passed on container creation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pStorage The storage handle to flush.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvCompletion The opaque user data which is returned upon completion.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppTask Where to store the opaque task handle.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnFlushAsync, (void *pvUser, void *pStorage,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get I/O interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first I/O interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_IO);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a progress interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileOpen(PVDINTERFACEIO pIfIo, const char *pszFilename,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnOpen(pIfIo->Core.pvUser, pszFilename, fOpen, pfnCompleted, ppStorage);
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileClose(PVDINTERFACEIO pIfIo, void *pStorage)
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileDelete(PVDINTERFACEIO pIfIo, const char *pszFilename)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnDelete(pIfIo->Core.pvUser, pszFilename);
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileMove(PVDINTERFACEIO pIfIo, const char *pszSrc,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnMove(pIfIo->Core.pvUser, pszSrc, pszDst, fMove);
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileGetFreeSpace(PVDINTERFACEIO pIfIo, const char *pszFilename,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnGetFreeSpace(pIfIo->Core.pvUser, pszFilename, pcbFree);
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileGetModificationTime(PVDINTERFACEIO pIfIo, const char *pcszFilename,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnGetModificationTime(pIfIo->Core.pvUser, pcszFilename,
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileGetSize(PVDINTERFACEIO pIfIo, void *pStorage,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnGetSize(pIfIo->Core.pvUser, pStorage, pcbSize);
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileSetSize(PVDINTERFACEIO pIfIo, void *pStorage,
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return pIfIo->pfnSetSize(pIfIo->Core.pvUser, pStorage, cbSize);
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileWriteSync(PVDINTERFACEIO pIfIo, void *pStorage,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnWriteSync(pIfIo->Core.pvUser, pStorage, uOffset,
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileReadSync(PVDINTERFACEIO pIfIo, void *pStorage,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnReadSync(pIfIo->Core.pvUser, pStorage, uOffset,
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfIoFileFlushSync(PVDINTERFACEIO pIfIo, void *pStorage)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfIo->pfnFlushSync(pIfIo->Core.pvUser, pStorage);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Create a VFS stream handle around a VD I/O interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The I/O interface will not be closed or free by the stream, the caller will
c869993e79c1eafbec61a56bf6cea848fe754c71xy * do so after it is done with the stream and has released the instances of the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * I/O stream object returned by this API.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfsIo Pointer to the VD I/O interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvStorage The storage argument to pass to the interface
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * methods.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param fFlags RTFILE_O_XXX, access mask requied.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param phVfsIos Where to return the VFS I/O stream handle on
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * success.
8bb4b220fdb894543e41a5f9037898cf3c3f312bglVBOXDDU_DECL(int) VDIfCreateVfsStream(PVDINTERFACEIO pVDIfsIo, void *pvStorage, uint32_t fFlags, PRTVFSIOSTREAM phVfsIos);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Create a VFS file handle around a VD I/O interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The I/O interface will not be closed or free by the VFS file, the caller will
c869993e79c1eafbec61a56bf6cea848fe754c71xy * do so after it is done with the VFS file and has released the instances of
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the VFS object returned by this API.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the VD I/O interface. If NULL, then @a
c869993e79c1eafbec61a56bf6cea848fe754c71xy * pVDIfsInt must be specified.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfsInt Pointer to the internal VD I/O interface. If NULL,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * then @ pVDIfs must be specified.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvStorage The storage argument to pass to the interface
c869993e79c1eafbec61a56bf6cea848fe754c71xy * methods.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param fFlags RTFILE_O_XXX, access mask requied.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param phVfsFile Where to return the VFS file handle on success.
c869993e79c1eafbec61a56bf6cea848fe754c71xyVBOXDDU_DECL(int) VDIfCreateVfsFile(PVDINTERFACEIO pVDIfs, struct VDINTERFACEIOINT *pVDIfsInt, void *pvStorage, uint32_t fFlags, PRTVFSFILE phVfsFile);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Callback which provides progress information about a currently running
c869993e79c1eafbec61a56bf6cea848fe754c71xy * lengthy operation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param uPercent Completion percentage.
c869993e79c1eafbec61a56bf6cea848fe754c71xytypedef DECLCALLBACK(int) FNVDPROGRESS(void *pvUser, unsigned uPercentage);
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Pointer to FNVDPROGRESS() */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Progress notification interface
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Per-operation. Optional.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common interface header.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Progress notification callbacks.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get progress interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first progress interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACEPROGRESS) VDIfProgressGet(PVDINTERFACE pVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_PROGRESS);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a progress interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Configuration information interface
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Per-image. Optional for most backends, but mandatory for images which do
c869993e79c1eafbec61a56bf6cea848fe754c71xy * not operate on files (including standard block or character devices).
c869993e79c1eafbec61a56bf6cea848fe754c71xytypedef struct VDINTERFACECONFIG
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common interface header.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Validates that the keys are within a set of valid names.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return true if all key names are found in pszzAllowed.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return false if not.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszzValid List of valid key names separated by '\\0' and ending with
c869993e79c1eafbec61a56bf6cea848fe754c71xy * a double '\\0'.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(bool, pfnAreKeysValid, (void *pvUser, const char *pszzValid));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Retrieves the length of the string value associated with a key (including
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the terminator, for compatibility with CFGMR3QuerySize).
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of the key to query.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbValue Where to store the value length. Non-NULL.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnQuerySize, (void *pvUser, const char *pszName, size_t *pcbValue));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query the string value associated with a key.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VERR_CFGM_NOT_ENOUGH_SPACE means that the buffer is not big enough.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of the key to query.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszValue Pointer to buffer where to store value.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cchValue Length of value buffer.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnQuery, (void *pvUser, const char *pszName, char *pszValue, size_t cchValue));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query the bytes value associated with a key.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VERR_CFGM_NOT_ENOUGH_SPACE means that the buffer is not big enough.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of the key to query.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppvData Pointer to buffer where to store the data.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbData Length of data buffer.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnQueryBytes, (void *pvUser, const char *pszName, void *ppvData, size_t cbData));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get configuration information interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first configuration information interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACECONFIG) VDIfConfigGet(PVDINTERFACE pVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_CONFIG);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a progress interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, validates that the keys are within a set of valid names.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return true if all key names are found in pszzAllowed.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return false if not.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszzValid List of valid names separated by '\\0' and ending with
c869993e79c1eafbec61a56bf6cea848fe754c71xy * a double '\\0'.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(bool) VDCFGAreKeysValid(PVDINTERFACECONFIG pCfgIf, const char *pszzValid)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pCfgIf->pfnAreKeysValid(pCfgIf->Core.pvUser, pszzValid);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, unsigned 64-bit integer value with default.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an integer value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pu64 Where to store the value. Set to default on failure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param u64Def The default value.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryU64Def(PVDINTERFACECONFIG pCfgIf,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc = pCfgIf->pfnQuery(pCfgIf->Core.pvUser, pszName, aszBuf, sizeof(aszBuf));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, unsigned 64-bit integer value.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an integer value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pu64 Where to store the value.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryU64(PVDINTERFACECONFIG pCfgIf, const char *pszName,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc = pCfgIf->pfnQuery(pCfgIf->Core.pvUser, pszName, aszBuf, sizeof(aszBuf));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, unsigned 32-bit integer value with default.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an integer value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pu32 Where to store the value. Set to default on failure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param u32Def The default value.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryU32Def(PVDINTERFACECONFIG pCfgIf,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc = VDCFGQueryU64Def(pCfgIf, pszName, &u64, u32Def);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, bool value with default.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an integer value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pf Where to store the value. Set to default on failure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param fDef The default value.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryBoolDef(PVDINTERFACECONFIG pCfgIf,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, bool value.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an integer value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pf Where to store the value.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryBool(PVDINTERFACECONFIG pCfgIf, const char *pszName,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, dynamically allocated (RTMemAlloc) zero terminated
c869993e79c1eafbec61a56bf6cea848fe754c71xy * character value.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an zero terminated character value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppszString Where to store the string pointer. Not set on failure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free this using RTMemFree().
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryStringAlloc(PVDINTERFACECONFIG pCfgIf,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc = pCfgIf->pfnQuerySize(pCfgIf->Core.pvUser, pszName, &cb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = pCfgIf->pfnQuery(pCfgIf->Core.pvUser, pszName, pszString, cb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, dynamically allocated (RTMemAlloc) zero terminated
c869993e79c1eafbec61a56bf6cea848fe754c71xy * character value with default.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an zero terminated character value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppszString Where to store the string pointer. Not set on failure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free this using RTMemFree().
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszDef The default value.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryStringAllocDef(PVDINTERFACECONFIG pCfgIf,
c869993e79c1eafbec61a56bf6cea848fe754c71xy const char *pszName,
c869993e79c1eafbec61a56bf6cea848fe754c71xy const char *pszDef)
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc = pCfgIf->pfnQuerySize(pCfgIf->Core.pvUser, pszName, &cb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = pCfgIf->pfnQuery(pCfgIf->Core.pvUser, pszName, pszString, cb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query configuration, dynamically allocated (RTMemAlloc) byte string value.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pCfgIf Pointer to configuration callback table.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszName Name of an zero terminated character value
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppvData Where to store the byte string pointer. Not set on failure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Free this using RTMemFree().
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbData Where to store the byte string length.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) VDCFGQueryBytesAlloc(PVDINTERFACECONFIG pCfgIf,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int rc = pCfgIf->pfnQuerySize(pCfgIf->Core.pvUser, pszName, &cb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = pCfgIf->pfnQueryBytes(pCfgIf->Core.pvUser, pszName, pbData, cb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy rc = pCfgIf->pfnQuery(pCfgIf->Core.pvUser, pszName, pbData, cb);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Exclude terminator if the byte data was obtained using the string query callback. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Forward declaration of a VD socket. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Pointer to a VD socket. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Nil socket handle. */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl/** Connect flag to indicate that the backend wants to use the extended
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * socket I/O multiplexing call. This might not be supported on all configurations
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * (internal networking and iSCSI)
c869993e79c1eafbec61a56bf6cea848fe754c71xy * and the backend needs to take appropriate action.
c869993e79c1eafbec61a56bf6cea848fe754c71xy#define VD_INTERFACETCPNET_CONNECT_EXTENDED_SELECT RT_BIT_32(0)
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** @name Select events
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Readable without blocking. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Writable without blocking. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Error condition, hangup, exception or similar. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Hint for the select that getting interrupted while waiting is more likely.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The interface implementation can optimize the waiting strategy based on this.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * It is assumed that it is more likely to get one of the above socket events
c869993e79c1eafbec61a56bf6cea848fe754c71xy * instead of being interrupted if the flag is not set. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy/** Mask of the valid bits. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy#define VD_INTERFACETCPNET_EVT_VALID_MASK UINT32_C(0x0000000f)
c869993e79c1eafbec61a56bf6cea848fe754c71xy * TCP network stack interface
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Per-image. Mandatory for backends which have the VD_CAP_TCPNET bit set.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgltypedef struct VDINTERFACETCPNET
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Common interface header.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Creates a socket. The socket is not connected if this succeeds.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @retval VERR_NOT_SUPPORTED if the combination of flags is not supported.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param fFlags Combination of the VD_INTERFACETCPNET_CONNECT_* #defines.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pSock Where to store the handle.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnSocketCreate, (uint32_t fFlags, PVDSOCKET pSock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Destroys the socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @param Sock Socket descriptor.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl DECLR3CALLBACKMEMBER(int, pfnSocketDestroy, (VDSOCKET Sock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Connect as a client to a TCP port.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszAddress The address to connect to.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param uPort The port to connect to.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cMillies Number of milliseconds to wait for the connect attempt to complete.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Use RT_INDEFINITE_WAIT to wait for ever.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Use RT_SOCKETCONNECT_DEFAULT_WAIT to wait for the default time
c869993e79c1eafbec61a56bf6cea848fe754c71xy * configured on the running system.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnClientConnect, (VDSOCKET Sock, const char *pszAddress, uint32_t uPort,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Close a TCP connection.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnClientClose, (VDSOCKET Sock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Returns whether the socket is currently connected to the client.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @returns true if the socket is connected.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * false otherwise.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(bool, pfnIsClientConnected, (VDSOCKET Sock));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Socket I/O multiplexing.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Checks if the socket is ready for reading.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cMillies Number of milliseconds to wait for the socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Use RT_INDEFINITE_WAIT to wait for ever.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnSelectOne, (VDSOCKET Sock, RTMSINTERVAL cMillies));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Receive data from a socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvBuffer Where to put the data we read.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbBuffer Read buffer size.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbRead Number of bytes read.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If NULL the entire buffer will be filled upon successful return.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * If not NULL a partial read can be done successfully.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnRead, (VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Send data to a socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvBuffer Buffer to write data to socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbBuffer How much to write.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnWrite, (VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Send data from scatter/gather buffer to a socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pSgBuffer Scatter/gather buffer to write data to socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnSgWrite, (VDSOCKET Sock, PCRTSGBUF pSgBuffer));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Receive data from a socket - not blocking.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvBuffer Where to put the data we read.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbBuffer Read buffer size.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbRead Number of bytes read.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnReadNB, (VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Send data to a socket - not blocking.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvBuffer Buffer to write data to socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbBuffer How much to write.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbWritten Number of bytes written.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnWriteNB, (VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer, size_t *pcbWritten));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Send data from scatter/gather buffer to a socket - not blocking.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pSgBuffer Scatter/gather buffer to write data to socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbWritten Number of bytes written.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnSgWriteNB, (VDSOCKET Sock, PRTSGBUF pSgBuffer, size_t *pcbWritten));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Flush socket write buffers.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Enables or disables delaying sends to coalesce packets.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param fEnable When set to true enables coalescing.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnSetSendCoalescing, (VDSOCKET Sock, bool fEnable));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Gets the address of the local side.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pAddr Where to store the local address on success.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnGetLocalAddress, (VDSOCKET Sock, PRTNETADDR pAddr));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Gets the address of the other party.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pAddr Where to store the peer address on success.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnGetPeerAddress, (VDSOCKET Sock, PRTNETADDR pAddr));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Socket I/O multiplexing - extended version which can be woken up.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Checks if the socket is ready for reading or writing.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @return iprt status code.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @retval VERR_INTERRUPTED if the thread was woken up by a pfnPoke call.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param fEvents Mask of events to wait for.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pfEvents Where to store the received events.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cMillies Number of milliseconds to wait for the socket.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Use RT_INDEFINITE_WAIT to wait for ever.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnSelectOneEx, (VDSOCKET Sock, uint32_t fEvents,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Wakes up the thread waiting in pfnSelectOneEx.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return iprt status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param Sock Socket descriptor.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get TCP network stack interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first TCP network stack interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACETCPNET) VDIfTcpNetGet(PVDINTERFACE pVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_TCPNET);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a progress interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Interface to synchronize concurrent accesses by several threads.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @note The scope of this interface is to manage concurrent accesses after
c869993e79c1eafbec61a56bf6cea848fe754c71xy * the HDD container has been created, and they must stop before destroying the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * container. Opening or closing images is covered by the synchronization, but
c869993e79c1eafbec61a56bf6cea848fe754c71xy * that does not mean it is safe to close images while a thread executes
c869993e79c1eafbec61a56bf6cea848fe754c71xy * <link to="VDMerge"/> or <link to="VDCopy"/> operating on these images.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Making them safe would require the lock to be held during the entire
c869993e79c1eafbec61a56bf6cea848fe754c71xy * operation, which prevents other concurrent acitivities.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @note Right now this is kept as simple as possible, and does not even
c869993e79c1eafbec61a56bf6cea848fe754c71xy * attempt to provide enough information to allow e.g. concurrent write
c869993e79c1eafbec61a56bf6cea848fe754c71xy * accesses to different areas of the disk. The reason is that it is very
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * difficult to predict which area of a disk is affected by a write,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * especially when different image formats are mixed. Maybe later a more
c869993e79c1eafbec61a56bf6cea848fe754c71xy * sophisticated interface will be provided which has the necessary information
c869993e79c1eafbec61a56bf6cea848fe754c71xy * about worst case affected areas.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Per-disk interface. Optional, needed if the disk is accessed concurrently
c869993e79c1eafbec61a56bf6cea848fe754c71xy * by several threads, e.g. when merging diff images while a VM is running.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common interface header.
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Start a read operation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Finish a read operation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnFinishRead, (void *pvUser));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Start a write operation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnStartWrite, (void *pvUser));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Finish a write operation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnFinishWrite, (void *pvUser));
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * Get thread synchronization interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first thread synchronization interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACETHREADSYNC) VDIfThreadSyncGet(PVDINTERFACE pVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_THREADSYNC);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a progress interface. */
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Interface to query usage of disk ranges.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Per-operation interface. Optional.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common interface header.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Query use of a disk range.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnQueryRangeUse, (void *pvUser, uint64_t off, uint64_t cb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get query range use interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first thread synchronization interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACEQUERYRANGEUSE) VDIfQueryRangeUseGet(PVDINTERFACE pVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_QUERYRANGEUSE);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a progress interface. */
fa25784ca4b51c206177d891a654f1d36a25d41fxy || ( (pIf->enmInterface == VDINTERFACETYPE_QUERYRANGEUSE)
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfQueryRangeUse(PVDINTERFACEQUERYRANGEUSE pIfQueryRangeUse, uint64_t off, uint64_t cb,
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfQueryRangeUse->pfnQueryRangeUse(pIfQueryRangeUse->Core.pvUser, off, cb, pfUsed);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Interface used to retrieve keys for cryptographic operations.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Per-module interface. Optional but cryptographic modules might fail and
c869993e79c1eafbec61a56bf6cea848fe754c71xy * return an error if this is not present.
c869993e79c1eafbec61a56bf6cea848fe754c71xytypedef struct VDINTERFACECRYPTO
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Common interface header.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Retains a key identified by the ID. The caller will only hold a reference
c869993e79c1eafbec61a56bf6cea848fe754c71xy * to the key and must not modify the key buffer in any way.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @returns VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszId The alias/id for the key to retrieve.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppbKey Where to store the pointer to the key buffer on success.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pcbKey Where to store the size of the key in bytes on success.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnKeyRetain, (void *pvUser, const char *pszId, const uint8_t **ppbKey, size_t *pcbKey));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Releases one reference of the key identified by the given identifier.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The caller must not access the key buffer after calling this operation.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @returns VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszId The alias/id for the key to release.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @note: It is advised to release the key whenever it is not used anymore so the entity
c869993e79c1eafbec61a56bf6cea848fe754c71xy * storing the key can do anything to make retrieving the key from memory more
c869993e79c1eafbec61a56bf6cea848fe754c71xy * difficult like scrambling the memory buffer for instance.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnKeyRelease, (void *pvUser, const char *pszId));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Gets the password to open a key store supplied through the onfig interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @returns VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param ppszPassword Where to store the password to unlock the key store on success.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnKeyStoreGetPassword, (void *pvUser, const char **ppszPassword));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Saves a key store.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @returns VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvKeyStore The key store to save.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbKeyStore Size of the key store in bytes.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @note The format is filter specific and should be treated as binary data.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnKeyStoreSave, (void *pvUser, const void *pvKeyStore, size_t cbKeyStore));
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Returns the parameters after the key store was loaded successfully.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @returns VBox status code.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pvUser The opaque user data associated with this interface.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pszCipher The cipher identifier the DEK is used for.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pbDek The raw DEK which was contained in the key store loaded by
c869993e79c1eafbec61a56bf6cea848fe754c71xy * VDINTERFACECRYPTO::pfnKeyStoreLoad().
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param cbDek The size of the DEK.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @note The provided pointer to the DEK is only valid until this call returns.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * The content might change afterwards with out notice (when scrambling the key
c869993e79c1eafbec61a56bf6cea848fe754c71xy * for further protection for example) or might be even freed.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @note This method is optional and can be NULL if the caller does not require the
c869993e79c1eafbec61a56bf6cea848fe754c71xy * parameters.
c869993e79c1eafbec61a56bf6cea848fe754c71xy DECLR3CALLBACKMEMBER(int, pfnKeyStoreReturnParameters, (void *pvUser, const char *pszCipher,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Get error interface from interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @return Pointer to the first error interface in the list.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @param pVDIfs Pointer to the interface list.
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(PVDINTERFACECRYPTO) VDIfCryptoGet(PVDINTERFACE pVDIfs)
c869993e79c1eafbec61a56bf6cea848fe754c71xy PVDINTERFACE pIf = VDInterfaceGet(pVDIfs, VDINTERFACETYPE_CRYPTO);
c869993e79c1eafbec61a56bf6cea848fe754c71xy /* Check that the interface descriptor is a crypto interface. */
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @copydoc VDINTERFACECRYPTO::pfnKeyRetain
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfCryptoKeyRetain(PVDINTERFACECRYPTO pIfCrypto, const char *pszId, const uint8_t **ppbKey, size_t *pcbKey)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfCrypto->pfnKeyRetain(pIfCrypto->Core.pvUser, pszId, ppbKey, pcbKey);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @copydoc VDINTERFACECRYPTO::pfnKeyRelease
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfCryptoKeyRelease(PVDINTERFACECRYPTO pIfCrypto, const char *pszId)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfCrypto->pfnKeyRelease(pIfCrypto->Core.pvUser, pszId);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl * @copydoc VDINTERFACECRYPTO::pfnKeyStoreGetPassword
8bb4b220fdb894543e41a5f9037898cf3c3f312bglDECLINLINE(int) vdIfCryptoKeyStoreGetPassword(PVDINTERFACECRYPTO pIfCrypto, const char **ppszPassword)
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl return pIfCrypto->pfnKeyStoreGetPassword(pIfCrypto->Core.pvUser, ppszPassword);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @copydoc VDINTERFACECRYPTO::pfnKeyStoreSave
c869993e79c1eafbec61a56bf6cea848fe754c71xyDECLINLINE(int) vdIfCryptoKeyStoreSave(PVDINTERFACECRYPTO pIfCrypto, const void *pvKeyStore, size_t cbKeyStore)
c869993e79c1eafbec61a56bf6cea848fe754c71xy return pIfCrypto->pfnKeyStoreSave(pIfCrypto->Core.pvUser, pvKeyStore, cbKeyStore);
c869993e79c1eafbec61a56bf6cea848fe754c71xy * @copydoc VDINTERFACECRYPTO::pfnKeyStoreReturnParameters
8bb4b220fdb894543e41a5f9037898cf3c3f312bglDECLINLINE(int) vdIfCryptoKeyStoreReturnParameters(PVDINTERFACECRYPTO pIfCrypto, const char *pszCipher,