[libvirt PATCH 2/3] cpu_x86: Prepare virCPUx86UpdateLive for easier extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adding more checks into the existing if statements would turn them into
an unreadable mess.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_x86.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index dca9ed2979..5a6b7bb1d8 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3036,9 +3036,15 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
 
     for (i = 0; i < map->nfeatures; i++) {
         virCPUx86FeaturePtr feature = map->features[i];
+        virCPUFeaturePolicy expected = VIR_CPU_FEATURE_LAST;
 
-        if (x86DataIsSubset(&enabled, &feature->data) &&
-            !x86DataIsSubset(&model->data, &feature->data)) {
+        if (x86DataIsSubset(&model->data, &feature->data))
+            expected = VIR_CPU_FEATURE_REQUIRE;
+        else
+            expected = VIR_CPU_FEATURE_DISABLE;
+
+        if (expected == VIR_CPU_FEATURE_DISABLE &&
+            x86DataIsSubset(&enabled, &feature->data)) {
             VIR_DEBUG("Feature '%s' enabled by the hypervisor", feature->name);
             if (cpu->check == VIR_CPU_CHECK_FULL)
                 virBufferAsprintf(&bufAdded, "%s,", feature->name);
@@ -3048,7 +3054,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
         }
 
         if (x86DataIsSubset(&disabled, &feature->data) ||
-            (x86DataIsSubset(&model->data, &feature->data) &&
+            (expected == VIR_CPU_FEATURE_REQUIRE &&
              !x86DataIsSubset(&enabled, &feature->data))) {
             VIR_DEBUG("Feature '%s' disabled by the hypervisor", feature->name);
             if (cpu->check == VIR_CPU_CHECK_FULL)
-- 
2.25.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux