Commit Graph

6702 Commits

Author SHA1 Message Date
Fabiano Fidêncio
1aa98c996a kata-sys-util: surface createContainer hook failures on /dev/kmsg
createContainer hooks run in the forked container child, where kata-agent's
async slog drain (its background thread) does not exist, so `error!` from a
failing hook is silently dropped and the failure leaves no trace at all.

Mirror hook failures to /dev/kmsg, the one log sink that survives the fork
and reaches the guest console, so a hook that can't be found or exits
non-zero is at least visible when debugging. Failures only.
2026-07-10 13:55:44 +02:00
Fabiano Fidêncio
5a173841d2 kata-sys-util: run OCI hooks by their absolute path
Hooks were spawned by PATH-searching `args[0]`. After `env_clear()` a bare
argv[0] only resolves against the compiled-in default PATH (/bin:/usr/bin),
so a hook binary living elsewhere - e.g. a composable-image extension under
/run/kata-extensions/<name>/bin - failed to start with ENOENT.

Execute the hook's `path` instead (an absolute path, already validated in
`new`), passing `args` as argv with argv[0] = args[0]. This matches OCI
runtime-spec semantics and lets hooks run from any location.
2026-07-10 13:55:44 +02:00
Fabiano Fidêncio
ede34696f0 config: boot composable base-nvidia image + gpu/coco extensions
Flip the runtime-rs NVIDIA GPU configs (plain/tdx/snp) from the monolithic
image to the driver-agnostic base-nvidia boot image plus a cold-plugged,
driver-versioned gpu extension mounted at /run/kata-extensions/gpu.
Confidential runtime-rs configs additionally cold-plug the CoCo
guest-components extension and enforce the base-nvidia dm-verity hash.

The Go runtime keeps booting the monolithic nvidia-gpu / nvidia-gpu-confidential
images, mirroring the CoCo split where runtime-rs is the first-class citizen and
Go stays on the monolithic layout.

Add the IMAGE{NAME,PATH}_NV_{BASE,EXTENSION} and NVIDIAGPUEXTENSIONVERITYPARAMS
make vars (runtime-rs only), and read the base-nvidia + gpu-extension root
hashes into runtime-rs's shim-v2 opts while the Go opts keep reading the
monolithic nvidia-gpu / nvidia-gpu-confidential hashes.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-07-10 13:55:44 +02:00
WaterWhisperer
89354c4441 runtime-rs: substitute CLH config source placeholder
The CLH runtime-rs config template uses @CONFIG_CLH_IN@ in its
source-file comment, but CONFIG_CLH_IN was missing from the generated
template variables.

Add it to USER_VARS so the generated config records the template path
instead of keeping the literal placeholder.

Fixes: #12941

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-07-08 19:03:34 -05:00
Dan Mihai
221b9cbe5b Merge pull request #13327 from ihanzh/fix-genpolicy-dot-slash-layer-paths
genpolicy: normalize layer tar paths
2026-07-08 10:15:01 -07:00
Fabiano Fidêncio
d3291b8778 runtime: publish TaskExit before sandbox teardown
Docker and containerd rely on the TaskExit event and a prompt Wait RPC,
not just the eventual sandbox teardown.  With the original ordering the
shim tore the sandbox down (Stop/Delete the guest) *before* publishing
the container exit, so for a slow guest shutdown -- e.g. the nvidia-gpu
config with an 8GB /dev/shm memory-backend on a constrained CI runner --
containerd could SIGKILL the shim before the exit was published.  The
`docker run --rm` removal then races the dead-shim cleanup and fails,
even though the container itself exited 0.

Publish the container exit (c.exitCh) and the TaskExit event *before*
the sandbox teardown, and run the teardown without holding s.mu so
concurrent Delete()/Shutdown() RPCs are not blocked.

To keep the guarantees the previous ordering provided:

  * teardownWg lets Shutdown() wait for an in-flight teardown to finish,
    so the sandbox run directory (watched by kata-monitor) and the CRI
    state are gone before the shim exits -- without holding s.mu across
    the slow guest shutdown; and
  * teardownOnce serialises wait()'s teardown with watchSandbox()'s
    killed-VMM teardown so the (not internally synchronized)
    Sandbox.Stop/Delete never run concurrently.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
80e3b07194 runtime: don't block shim cleanup on a dead agent
For `docker run --rm`, containerd invokes the shim `delete` binary
(cleanupAfterDeadShim) once the container task exits.  Kata's Cleanup
path re-loads the sandbox and calls StopContainer/DeleteContainer/Stop,
each of which lazily connects to the guest agent over vsock.

When the sandbox was already torn down by the main shim (the common
case for a short-lived `docker run --rm`), the VM -- and its agent --
are gone, so that vsock connect blocks until containerd's delete
timeout SIGKILLs the binary.  The removal then fails and `docker run
--rm` returns non-zero even though the container itself exited 0.

Detect the already-dead hypervisor (its pidfile is gone / the pid no
longer maps to a live process) at the start of CleanupContainer and
mark the agent dead.  Subsequent agent RPCs then fail fast with "Dead
agent" and the force path performs only host-side cleanup, so the
delete binary returns promptly instead of hanging.

The legitimate "shim crashed but VM still alive" cleanup is unaffected:
the hypervisor is still running, so the agent is not marked dead and
the normal agent-based teardown proceeds.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
2fe3dacb41 runtime-rs/qemu: reserve a memory hotplug region for virtio-mem
virtio-mem is enabled on s390x, where memory hotplug goes through a
virtio-mem-ccw device set up during VM initialization.  That device --
and the later resize -- require a memory hotplug region (a non-zero
maxmem/slots on the QEMU command line).

The runtime-rs command line generator, however, zeroes maxmem/slots
whenever the guest uses the shared /dev/shm memory-backend with a
non-nvdimm rootfs (the s390x case: virtio-blk-ccw rootfs).  With no
hotplug region reserved, two things broke on s390x:

  * setup_virtio_mem failed VM start with "the configuration is not
    prepared for memory devices, consider specifying the maxmem option";
  * with virtio-mem unavailable, memory resize fell back to pc-dimm,
    which is not a valid device model on s390x, breaking
    TestContainerMemoryUpdate:
      'pc-dimm' is not a valid device model name

Keep the hotplug region when virtio-mem is enabled, mirroring the Go
runtime which reserves maxmem and hotplugs via virtio-mem-ccw on s390x.
This lets setup_virtio_mem succeed at boot and makes memory resize use
virtio-mem instead of pc-dimm.

Also guard setup_virtio_mem behind QemuCmdLine::has_memory_hotplug_region()
as a defensive fallback: if some configuration still ends up without a
hotplug region, skip virtio-mem setup (like static-sizing arches such as
arm64) rather than failing VM start.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
92da7974f5 runtime: fall back to CDI annotations when kubelet socket is absent
NVIDIA GPU configs default pod_resource_api_sock to the kubelet Pod
Resources API path. On non-Kubernetes hosts that path is usually missing;
use CDI sandbox annotations for cold-plug instead of failing kubelet lookup.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
478970131c runtime-rs: tag standalone containers as single_container
The container create flow forced every non-pod-container to the
"pod_sandbox" type. Standalone engines (Docker/nerdctl/podman) surface
as SingleContainer, so they were mislabeled as pod sandboxes.

