Skip to content

kvm: only emit known video and CPU model names in the domain XML - #14422

Open
wido wants to merge 1 commit into
apache:mainfrom
wido:kvm-validate-video-model
Open

wido wants to merge 1 commit into
apache:mainfrom
wido:kvm-validate-video-model

Conversation

@wido

@wido wido commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

The KVM agent copies the video.hardware and guest.cpu.model VM details into the domain XML as-is. Every other detail that ends up in the XML (disk controller, NIC model, TPM) is mapped through an enum first, these two were the exception.

VideoDef now has a VideoModel enum with the model types libvirt accepts (vga, cirrus, vmvga, xen, vbox, qxl, virtio, gop, bochs, ramfb, none), matched case-insensitively. CpuModeDef only accepts plain QEMU model names such as Nehalem, EPYC-Rome-v2 or x86-64-v2. An unknown value is logged and ignored, the agent property or the x86 default is used instead. libvirt rejects unknown model types anyway, so existing working setups are unaffected.

Types of changes

  • Enhancement (improves an existing feature and functionality)

Feature/Enhancement Scale or Bug Severity

  • Minor

How Has This Been Tested?

Unit tests added to LibvirtVMDefTest and LibvirtComputingResourceTest, covering case-insensitive matching, an unknown agent property, an unknown detail and the fallback to the agent default. Both classes pass.

VideoDef now maps the video.hardware detail through an enum of the model types libvirt accepts, and CpuModeDef only accepts plain QEMU model names for guest.cpu.model. Unknown values are ignored with a warning and the agent default is used instead, like the agent already does for disk controllers, NIC models and the TPM.
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.85106% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.39%. Comparing base (d3f0700) to head (daa60c8).

Files with missing lines Patch % Lines
...ervisor/kvm/resource/LibvirtComputingResource.java 72.22% 4 Missing and 1 partial ⚠️
...om/cloud/hypervisor/kvm/resource/LibvirtVMDef.java 86.20% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14422      +/-   ##
============================================
- Coverage     20.39%   20.39%   -0.01%     
+ Complexity    21283    21281       -2     
============================================
  Files          6481     6481              
  Lines        588040   588079      +39     
  Branches      72021    72029       +8     
============================================
  Hits         119957   119957              
- Misses       455052   455097      +45     
+ Partials      13031    13025       -6     
Flag Coverage Δ
uitests 3.70% <ø> (ø)
unittests 21.69% <80.85%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant