render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Pablo Greco 40546a
From bc74a9da7d6b5c747655468022fdcdd9f9f5f25d Mon Sep 17 00:00:00 2001
Pablo Greco 40546a
Message-Id: <bc74a9da7d6b5c747655468022fdcdd9f9f5f25d@dist-git>
Pablo Greco 40546a
From: Jiri Denemark <jdenemar@redhat.com>
Pablo Greco 40546a
Date: Fri, 7 Feb 2020 10:41:41 +0100
Pablo Greco 40546a
Subject: [PATCH] qemu: Fix hyperv features with QEMU 4.1
Pablo Greco 40546a
MIME-Version: 1.0
Pablo Greco 40546a
Content-Type: text/plain; charset=UTF-8
Pablo Greco 40546a
Content-Transfer-Encoding: 8bit
Pablo Greco 40546a
Pablo Greco 40546a
Originally the names of the hyperv CPU features were only used
Pablo Greco 40546a
internally for looking up their CPUID bits. So we used "__kvm_hv_"
Pablo Greco 40546a
prefix for them to make sure the names do not collide with normal CPU
Pablo Greco 40546a
features stored in our CPU map.
Pablo Greco 40546a
Pablo Greco 40546a
But with QEMU 4.1 we check which features were enabled or disabled by a
Pablo Greco 40546a
freshly started QEMU process using their names rather than their CPUID
Pablo Greco 40546a
bits (mostly because of MSR features). Thus we need to change our made
Pablo Greco 40546a
up internal names into the actual names used by QEMU. Most of the names
Pablo Greco 40546a
are only used with QEMU 4.1 and newer and the reset was introduced with
Pablo Greco 40546a
QEMU recently enough to already support spelling with "-". Thus we don't
Pablo Greco 40546a
need to define them as "hv_*" with a translation to "hv-*" for new QEMU.
Pablo Greco 40546a
Pablo Greco 40546a
Without this patch libvirt would mistakenly report all hyperv features
Pablo Greco 40546a
as unavailable and refuse to start any domain using them with QEMU 4.1.
Pablo Greco 40546a
Pablo Greco 40546a
Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Pablo Greco 40546a
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Pablo Greco 40546a
Tested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Pablo Greco 40546a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Pablo Greco 40546a
(cherry picked from commit 0ccdd476bb329f1486438b896255e5c44a91ff4a)
Pablo Greco 40546a
Pablo Greco 40546a
https://bugzilla.redhat.com/show_bug.cgi?id=1794868
Pablo Greco 40546a
Pablo Greco 40546a
Conflicts:
Pablo Greco 40546a
	src/cpu/cpu_x86_data.h
Pablo Greco 40546a
            - a few extra features were added upstream between 4.5.0 and
Pablo Greco 40546a
              5.5.0
Pablo Greco 40546a
            - downstream lacks #pragma once and thus all defines have to
Pablo Greco 40546a
              be indented
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Pablo Greco 40546a
Message-Id: <8e882b79ff88eccdb68ede1c5afd4550fcd554b6.1581064395.git.jdenemar@redhat.com>
Pablo Greco 40546a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Pablo Greco 40546a
---
Pablo Greco 40546a
 src/cpu/cpu_x86_data.h  | 24 ++++++++++++------------
Pablo Greco 40546a
 src/qemu/qemu_process.c |  2 +-
Pablo Greco 40546a
 2 files changed, 13 insertions(+), 13 deletions(-)
Pablo Greco 40546a
Pablo Greco 40546a
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
Pablo Greco 40546a
index 454345b688..77797f633c 100644
Pablo Greco 40546a
--- a/src/cpu/cpu_x86_data.h
Pablo Greco 40546a
+++ b/src/cpu/cpu_x86_data.h
Pablo Greco 40546a
@@ -62,19 +62,19 @@ struct _virCPUx86MSR {
Pablo Greco 40546a
 /*
Pablo Greco 40546a
  * The following HyperV feature names suffixes must exactly match corresponding
Pablo Greco 40546a
  * ones defined for virDomainHyperv in domain_conf.c.
Pablo Greco 40546a
- * E.g "__kvm_runtime" -> "runtime", "__kvm_hv_spinlocks" -> "spinlocks" etc.
Pablo Greco 40546a
+ * E.g "hv-runtime" -> "runtime", "hv-spinlocks" -> "spinlocks" etc.
Pablo Greco 40546a
 */
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_RUNTIME   "__kvm_hv_runtime"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_SYNIC     "__kvm_hv_synic"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_STIMER    "__kvm_hv_stimer"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_RELAXED   "__kvm_hv_relaxed"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_SPINLOCKS  "__kvm_hv_spinlocks"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_VAPIC     "__kvm_hv_vapic"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_VPINDEX   "__kvm_hv_vpindex"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_RESET     "__kvm_hv_reset"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_FREQUENCIES "__kvm_hv_frequencies"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "__kvm_hv_reenlightenment"
Pablo Greco 40546a
-# define VIR_CPU_x86_KVM_HV_TLBFLUSH  "__kvm_hv_tlbflush"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_RUNTIME   "hv-runtime"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_SYNIC     "hv-synic"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_STIMER    "hv-stimer"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_RELAXED   "hv-relaxed"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_SPINLOCKS "hv-spinlocks"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_VAPIC     "hv-vapic"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_VPINDEX   "hv-vpindex"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_RESET     "hv-reset"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_FREQUENCIES "hv-frequencies"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "hv-reenlightenment"
Pablo Greco 40546a
+# define VIR_CPU_x86_KVM_HV_TLBFLUSH  "hv-tlbflush"
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
 # define VIR_CPU_X86_DATA_INIT { 0 }
Pablo Greco 40546a
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
Pablo Greco 40546a
index 0700b054f3..312ce69ba5 100644
Pablo Greco 40546a
--- a/src/qemu/qemu_process.c
Pablo Greco 40546a
+++ b/src/qemu/qemu_process.c
Pablo Greco 40546a
@@ -3923,7 +3923,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
Pablo Greco 40546a
         if (def->hyperv_features[i] != VIR_TRISTATE_SWITCH_ON)
Pablo Greco 40546a
             continue;
Pablo Greco 40546a
 
Pablo Greco 40546a
-        if (virAsprintf(&cpuFeature, "__kvm_hv_%s",
Pablo Greco 40546a
+        if (virAsprintf(&cpuFeature, "hv-%s",
Pablo Greco 40546a
                         virDomainHypervTypeToString(i)) < 0)
Pablo Greco 40546a
             return -1;
Pablo Greco 40546a
 
Pablo Greco 40546a
-- 
Pablo Greco 40546a
2.25.0
Pablo Greco 40546a