Commit Graph

6784 Commits

Author SHA1 Message Date
Zvonko Kaiser
089fcf6b4e qemu/machine/fixtures: normalize memory-backend-file option order
The vEGM fixtures used id,mem-path,size,share,prealloc while the vCMDQ
and Q35 SHM fixtures use id,size,mem-path with prealloc before share.
QEMU treats the options as unordered, but the golden tests compare
strings exactly, so a single canonical order keeps the emitter free of
per-backend special cases.  Canonical: id, size, mem-path, then
host-nodes/policy where pinned, then prealloc=on, share=on.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
e1698f08e8 qemu/machine: fix highmem_mmio_size doc and Makefile claim
The highmem_mmio_size doc comment ended with a dangling "bytes." line;
fold the unit into the opening sentence, in virt.rs and the copy quoted
in ARCHITECTURE.md.

ARCHITECTURE.md claimed the Makefile already defaults CPUFEATURES and
TDXCPUFEATURES to include host-phys-bits=on; the repo defaults are
still pmu=off only.  State the actual situation: the flag must be set
per configuration file until the Makefile defaults are extended.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
dc5fdc0c0a docs: backtick technical terms in ARCHITECTURE.md for spellcheck
cspell flags domain terms and identifiers (SMMU, CMDQ, SRAT, VAES,
iommufd, pseries, prefetchable, and friends) as unknown words.  Wrap
them in backticks: the spellcheck config ignores inline code spans,
and these tokens are identifiers or hardware acronyms that belong in
code style anyway.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
9ad7a8ad87 qemu/machine: address review comments on fixtures and ARCHITECTURE.md
- q35_vanilla_kata_x86.args: header said 65 vCPUs but the NUMA ranges
  (0-32, 33-65) cover 66; fix the count.
- q35_coco_snp_single_gpu.args: replace the production-captured
  host-data blob with a clearly synthetic placeholder (base64 of
  "KATA-SYNTHETIC-HOST-DATA-0000000"); the fixture validates arg shape
  and ordering, not attestation material.
- ARCHITECTURE.md: kernel-irqchip -> kernel_irqchip in four places to
  match the actual QEMU -machine option spelling used by the code and
  fixtures.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
