VirtualBox

source: vbox/trunk/src/VBox/Storage/VDBackendsInline.h@ 66491

Last change on this file since 66491 was 66491, checked in by vboxsync, 8 years ago

Storage/VD: Macros to make adding stubs for features not supported by backends easier to implement and copy less code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: VDBackendsInline.h 66491 2017-04-10 09:45:09Z vboxsync $ */
2/** @file
3 * VD - backends inline helpers.
4 */
5
6/*
7 * Copyright (C) 2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#ifndef ___VDBackendsInline_h
22#define ___VDBackendsInline_h
23
24#include <iprt/cdefs.h>
25
26RT_C_DECLS_BEGIN
27
28/**
29 * Stub for VDIMAGEBACKEND::pfnGetComment when the backend doesn't suport comments.
30 *
31 * @returns VBox status code.
32 * @param a_szPrefixBackend The backend prefix.
33 */
34#define VD_BACKEND_CALLBACK_GET_COMMENT_DEF_NOT_SUPPORTED(a_szStubName) \
35 static DECLCALLBACK(int) a_szStubName(void *pvBackend, char *pszComment, size_t cbComment) \
36 { \
37 RT_NOREF2(pszComment, cbComment); \
38 LogFlowFunc(("pvBackend=%#p pszComment=%#p cbComment=%zu\n", pvBackend, pszComment, cbComment)); \
39 AssertPtrReturn(pvBackend, VERR_VD_NOT_OPENED); \
40 LogFlowFunc(("returns %Rrc comment='%s'\n", VERR_NOT_SUPPORTED, pszComment)); \
41 return VERR_NOT_SUPPORTED; \
42 } \
43 typedef int ignore_semicolon
44
45
46/**
47 * Stub for VDIMAGEBACKEND::pfnSetComment when the backend doesn't suport comments.
48 *
49 * @returns VBox status code.
50 * @param a_szPrefixBackend The backend prefix.
51 * @param a_ImageStateType Type of the backend image state.
52 */
53#define VD_BACKEND_CALLBACK_SET_COMMENT_DEF_NOT_SUPPORTED(a_szStubName, a_ImageStateType) \
54 static DECLCALLBACK(int) a_szStubName(void *pvBackend, const char *pszComment) \
55 { \
56 RT_NOREF1(pszComment); \
57 LogFlowFunc(("pvBackend=%#p pszComment=\"%s\"\n", pvBackend, pszComment)); \
58 a_ImageStateType pThis = (a_ImageStateType)pvBackend; \
59 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); \
60 int rc = VERR_NOT_SUPPORTED; \
61 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) \
62 rc = VERR_VD_IMAGE_READ_ONLY; \
63 LogFlowFunc(("returns %Rrc\n", rc)); \
64 return rc; \
65 } \
66 typedef int ignore_semicolon
67
68
69/**
70 * Stub for VDIMAGEBACKEND::pfnGetUuid when the backend doesn't suport UUIDs.
71 *
72 * @returns VBox status code.
73 * @param a_szPrefixBackend The backend prefix.
74 */
75#define VD_BACKEND_CALLBACK_GET_UUID_DEF_NOT_SUPPORTED(a_szStubName) \
76 static DECLCALLBACK(int) a_szStubName(void *pvBackend, PRTUUID pUuid) \
77 { \
78 RT_NOREF1(pUuid); \
79 LogFlowFunc(("pvBackend=%#p pUuid=%#p\n", pvBackend, pUuid)); \
80 AssertPtrReturn(pvBackend, VERR_VD_NOT_OPENED); \
81 LogFlowFunc(("returns %Rrc (%RTuuid)\n", VERR_NOT_SUPPORTED, pUuid)); \
82 return VERR_NOT_SUPPORTED; \
83 } \
84 typedef int ignore_semicolon
85
86
87/**
88 * Stub for VDIMAGEBACKEND::pfnSetComment when the backend doesn't suport UUIDs.
89 *
90 * @returns VBox status code.
91 * @param a_szPrefixBackend The backend prefix.
92 * @param a_ImageStateType Type of the backend image state.
93 */
94#define VD_BACKEND_CALLBACK_SET_UUID_DEF_NOT_SUPPORTED(a_szStubName, a_ImageStateType) \
95 static DECLCALLBACK(int) a_szStubName(void *pvBackend, PCRTUUID pUuid) \
96 { \
97 RT_NOREF1(pUuid); \
98 LogFlowFunc(("pvBackend=%#p Uuid=%RTuuid\n", pvBackend, pUuid)); \
99 a_ImageStateType pThis = (a_ImageStateType)pvBackend; \
100 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); \
101 int rc = VERR_NOT_SUPPORTED; \
102 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) \
103 rc = VERR_VD_IMAGE_READ_ONLY; \
104 LogFlowFunc(("returns %Rrc\n", rc)); \
105 return rc; \
106 } \
107 typedef int ignore_semicolon
108
109RT_C_DECLS_END
110
111#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