src/libs/README.md
The src/libs directory hosts library crates shared by multiple Kata Containers components. These libraries provide common utilities, data types, and protocol definitions to facilitate development and maintain consistency across the project.
| Library | Description |
|---|---|
| kata-types | Constants, data types, and configuration structures shared by Kata Containers components |
| kata-sys-util | System utilities: CPU, device, filesystem, hooks, K8s, mount, netns, NUMA, PCI, protection, spec validation |
| protocols | ttrpc protocol definitions for agent, health, remote, CSI, OCI, confidential data hub |
| runtime-spec | OCI runtime spec data structures and constants |
| shim-interface | Shim management interface with RESTful API over Unix domain socket |
| logging | Slog-based logging with JSON output and systemd journal support |
| safe-path | Safe path resolution to prevent symlink and TOCTOU attacks |
| mem-agent | Memory management agent: memcg, compact, PSI monitoring |
| test-utils | Test macros for root/non-root privileges and KVM accessibility |
Core types and configurations including:
System-level utilities:
cpu: CPU information and affinitydevice: Device managementfs: Filesystem operationshooks: Hook executionk8s: Kubernetes utilitiesmount: Mount operationsnetns: Network namespace handlingnuma: NUMA topologypcilibs: PCI device accessprotection: Hardware protection featuresspec: OCI spec loadingvalidate: Input validationGenerated ttrpc protocol bindings:
agent: Kata agent APIhealth: Health check serviceremote: Remote hypervisor APIcsi: Container storage interfaceoci: OCI specificationsconfidential_data_hub: Confidential computing supportFeatures: async for async ttrpc, with-serde for serde support.
OCI runtime specification types:
ContainerState: Creating, Created, Running, Stopped, PausedState: Container state with version, id, status, pid, bundle, annotationsShim management service interface:
/run/kata/<sid>/shim-monitor.sock)MgmtClient for HTTP requests to shim management serverSlog-based logging framework:
Secure filesystem path handling:
scoped_join(): Safely join paths under a root directoryscoped_resolve(): Resolve paths constrained by rootPinnedPathBuf: TOCTOU-safe path referenceScopedDirBuilder: Safe directory creationMemory management for containers:
memcg: Memory cgroup configuration and monitoringcompact: Memory compaction controlpsi: Pressure stall information monitoringTesting utilities:
skip_if_root!: Skip test if running as rootskip_if_not_root!: Skip test if not running as rootskip_if_kvm_unaccessable!: Skip test if KVM is unavailableassert_result!: Assert expected vs actual resultsAll crates are licensed under Apache-2.0.