82fc3f2d4c hypervisor/qemu: add CpuConfig/CpuModel with attestation rationale
For CoCo SNP the CPU model is part of the attestation identity: a fleet
with mixed Milan/Genoa/Turin nodes produces different CPUID per node with
cpu=host, so attestation reference values diverge and rescheduled Pods
fail (#12329).  Pinning to EPYC-v4 gives a stable, portable identity
across the fleet, but strips AVX-512 and VAES extensions, halving
AES-GCM throughput to ~4 GB/s (#12382).

CpuModel::EpycV4 { extra_features } resolves both: attestation identity
is fixed while SNP_CRYPTO_FEATURES re-enables the stripped extensions.
CpuModel::Host { extra_features } carries pmu=off and host-phys-bits=on
for vanilla/TDX x86_64 guests (#13270).

ARCHITECTURE.md gains a BaseMachine/CpuConfig section with the full
rationale table and links to the four issues as breadcrumbs.

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
c28ea4eace hypervisor/qemu: document #13270 (4+ Blackwell GPU GPA cap) in known issues
Explains the root cause (40-bit GPA without host-phys-bits=on), the
short-term fix in the Makefile, and the post-refactor path (Q35 Platform
builder should emit host-phys-bits=on unconditionally for x86_64/KVM).

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
cdd81c7a42 hypervisor/qemu: address Phase 0 review comments
Four items promised in replies to Copilot review:

virt.rs: add "bytes." to highmem_mmio_size doc comment so the unit is
unambiguous when emitting QEMU highmem-mmio-size=.

platform.rs: clarify BaseMachine::memory_backend doc — None is correct
for multi-socket vEGM where each socket supplies its own memory-backend
via -numa node,memdev= rather than a single machine-wide backend.

ARCHITECTURE.md: update module layout diagram to reflect what Phase 0
actually introduces (platform.rs, topology.rs, tests.rs all present;
probe.rs holds HostTopology only — PlatformProbe is Phase 1). Annotate
runtime: RuntimeFeatures fields in both Machine code samples as Phase 3+
so the doc is self-consistent with the current stubs.

tests.rs: run cargo fmt (long assignment line on check() helper).

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
391866e084 hypervisor/qemu: add CoCo SEV-SNP + GPU fixture from production capture
Adds fixture and ignored test (Phase 3) for Q35 CoCo (SEV-SNP) with one
GPU passed through, based on a production invocation (AMD EPYC host,
2026-07-13, H100 80GB at 0000:e1:00.0).

Key differences from Grace/virt and vanilla Q35 documented in fixture
and ARCHITECTURE.md Planned Fixtures section:

- sev-snp-guest object emitted before the -machine line (QEMU requires
  the protection object first); kernel_irqchip=split required for SNP
- Memory model: memory-backend-ram with host-nodes=1,policy=bind (not
  file-backed; CoCo uses RAM backend for NUMA pinning on x86)
- GPU passthrough via pxb-pcie + pcie-root-port + vfio-pci (not
  vfio-pci-nohotplug); no arm-smmuv3 — x86 uses global AMD/Intel IOMMU
- iommufd is per-device (id=iommufdvfio-<uuid>), not the shared
  iommufd0 used on Grace
- x-pci-vendor-id/x-pci-device-id overrides required so the guest sees
  correct device IDs for measured boot attestation
- AMDSEV.fd firmware (AMD-specific OVMF, not generic OVMF.fd)
- pxb-pcie bus_nr=32 (not the Grace 1-indexed cumulative formula)

Phase 3 items enumerated: Objects::protection, Q35::kernel_irqchip and
confidential_guest_support typed fields, MemoryBackend::Ram host_nodes
and policy, per-device iommufd, VfioDevice vendor/device id overrides.

TDX capture still needed.

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
43ac4f83c9 hypervisor/qemu: add Q35 fixture, platform parity, and planned fixtures
Q35 vanilla kata fixture (q35_vanilla_kata_x86.args) from a production
DGX x86 invocation (2026-07-07): 2-socket NUMA, 65 vCPUs, 36864M per
socket pinned to /dev/shm, 8 cold-plug pcie-root-ports on pcie.0.
Test added as #[ignore = "Phase 3"]; it drives the Phase 3 API design.

Key differences from the Grace/virt topology that inform Phase 3 scope:
- No kernel-irqchip on vanilla Q35 (only required for CoCo)
- NUMA SHM memory model: per-socket file-backed backends with host-nodes
  and policy=bind rather than a single backend on the -machine line
- Q35 GPU passthrough uses cold-plug onto pre-provisioned pcie-root-ports
  (cold_plug_vfio=root-port, pcie_root_port=8, hot_plug_vfio=no-port);
  no pxb-pcie, no arm-smmuv3

Platform Parity section: documents legacy Machine fields without typed
homes (machine_accelerators, confidential_guest_support), baseline
-machine output for each supported machine type, and Platform fields
required before the legacy struct can be deleted.

Planned Fixture Configurations section: enumerates the four fixture sets
needed before Phase 6 closes (vanilla virt, Q35 vanilla, CoCo+GPU,
8-GPU+4-NVSwitch), notes what data is captured vs. still needed, and
lists the new types required for each.

Known Issues and Follow-up Items section: QMP startup timeout (#13343),
seccomp_sandbox not yet in Platform, machine_accelerators /
confidential_guest_support cross-references.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
f8af92b8be hypervisor/qemu: add golden test harness for platform generation
Seven fixture files encode the expected QEMU argument list for each
Grace passthrough topology derived from tested production deployments:

  grace_1_single_gpu          -- 1 GPU, 1 SMMU, 9 NUMA nodes
  grace_2_four_gpus_1_per_smmu -- 4 GPUs x 1-per-SMMU, 33 NUMA nodes
  grace_3_four_gpus_2_per_smmu -- 4 GPUs x 2-per-SMMU, 33 NUMA nodes
  grace_4_gpu_and_nic         -- GPU + NIC, NIC emits no generic-initiators
  grace_5_vcmdq               -- hugepages backing + cmdqv=on on arm-smmuv3
  grace_6_vegm_1_per_socket   -- vEGM, 4 sockets, 1 GPU each
  grace_7_vegm_2_per_socket   -- vEGM, 2 sockets, 2 GPUs each

Each test is #[ignore] until the corresponding phase lands. The harness
reads fixtures as one Vec<String> element per line; blank lines and
lines starting with '#' are skipped.

The fixtures are the contract: any Platform implementation must reproduce
them exactly before a phase PR can be merged.

Refs: #12187, #12125

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
0c742aeca1 hypervisor/qemu: add typed machine module
The existing cmdline_generator.rs (~3700 lines) encodes bus-assignment
logic inside each device and uses a single stringly-typed Machine struct
for all machine types. This makes adding Grace/vCMDQ/vEGM support
impractical without touching every device.

Introduce src/qemu/machine/ with the target types:

  Platform      -- top-level wiring point (machine + PCIe topology + objects)
  Machine       -- per-machine-type structs (Q35, Virt, Pseries, S390xCcwVirtio)
  PciTopology   -- PCIe expander buses with per-RC numa_node and BusIommu
  BusIommu      -- bus-attached IOMMU (SmmuV3); IntelIommu lives on Q35 directly
  Objects       -- typed -object registry (MemoryBackend, AcpiPciNodeLink, ...)
  HostTopology  -- probe result consumed by apply_host_defaults

All methods are todo!() stubs. No behaviour change; cmdline_generator.rs
is untouched. Implementations land phase by phase starting at Phase 2.

Refs: #12187, #12125

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-17 17:47:39 +00:00
Zvonko Kaiser
bf086ff559 hypervisor/qemu: document machine-centric architecture
The current cmdline_generator.rs (~3700 lines) has three structural
problems: bus-assignment logic duplicated across every device via
#[cfg(target_arch)], a single stringly-typed Machine struct shared by
all machine types, and no NUMA-aware memory backend support.

Add ARCHITECTURE.md describing the target design before any code
changes land. The document covers:

  current pain points
  target module layout and core types (Platform, Machine, PciTopology,
    BusIommu, Objects, HostTopology)
  NUMA layout rules (ACPI SRAT ordering, 8 nodes per GPU for MIG,
    highmem-mmio-size sizing, hotplug placeholder)
  7 Grace platform configurations as golden test fixtures
  6-phase migration plan (Phase 0 test harness through Phase 6 cleanup)
  design principles

The document is a living reference updated with each phase PR.
It becomes a clean stable reference once Phase 6 completes.

Refs: #12187, #12125

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2026-07-17 17:47:39 +00:00
Alex Lyn
89509fd3ea runtime-rs: Gate block emptyDir discard by hypervisor capability
Only enable discard for block-plain emptyDir volumes when the
hypervisor reports block device discard support.

The resource manager now queries hypervisor capabilities once and
passes block discard support through VolumeContext. Block emptyDir
volume setup uses that capability to decide whether to add the
discard mount option and related mount metadata, avoiding unsupported
discard mounts on hypervisors that cannot expose discard/unmap to the
guest.

It will correctly adjust the related codes with the new support.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-07-17 10:36:44 +02:00
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