Commit Graph

6771 Commits

Author SHA1 Message Date
Alex Lyn
4f28b68af0 runtime-rs: Propagate and map discard as Dragonball sparse
Map BlockConfigModern.discard_unmap to Dragonball block device
sparse support when adding modern block devices.
This lets runtime-rs request guest-visible discard support through
the Dragonball block device configuration while leaving vhost-user
block devices disabled.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
95e4703e84 dragonball: Add sparse block discard support
Add a sparse flag to Dragonball block device configuration and use
it to expose virtio-blk discard support to the guest. Handle discard
requests by validating the requested range and punching holes in
sparse local file backends, returning an I/O error instead of
panicking on discard failures.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
a886f99a00 runtime-rs: Map and propagate block discard to CH sparse disks
Add the Cloud Hypervisor disk sparse option to the local DiskConfig
model and keep its default aligned with upstream. Map
BlockConfigModern.discard_unmap to DiskConfig.sparse so block devices
that request discard/unmap explicitly expose sparse discard support
through the CH API.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
f1b772eef0 runtime-rs: Add Discard Capability in each vmm driver
Add the BlockDeviceDiscardSupport cap in the qemu/clh/dragonball
drivers.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
4951b14611 kata-types: Add support for capability of block discard/unmap
To tells if the hypervisor exposes block discard/unmap support to
the guest, we introduce a new capability of discard/unmap named
`BlockDeviceDiscardSupport` in the capability set.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
569cbd21ca runtime-rs: Drop legacy Block device path fully
Remove the remaining legacy Block device implementation now that
BlockModern covers all block paths, finishing the migration started
by the QEMU and DeviceManager legacy-path drops.

Delete virtio_blk.rs (BlockConfig, BlockDevice and its Device impl)
and stop exporting it from driver/mod.rs. Drop the BlockCfg variant
from DeviceConfig and the Block variant from DeviceType. Remove the
DeviceConfig::BlockCfg handling and the create_block_device helper
from DeviceManager, and drop DeviceType::Block from the QEMU
hotunplug unsupported list.

No new behavior; pure removal of the dead legacy path.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
eaf1d0de28 runtime-rs: Drop legacy Block device path from Device Manager
Remove DeviceType::Block so BlockModern is the single code path,
completing the BlockConfig -> BlockConfigModern migration at the
Device Manager layer.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
ed571d3ea2 runtime-rs: Drop legacy Block device path from Qemu
The preceding "Use BlockConfigModern for ..." series converted every
block-device producer in the Qemu path to emit BlockModern. The Qemu
inner module still held the matching legacy Block consumer code across
all three lifecycle ops (coldplug/hotplug/hotunplug), now unreachable.

Remove it so BlockModern is the single code path, completing the
BlockConfig -> BlockConfigModern migration at the Qemu layer.
The hotunplug arm for Block now returns an explicit "unsupported"
error instead of a stale QMP detach. The new added Block(_) is just a
place holder and it will be removed in a follow-up commit.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
5ca05ad908 runtime-rs: Use BlockConfigModern for firecracker
Migrate the block config from BlockConfig to BlockConfigModern,
routing it through DeviceConfig::BlockCfgModern for firecacker.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
81e634001b runtime-rs: Use BlockConfigModern for agent-ctl vm_ops
Migrate the block config from BlockConfig to BlockConfigModern,
routing it through DeviceConfig::BlockCfgModern for agent-ctl vm_ops.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
c70f824335 runtime-rs: Use BlockConfigModern for erofs rootfs
Migrate the erofs rootfs path from BlockConfig to BlockConfigModern,
routing its block-device attachment through BlockCfgModern.
This covers the rw layer, single-device raw, multi-device VMDK, and
GPT-partitioned VMDK attachment points in erofs_rootfs.rs.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
8153fd44cb runtime-rs: Use BlockConfigModern for swap task
Migrate the block config from BlockConfig to BlockConfigModern,
routing it through DeviceConfig::BlockCfgModern for swap task.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
ee64539976 runtime-rs: Use BlockConfigModern for block rootfs
Migrate the block config from BlockConfig to BlockConfigModern,
routing it through DeviceConfig::BlockCfgModern for block rootfs.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
71b66d1988 runtime-rs: Use BlockConfigModern for block devices in handler_devices
Migrate the host block-device (major/minor) passthrough path in
ResourceManagerInner from BlockConfig to BlockConfigModern, routing it
through DeviceConfig::BlockCfgModern. This continues the BlockModern
migration to cover block-mode devices carried in the OCI spec.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
578d403409 runtime-rs: Use BlockConfigModern for InitData
Switch the InitData resource path from BlockConfig to BlockConfigModern
so the InitData is handled through the modern block device pipeline,
consistent with the recent BlockModern migration for block volumes.

This changes ResourceConfig::InitData to wrap BlockConfigModern,
routes its handling through DeviceConfig::BlockCfgModern, and updates
its related helper function in virt_container to build a
BlockConfigModern.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
3537b18768 runtime-rs: Use BlockConfigModern for VM rootfs
Switch the VmRootfs resource path from BlockConfig to BlockConfigModern
so the VM rootfs is handled through the modern block device pipeline,
consistent with the recent BlockModern migration for block volumes.

This changes ResourceConfig::VmRootfs to wrap BlockConfigModern, routes
its handling through DeviceConfig::BlockCfgModern, and updates
prepare_rootfs_config() in virt_container to build a BlockConfigModern.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
0544de8eb4 runtime-rs: Add BlockModern hotplug support in QEMU
Introduce a new field of serial_override in the BlockModern config.
Add a DeviceType::BlockModern branch to the QEMU QMP hotplug path,
mirroring the existing Block semantics: skip block devices that
represent the initrd, and dispatch to nvdimm or blk/ccw/scsi
according to driver_option. Snapshot the config parameters under
lock and run the asynchronous hotplug without holding it to avoid
awaiting across the lock.
Pass the real block format and, when enabled, the first independent
iothread (indep_iothread_0) to hotplug_block_device instead of the
default format and None, and return DeviceType::BlockModern so the
hotplugged device is tracked.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
37739bcc69 runtime-rs: Use bind mounts for direct volume targets
Treat SPDK and VFIO direct volumes as a two-step mount. The agent
storage entry mounts the device inside the guest with block storage
options, while the OCI mount bind-mounts that guest path into the
container.

Filter bind flags from storage options, preserve direct-volume
mountInfo options when present, and add ro when the volume is
read-only.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
22f2d57e4f runtime-rs: Move block volumes to BlockModern
Build regular block volumes with BlockConfigModern and submit them
through DeviceConfig::BlockCfgModern. Preserve the existing block
device attributes while also recording the host path required by the
modern block device model.

Update block volume helper call sites with the default option slice
so this change remains buildable with the modern helper signature.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
346b9e38e2 runtime-rs: Add BlockModern support in Cloud Hypervisor
Switch the Cloud Hypervisor device handling path from the legacy
Block device variant to BlockModern. Keep the block device behind
its shared mutex while snapshotting the configuration for the
hotplug request, and persist the PCI path assigned by Cloud
Hypervisor back into the shared device state.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
f2df09d738 runtime-rs: Refactor mount options handling and add utility functions
Introduce build_bind_mount_options() to construct OCI mount options for
container-side bind mount, preferring volume_options over OCI options
and ensuring a bind/rbind flag is present.
And addfilter_block_storage_options() to strip bind/rbind flags from
Storage.options, preventing ENOTDIR when the agent mounts a block
device to a filesystem inside the guest.
And then Extend handle_block_volume() with a volume_options parameter
and replace hardcoded ro/empty options with the new filter+ro logic,
narrowing the function to a BlockModern-only path by removing the
DeviceType::Block branch.
Fix generate_shared_path to always create under rw/ since ro/
is a read-only bind mount of rw/ and direct creation fails with ReadOnly
FS. Switch the OCI Mount type from fs_type to KATA_MOUNT_BIND_TYPE because
the mount source is a directory (guest_path), not a block device.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
28e2318a35 runtime-rs: Consolidate virtio-blk shared types into BlockModern module
Move the block device type definitions shared between BlockDevice and
BlockDeviceModern — VIRTIO_BLOCK_{PCI,MMIO,CCW}/VIRTIO_PMEM constants,
KATA_*_DEV_TYPE aliases, and the BlockDeviceAio / BlockDeviceFormat
enums — from virtio_blk.rs into virtio_blk_modern.rs, so they live
alongside the BlockModern handler that will replace the legacy
BlockDevice.