The agent skips CDI device injection when the container type is
"pod_sandbox", so the NVIDIA CDI edits carried in the "cdi.k8s.io/*"
annotations were never applied and the GPU userspace (e.g. nvidia-smi)
was missing in the guest. Emit the actual container type instead, which
matches the Go runtime and lets the agent inject CDI devices for the
single-container flow.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <noreply@cursor.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
898ed869d2 kata-types: parse single_container OCI container type
ContainerType already renders as "single_container" via Display, but
from_str rejected it. Accept it so the value can round-trip, matching
the container type the Go runtime uses for standalone containers.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <noreply@cursor.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
023c25838e runtime-rs: cold-plug CDI VFIO devices for single containers
The kubelet PodResources API is only available under Kubernetes. For
single-container engines (Docker/nerdctl/podman) the CDI runtime applies
the device's containerEdits directly to the OCI spec, so the VFIO nodes
(e.g. /dev/vfio/devices/vfio0) show up in linux.devices instead.

Discover those nodes from the OCI spec in addition to the PodResources
API and feed both into the same cold-plug path, de-duplicating by host
path. This reuses the existing Kubernetes machinery so GPU passthrough
works for single containers with no changes to device handling.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <noreply@cursor.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
403fc1400a runtime-rs: drop non-passthrough functions from VFIO groups
A discrete GPU usually shares its IOMMU group with an audio function
(e.g. NVIDIA 02:00.1). Cold-plugging every function in the group made
QEMU emit a vfio-pci/pcie-root-port/iommufd triple per function while
reusing the GPU's root-port and IOMMUFD object ids, so QEMU aborted with
a duplicate-id error before it was reachable over QMP.

Apply the existing IOMMU_IGNORE classification while discovering the
group so audio controllers and bridges are pruned, leaving only the
passthrough-capable device(s). Also fix filter_bridge_device to parse
the sysfs class attribute as hex; the previous decimal parse always
failed, which is why the filter never removed anything.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <noreply@cursor.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
354e2ad637 hypervisor: fix CH network test initializer pci_path field
Set the new pci_path field in cloud-hypervisor network test config so
unit tests compile with the updated NetworkConfig struct.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
59c308e17b runtime-rs: pass NIC PCI path to agent on hot-plug
Persist and forward the hot-plugged NIC guest PCI path so the agent can
resolve sysfs location and update interfaces reliably.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
eb94c30c5e runtime-rs/qemu: track PCI bridge slots for NIC hot-plug
Network interface hot-plug places the NIC on the pcie-pci-bridge nested
under a root port. Track the bridge slots already occupied (queried via
query-pci) and reserve bridge slot ranges correctly so repeated NIC
hot-plug operations do not collide on the same bridge slot.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
ab90624d79 runtime-rs/qemu: nest NIC hot-plug bridge topology on Q35 OVMF
Network interface hot-plug on Q35 with OVMF needs a hot-pluggable PCIe
slot to attach the NIC to after boot. Add the nested root-port plus
pcie-pci-bridge topology and the related QEMU argument ordering so a
network device can be hot-plugged into the bridge.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
e588764e31 agent: fix OVMF nested PCI path resolution
Treat three-segment PCI paths as pxb-only when the bus indicates pxb,
preventing wrong root-bus lookup for nested OVMF hot-plug devices.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
c7e91684b8 runtime: nest pcie-pci-bridge under root-port on OVMF
Use a nested root-port plus pcie-pci-bridge topology on Q35+OVMF so
firmware reserves hot-plug resources and NIC hot-plug works reliably.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
da4fe9a0f4 runtime: avoid addr=0 on auto-assigned root ports
Stop forcing addr=0 for auto-assigned PCIe root ports to avoid slot
conflicts with Q35 host bridge devices.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Fabiano Fidêncio
7d91b15a3b govmm/qemu: always honor explicit PCIe root-port addr
Emit addr= for PCIe root ports regardless of multifunction so guest PCI
paths stay stable for downstream hot-plug resolution.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-08 13:12:19 +02:00
Alex Lyn
7e987cd6c8 Merge pull request #13321 from PiotrProkop/fix-vfio-init
runtime: Hotplug VFIO network devices before any container starts
2026-07-08 11:08:14 +08:00
Han Zhang
b95ab6a4e1 genpolicy: normalize layer tar paths
Layer tar entries may include current-directory components, such as
./etc/passwd, when images are produced by common tar commands.

