From: Jonathon Jongsma Date: Thu, 26 Mar 2026 19:01:24 +0000 (-0500) Subject: hyperv: report nested virtualization setting in domain XML X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=0f014efea391c934dd3a3f8db97b97eeb2c3eac8;p=thirdparty%2Flibvirt.git hyperv: report nested virtualization setting in domain XML 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: - AMD hosts: 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 Reviewed-by: Michal Privoznik --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 7cd83e7565..68b2e7fa67 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -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 */ diff --git a/src/hyperv/hyperv_wmi_generator.input b/src/hyperv/hyperv_wmi_generator.input index fccbe9009f..94685e4428 100644 --- a/src/hyperv/hyperv_wmi_generator.input +++ b/src/hyperv/hyperv_wmi_generator.input @@ -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