render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From 760e248164be819bebc03893ace58e0ddae7e440 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <760e248164be819bebc03893ace58e0ddae7e440@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:58:52 +0200
a41c76
Subject: [PATCH] cpu_x86: Prepare virCPUx86UpdateLive for easier extension
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Adding more checks into the existing if statements would turn them into
a41c76
an unreadable mess.
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 8dc791b5d3b20552cc0b8d6c04e34dd0f3ebe2ff)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1839999
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <169ed0334144715b52575ca3f7e67ce3170ba91a.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 12 +++++++++---
a41c76
 1 file changed, 9 insertions(+), 3 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index 9b7981d574..9e686a86d2 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -3036,9 +3036,15 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
a41c76
 
a41c76
     for (i = 0; i < map->nfeatures; i++) {
a41c76
         virCPUx86FeaturePtr feature = map->features[i];
a41c76
+        virCPUFeaturePolicy expected = VIR_CPU_FEATURE_LAST;
a41c76
 
a41c76
-        if (x86DataIsSubset(&enabled, &feature->data) &&
a41c76
-            !x86DataIsSubset(&model->data, &feature->data)) {
a41c76
+        if (x86DataIsSubset(&model->data, &feature->data))
a41c76
+            expected = VIR_CPU_FEATURE_REQUIRE;
a41c76
+        else
a41c76
+            expected = VIR_CPU_FEATURE_DISABLE;
a41c76
+
a41c76
+        if (expected == VIR_CPU_FEATURE_DISABLE &&
a41c76
+            x86DataIsSubset(&enabled, &feature->data)) {
a41c76
             VIR_DEBUG("Feature '%s' enabled by the hypervisor", feature->name);
a41c76
             if (cpu->check == VIR_CPU_CHECK_FULL)
a41c76
                 virBufferAsprintf(&bufAdded, "%s,", feature->name);
a41c76
@@ -3048,7 +3054,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
a41c76
         }
a41c76
 
a41c76
         if (x86DataIsSubset(&disabled, &feature->data) ||
a41c76
-            (x86DataIsSubset(&model->data, &feature->data) &&
a41c76
+            (expected == VIR_CPU_FEATURE_REQUIRE &&
a41c76
              !x86DataIsSubset(&enabled, &feature->data))) {
a41c76
             VIR_DEBUG("Feature '%s' disabled by the hypervisor", feature->name);
a41c76
             if (cpu->check == VIR_CPU_CHECK_FULL)
a41c76
-- 
a41c76
2.26.2
a41c76