Normalize layer paths before matching passwd, group, and whiteout
entries. This lets genpolicy handle equivalent relative paths while
skipping empty, unsafe, or absolute paths.

Fixes: #12692

Assisted-By: OpenAI Codex
Signed-off-by: Han Zhang <ihanzhzh@gmail.com>
2026-07-07 08:15:22 +08:00
Steve Horsman
068bd806d3 Merge pull request #13243 from jimmykarily/static-musl-host-binaries
Build the kata host binaries (and payload) statically for musl-only hosts
2026-07-06 13:44:42 +01:00
Fabiano Fidêncio
9050746529 Merge pull request #13316 from stevenhorsman/crate-bumps-round-2
deps: Another round of crate bumps
2026-07-06 12:06:33 +02:00
Dimitris Karakasilis
95edf90073 runtime: remove cgo from KVM capability checks
The host KVM capability checks obtained the KVM_CREATE_VM and
KVM_CHECK_EXTENSION ioctl request numbers from <linux/kvm.h> via cgo
(kata-check.go for the generic check, hypervisor_linux_arm64.go for the
Arm RME check). This was the only remaining use of cgo in the runtime,
and it forced the runtime to be linked against the host libc.

Replacing these with plain Go constants lets kata-runtime,
containerd-shim-kata-v2 and kata-monitor build with CGO_ENABLED=0,
which is a prerequisite for producing fully static, libc-agnostic
binaries that run on musl-only hosts (the kata-deploy payload otherwise
fails to exec on a glibc-free distribution because its requested dynamic
loader is absent).

The ioctl numbers are stable kernel ABI. The asm-generic encoding used
by amd64, arm64, s390x and riscv64 gives _IO(KVMIO, nr) == (0xAE << 8) |
nr, while powerpc uses the legacy encoding (_IOC_NONE == 1, direction
shifted by 29). The values are split into kvm_ioctls_generic.go and
kvm_ioctls_ppc64le.go accordingly so each architecture keeps the exact
value its kernel headers would have produced.

No functional change: the runtime issues the same ioctls as before.

Signed-off-by: Dimitris Karakasilis <dimitris@spectrocloud.com>
Generated-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
2026-07-06 12:02:13 +02:00
PiotrProkop
86ab1b22a3 runtime: Hotplug VFIO network devices before any container starts
A VFIO-backed network interface used to be hotplugged only as a side
effect of creating the workload container that references the VFIO
device in its OCI spec: setupNetworks() skipped VfioEndpoints when it
ran at sandbox start and applied their configuration later, on the
second invocation from createContainer(), guarded by the
hotplugNetworkConfigApplied flag.

Init containers run before that workload container, so they started
with the VFIO interface absent and thus without pod networking.

Attach the device at sandbox scope instead, from setupNetworks() at
sandbox start, before any container is created:

- Add Sandbox.hotplugVfioNetworkDevice(): resolve the VFIO device
  node backing the endpoint's host BDF, hotplug it and record the
  guest PCI path on the endpoint. When the workload container later
  references the same VFIO group through a device plugin, the device
  manager finds the device by major:minor and only bumps reference
  counts, so it is neither plugged twice nor unplugged when that
  container exits.

- Configure all endpoints, VfioEndpoints included, in a single
  setupNetworks() pass at sandbox start. The Container parameter, the
  second invocation from createContainer() and the
  hotplugNetworkConfigApplied flag are no longer needed.

Add unit tests for the hotplugVfioNetworkDevice() guard paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: PiotrProkop <pprokop@nvidia.com>
2026-07-03 15:14:22 +02:00
Alex Lyn
49114a491d Merge pull request #12986 from annu0905/feat/memoryhotplug-support-rs
runtime-rs: Add memory hotplug support via virtio-mem for s390x
2026-07-02 09:47:10 +08:00
stevenhorsman
b2c91136a1 libs: bump toml 0.5.8 → 1.1.2
Migrate kata-types and kata-agent from toml 0.5 to 1.x:

- Consolidate kata-types onto the workspace toml version
- Replace toml::to_vec() (removed in 1.x) with to_string().into_bytes()
- Map toml::de::Error with .map_err(std::io::Error::other) where functions
  return io::Result (From impl was removed in 1.x)
- Update test assertions: toml 1.x serializes strings with double quotes
  instead of single quotes

Generated-by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2026-07-01 09:13:02 -07:00
stevenhorsman
320decbcd6 agent/policy: bump json-patch 2.0.0 → 4.2.0
No API changes required: Patch, PatchOperation, and patch() have
compatible signatures across the 2.x → 4.x range.

Generated-by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2026-07-01 09:12:26 -07:00
stevenhorsman
875cee455f deps: bump subprocess 0.2.8 → 1.2.0
Migrate hooks.rs from the removed Popen/PopenConfig/CommunicateError API
to the subprocess 1.x Exec/Job builder API:

- Replace Popen::create() + PopenConfig with Exec builder + Job
- communicate_start().read_string() → job.communicate()?.limit_time().read_string()
- read_string() now returns io::Result<(String,String)> (no Option wrapper)
- ExitStatus enum variants replaced with ExitStatus::code() / signal() methods
- Timeout errors propagated with io::ErrorKind::TimedOut as before

Generated-by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2026-07-01 09:12:26 -07:00
stevenhorsman
54f705af69 runtime-rs: bump hyper 0.14.20 → 1.10.1 and migrate to hyper 1.x API
Update hyper to 1.10.1 and hyperlocal to 0.9.1 (required for hyper 1.x
compatibility). Add http-body-util 0.1, hyper-util 0.1 and bytes 1.0 as
workspace dependencies.

API changes applied across shim-interface, runtimes, hypervisor
(firecracker) and resource (nydus_client) crates:

- hyper::Body → http_body_util::Full<Bytes> for outgoing bodies
- hyper::body::Incoming for incoming server request bodies
- hyper::Client → hyper_util::client::legacy::Client
- hyper::Server + make_service_fn → TcpListener loop +
  hyper_util::server::conn::auto::Builder (kata-ctl http_server)
- hyper::server::conn::Http → hyper::server::conn::http1::Builder
  with hyper_util::rt::TokioIo wrapper (runtimes shim_mgmt server)
- hyper::body::to_bytes() → BodyExt::collect().await?.to_bytes()
- Client::unix() now requires explicit body type parameter Full<Bytes>
- Drop removed 'stream' feature flag from hyper dependency declarations

Generated-by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2026-07-01 09:03:21 -07:00
Fabiano Fidêncio
159df44abf Merge pull request #13290 from fidencio/topic/runtime-fix-multi-node-pxb-pxie-when-using-less-vcpus-than-numa-nodes
runtime: fix multi-node pxb-pcie topology for dual-socket GPU pods
2026-07-01 17:08:46 +02:00
Annu Sharma
fcc705c31d runtime-rs: Use virtio-mem for memory hotplug operations
Integrate virtio-mem into memory hotplug and hotunplug operations:

- Modified hotplug_memory() to automatically detect virtio-mem device
  and use resize instead of pc-dimm hotplug
- Modified hotunplug_memory() to use virtio-mem resize for memory
  decrease with saturating_sub to prevent underflow
- Modified hotplugged_memory_size() to account for virtio-mem devices
- Falls back to pc-dimm when virtio-mem is not available

This completes the virtio-mem integration, enabling dynamic memory
management with virtio-mem-ccw on s390x while maintaining full
backward compatibility with pc-dimm.

