Skip to content

Conversation

loktev-d
Copy link
Contributor

@loktev-d loktev-d commented Sep 9, 2025

Description

This PR changes the base CPU model for Discovery and Features CPU types from kvm64 to qemu64 to improve compatibility with AMD processors and because kvm64 is not recommended by qemu docs

Additionally, the svm CPU feature (AMD virtualization extension) is now marked as optional for Intel CPU compatibility (svm is required by default in qemu64).

Nested virtualization and migrations from kvm64 to qemu64 were tested on both Intel and AMD proccessors.

Why do we need it, and what problem does it solve?

We've encountered an issue where VMs with Nehalem VMClass fail to schedule in nested virtualization environments on AMD hosts. The problem occurs because:

  1. The lahf_lm feature is required by Discovery VMClass
  2. In nested virtualization on AMD processors, this feature is not exposed due to QEMU bug specific to kvm64 and AMD CPU
  3. This causes the VMClass to remain in Pending state with no suitable nodes available

What is the expected result?

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vmclass
type: fix
summary: Use qemu64 CPU model for Discovery and Features types to fix nested virtualization on AMD hosts

Summary by Sourcery

Use qemu64 as the generic CPU model for Discovery and Features VMClasses and mark svm as an optional feature to improve AMD compatibility and nested virtualization support.

Bug Fixes:

  • Switch the base CPU model for Discovery and Features types from kvm64 to qemu64 to resolve nested virtualization failures on AMD hosts
  • Make the svm CPU feature optional when deriving features to maintain Intel compatibility

Build:

  • Bump 3p-kubevirt component version to v1.3.1-v12n.14

Documentation:

  • Update internal CPU model discovery documentation to reflect qemu64 usage

Signed-off-by: Daniil Loktev <[email protected]>
loktev-d and others added 12 commits September 10, 2025 10:43
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
@loktev-d loktev-d added this to the v1.1.0 milestone Sep 18, 2025
@loktev-d loktev-d added validation/skip/doc_changes Skip doc changes validation e2e/run Run e2e test on cluster of PR author labels Sep 19, 2025
@deckhouse-BOaTswain
Copy link
Contributor

deckhouse-BOaTswain commented Sep 19, 2025

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: success.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Sep 19, 2025
loktev-d and others added 3 commits September 29, 2025 18:05
@loktev-d loktev-d marked this pull request as ready for review September 29, 2025 15:13
Copy link

sourcery-ai bot commented Sep 29, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR shifts the base CPU model from kvm64 to qemu64 for Discovery and Features VM classes to resolve nested virtualization issues on AMD hosts and adds optional handling for the AMD-specific svm feature, with accompanying documentation updates and a component version bump.

Entity relationship diagram for updated CPU model and features in VMClass

erDiagram
    VIRTUAL_MACHINE_CLASS {
        string Spec_CPU_Model
        string Spec_CPU_Type
        string[] Status_CpuFeatures_Enabled
    }
    CPU_FEATURE {
        string Name
        string Policy
    }
    VIRTUAL_MACHINE_CLASS ||--o{ CPU_FEATURE : has
    VIRTUAL_MACHINE_CLASS {
        string CPU_Model = "qemu64"
    }
    CPU_FEATURE {
        string Name = "svm"
        string Policy = "optional"
    }
Loading

Class diagram for updated CPU model and feature handling in KVVM

classDiagram
    class KVVM {
        +SetCPUModel(class: VirtualMachineClass) error
    }
    class VirtualMachineClass {
        Spec: CPU
        Status: CpuFeatures
    }
    class CPU {
        Model: string
        Type: string
    }
    class CpuFeatures {
        Enabled: []string
    }
    class CPUFeature {
        Name: string
        Policy: string
    }
    KVVM --> VirtualMachineClass
    VirtualMachineClass --> CPU
    VirtualMachineClass --> CpuFeatures
    KVVM ..> CPUFeature : uses
    CPUFeature <|-- "svm (optional)"
    CPUFeature <|-- "invtsc (optional)"
    CPUFeature <|-- "other features (require)"
Loading

File-Level Changes

Change Details Files
Use qemu64 as the default CPU model
  • Change GenericCPUModel constant from "kvm64" to "qemu64"
  • Ensure Discovery/Features types pick up the updated GenericCPUModel
images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go
Mark "svm" CPU feature as optional
  • Add hasSvm flag when iterating enabled features
  • Allocate slice with extra capacity and append optional "svm" if missing
  • Set policy to "optional" for the added svm feature
images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go
Update documentation to reflect qemu64 model usage
  • Replace references to kvm64 with qemu64 in cpu_model_type_discovery.md
  • Adjust patch instructions for cpu model nodeSelector accordingly
docs/internal/cpu_model_type_discovery.md
Bump kubevirt component version
  • Update 3p-kubevirt from v1.3.1-v12n.13 to v1.3.1-v12n.14
build/components/versions.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@loktev-d loktev-d merged commit 7d61da6 into main Sep 29, 2025
29 of 30 checks passed
@loktev-d loktev-d deleted the fix/vmclass/qemu64-for-nested-amd branch September 29, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation/skip/doc_changes Skip doc changes validation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants