1 | /** $Id: VDIoBackend.h 99739 2023-05-11 01:01:08Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox HDD container test utility, async I/O backend
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2013-2023 Oracle and/or its affiliates.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox base platform packages, as
|
---|
11 | * available from https://www.virtualbox.org.
|
---|
12 | *
|
---|
13 | * This program is free software; you can redistribute it and/or
|
---|
14 | * modify it under the terms of the GNU General Public License
|
---|
15 | * as published by the Free Software Foundation, in version 3 of the
|
---|
16 | * License.
|
---|
17 | *
|
---|
18 | * This program is distributed in the hope that it will be useful, but
|
---|
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | * General Public License for more details.
|
---|
22 | *
|
---|
23 | * You should have received a copy of the GNU General Public License
|
---|
24 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | *
|
---|
26 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | */
|
---|
28 |
|
---|
29 | #ifndef VBOX_INCLUDED_SRC_testcase_VDIoBackend_h
|
---|
30 | #define VBOX_INCLUDED_SRC_testcase_VDIoBackend_h
|
---|
31 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
32 | # pragma once
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #include <iprt/sg.h>
|
---|
36 |
|
---|
37 | #include "VDDefs.h"
|
---|
38 |
|
---|
39 | /** I/O backend handle. */
|
---|
40 | typedef struct VDIOBACKEND *PVDIOBACKEND;
|
---|
41 | /** Pointer to a I/O backend handle. */
|
---|
42 | typedef PVDIOBACKEND *PPVDIOBACKEND;
|
---|
43 |
|
---|
44 | /** Storage handle. */
|
---|
45 | typedef struct VDIOSTORAGE *PVDIOSTORAGE;
|
---|
46 | /** Pointer to a storage handle. */
|
---|
47 | typedef PVDIOSTORAGE *PPVDIOSTORAGE;
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Completion handler.
|
---|
51 | *
|
---|
52 | * @returns IPRT status code.
|
---|
53 | * @param pvUser Opaque user data.
|
---|
54 | * @param rcReq Completion code for the request.
|
---|
55 | */
|
---|
56 | typedef DECLCALLBACKTYPE(int, FNVDIOCOMPLETE,(void *pvUser, int rcReq));
|
---|
57 | /** Pointer to a completion handler. */
|
---|
58 | typedef FNVDIOCOMPLETE *PFNVDIOCOMPLETE;
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Creates a new memory I/O backend.
|
---|
62 | *
|
---|
63 | * @returns IPRT status code.
|
---|
64 | *
|
---|
65 | * @param ppIoBackend Where to store the handle on success.
|
---|
66 | */
|
---|
67 | int VDIoBackendCreate(PPVDIOBACKEND ppIoBackend);
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Destroys a memory I/O backend.
|
---|
71 | *
|
---|
72 | * @param pIoBackend The backend to destroy.
|
---|
73 | */
|
---|
74 | void VDIoBackendDestroy(PVDIOBACKEND pIoBackend);
|
---|
75 |
|
---|
76 | int VDIoBackendStorageCreate(PVDIOBACKEND pIoBackend, const char *pszBackend,
|
---|
77 | const char *pszName, PFNVDIOCOMPLETE pfnComplete,
|
---|
78 | PPVDIOSTORAGE ppIoStorage);
|
---|
79 |
|
---|
80 | void VDIoBackendStorageDestroy(PVDIOSTORAGE pIoStorage);
|
---|
81 |
|
---|
82 | int VDIoBackendStorageSetSize(PVDIOSTORAGE pIoStorage, uint64_t cbSize);
|
---|
83 |
|
---|
84 | int VDIoBackendStorageGetSize(PVDIOSTORAGE pIoStorage, uint64_t *pcbSize);
|
---|
85 |
|
---|
86 | DECLHIDDEN(int) VDIoBackendDumpToFile(PVDIOSTORAGE pIoStorage, const char *pszPath);
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Enqueues a new I/O request.
|
---|
90 | *
|
---|
91 | * @returns IPRT status code.
|
---|
92 | *
|
---|
93 | * @param pIoStorage Storage handle.
|
---|
94 | * @param enmTxDir The transfer direction.
|
---|
95 | * @param off Start offset of the transfer.
|
---|
96 | * @param cbTransfer Size of the transfer.
|
---|
97 | * @param pSgBuf S/G buffer to use.
|
---|
98 | * @param pvUser Opaque user data.
|
---|
99 | * @param fSync Flag whether to wait for the operation to complete.
|
---|
100 | */
|
---|
101 | int VDIoBackendTransfer(PVDIOSTORAGE pIoStorage, VDIOTXDIR enmTxDir, uint64_t off,
|
---|
102 | size_t cbTransfer, PRTSGBUF pSgBuf, void *pvUser, bool fSync);
|
---|
103 |
|
---|
104 | #endif /* !VBOX_INCLUDED_SRC_testcase_VDIoBackend_h */
|
---|