Assisted-by: IBM Bob
Signed-off-by: Annu Sharma <annu-sharma@ibm.com>
2026-07-01 14:42:31 +01:00
Annu Sharma
b65b935492 runtime-rs: Integrate virtio-mem setup into VM initialization
Call setup_virtio_mem() during VM startup when enable_virtio_mem flag
is set:

- Added setup call after QMP connection is established
- Proper error handling with context

Assisted-by: IBM Bob
Signed-off-by: Annu Sharma <annu-sharma@ibm.com>
2026-07-01 14:42:31 +01:00
Annu Sharma
cc30701120 runtime-rs: Add virtio-mem configuration and QMP operations
Add infrastructure for virtio-mem memory hotplug on s390x:

1. QMP Operations (qmp.rs):
   - setup_virtio_mem(): Creates virtio-mem-ccw device with CCW
     addressing (fe.0.dddd format). Takes primitive parameters
     (default_memory, default_maxmemory, machine_type, shared_fs)
     and determines memory backend inline based on shared filesystem
     configuration.
   - resize_virtio_mem(): Adjusts memory via QMP qom-set command
     with inline size validation.
   - cleanup_virtio_mem_setup(): Error handling helper for setup
     failures.

2. Build System:
   - Updated configuration template with enable_virtio_mem parameter
   - Added DEFENABLEVIRTIOMEM to Makefile
   - Updated s390x-options.mk

Assisted-by: IBM Bob
Signed-off-by: Annu Sharma <annu-sharma@ibm.com>
2026-07-01 14:42:17 +01:00
Fabiano Fidêncio
6d456811e3 Merge pull request #13302 from stevenhorsman/opencontainers/runc-1.3.6-bump
runtime: bump github.com/opencontainers/runc
2026-07-01 14:37:32 +02:00
Fabiano Fidêncio
4ce42834cf Merge pull request #13288 from kata-containers/dependabot/cargo/opentelemetry_sdk-0.32.1
build(deps): bump opentelemetry_sdk from 0.27.1 to 0.32.1
2026-07-01 14:36:32 +02:00
Fabiano Fidêncio
51aa51a377 runtime: fix multi-node pxb-pcie topology for dual-socket GPU pods
When VFIO GPUs span both host NUMA nodes, emit guest NUMA nodes even
if vCPUs < node count (memory-only nodes), and pin each pxb-pcie to
bus=pcie.0 so QEMU does not attach the second expander to the first.

Also fix checkVCPUsPinningNUMA to tolerate vCPUs < NUMA node count.
The memory-only NUMA topology (emitted for pxb-pcie placement when
default_vcpus=1) creates more guest NUMA nodes than there are vCPUs;
the previous hard error silently tore down every sandbox.  Now the
available vCPU(s) are pinned to the first node(s) and memory-only
nodes are skipped.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-07-01 12:41:59 +02:00
Hyounggyu Choi
a30c22bd64 runtime-rs: Remove hotplug_vfio_on_root_bus
The `hotplug_vfio_on_root_bus` configuration option is no longer needed
in the runtime-rs.

Remove the option from:
- `DeviceInfo` struct and its `hotplug_vfio_on_root_bus` field
- `PCIeTopology` struct and its construction in `topology.rs`
- `HypervisorInfo` struct and its `hotplug_vfio_on_root_bus` field
- `KATA_ANNO_CFG_HYPERVISOR_HOTPLUG_VFIO_ON_ROOT_BUS` annotation constant
  and its handler in `Annotation::apply()`
- DragonBall validation check in `ConfigPlugin::adjust_config()`
- All runtime-rs TOML config templates (qemu, fc, nvidia GPU variants)
- Test fixture TOML files

Update the documentation having a reference to it.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2026-07-01 04:15:26 +02:00
Fabiano Fidêncio
effac686fc agent: resolve and launch CoCo guest components via extension manifest
Make the agent's handling of CoCo guest components data-driven so that a
new extension bundle can be introduced without changing agent code.

