CFGM.cpp revision a5c3cd5df26f544018e48530e8392f32c1aa12c8
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * CFGM - Configuration Manager.
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2006-2008 Sun Microsystems, Inc.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * available from http://www.virtualbox.org. This file is free software;
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * General Public License (GPL) as published by the Free Software
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * additional information or have any questions.
5eabf773597082761832bc0a32b3660e8771f9f1vboxsync/** @page pg_cfgm CFGM - The Configuration Manager
5eabf773597082761832bc0a32b3660e8771f9f1vboxsync * The configuration manager is a directory containing the VM configuration at
5eabf773597082761832bc0a32b3660e8771f9f1vboxsync * run time. It works in a manner similar to the windows registry - it's like a
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * file system hierarchy, but the files (values) live in a separate name space
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * and can include the path separators.
5eabf773597082761832bc0a32b3660e8771f9f1vboxsync * The configuration is normally created via a callback passed to VMR3Create()
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * via the pfnCFGMConstructor parameter. To make testcase writing a bit simpler,
8599686860198730ae53d5895386d1b57dbc060evboxsync * we allow the callback to be NULL, in which case a simple default
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * configuration will be created by cfgmR3CreateDefaultTree(). The
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Console::configConstructor() method in Main/ConsoleImpl2.cpp creates the
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * configuration from the XML.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Devices, drivers, services and other PDM stuff are given their own subtree
8599686860198730ae53d5895386d1b57dbc060evboxsync * where they are protected from accessing information of any parents. This is
7748b9362d6a39df9045d5d05ccb57871145a649vboxsync * is implemented via the CFGMR3SetRestrictedRoot() API.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Data validation out over the basic primitives is left to the caller. The
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * caller is in a better position to know the proper validation rules of the
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * individual properties.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @see grp_cfgm
7748b9362d6a39df9045d5d05ccb57871145a649vboxsync * @section sec_cfgm_primitives Data Primitives
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * CFGM supports the following data primitives:
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * - Integers. Representation is unsigned 64-bit. Boolean, unsigned and
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * small integers, and pointers are all represented using this primitive.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * - Zero terminated character strings. These are of course UTF-8.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * - Variable length byte strings. This can be used to get/put binary
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * objects like for instance RTMAC.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync/*******************************************************************************
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync* Header Files *
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync*******************************************************************************/
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync/*******************************************************************************
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsync* Internal Functions *
de6ba1989c812829372828f1801b232b3e7f09bfvboxsync*******************************************************************************/
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncstatic void cfgmR3DumpPath(PCFGMNODE pNode, PCDBGFINFOHLP pHlp);
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncstatic void cfgmR3Dump(PCFGMNODE pRoot, unsigned iLevel, PCDBGFINFOHLP pHlp);
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncstatic DECLCALLBACK(void) cfgmR3Info(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncstatic int cfgmR3ResolveNode(PCFGMNODE pNode, const char *pszPath, PCFGMNODE *ppChild);
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncstatic int cfgmR3ResolveLeaf(PCFGMNODE pNode, const char *pszName, PCFGMLEAF *ppLeaf);
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncstatic int cfgmR3InsertLeaf(PCFGMNODE pNode, const char *pszName, PCFGMLEAF *ppLeaf);
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncstatic void cfgmR3RemoveLeaf(PCFGMNODE pNode, PCFGMLEAF pLeaf);
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsync * Constructs the configuration for the VM.
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsync * @returns VBox status code.
de6ba1989c812829372828f1801b232b3e7f09bfvboxsync * @param pVM Pointer to VM which configuration has not yet been loaded.
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * @param pfnCFGMConstructor Pointer to callback function for constructing the VM configuration tree.
92473d1de9ab080ff886ad61a4d908f7c3429608vboxsync * This is called in the EM.
de6ba1989c812829372828f1801b232b3e7f09bfvboxsync * @param pvUser The user argument passed to pfnCFGMConstructor.
de6ba1989c812829372828f1801b232b3e7f09bfvboxsync * @thread EMT.
8599686860198730ae53d5895386d1b57dbc060evboxsyncVMMR3DECL(int) CFGMR3Init(PVM pVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUser)
8599686860198730ae53d5895386d1b57dbc060evboxsync LogFlow(("CFGMR3Init: pfnCFGMConstructor=%p pvUser=%p\n", pfnCFGMConstructor, pvUser));
d7097a142464c500766b2cb3d564986e0a072799vboxsync * Init data members.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Register DBGF into item.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync int rc = DBGFR3InfoRegisterInternal(pVM, "cfgm", "Dumps a part of the CFGM tree. The argument indicates where to start.", cfgmR3Info);
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Create the configuration tree.
8599686860198730ae53d5895386d1b57dbc060evboxsync * Root Node.
8599686860198730ae53d5895386d1b57dbc060evboxsync PCFGMNODE pRoot = (PCFGMNODE)MMR3HeapAllocZ(pVM, MM_TAG_CFGM, sizeof(*pRoot));
8599686860198730ae53d5895386d1b57dbc060evboxsync * Call the constructor.
8599686860198730ae53d5895386d1b57dbc060evboxsync Log(("CFGMR3Init: Successfully constructed the configuration\n"));
8599686860198730ae53d5895386d1b57dbc060evboxsync NOT_DMIK(AssertMsgFailed(("Constructor failed with rc=%Rrc pfnCFGMConstructor=%p\n", rc, pfnCFGMConstructor)));
8599686860198730ae53d5895386d1b57dbc060evboxsync * Terminates the configuration manager.
8599686860198730ae53d5895386d1b57dbc060evboxsync * @returns VBox status code.
377e22fd02a277efa645dfe4e1a327f4fa26c2aavboxsync * @param pVM VM handle.
8599686860198730ae53d5895386d1b57dbc060evboxsync * Gets the root node for the VM.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns Pointer to root node.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pVM VM handle.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Gets the parent of a CFGM node.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns Pointer to the parent node.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns NULL if pNode is Root or pNode is the start of a
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * restricted subtree (use CFGMr3GetParentEx() for that).
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * @param pNode The node which parent we query.
10f18618390096a9c968016b6ca94d77b91618fbvboxsyncVMMR3DECL(PCFGMNODE) CFGMR3GetParent(PCFGMNODE pNode)
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * Gets the parent of a CFGM node.
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * @returns Pointer to the parent node.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns NULL if pNode is Root or pVM is not correct.
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * @param pVM The VM handle, used as token that the caller is trusted.
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * @param pNode The node which parent we query.
10f18618390096a9c968016b6ca94d77b91618fbvboxsyncVMMR3DECL(PCFGMNODE) CFGMR3GetParentEx(PVM pVM, PCFGMNODE pNode)
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * Query a child node.
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * @returns Pointer to the specified node.
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * @returns NULL if node was not found or pNode is NULL.
10f18618390096a9c968016b6ca94d77b91618fbvboxsync * @param pNode Node pszPath is relative to.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pszPath Path to the child node or pNode.
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * It's good style to end this with '/'.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsyncVMMR3DECL(PCFGMNODE) CFGMR3GetChild(PCFGMNODE pNode, const char *pszPath)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync int rc = cfgmR3ResolveNode(pNode, pszPath, &pChild);
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * Query a child node by a format string.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @returns Pointer to the specified node.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @returns NULL if node was not found or pNode is NULL.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @param pNode Node pszPath is relative to.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @param pszPathFormat Path to the child node or pNode.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * It's good style to end this with '/'.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @param ... Arguments to pszPathFormat.
7748b9362d6a39df9045d5d05ccb57871145a649vboxsyncVMMR3DECL(PCFGMNODE) CFGMR3GetChildF(PCFGMNODE pNode, const char *pszPathFormat, ...)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync PCFGMNODE pRet = CFGMR3GetChildFV(pNode, pszPathFormat, Args);
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Query a child node by a format string.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns Pointer to the specified node.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns NULL if node was not found or pNode is NULL.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pNode Node pszPath is relative to.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pszPathFormat Path to the child node or pNode.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * It's good style to end this with '/'.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param Args Arguments to pszPathFormat.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsyncVMMR3DECL(PCFGMNODE) CFGMR3GetChildFV(PCFGMNODE pNode, const char *pszPathFormat, va_list Args)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync int rc = cfgmR3ResolveNode(pNode, pszPath, &pChild);
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Gets the first child node.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Use this to start an enumeration of child nodes.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns Pointer to the first child.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns NULL if no children.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pNode Node to enumerate children for.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsyncVMMR3DECL(PCFGMNODE) CFGMR3GetFirstChild(PCFGMNODE pNode)
8599686860198730ae53d5895386d1b57dbc060evboxsync * Gets the next sibling node.
8599686860198730ae53d5895386d1b57dbc060evboxsync * Use this to continue an enumeration.
8599686860198730ae53d5895386d1b57dbc060evboxsync * @returns Pointer to the first child.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns NULL if no children.
8599686860198730ae53d5895386d1b57dbc060evboxsync * @param pCur Node to returned by a call to CFGMR3GetFirstChild()
8599686860198730ae53d5895386d1b57dbc060evboxsync * or successive calls to this function.
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsyncVMMR3DECL(PCFGMNODE) CFGMR3GetNextChild(PCFGMNODE pCur)
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * Gets the name of the current node.
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * (Needed for enumeration.)
8599686860198730ae53d5895386d1b57dbc060evboxsync * @returns VBox status code.
99cd1ce586a12bf6b8c6084cbcdebe8fe3553cc2vboxsync * @param pCur Node to returned by a call to CFGMR3GetFirstChild()
99cd1ce586a12bf6b8c6084cbcdebe8fe3553cc2vboxsync * or successive calls to CFGMR3GetNextChild().
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * @param pszName Where to store the node name.
8599686860198730ae53d5895386d1b57dbc060evboxsync * @param cchName Size of the buffer pointed to by pszName (with terminator).
8599686860198730ae53d5895386d1b57dbc060evboxsyncVMMR3DECL(int) CFGMR3GetName(PCFGMNODE pCur, char *pszName, size_t cchName)
6d51216d13610f142b377a8e15c6c51adb83ba1bvboxsync * Gets the length of the current node's name.
8599686860198730ae53d5895386d1b57dbc060evboxsync * (Needed for enumeration.)
8599686860198730ae53d5895386d1b57dbc060evboxsync * @returns Node name length in bytes including the terminating null char.
7748b9362d6a39df9045d5d05ccb57871145a649vboxsync * @returns 0 if pCur is NULL.
8599686860198730ae53d5895386d1b57dbc060evboxsync * @param pCur Node to returned by a call to CFGMR3GetFirstChild()
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * or successive calls to CFGMR3GetNextChild().
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Validates that the child nodes are within a set of valid names.
d4162288035439690deb3175bc2ca74a015e325bvboxsync * @returns true if all names are found in pszzAllowed.
d4162288035439690deb3175bc2ca74a015e325bvboxsync * @returns false if not.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pNode The node which children should be examined.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pszzValid List of valid names separated by '\\0' and ending with
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * a double '\\0'.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsyncVMMR3DECL(bool) CFGMR3AreChildrenValid(PCFGMNODE pNode, const char *pszzValid)
8ed69d0690530fb94a9d77e642c563a092fe6643vboxsync for (PCFGMNODE pChild = pNode->pFirstChild; pChild; pChild = pChild->pNext)
8ed69d0690530fb94a9d77e642c563a092fe6643vboxsync /* search pszzValid for the name */
8ed69d0690530fb94a9d77e642c563a092fe6643vboxsync /* if at end of pszzValid we didn't find it => failure */
8ed69d0690530fb94a9d77e642c563a092fe6643vboxsync AssertMsgFailed(("Couldn't find '%s' in the valid values\n", pChild->szName));
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync return false;
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync /* all ok. */
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync return true;
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Gets the first value of a node.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Use this to start an enumeration of values.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @returns Pointer to the first value.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pCur The node (Key) which values to enumerate.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsyncVMMR3DECL(PCFGMLEAF) CFGMR3GetFirstValue(PCFGMNODE pCur)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Gets the next value in enumeration.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @returns Pointer to the next value.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pCur The current value as returned by this function or CFGMR3GetFirstValue().
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsyncVMMR3DECL(PCFGMLEAF) CFGMR3GetNextValue(PCFGMLEAF pCur)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Get the value name.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * (Needed for enumeration.)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @returns VBox status code.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pCur Value returned by a call to CFGMR3GetFirstValue()
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * or successive calls to CFGMR3GetNextValue().
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pszName Where to store the value name.
b3a342577cc87b05977a5bfc90924c9e80e0877bvboxsync * @param cchName Size of the buffer pointed to by pszName (with terminator).
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsyncVMMR3DECL(int) CFGMR3GetValueName(PCFGMLEAF pCur, char *pszName, size_t cchName)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Gets the length of the current node's name.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * (Needed for enumeration.)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns Value name length in bytes including the terminating null char.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns 0 if pCur is NULL.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pCur Value returned by a call to CFGMR3GetFirstValue()
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * or successive calls to CFGMR3GetNextValue().
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsyncVMMR3DECL(size_t) CFGMR3GetValueNameLen(PCFGMLEAF pCur)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Gets the value type.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * (For enumeration.)
230bd8589bba39933ac5ec21482d6186d675e604vboxsync * @returns VBox status code.
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsync * @param pCur Value returned by a call to CFGMR3GetFirstValue()
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * or successive calls to CFGMR3GetNextValue().
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsyncVMMR3DECL(CFGMVALUETYPE) CFGMR3GetValueType(PCFGMLEAF pCur)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Validates that the values are within a set of valid names.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns true if all names are found in pszzAllowed.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns false if not.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pNode The node which values should be examined.
83dc9ca94cd3c31dabc33a35b945de124d43aaeavboxsync * @param pszzValid List of valid names separated by '\\0' and ending with
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * a double '\\0'.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsyncVMMR3DECL(bool) CFGMR3AreValuesValid(PCFGMNODE pNode, const char *pszzValid)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync for (PCFGMLEAF pLeaf = pNode->pFirstLeaf; pLeaf; pLeaf = pLeaf->pNext)
7748b9362d6a39df9045d5d05ccb57871145a649vboxsync /* search pszzValid for the name */
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync /* if at end of pszzValid we didn't find it => failure */
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync AssertMsgFailed(("Couldn't find '%s' in the valid values\n", pLeaf->szName));
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync return false;
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync /* all ok. */
98502a585f6eda30527b54f7df18dd3de3d3d7c6vboxsync return true;
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Query value type.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns VBox status code.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pNode Which node to search for pszName in.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pszName Name of an integer value.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param penmType Where to store the type.
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncVMMR3DECL(int) CFGMR3QueryType(PCFGMNODE pNode, const char *pszName, PCFGMVALUETYPE penmType)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync int rc = cfgmR3ResolveLeaf(pNode, pszName, &pLeaf);
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * Query value size.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * This works on all types of values.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @returns VBox status code.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pNode Which node to search for pszName in.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pszName Name of an integer value.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pcb Where to store the value size.
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncVMMR3DECL(int) CFGMR3QuerySize(PCFGMNODE pNode, const char *pszName, size_t *pcb)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync int rc = cfgmR3ResolveLeaf(pNode, pszName, &pLeaf);
7748b9362d6a39df9045d5d05ccb57871145a649vboxsync AssertMsgFailed(("Invalid value type %d\n", pLeaf->enmType));
83dc9ca94cd3c31dabc33a35b945de124d43aaeavboxsync * Query integer value.
fb1975a6972d89de9e515bed0248db93f04ec9d8vboxsync * @returns VBox status code.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pNode Which node to search for pszName in.
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync * @param pszName Name of an integer value.
83dc9ca94cd3c31dabc33a35b945de124d43aaeavboxsync * @param pu64 Where to store the integer value.
8fa1e8a8a8702ee38195fbe7ad5959bf971eb93bvboxsyncVMMR3DECL(int) CFGMR3QueryInteger(PCFGMNODE pNode, const char *pszName, uint64_t *pu64)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync int rc = cfgmR3ResolveLeaf(pNode, pszName, &pLeaf);
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Query integer value with default.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @returns VBox status code.
b3a342577cc87b05977a5bfc90924c9e80e0877bvboxsync * @param pNode Which node to search for pszName in.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @param pszName Name of an integer value.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @param pu64 Where to store the integer value. This is set to the default on failure.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsync * @param u64Def The default value.
e37bf11b9c725db1bb30da247fedebdb4ed20d29vboxsyncVMMR3DECL(int) CFGMR3QueryIntegerDef(PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def)
b3a342577cc87b05977a5bfc90924c9e80e0877bvboxsync int rc = cfgmR3ResolveLeaf(pNode, pszName, &pLeaf);
b3a342577cc87b05977a5bfc90924c9e80e0877bvboxsync if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Query zero terminated character value.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @returns VBox status code.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pNode Which node to search for pszName in.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pszName Name of a zero terminate character value.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pszString Where to store the string.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param cchString Size of the string buffer. (Includes terminator.)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsyncVMMR3DECL(int) CFGMR3QueryString(PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync int rc = cfgmR3ResolveLeaf(pNode, pszName, &pLeaf);
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync memcpy(pszString, pLeaf->Value.String.psz, pLeaf->Value.String.cch);
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync memset(pszString + pLeaf->Value.String.cch, 0, cchString - pLeaf->Value.String.cch);
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * Query zero terminated character value with default.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @returns VBox status code.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pNode Which node to search for pszName in.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pszName Name of a zero terminate character value.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pszString Where to store the string. This will not be set on overflow error.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param cchString Size of the string buffer. (Includes terminator.)
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsync * @param pszDef The default value.
57a94b9fea6a6400f7a80e322e84b5b453c3bff0vboxsyncVMMR3DECL(int) CFGMR3QueryStringDef(PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString, const char *pszDef)
7bf0220c3332700233120b513c9b4ba20a0caa9bvboxsync int rc = cfgmR3ResolveLeaf(pNode, pszName, &pLeaf);
return rc;
return rc;
int rc;
if (!pRoot)
return VERR_NO_MEMORY;
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
#ifdef DEBUG
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
UPDATERC();
return rcAll;
if (pNode)
pszPath++;
if (!*pszPath)
if (!pChild)
return VERR_CFGM_INVALID_CHILD_PATH;
return VINF_SUCCESS;
if (!pszNext)
if (!pChild)
return VERR_CFGM_CHILD_NOT_FOUND;
return VERR_CFGM_NO_PARENT;
int rc;
if (pNode)
while (pLeaf)
return VINF_SUCCESS;
return rc;
if (pNew)
return pNew;
VMMR3DECL(int) CFGMR3InsertSubTree(PCFGMNODE pNode, const char *pszName, PCFGMNODE pSubTree, PCFGMNODE *ppChild)
if (ppChild)
return rc;
int rc;
if (pNode)
pszName++;
if (pszDup)
if (pszNext)
pszNext++;
if (!pChild)
if (!pszNext)
if (ppChild)
else if (!pszNext)
else if (*pszName)
if (pPrev)
return VERR_CFGM_NODE_EXISTS;
if (pNew)
if (pPrev)
if (ppChild)
return rc;
VMMR3DECL(int) CFGMR3InsertNodeF(PCFGMNODE pNode, PCFGMNODE *ppChild, const char *pszNameFormat, ...)
return rc;
VMMR3DECL(int) CFGMR3InsertNodeFV(PCFGMNODE pNode, PCFGMNODE *ppChild, const char *pszNameFormat, va_list Args)
int rc;
char *pszName;
if (pszName)
return rc;
if (pNode)
int rc;
if (*pszName)
if (pNode)
if (pPrev)
return VERR_CFGM_LEAF_EXISTS;
if (pNew)
if (pPrev)
return rc;
if (pNode)
if (pLeaf)
case CFGMVALUETYPE_BYTES:
case CFGMVALUETYPE_STRING:
case CFGMVALUETYPE_INTEGER:
return rc;
int rc;
if (pNode)
char *pszStringCopy = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_STRING, RT_ALIGN_Z(cchString, 16));
if (pszStringCopy)
return rc;
VMMR3DECL(int) CFGMR3InsertBytes(PCFGMNODE pNode, const char *pszName, const void *pvBytes, size_t cbBytes)
int rc;
if (pNode)
return rc;
return rc;
VMMR3DECL(int) CFGMR3QueryU64Def(PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def)
return rc;
VMMR3DECL(int) CFGMR3QueryS64Def(PCFGMNODE pNode, const char *pszName, int64_t *pi64, int64_t i64Def)
return rc;
return rc;
VMMR3DECL(int) CFGMR3QueryU32Def(PCFGMNODE pNode, const char *pszName, uint32_t *pu32, uint32_t u32Def)
return rc;
return rc;
VMMR3DECL(int) CFGMR3QueryS32Def(PCFGMNODE pNode, const char *pszName, int32_t *pi32, int32_t i32Def)
return rc;
return rc;
VMMR3DECL(int) CFGMR3QueryU16Def(PCFGMNODE pNode, const char *pszName, uint16_t *pu16, uint16_t u16Def)
return rc;
return rc;
VMMR3DECL(int) CFGMR3QueryS16Def(PCFGMNODE pNode, const char *pszName, int16_t *pi16, int16_t i16Def)
return rc;
return rc;
return rc;
return rc;
return rc;
return rc;
return rc;
VMMR3DECL(int) CFGMR3QueryPortDef(PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort, RTIOPORT PortDef)
VMMR3DECL(int) CFGMR3QueryUIntDef(PCFGMNODE pNode, const char *pszName, unsigned int *pu, unsigned int uDef)
VMMR3DECL(int) CFGMR3QuerySIntDef(PCFGMNODE pNode, const char *pszName, signed int *pi, signed int iDef)
if (u64 == u)
*ppv = (void *)u;
return rc;
if (u64 == u)
*ppv = (void *)u;
return rc;
if (u64 == u)
*pGCPtr = u;
return rc;
VMMR3DECL(int) CFGMR3QueryGCPtrDef(PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr, RTGCPTR GCPtrDef)
if (u64 == u)
*pGCPtr = u;
return rc;
if (u64 == u)
*pGCPtr = u;
return rc;
VMMR3DECL(int) CFGMR3QueryGCPtrUDef(PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr, RTGCUINTPTR GCPtrDef)
if (u64 == u)
*pGCPtr = u;
return rc;
*pGCPtr = u;
return rc;
VMMR3DECL(int) CFGMR3QueryGCPtrSDef(PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr, RTGCINTPTR GCPtrDef)
*pGCPtr = u;
return rc;
if (pszString)
return rc;
VMMR3DECL(int) CFGMR3QueryStringAllocDef(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef)
if (pszString)
return rc;
pHlp->pfnPrintf(pHlp, "] (level %d)%s\n", iLevel, pRoot->fRestrictedRoot ? " (restricted root)" : "");
case CFGMVALUETYPE_INTEGER:
pHlp->pfnPrintf(pHlp, " %-*s <integer> = %#018llx (%lld)\n", (int)cchMax, pLeaf->szName, pLeaf->Value.Integer.u64, pLeaf->Value.Integer.u64);
case CFGMVALUETYPE_STRING:
pHlp->pfnPrintf(pHlp, " %-*s <string> = \"%s\" (cch=%d)\n", (int)cchMax, pLeaf->szName, pLeaf->Value.String.psz, pLeaf->Value.String.cch);
case CFGMVALUETYPE_BYTES: