1 | /** @file
|
---|
2 | * CFGM - Configuration Manager.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2015 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_vmm_cfgm_h
|
---|
27 | #define ___VBox_vmm_cfgm_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 | #include <iprt/stdarg.h>
|
---|
31 |
|
---|
32 | /** @defgroup grp_cfgm The Configuration Manager API
|
---|
33 | * @ingroup grp_vmm
|
---|
34 | * @{
|
---|
35 | */
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Configuration manager value type.
|
---|
39 | */
|
---|
40 | typedef enum CFGMVALUETYPE
|
---|
41 | {
|
---|
42 | /** Integer value. */
|
---|
43 | CFGMVALUETYPE_INTEGER = 1,
|
---|
44 | /** String value. */
|
---|
45 | CFGMVALUETYPE_STRING,
|
---|
46 | /** Bytestring value. */
|
---|
47 | CFGMVALUETYPE_BYTES
|
---|
48 | } CFGMVALUETYPE;
|
---|
49 | /** Pointer to configuration manager property type. */
|
---|
50 | typedef CFGMVALUETYPE *PCFGMVALUETYPE;
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 | RT_C_DECLS_BEGIN
|
---|
55 |
|
---|
56 | #ifdef IN_RING3
|
---|
57 | /** @defgroup grp_cfgm_r3 The CFGM Host Context Ring-3 API
|
---|
58 | * @{
|
---|
59 | */
|
---|
60 |
|
---|
61 | typedef enum CFGMCONFIGTYPE
|
---|
62 | {
|
---|
63 | /** pvConfig points to nothing, use defaults. */
|
---|
64 | CFGMCONFIGTYPE_NONE = 0,
|
---|
65 | /** pvConfig points to a IMachine interface. */
|
---|
66 | CFGMCONFIGTYPE_IMACHINE
|
---|
67 | } CFGMCONFIGTYPE;
|
---|
68 |
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * CFGM init callback for constructing the configuration tree.
|
---|
72 | *
|
---|
73 | * This is called from the emulation thread, and the one interfacing the VM
|
---|
74 | * can make any necessary per-thread initializations at this point.
|
---|
75 | *
|
---|
76 | * @returns VBox status code.
|
---|
77 | * @param pUVM The user mode VM handle.
|
---|
78 | * @param pVM The cross context VM structure.
|
---|
79 | * @param pvUser The argument supplied to VMR3Create().
|
---|
80 | */
|
---|
81 | typedef DECLCALLBACK(int) FNCFGMCONSTRUCTOR(PUVM pUVM, PVM pVM, void *pvUser);
|
---|
82 | /** Pointer to a FNCFGMCONSTRUCTOR(). */
|
---|
83 | typedef FNCFGMCONSTRUCTOR *PFNCFGMCONSTRUCTOR;
|
---|
84 |
|
---|
85 | VMMR3DECL(int) CFGMR3Init(PVM pVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUser);
|
---|
86 | VMMR3DECL(int) CFGMR3Term(PVM pVM);
|
---|
87 | VMMR3DECL(int) CFGMR3ConstructDefaultTree(PVM pVM);
|
---|
88 |
|
---|
89 | VMMR3DECL(PCFGMNODE) CFGMR3CreateTree(PUVM pUVM);
|
---|
90 | VMMR3DECL(int) CFGMR3DestroyTree(PCFGMNODE pRoot);
|
---|
91 | VMMR3DECL(void) CFGMR3Dump(PCFGMNODE pRoot);
|
---|
92 | VMMR3DECL(int) CFGMR3DuplicateSubTree(PCFGMNODE pRoot, PCFGMNODE *ppCopy);
|
---|
93 | VMMR3DECL(int) CFGMR3ReplaceSubTree(PCFGMNODE pRoot, PCFGMNODE pNewRoot);
|
---|
94 | VMMR3DECL(int) CFGMR3InsertSubTree(PCFGMNODE pNode, const char *pszName, PCFGMNODE pSubTree, PCFGMNODE *ppChild);
|
---|
95 | VMMR3DECL(int) CFGMR3InsertNode(PCFGMNODE pNode, const char *pszName, PCFGMNODE *ppChild);
|
---|
96 | VMMR3DECL(int) CFGMR3InsertNodeF(PCFGMNODE pNode, PCFGMNODE *ppChild,
|
---|
97 | const char *pszNameFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
98 | VMMR3DECL(int) CFGMR3InsertNodeFV(PCFGMNODE pNode, PCFGMNODE *ppChild,
|
---|
99 | const char *pszNameFormat, va_list Args) RT_IPRT_FORMAT_ATTR(3, 0);
|
---|
100 | VMMR3DECL(void) CFGMR3SetRestrictedRoot(PCFGMNODE pNode);
|
---|
101 | VMMR3DECL(void) CFGMR3RemoveNode(PCFGMNODE pNode);
|
---|
102 | VMMR3DECL(int) CFGMR3InsertInteger(PCFGMNODE pNode, const char *pszName, uint64_t u64Integer);
|
---|
103 | VMMR3DECL(int) CFGMR3InsertString(PCFGMNODE pNode, const char *pszName, const char *pszString);
|
---|
104 | VMMR3DECL(int) CFGMR3InsertStringN(PCFGMNODE pNode, const char *pszName, const char *pszString, size_t cchString);
|
---|
105 | VMMR3DECL(int) CFGMR3InsertStringF(PCFGMNODE pNode, const char *pszName,
|
---|
106 | const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
107 | VMMR3DECL(int) CFGMR3InsertStringFV(PCFGMNODE pNode, const char *pszName,
|
---|
108 | const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
|
---|
109 | VMMR3DECL(int) CFGMR3InsertStringW(PCFGMNODE pNode, const char *pszName, PCRTUTF16 pwszValue);
|
---|
110 | VMMR3DECL(int) CFGMR3InsertBytes(PCFGMNODE pNode, const char *pszName, const void *pvBytes, size_t cbBytes);
|
---|
111 | VMMR3DECL(int) CFGMR3InsertValue(PCFGMNODE pNode, PCFGMLEAF pValue);
|
---|
112 | VMMR3DECL(int) CFGMR3RemoveValue(PCFGMNODE pNode, const char *pszName);
|
---|
113 |
|
---|
114 | /** @name CFGMR3CopyTree flags.
|
---|
115 | * @{ */
|
---|
116 | /** Reserved value disposition \#0. */
|
---|
117 | #define CFGM_COPY_FLAGS_RESERVED_VALUE_DISP_0 UINT32_C(0x00000000)
|
---|
118 | /** Reserved value disposition \#1. */
|
---|
119 | #define CFGM_COPY_FLAGS_RESERVED_VALUE_DISP_1 UINT32_C(0x00000001)
|
---|
120 | /** Replace exiting values. */
|
---|
121 | #define CFGM_COPY_FLAGS_REPLACE_VALUES UINT32_C(0x00000002)
|
---|
122 | /** Ignore exiting values. */
|
---|
123 | #define CFGM_COPY_FLAGS_IGNORE_EXISTING_VALUES UINT32_C(0x00000003)
|
---|
124 | /** Value disposition mask. */
|
---|
125 | #define CFGM_COPY_FLAGS_VALUE_DISP_MASK UINT32_C(0x00000003)
|
---|
126 |
|
---|
127 | /** Replace exiting keys. */
|
---|
128 | #define CFGM_COPY_FLAGS_RESERVED_KEY_DISP UINT32_C(0x00000000)
|
---|
129 | /** Replace exiting keys. */
|
---|
130 | #define CFGM_COPY_FLAGS_MERGE_KEYS UINT32_C(0x00000010)
|
---|
131 | /** Replace exiting keys. */
|
---|
132 | #define CFGM_COPY_FLAGS_REPLACE_KEYS UINT32_C(0x00000020)
|
---|
133 | /** Ignore existing keys. */
|
---|
134 | #define CFGM_COPY_FLAGS_IGNORE_EXISTING_KEYS UINT32_C(0x00000030)
|
---|
135 | /** Key disposition. */
|
---|
136 | #define CFGM_COPY_FLAGS_KEY_DISP_MASK UINT32_C(0x00000030)
|
---|
137 | /** @} */
|
---|
138 | VMMR3DECL(int) CFGMR3CopyTree(PCFGMNODE pDstTree, PCFGMNODE pSrcTree, uint32_t fFlags);
|
---|
139 |
|
---|
140 | VMMR3DECL(bool) CFGMR3Exists( PCFGMNODE pNode, const char *pszName);
|
---|
141 | VMMR3DECL(int) CFGMR3QueryType( PCFGMNODE pNode, const char *pszName, PCFGMVALUETYPE penmType);
|
---|
142 | VMMR3DECL(int) CFGMR3QuerySize( PCFGMNODE pNode, const char *pszName, size_t *pcb);
|
---|
143 | VMMR3DECL(int) CFGMR3QueryInteger( PCFGMNODE pNode, const char *pszName, uint64_t *pu64);
|
---|
144 | VMMR3DECL(int) CFGMR3QueryIntegerDef( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def);
|
---|
145 | VMMR3DECL(int) CFGMR3QueryString( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString);
|
---|
146 | VMMR3DECL(int) CFGMR3QueryStringDef( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString, const char *pszDef);
|
---|
147 | VMMR3DECL(int) CFGMR3QueryBytes( PCFGMNODE pNode, const char *pszName, void *pvData, size_t cbData);
|
---|
148 |
|
---|
149 |
|
---|
150 | /** @name Helpers
|
---|
151 | * @{
|
---|
152 | */
|
---|
153 | VMMR3DECL(int) CFGMR3QueryU64( PCFGMNODE pNode, const char *pszName, uint64_t *pu64);
|
---|
154 | VMMR3DECL(int) CFGMR3QueryU64Def( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def);
|
---|
155 | VMMR3DECL(int) CFGMR3QueryS64( PCFGMNODE pNode, const char *pszName, int64_t *pi64);
|
---|
156 | VMMR3DECL(int) CFGMR3QueryS64Def( PCFGMNODE pNode, const char *pszName, int64_t *pi64, int64_t i64Def);
|
---|
157 | VMMR3DECL(int) CFGMR3QueryU32( PCFGMNODE pNode, const char *pszName, uint32_t *pu32);
|
---|
158 | VMMR3DECL(int) CFGMR3QueryU32Def( PCFGMNODE pNode, const char *pszName, uint32_t *pu32, uint32_t u32Def);
|
---|
159 | VMMR3DECL(int) CFGMR3QueryS32( PCFGMNODE pNode, const char *pszName, int32_t *pi32);
|
---|
160 | VMMR3DECL(int) CFGMR3QueryS32Def( PCFGMNODE pNode, const char *pszName, int32_t *pi32, int32_t i32Def);
|
---|
161 | VMMR3DECL(int) CFGMR3QueryU16( PCFGMNODE pNode, const char *pszName, uint16_t *pu16);
|
---|
162 | VMMR3DECL(int) CFGMR3QueryU16Def( PCFGMNODE pNode, const char *pszName, uint16_t *pu16, uint16_t u16Def);
|
---|
163 | VMMR3DECL(int) CFGMR3QueryS16( PCFGMNODE pNode, const char *pszName, int16_t *pi16);
|
---|
164 | VMMR3DECL(int) CFGMR3QueryS16Def( PCFGMNODE pNode, const char *pszName, int16_t *pi16, int16_t i16Def);
|
---|
165 | VMMR3DECL(int) CFGMR3QueryU8( PCFGMNODE pNode, const char *pszName, uint8_t *pu8);
|
---|
166 | VMMR3DECL(int) CFGMR3QueryU8Def( PCFGMNODE pNode, const char *pszName, uint8_t *pu8, uint8_t u8Def);
|
---|
167 | VMMR3DECL(int) CFGMR3QueryS8( PCFGMNODE pNode, const char *pszName, int8_t *pi8);
|
---|
168 | VMMR3DECL(int) CFGMR3QueryS8Def( PCFGMNODE pNode, const char *pszName, int8_t *pi8, int8_t i8Def);
|
---|
169 | VMMR3DECL(int) CFGMR3QueryBool( PCFGMNODE pNode, const char *pszName, bool *pf);
|
---|
170 | VMMR3DECL(int) CFGMR3QueryBoolDef( PCFGMNODE pNode, const char *pszName, bool *pf, bool fDef);
|
---|
171 | VMMR3DECL(int) CFGMR3QueryPort( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort);
|
---|
172 | VMMR3DECL(int) CFGMR3QueryPortDef( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort, RTIOPORT PortDef);
|
---|
173 | VMMR3DECL(int) CFGMR3QueryUInt( PCFGMNODE pNode, const char *pszName, unsigned int *pu);
|
---|
174 | VMMR3DECL(int) CFGMR3QueryUIntDef( PCFGMNODE pNode, const char *pszName, unsigned int *pu, unsigned int uDef);
|
---|
175 | VMMR3DECL(int) CFGMR3QuerySInt( PCFGMNODE pNode, const char *pszName, signed int *pi);
|
---|
176 | VMMR3DECL(int) CFGMR3QuerySIntDef( PCFGMNODE pNode, const char *pszName, signed int *pi, signed int iDef);
|
---|
177 | VMMR3DECL(int) CFGMR3QueryPtr( PCFGMNODE pNode, const char *pszName, void **ppv);
|
---|
178 | VMMR3DECL(int) CFGMR3QueryPtrDef( PCFGMNODE pNode, const char *pszName, void **ppv, void *pvDef);
|
---|
179 | VMMR3DECL(int) CFGMR3QueryGCPtr( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr);
|
---|
180 | VMMR3DECL(int) CFGMR3QueryGCPtrDef( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr, RTGCPTR GCPtrDef);
|
---|
181 | VMMR3DECL(int) CFGMR3QueryGCPtrU( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr);
|
---|
182 | VMMR3DECL(int) CFGMR3QueryGCPtrUDef( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr, RTGCUINTPTR GCPtrDef);
|
---|
183 | VMMR3DECL(int) CFGMR3QueryGCPtrS( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr);
|
---|
184 | VMMR3DECL(int) CFGMR3QueryGCPtrSDef( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr, RTGCINTPTR GCPtrDef);
|
---|
185 | VMMR3DECL(int) CFGMR3QueryStringAlloc( PCFGMNODE pNode, const char *pszName, char **ppszString);
|
---|
186 | VMMR3DECL(int) CFGMR3QueryStringAllocDef(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef);
|
---|
187 |
|
---|
188 | /** @} */
|
---|
189 |
|
---|
190 | /** @name Tree Navigation and Enumeration.
|
---|
191 | * @{
|
---|
192 | */
|
---|
193 | VMMR3DECL(PCFGMNODE) CFGMR3GetRoot(PVM pVM);
|
---|
194 | VMMR3DECL(PCFGMNODE) CFGMR3GetRootU(PUVM pUVM);
|
---|
195 | VMMR3DECL(PCFGMNODE) CFGMR3GetParent(PCFGMNODE pNode);
|
---|
196 | VMMR3DECL(PCFGMNODE) CFGMR3GetParentEx(PVM pVM, PCFGMNODE pNode);
|
---|
197 | VMMR3DECL(PCFGMNODE) CFGMR3GetChild(PCFGMNODE pNode, const char *pszPath);
|
---|
198 | VMMR3DECL(PCFGMNODE) CFGMR3GetChildF(PCFGMNODE pNode, const char *pszPathFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
|
---|
199 | VMMR3DECL(PCFGMNODE) CFGMR3GetChildFV(PCFGMNODE pNode, const char *pszPathFormat, va_list Args) RT_IPRT_FORMAT_ATTR(3, 0);
|
---|
200 | VMMR3DECL(PCFGMNODE) CFGMR3GetFirstChild(PCFGMNODE pNode);
|
---|
201 | VMMR3DECL(PCFGMNODE) CFGMR3GetNextChild(PCFGMNODE pCur);
|
---|
202 | VMMR3DECL(int) CFGMR3GetName(PCFGMNODE pCur, char *pszName, size_t cchName);
|
---|
203 | VMMR3DECL(size_t) CFGMR3GetNameLen(PCFGMNODE pCur);
|
---|
204 | VMMR3DECL(bool) CFGMR3AreChildrenValid(PCFGMNODE pNode, const char *pszzValid);
|
---|
205 | VMMR3DECL(PCFGMLEAF) CFGMR3GetFirstValue(PCFGMNODE pCur);
|
---|
206 | VMMR3DECL(PCFGMLEAF) CFGMR3GetNextValue(PCFGMLEAF pCur);
|
---|
207 | VMMR3DECL(int) CFGMR3GetValueName(PCFGMLEAF pCur, char *pszName, size_t cchName);
|
---|
208 | VMMR3DECL(size_t) CFGMR3GetValueNameLen(PCFGMLEAF pCur);
|
---|
209 | VMMR3DECL(CFGMVALUETYPE) CFGMR3GetValueType(PCFGMLEAF pCur);
|
---|
210 | VMMR3DECL(bool) CFGMR3AreValuesValid(PCFGMNODE pNode, const char *pszzValid);
|
---|
211 | VMMR3DECL(int) CFGMR3ValidateConfig(PCFGMNODE pNode, const char *pszNode,
|
---|
212 | const char *pszValidValues, const char *pszValidNodes,
|
---|
213 | const char *pszWho, uint32_t uInstance);
|
---|
214 |
|
---|
215 | /** @} */
|
---|
216 |
|
---|
217 |
|
---|
218 | /** @} */
|
---|
219 | #endif /* IN_RING3 */
|
---|
220 |
|
---|
221 |
|
---|
222 | RT_C_DECLS_END
|
---|
223 |
|
---|
224 | /** @} */
|
---|
225 |
|
---|
226 | #endif
|
---|
227 |
|
---|