Add a `format: BlockDeviceFormat` field to BlockConfigModern to match
the legacy BlockConfig. Update mod.rs re-exports accordingly.

No behavior change; pure relocation plus the new field.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
525b68e332 runtime-rs: Add BlockModern support in Dragonball VMM
Extend add_block_device with num_queues and queue_size parameters
to support multi-queue virtio-blk configuration, and add BlockModern
hotplug/hotunplug handler that extracts config from
Arc<Mutex<BlockDeviceModern>>, passes the new parameters to
add_block_device, and updates pci_path on successful hotplug.

And we will use BlockDeviceModern to handle block device instead of
Legacy BlockDevice.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Alex Lyn
65d580c2b0 runtime-rs: Add BlockModern arm in DeviceManager
Add BlockModern handling in DeviceManager so that device index is
correctly released both in get_device_info and in the error path.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
Manuel Huber
de8cb3e037 runtime-rs: support scsi container block rootfs
Use the hotplug-returned SCSI address as Storage.source when a
container rootfs is backed by a block device.

Signed-off-by: Manuel Huber <manuelh@nvidia.com>
2026-07-16 17:26:09 +00:00
Xuewei Niu
5bf558c718 dragonball: Remove accidentally-committed out file
src/dragonball/out is an 893 KB `cargo metadata` JSON dump that was swept
into the tree by accident in commit 1d2d2cc3d ("ci: Remove duplicated
rust-vmm dependencies"), whose only intended change was a one-line edit to
.github/dependabot.yml. Nothing references the file -- no script, CI job,
or Makefile -- so it is pure build cruft. Remove it.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2026-07-16 16:08:32 +08:00
Xuewei Niu
57f416134c dragonball: Group dbs_* crates under crates/
At src/dragonball/, the dragonball crate's own module tree (src/) sat as a
sibling of whole separate crates (dbs_acpi/, dbs_pci/, ...). That level
mixed one crate's guts with other crates -- neither cleanly one crate nor
a clean set of crates. Move the dbs_* under src/dragonball/crates/ so the
top level is the dragonball crate plus a crates/ folder of its libraries,
matching the layout src/runtime-rs already uses.

The dbs_* were imported ~2 years ago from the standalone dragonball-sandbox
repo and kept that repo's flat layout verbatim. They are now private to
kata (unpublished, versions frozen) -- plain internal workspace members --
so no external consumers are affected and the "independently published
building blocks" rationale for the flat layout no longer holds. Pure
layout change; no code or build behavior changes.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
2026-07-16 16:08:32 +08:00
manuelh-dev
fe5071ccd2 Merge pull request #12971 from burgerdev/pathrs
agent: constrain copy_file to shared directory
2026-07-15 17:36:48 -07:00
Markus Rudy
3dba12cd81 agent: constrain copy_file to shared directory
In confidential mode, the host is not trusted and might try to create
malicious files in the guest VM. This commit changes the implementation
of the CopyFile method to use pathrs, which is designed to prevent
accidental writes to locations outside the shared directory
(/run/kata-containers/shared/containers). It also adds a detailed
description of what the method does, and test cases for intended and
malicious use cases.

This was originally considered as a mitigation candidate for
https://github.com/kata-containers/kata-containers/security/advisories/GHSA-q49m-57vm-c8cc,
but we decided to go with the simpler change to address the immediate
risk. It's still desirable to lock down CopyFile writes for defense in
depth, thus the resubmission outside the GHSA.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2026-07-15 20:44:26 +02:00
Hyounggyu Choi
f51a1ec904 Merge pull request #13375 from fidencio/topic/nvidia-cpu-arm64-does-not-require-ovmf
runtime: do not require OVMF for qemu-nvidia-cpu on arm64
2026-07-15 17:09:40 +02:00
Fabiano Fidêncio
2148520998 Merge pull request #13331 from lifupan/wmain
dragonball: validate full guest buffer range in virtio-blk async I/O
2026-07-15 16:10:03 +02:00
Fabiano Fidêncio
e8bb619b1b runtime: do not require OVMF for qemu-nvidia-cpu on arm64
Use dedicated empty firmware makefile variables so the NVIDIA CPU
runtime does not inherit generic OVMF/AAVMF firmware paths.

runtime-rs already sets the correct option by default, so, no changed
needed on that front.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2026-07-15 14:28:39 +02:00
Fabiano Fidêncio
ffb43bab0b Merge pull request #13318 from Apokleos/fix-network-queues
runtime-rs: Fix network queues and propagate it to network endpoints
2026-07-15 06:57:58 +02:00
Zvonko Kaiser
0348bb01f6 Merge pull request #13349 from kata-containers/topic/nvidia-cpu-stuff
nvidia: Add qemu-nvidia-cpu{,-runtime-rs} runtimeclasses and tests
2026-07-14 13:57:05 -04:00
Alex Lyn
4522ae6006 runtime-rs: Fix Clh network hotplug queue pair-to-virtqueue conversion
The network hotplug (handle_network_device) passed `queue_num`, a
queue pair count, straight as `num_queues`, while cloud-hypervisor's
virtio-net expects a raw virtqueue count.
With the default network_queues=1 this hit "Number of queues (1) to
virtio_net should be higher than 2" on the post-start netdev add,
failing sandbox start.

Convert the pair count to the raw queue count (queue_num.max(1) * 2),
matching the coldplug path which already does network_queues_pairs * 2.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-14 20:36:21 +08:00
Alex Lyn
a53bc4ddb9 runtime-rs: Fix Dragonball network queue pair-to-virtqueue conversion
NetworkConfig.queue_num is a queue pair count, but Dragonball's
virtio/vhost-net backends expect an even raw virtqueue count. Passing
it through without doubling caused InvalidQueueNum(1) on the default
network_queues=1, failing sandbox start.

Convert pair count to raw count (queue_num.max(1) * 2) at both
Dragonball network entry points, mirroring the Cloud Hypervisor
backend.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-14 20:36:21 +08:00
Alex Lyn
898a8040e3 runtime-rs: Propagate num_queues to QEMU network device helpers
As part of the effort to thread network queues from the top-level
configuration all the way down to each endpoint instead of having
low-level helpers re-read the global configuration, propagate the
per-network queue_num into the QEMU cmdline generator and hotplug
path.

add_network_device() and get_network_device() now take an explicit
num_queues argument sourced from network.config.queue_num, replacing
the direct read of network_info.network_queues, so each network
endpoint honors its own configured queue count.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-14 20:36:21 +08:00
Alex Lyn
69d4064c87 runtime-rs: Introduce queues for DanConfig to make it configurable
As there's no field to map the configuration's network_queues item
in the `DanConfig`, this commit introduces a network_queues to do this.

And accordingly, we also make it passed down from sandbox layer to
Dan network configurations.

To make it work well, it make it more robust for queues and queue_size
settings with checking logics. And related UT is added.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-14 20:36:21 +08:00
Alex Lyn
69f35bc73e runtime-rs: Propagate queue_num and queue_size to network endpoints
Set queue_num (derived from net_pair.queues, one TX + one RX per
queue pair) and queue_size (256) when building the network pair for
veth, macvlan, ipvlan and vlan endpoints so the virtio-net device is
created with the configured multi-queue layout.

Meanwhile, update endpoint tests accordingly.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-14 20:36:21 +08:00
Alex Lyn
1ddeb3bd85 runtime-rs: Introduce a field for mapping configuration network_queues
Number of virtio queue pairs (each pair = 1 RX + 1 TX).
Derived from `network_queues` in the hypervisor TOML config.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-14 20:36:21 +08:00
Fabiano Fidêncio
7a77673885 runtime-rs: Bump containerd-shim to 0.11 and ttrpc to 0.9
Move runtime-rs onto containerd-shim/containerd-shim-protos 0.11.0,
which drops the legacy cgroups-rs 0.3.x dependency. Adapt to ttrpc
0.9 API changes for async connect, server listener setup, and event
forwarding.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Composer <cursor@cursor.com>
2026-07-14 13:11:54 +02:00
Fabiano Fidêncio
e75ee5606c build: Bump cgroups-rs to 0.5.1 via workspace
Unify agent, rustjail, and runtime-rs on cgroups-rs 0.5.1 from
crates.io instead of the v0.3.5 git fork. Add a rustjail shim for
the 0.5.x API layout where the legacy cgroupfs types moved under
cgroups::fs.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Composer <cursor@cursor.com>
2026-07-14 12:58:17 +02:00
Zvonko Kaiser
662879f9a8 agent: Bump container-device-interface to 1.1.1
cdi-rs 1.1.1 is the first release built against oci-spec 0.10, so
the Spec type its inject_devices() takes now unifies with the
workspace oci-spec and the kata-agent builds again.

kata-agent and pod-resources-rs each carried their own pin (0.1.1
and 0.1.2). Hoist the dependency to the root workspace like
oci-spec in the previous commit, so both consumers stay on the
same cdi types and future bumps apply to the whole tree at once.

The kata code compiles unchanged against the 0.1.2 -> 1.1.1 jump;
the API surface we use (annotations, cache, spec_dirs,
inject_devices) is source-compatible.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 12:58:05 +02:00
Zvonko Kaiser
a3f211ff19 libs: Inherit oci-spec from the root workspace
Bumping oci-spec to 0.10.0 in the root manifest broke the
kata-agent build: kata-types, protocols and kata-sys-util
declare their own oci-spec pin (0.8.1) instead of inheriting
the workspace dependency, so the bump left them behind on
0.8.4 while the agent and runtime-rs crates moved to 0.10.0.
Since 0.x lines are semver-incompatible, cargo compiles both
versions side by side, and every oci-spec type these libs
expose in their public API (e.g. oci_spec::runtime::Spec) no
longer matches the type the agent expects — a wall of
"expected Spec, found Spec" mismatches.

Switch the three crates to `workspace = true` like the other
members so the root manifest is the single source of truth
and future bumps apply to the whole tree atomically. The
`runtime` feature is inherited from the workspace declaration.
No resolution change yet: both sides currently resolve to
0.8.4; the actual bump follows in the next commit.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-14 12:58:05 +02:00
Hyounggyu Choi
f430ce4918 Merge pull request #13364 from manuelh-dev/mahuber/runtime-rs-qemu-memory-backend-ram
runtime-rs/qemu: use RAM memory backend
2026-07-14 11:58:47 +02:00
Fabiano Fidêncio
734826756d runtime: skip CPU-less host NUMA nodes when auto-deriving topology
On hosts with memory-only NUMA nodes (GPU/CXL memory, e.g. the empty
nodes 1-8 a Grace-Hopper GH200 exposes next to its single CPU node), the
auto NUMA path built a guest node for every host node and then failed in
DistributeVCPUsProportionally with "HostCPUs for NUMA node N must not be
empty". This broke sandbox creation for any qemu-nvidia-cpu pod once
enable_numa is on, not just the NUMA tests.

Filter CPU-less nodes out of the auto-derived topology in
maybeRightSizeAutoNUMA() so the guest CPU topology only spans nodes that
can host vCPUs. Keep the full set when a VFIO device is attached, since a
passed-through GPU may live on a CPU-less node that still needs a guest
NUMA node for pxb-pcie placement.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-07-14 10:20:59 +02:00
Fabiano Fidêncio
7cb4a189c1 config: add CPU-only NVIDIA runtime classes
qemu-nvidia-gpu boots the driver-agnostic NVIDIA base image and then
cold-plugs the GPU extension on top.  Nothing, however, just boots that
base image on NVIDIA hosts that have no GPU (or where the GPU isn't handed
to the guest), even though the base image is perfectly usable on its own.

Add qemu-nvidia-cpu (Go) and qemu-nvidia-cpu-runtime-rs (Rust), cloned
from the qemu-nvidia-gpu configs with every GPU-passthrough bit dropped:
no guest_extension_images, cold_plug_vfio = "no-port", pcie_root_port = 0,
no VFIO pod-resource wiring and no GPU NUMA validation.  Resource defaults
and timeouts are pulled back in line with qemu[-runtime-rs] (1 vCPU,
DEFMEMSZ, small overheads) rather than the GPU-tuned values, and firmware
is left to the arch default so x86_64 boots without OVMF.

Both classes boot the measured nvidia base image verity-backed.  The Rust
runtime already maps KERNELVERITYPARAMS_NV to the base hash; the Go runtime
maps it to the monolith, so a dedicated KERNELVERITYPARAMS_NV_BASE var is
added for qemu-nvidia-cpu.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-07-14 10:20:59 +02:00
Fabiano Fidêncio
afb4b38050 runtime: floor static-mgmt DefaultMaxVCPUs at 1
Under static_sandbox_resource_mgmt the VM is sized to exactly what OCI
requests (base default_vcpus plus workload CPU limits) and CPU hotplug is
off, so DefaultMaxVCPUs is set to the sized NumVCPUs().

When a pod requests default_vcpus=0 with no CPU limit, that sized count
rounds to 0. DefaultMaxVCPUs then becomes 0, which the hypervisor later
expands to the host maximum (govmm.MaxVCPUs()). With NUMA enabled the SMP
topology becomes sockets=maxcpus=host_max, e.g. maxcpus=240, which fails
to boot on hosts where KVM caps the recommended vCPU count (the sandbox
never comes up and k8s-sandbox-vcpus-allocation / k8s-cpu-ns time out on
qemu-nvidia-cpu).

A VM cannot boot with zero vCPUs (QEMU already clamps -smp to 1), so floor
DefaultMaxVCPUs at that same single boot vCPU rather than falling back to
the host maximum. This keeps the value equal to the OCI-requested count in
every non-degenerate case and never consults the host maximum under static
management.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
Assisted-by: Cursor <cursoragent@cursor.com>
2026-07-14 10:20:59 +02:00
Manuel Huber
125cd3732c runtime-rs/qemu: use RAM memory backend
Use an explicit memory-backend-ram object for normal,
non-file-backed QEMU memory and bind it through the machine
memory-backend option.

This aligns the runtime-rs QEMU command line more closely with the
runtime-go QEMU path when filesystem sharing is disabled. Further,
when enable_mem_prealloc is enabled, runtime-rs now emits
prealloc=on for that backend, matching the runtime-go behavior.

This supports #13363, where the non-confidential NVIDIA runtime-rs
handler disables filesystem sharing and uses the EROFS snapshotter as
its Kubernetes image-layer transport. This is expected to reduce the
likelihood of the QMP startup delays seen in #13084 for NVIDIA GPU
passthrough with filesystem sharing disabled. A separate issue on the
behavior of the QMP timeout logic is additionally tracked in #13343.

In addition to these changes, #12187 tracks a machine-centric QEMU
refactor. In particular, the phase 3 work described there plans to
lift memory backends into QEMU Objects. After this work, command
line generation will be refactored, and, full NUMA support be ported
to runtime-rs.

This commit also adds the first command-line generator unit tests for
this file to cover the new RAM backend behavior.

Signed-off-by: Manuel Huber <manuelh@nvidia.com>
Assisted-by: OpenAI Codex <codex@openai.com>
2026-07-13 23:01:45 +00:00
Bozhidar Marinov
2212dbdd48 agent: send SIGTERM only to root container process on container deletion
When containerd wants to terminate a container, it sends a KillRequest with exec_id="", all=false, signal=SIGTERM.
Kata-shim translates that to a SignalProcessRequest with exec_id="", signal=SIGTERM
Kata agent used to interpret exec_id="" as implying all=true.
That was correct for forceful deletion of containers, as it uses a KillRequest with all=true, signal=SIGKILL.
However, for graceful termination, we want to only signal the root process of the container (all=false).

This changes makes it so that Kata agent interprets exec_id="" && signal=SIGKILL as implying all=true, and uses all=false otherwise.
It also fixes an unrelated bug, where Kata agent would signal the root process twice when all=true.

Fixes #13152 - sending SIGTERM twice to the container's init process on graceful shutdown of a container.

Signed-off-by: Bozhidar Marinov <bozhidar.marinov1@digits.schwarz>
Co-authored-by: Markus Rudy <webmaster@burgerdev.de>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-13 22:39:42 +02:00