Skip to content

feat(kubevirt): host_devices, the schema half of nested virtualisation - #277

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/kubevirt-host-devices
Oct 23, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/kubevirt-host-devices

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

#KubevirtDevices gains host_devices — a list of the new #KubevirtHostDevice
(device_name, optional name). It is the schema half of nested virtualisation: a KubeVirt guest
gets its own /dev/kvm only through spec.domain.devices.hostDevices, and a guest without
/dev/kvm cannot run a VM at all. A CPU feature (svm) alone is not enough.

Why it is needed — measured, not assumed

The blacksmith-*-labelled Ubuntu runners stand in for real Blacksmith runners, and Blacksmith
documents KVM / nested virtualisation as supported by default on its x64 Linux runners
(https://docs.blacksmith.sh/blacksmith-runners/overview#do-blacksmith-runners-support-kvm-or-nested-virtualization).
Our fleet does not meet that bar today.

Host side — ready, measured on a virt-launcher pod on quant-dev:

$ kubectl exec virt-launcher-… -- sh -c 'cat /sys/module/kvm_*/parameters/nested; \
    grep -m1 vendor_id /proc/cpuinfo; ls -l /dev/kvm'
nested=1
vendor_id : AuthenticAMD
crw-rw---- 1 qemu qemu 10, 232 /dev/kvm

All three nodes advertise devices.kubevirt.io/kvm: 1k.

Guest side — nothing reaches the guest:

charly-ci-runner-2vcpu-1   /dev/kvm: No such file or directory   vmx/svm in cpuinfo: none
charly-ci-runner-8vcpu-1   /dev/kvm: No such file or directory   vmx/svm in cpuinfo: none
charly-ci-runner-32vcpu-1  /dev/kvm: No such file or directory   vmx/svm in cpuinfo: none

The rendered VMI explains both: cpu: {cores: 8, model: host-model} (a migratable model, so
svm is dropped) and a devices: block with no hostDevices. cpu.model was already
expressible; hostDevices was not. This unblocks it.

Shape

host_devices?: [...#KubevirtHostDevice]

#KubevirtHostDevice: {
    device_name: string   // the resource the device plugin advertises, minus `devices.kubevirt.io/`
    name?:       string   // the label inside the guest; KubeVirt defaults it to device_name
}

Typed rather than typed-open like disks, because both fields are meaningful and device_name
is required. The device vocabulary stays the cluster's, not ours — kvm today, anything a device
plugin advertises tomorrow.

How tested

$ charly task cue-gen
task cue-gen: 2 step(s), 0 failed
  [pass] run — gengotypes + schemagen the generated Go
  [pass] check — regen is reproducible — TestGenReproducible passes on the committed tree

$ GOWORK=off go build ./...
$ echo $?
0
$ GOWORK=off go test ./spec/ -run TestGenReproducible -count=1
ok  github.com/opencharly/spec/spec  0.171s

The regeneration touched only the two files this change is about (schema/kubevirt.cue +14,
spec/cue_types_gen.go +16), and the reproducibility check is part of cue-gen itself, so a
non-idempotent edit cannot land.

Rulebook compliance

Rule How it is honoured
R1 Both sides of the claim are measured on the live cluster (host ready, guest not) rather than inferred from the docs.
R2 One field, one new definition; no second way to add a device.
R5 Additive only — no existing field changes meaning.
R7 cue-gen is reproducible on the committed tree (its own check:), and the generated Go is what the consumer will compile against.
SDD CUE first; Go is generated, never hand-transcribed; the diff proves it.

Change classification

Schema addition plus its generated Go. No consumer uses the field until the follow-up PRs land,
so nothing changes behaviour by itself.

Agent: claude-code-crabbox-ci · Assisted-by: Claude Code DeepSeek deepseek-v4.1-flash:cloud (analysed on a live system)

A KubeVirt guest gets its own `/dev/kvm` only through
`spec.domain.devices.hostDevices` — a CPU feature alone is not enough — and a guest without
`/dev/kvm` cannot run a VM at all. `#KubevirtDevices` had no way to express it, so no charly
kubevirt entity could.

`host_devices` is a list of `#KubevirtHostDevice` (`device_name`, optional `name`). The device
vocabulary belongs to the cluster's device plugin: on `quant-dev` it advertises
`devices.kubevirt.io/kvm`, so a nested-virt guest asks for `{device_name: "kvm", name: "kvm"}`.

Measured need (2026-10-23): the `quant-dev` hosts are ready — `nested=1`, `/dev/kvm` present,
all three nodes advertising `devices.kubevirt.io/kvm: 1k` — while every Ubuntu CI runner guest
had neither `/dev/kvm` nor `svm` in `/proc/cpuinfo`, because the rendered VMI carries
`cpu.model: host-model` and no host devices.

Assisted-by: Claude Code DeepSeek deepseek-v4.1-flash:cloud (analysed on a live system)
@github-actions

Copy link
Copy Markdown

Review — PASS

Scope and correctness

The change is exactly what the body claims: two files, additive only.

  • schema/kubevirt.cue: host_devices?: [...#KubevirtHostDevice] is added inside #KubevirtDevices (the struct carrying rng, disks, inputs, watchdog, i.e. the spec.domain.devices shape), and a new #KubevirtHostDevice definition (device_name: string required, name?: string optional) is added immediately after it. This is the right home for spec.domain.devices.hostDevices, and it is additive — no existing field changes meaning.
  • spec/cue_types_gen.go: the generated Host_devices []KubevirtHostDevice field and the KubevirtHostDevice struct mirror the CUE 1:1, with the same comments. The required/optional tag convention matches the generator's established pattern elsewhere in the file (device_name required → json:"device_name" with yaml:"...,omitempty"; name optional → omitempty on both), so this reads as generated output, not a hand-edit.

Body honesty

  • "2 changed files … schema/kubevirt.cue +14, spec/cue_types_gen.go +16" matches the diff counts exactly (+14/-0 and +16/-0).
  • The host_devices shape quoted in the body matches the CUE verbatim.
  • The claim that no consumer uses the field yet is consistent with the diff (schema + generated code only).
  • The measured host/guest evidence is presented as data; nothing in the diff contradicts it. The comment nuance ("without the devices.kubevirt.io/ prefix — kvm, nvidia.com/gpu") is slightly loose for external device plugins, but it is a doc comment, not a behavioural claim, and the KubeVirt kvm case it illustrates is accurate.

Tests

TestGenReproducible (part of cue-gen) regenerates from the CUE and compares against the committed Go, so a mismatch between schema/kubevirt.cue and spec/cue_types_gen.go would fail. That is the appropriate regression guard for a schema-plus-generated-code change, and the committed tree is consistent. There is no dedicated parse/validation test for the new field, but that is a mild nice-to-have, not a defect for an additive schema definition.

Security

No secrets, no input handling, no privilege or dependency changes. Pure schema/type addition.

Comments

There are no comments to disposition.

Commits

Single focused commit; message matches the change.

No blocking findings.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 23, 2026 13:34
@github-actions

Copy link
Copy Markdown

Review — PASS

What the diff actually does

  • schema/kubevirt.cue: inside #KubevirtDevices (the spec.domain.devices shape carrying rng, disks, inputs, watchdog), a new optional field host_devices?: [...#KubevirtHostDevice] is inserted between disks and inputs. A new definition #KubevirtHostDevice with required device_name: string and optional name?: string is added between the bus-bearing definition and #KubevirtWatchdog. Both edits are purely additive; no existing field's meaning changes.
  • spec/cue_types_gen.go: Host_devices []KubevirtHostDevice (with omitempty on both tags, matching the Disks/Inputs convention for optional lists) and the KubevirtHostDevice struct (Device_name → json:"device_name" no-omitempty + yaml:"...,omitempty", i.e. the established "required" convention seen on KubevirtInput.Type; Name → omitempty both, the "optional" convention). The comments are copied verbatim from the CUE, and the type slots between KubevirtDevices and KubevirtInput, which is exactly where alphabetical emission of definitions would place it (Devices < HostDevice < Input < Watchdog). That ordering consistency is positive evidence this is generated output, not a hand-transcription.

Body honesty

  • "2 changed files … schema/kubevirt.cue +14, spec/cue_types_gen.go +16" reproduces exactly: I count 14 added lines in the CUE (6 + 8 across the two hunks) and 16 in the Go (7 + 9). ✓
  • The host_devices/#KubevirtHostDevice shape quoted in the body matches the CUE verbatim. ✓
  • "No consumer uses the field yet" is consistent with a schema-plus-generated-code diff. ✓
  • The measured host/guest console evidence is presented as data; nothing in the diff contradicts it. It is not independently reproducible from this message, but it is not contradicted either.

Tests

TestGenReproducible (run as part of cue-gen) regenerates from the CUE and compares to the committed Go, so any divergence between schema/kubevirt.cue and spec/cue_types_gen.go fails the build. That is the correct regression guard for a generated-schema change. There is no dedicated parse/validation test for host_devices, but for an additive definition whose only behaviour is "round-trips through the generator", that is a nice-to-have rather than a defect. The claimed go build ./... and go test ./spec/ -run TestGenReproducible outputs are plausible and not contradicted.

Security

No secrets, no input handling, no privilege or dependency changes. Pure type addition.

Scope and cleanliness

Single coherent change, no dead code, no legacy path, no duplication. The new definition is the single way to express a host device (honours the "one way" intent stated in the body).

Comments

One comment: @github-actions[bot] — an automated action-review PASS. This is a bot, not a designated maintainer, so per the sign-off rule it is not treated as an approval; the change must stand on its own evidence, and it does. Re-deriving its claims against the current tree, they hold: file counts match, the shape matches, the tag conventions match, and TestGenReproducible is the right guard. Its one caveat is worth recording as a non-blocking nit, below.

Non-blocking nit

The device_name doc comment (both CUE and generated Go) says the value is "the resource the device plugin advertises, without its devices.kubevirt.io/ prefix — kvm, nvidia.com/gpu, …". The prefix-stripping rule only applies to KubeVirt's own built-in resources (devices.kubevirt.io/kvm → kvm); for third-party plugins the value is the full resource name (nvidia.com/gpu is used as-is, not stripped). The example list is therefore slightly self-contradictory. This is a comment-only inaccuracy with no behavioural effect — worth tightening in a follow-up, but it does not block an otherwise correct additive schema change.

No blocking findings.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot merged commit 30b7f1f into main Oct 23, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 23, 2026
github-actions Bot pushed a commit to opencharly/plugin-kubevirt that referenced this pull request Oct 23, 2026
…stDevices (#43)

A guest gets its own /dev/kvm only through KubeVirt host-device
passthrough; a CPU feature alone is not enough. Render the authored
`devices.host_devices` entries (schema half merged: opencharly/spec#277)
onto `spec.template.spec.domain.devices.hostDevices`, with `deviceName`
required and the optional guest `name` omitted when unset so KubeVirt's
own default (deviceName) applies.

Bump the lockstep module set: spec v0.2026296.1338 (the first tag carrying
Host_devices) and sdk v0.2026296.1207 (the older sdk aliases spec types
that were removed since v0.2026287.638, so spec could not move alone).

Document the nested-virtualisation authoring in the kubevirt skill and
the candy description.

Test: TestRenderVirtualMachine_HostDevices fails without the renderer
(`hostDevices = <nil>, want 2 entries`) and passes with it; build, vet,
gofmt and the full package test suite pass on this tree.

Assisted-by: Claude Code DeepSeek deepseek-v4.1-flash:cloud (analysed on a live system)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant