]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: report nested virtualization setting in domain XML
authorJonathon Jongsma <jjongsma@redhat.com>
Thu, 26 Mar 2026 19:01:24 +0000 (14:01 -0500)
committerJonathon Jongsma <jjongsma@redhat.com>
Wed, 3 Jun 2026 14:52:38 +0000 (09:52 -0500)
When Hyper-V is configured to expose virtualization extensions to a
guest, report this in the domain XML by adding the vendor-appropriate
CPU feature flag:

- Intel hosts: <feature policy='require' name='vmx'/>
- AMD hosts: <feature policy='require' name='svm'/>

This requires adding ExposeVirtualizationExtensions and several other
fields introduced in Windows 10 to the Msvm_ProcessorSettingData WMI
class definition.

Resolves: https://redhat.atlassian.net/browse/RHEL-159129

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/hyperv/hyperv_driver.c
src/hyperv/hyperv_wmi_generator.input

index 7cd83e7565813c295d7420318fa8872873fc6077..68b2e7fa67d903d3eaa64311caafb8de524a3772 100644 (file)
@@ -44,6 +44,7 @@
 #include "snapshot_conf.h"
 #include "virfdstream.h"
 #include "virfile.h"
+#include "cpu_conf.h"
 
 #define VIR_FROM_THIS VIR_FROM_HYPERV
 
@@ -2766,6 +2767,28 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     if (virDomainDefSetVcpus(def, processorSettingData->data->VirtualQuantity) < 0)
         return NULL;
 
+    if (processorSettingData->data->ExposeVirtualizationExtensions) {
+        g_autoptr(Win32_Processor) processors = NULL;
+        const char *cpuFeature = NULL;
+
+        if (hypervGetProcessorList(priv, NULL, &processors) < 0)
+            return NULL;
+
+        if (STREQ_NULLABLE(processors->data->Manufacturer, "GenuineIntel"))
+            cpuFeature = "vmx";
+        else if (STREQ_NULLABLE(processors->data->Manufacturer, "AuthenticAMD"))
+            cpuFeature = "svm";
+
+        if (cpuFeature) {
+            def->cpu = virCPUDefNew();
+            def->cpu->mode = VIR_CPU_MODE_HOST_PASSTHROUGH;
+            def->cpu->type = VIR_CPU_TYPE_GUEST;
+
+            if (virCPUDefAddFeature(def->cpu, cpuFeature, VIR_CPU_FEATURE_REQUIRE) < 0)
+                return NULL;
+        }
+    }
+
     def->os.type = VIR_DOMAIN_OSTYPE_HVM;
 
     /* Generation 2 VMs use UEFI firmware */
index fccbe9009f00f30d133e3aec97f91dd34ef250d0..94685e4428e02a4c84894159be1cbef9091fa47f 100644 (file)
@@ -174,9 +174,14 @@ class Msvm_ProcessorSettingData
     string  AddressOnParent
     string  VirtualQuantityUnits
     boolean LimitCPUID
+    uint64  HwThreadsPerCore
     boolean LimitProcessorFeatures
     uint64  MaxProcessorsPerNumaNode
     uint64  MaxNumaNodesPerSocket
+    boolean EnableHostResourceProtection
+    string  CpuGroupId
+    boolean HideHypervisorPresent
+    boolean ExposeVirtualizationExtensions
 end