Add a new `extension` module defining a generic component manifest contract.
When a CoCo extension image is mounted at /run/kata-extensions/coco/, the agent
reads etc/kata-extensions/components.toml from it to discover:

- path-only components (looked up by id under the `[paths]` table), used
  for the ocicrypt config and the pause bundle, and
- launchable processes (`[[process]]` entries) describing the binary
  path, args, optional args, config file, environment, socket to wait on
  and timeout.

`${var}` tokens in process fields are substituted from a fixed,
documented context the agent builds at runtime (attestation socket/uri,
config paths, rest-api features, initdata toml path, launch timeout,
resolved ocicrypt config path). Referencing an unknown variable is a
hard error, and manifest paths are validated against traversal, so the
contract stays fail-closed.

Processes are gated by a numeric `level` mapped from
guest_components_procs (AttestationAgent < ConfidentialDataHub <
ApiServerRest), preserving the existing implication semantics.

When no extension is mounted, launch_plan() returns None and the agent uses
a built-in plan that reproduces the legacy behaviour byte-for-byte
(binaries under /usr/local/bin, /etc/ocicrypt_config.json, /pause_bundle).
Monolithic / non-split confidential images are therefore unaffected.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:51:48 +02:00
Fabiano Fidêncio
bd93a93990 config: use split CoCo image for runtime-rs, keep Go on monolithic
During the transition to composable (base + extension) CoCo images, run the
two runtimes on different image layouts so CI exercises both paths via
the existing qemu-{snp,tdx,coco-dev} (Go) and -runtime-rs (Rust) shims:

- runtime-rs (Rust) CoCo templates use the standard base image plus a
  CoCo extension extra_image:
      image = "@IMAGEPATH@"          (was @IMAGECONFIDENTIALPATH@)
      [[hypervisor.qemu.guest_extension_images]]
      name = "coco"
      path = "@COCOIMAGEPATH@"
      verity_params = "@COCOVERITYPARAMS@"
  COCOIMAGENAME/COCOIMAGEPATH/COCOVERITYPARAMS are added to the
  runtime-rs Makefile only.

- runtime (Go) CoCo templates keep the monolithic confidential image
  (@IMAGECONFIDENTIALPATH@) and pull rootfs-image-confidential.

shim-components.json reflects this: Go CoCo shims depend on
rootfs-image-confidential while the runtime-rs CoCo shims depend on
rootfs-image + rootfs-image-coco-extension.

shim-v2/build.sh feeds each runtime its own dm-verity params: Rust gets
the measured base image hash (@KERNELVERITYPARAMS@) plus the extension hash
(@COCOVERITYPARAMS@); Go gets the monolithic confidential image hash
(@KERNELVERITYPARAMS@).  This is wired per make invocation so the same
@KERNELVERITYPARAMS@ placeholder resolves correctly for each.

Once the split path is validated we can flip the Go templates too and
drop the monolithic confidential image.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:51:48 +02:00
Fabiano Fidêncio
e85a19a8a6 agent: add systemd template unit for extension image mount/unmount
Add a systemd template unit kata-extension-mount@.service and companion
helper scripts (kata-extension-mount.sh, kata-extension-umount.sh) that handle
the guest-side setup of extension block device images.

The mount script:
- Discovers the block device by matching its virtio serial (extension-<name>)
- Reads verity parameters from kata.extension.<name>.verity_params on the
  kernel command line
- Creates a dm-verity device and mounts the EROFS filesystem read-only
  at /run/kata-extensions/<name>/

The unit uses ConditionKernelCommandLine=kata.extension.%i.verity_params so
it only activates when that extension is configured for the VM, and is
ordered before kata-agent.service so extension contents are available when
the agent starts.

A systemd generator (kata-extension-mount-generator) instantiates the
template for every kata.extension.<name>.verity_params entry on the kernel
command line. Because the runtime emits one such entry per configured
guest_extension_images, extensions are enabled purely from the cmdline and
adding a new one needs no change to the rootfs build.

The agent Makefile is updated to install the unit, scripts and generator.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:51:48 +02:00
Fabiano Fidêncio
968d6e9431 runtime: add guest_extension_images cold-plug support for Go runtime
Mirror the Rust runtime's guest_extension_images support in the Go runtime:

- hypervisor.go: add GuestExtensionImage struct and GuestExtensionImages field to
  HypervisorConfig.
- config.go: parse [[hypervisor.qemu.guest_extension_images]] TOML sections
  via toGuestExtensionImages(), validating that every extension has a non-empty
  name and valid dm-verity parameters.
- qemu.go: in buildDevices(), attach each extra image as a virtio-blk
  drive with ID extension-<name>; in kernelParameters(), append
  kata.extension.<name>.verity_params=... for each extra image.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:51:48 +02:00
Fabiano Fidêncio
e96b6c8b17 runtime-rs: wire guest_extension_images cold-plug
Add a serial_override field to BlockConfig and DeviceVirtioBlk so that
extension images get a deterministic QEMU serial (extension-<name>) instead of
the auto-generated image-<id>.  This lets the guest discover each extension
via /dev/disk/by-id/virtio-extension-<name>.

Wire up the full cold-plug path for guest_extension_images:

- sandbox.rs: iterate boot_info.guest_extension_images, create read-only
  BlockConfig entries with the correct serial_override, and push them
  as ResourceConfig::GuestExtensionImage.
- resource lib.rs / manager_inner.rs: handle the new GuestExtensionImage variant
  by delegating to the existing block device path.
- cmdline_generator.rs: use serial_override when present for the QEMU
  serial= parameter; append kata.extension.<name>.verity_params=... to the
  kernel command line for each extra image.
- inner.rs: propagate serial_override from BlockConfig to the cmdline
  generator's add_block_device().

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:51:48 +02:00
Fabiano Fidêncio
f657d3729a kata-types: add GuestExtensionImage type and field to BootInfo
Introduce the GuestExtensionImage type to describe extension block-device images
(e.g. CoCo guest components) that are cold-plugged into the VM
alongside the main rootfs.

Each GuestExtensionImage carries a short name (used as the virtio-blk serial
and in kernel cmdline verity parameters), a host-side path, and
dm-verity parameters (required -- extension images must be integrity-
protected).

A new guest_extension_images Vec is added to BootInfo so that both the Rust
and Go runtimes can iterate the configured extensions when building the
VM device list and kernel command line.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-06-30 21:51:48 +02:00
Steve Horsman
8635c59e07 Merge pull request #13249 from stevenhorsman/thiserror-update
Thiserror and path-absolutize update
2026-06-30 14:43:45 +01:00
stevenhorsman
c292d93ec3 runtime: bump github.com/opencontainers/runc
Bumps github.com/opencontainers/runc from v1.2.8 to v1.3.6 to fix
GHSA-xjvp-4fhw-gc47 (CVE, CVSS 4.8).

The libcontainer/cgroups/systemd sub-package was removed from runc in
v1.3.x and moved to the standalone github.com/opencontainers/cgroups
module. Update the import in pkg/resourcecontrol/utils_linux.go
accordingly, and promote github.com/opencontainers/cgroups to a direct
dependency.

Fixes: https://osv.dev/GHSA-xjvp-4fhw-gc47
Generated-by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2026-06-30 09:55:40 +01:00
Fabiano Fidêncio
b5c61229c0 Merge pull request #13289 from stevenhorsman/mem-agent-rpc-policy
Mem agent rpc policy
2026-06-29 16:54:43 +02:00
Dan Mihai
d9fc56d6b3 Merge pull request #13105 from manuelh-dev/mahuber/no-guest-pull-skip-pol
genpolicy: stop skipping image UID/GID derivation for guest-pull
2026-06-29 07:06:22 -07:00