NVIDIA/nsmd
C++
Captured source
source ↗NVIDIA/nsmd
Description: MCTP VDM-based Nvidia System Management API
Language: C++
License: Apache-2.0
Stars: 11
Forks: 2
Open issues: 1
Created: 2024-07-23T19:38:54Z
Pushed: 2026-06-10T18:22:38Z
Default branch: develop
Fork: no
Archived: no
README:
nsmd - Nvidia System Management Daemon
How to build
Install dependencies
sudo apt update && sudo apt install build-essential g++-14 gcc-14 libdbus-1-dev libssl-dev nlohmann-json3-dev pkg-config python3-dev sccache valgrind pip install --user meson ninja
Install Boost
sudo apt install libboost1.84-all-dev
or
sudo apt install libboost1.83-all-dev
or download and install it from source.
wget https://downloads.sourceforge.net/project/boost/boost/1.84.0/boost_1_84_0.tar.gz tar -xzf boost_1_84_0.tar.gz cd boost_1_84_0 ./bootstrap.sh --prefix=/usr/local sudo ./b2 -j$(nproc) install ls /usr/local/lib | grep boost grep BOOST_LIB_VERSION /usr/local/include/boost/version.hpp
Copy libmctp header for local development
> git archive --remote=ssh://git@gitlab-master.nvidia.com:12051/dgx/bmc/libmctp.git develop libmctp-externals.h | tar -x -C common/
Configure and build with Meson
export CC="sccache gcc" export CXX="sccache g++" export SCCACHE_DIR="$HOME/.cache/sccache" export SCCACHE_CACHE_SIZE=10G # Configure Meson build with debug options and compiler flags (copied from openbmc-build-scripts repo) meson setup --reconfigure -Db_sanitize=address,undefined -Db_lundef=true -Dwerror=true -Dwarning_level=3 -Db_colorout=never -Ddebug=true -Doptimization=g -Dcpp_args="-DBOOST_USE_VALGRIND -Wno-error=invalid-constexpr -Wno-invalid-constexpr -Werror=uninitialized -Wno-error=maybe-uninitialized -Werror=strict-aliasing" builddir # Build all targets ninja -C builddir
Build and run unit tests
# Run all unit tests meson test -C builddir # Run specific unit test meson test -C builddir nsmChassis_test # Run all unit tests with Valgrind (memory leak detection) meson test -t 10 -C builddir --print-errorlogs --wrapper "valgrind --leak-check=full --track-origins=yes --show-reachable=yes" # Run specific unit test with Valgrind meson test -t 10 -C builddir nsmChassis_test --print-errorlogs --wrapper "valgrind --leak-check=full --track-origins=yes --show-reachable=yes"
Generate coverage report
meson setup --reconfigure -Db_coverage=true -Db_sanitize=address,undefined -Db_lundef=true -Dwerror=true -Dwarning_level=3 -Db_colorout=never -Ddebug=true -Doptimization=g -Dcpp_args="-DBOOST_USE_VALGRIND -Wno-error=invalid-constexpr -Wno-invalid-constexpr -Werror=uninitialized -Wno-error=maybe-uninitialized -Werror=strict-aliasing" builddir/coverage # Build all targets meson test -t 10 -C builddir/coverage ninja -C builddir/coverage coverage
Troubleshooting Build Issues
sdbusplus Version Mismatch
If you encounter sdbusplus build errors, verify that the revision in subprojects/sdbusplus.wrap matches the version specified in the openbmc-build-scripts repository. Version mismatches can cause build failures.
Updating Subproject Dependencies
For other subproject-related errors, you can update all subproject repositories to their latest commits using:
cd subprojects find -L . -type d -name ".git" | while read gitdir; do repo=$(dirname "$gitdir") echo "Pulling updates in $repo" cd "$repo" git pull cd - > /dev/null done
Unit Tests Debugging
Debugging with GDB in console
# Debug all tests meson test -C builddir --gdb # Debug specific test meson test -C builddir nsmChassis_test --gdb
Debugging with GDB in VSCode/Cursor
1. Configure launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug file with Meson",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/builddir/${relativeFileDirname}/${fileBasenameNoExtension}",
"cwd": "${workspaceFolder}/builddir/${relativeFileDirname}",
"preLaunchTask": "Compile meson test"
}
]
}2. Configure tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile meson test",
"type": "shell",
"command": "meson compile -C builddir ${fileBasenameNoExtension}",
"group": "build",
}
]
}3. Open the unit test file you want to debug in VSCode/Cursor 4. Set breakpoints in the code where needed 5. Press F5 to start debugging the test
Installing clang-format-20 for CI Usage
To ensure code consistency and formatting standards in the CI pipeline, clang-format-20 needs to be installed. Follow the steps below to install clang-format-20 on your system:
# Update the package list sudo apt update # Install clang-format-20 sudo apt install clang-format-20
This will install clang-format-20 on your system, enabling it for use in the CI pipeline.
Using clang-format-20 for all changed files before commit
To automatically format your code before each commit, create a pre-commit hook with the following steps:
cat > .git/hooks/pre-commit NsmPort::queryPortStatus()
{
nsm_sw_codes rc = decode_query_port_status_resp(responseMsg.get(), responseLen,
&cc, &reasonCode, &dataSize,
&portState, &portStatus);
// PREFERRED: Use LG2_ERROR_FLT macro - automatically handles shouldLog()
// The odd-indexed arguments (values in key-value pairs) are tracked for state changes
LG2_ERROR_FLT(
"decode_query_port_status_resp failure | reasonCode: {REASONCODE}, cc: {CC}, rc: {RC}",
"REASONCODE", reasonCode, // logged and tracked
"CC", cc, // logged and tracked
"RC", rc // logged and tracked
);
// ... rest of implementation
}How it works:
- First call with error codes: logs the error
- Subsequent calls with same error codes: silently skips logging (flood prevention)
- Call with different error codes: logs the new error
- Call with success codes: logs a success message with cleared codes and removes the logger
Note: When using LG2_LEVEL_FLT macros, the framework automatically extracts odd-indexed arguments (values in key-value pairs) for state change tracking. Only the following types are supported for state tracking:
boolnsm_reason_codesnsm_sw_codesnsm_completion_codes
Other types (like int, uint8_t, uint16_t, std::string) can be used in log messages but will NOT be tracked for state changes.
Example 2: Using LG2_ERROR_FLT with Boolean Flag…
Excerpt shown — open the source for the full document.
Notability
notability 3.0/10New repo, low traction