render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 759fe35a1acdccf68577de62752c087aea4b8268 Mon Sep 17 00:00:00 2001
Message-Id: <759fe35a1acdccf68577de62752c087aea4b8268@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:37 +0200
Subject: [PATCH] cpu_x86: Make x86cpuidMatch more general
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The function now works on virCPUx86DataItem and it's called
virCPUx86DataItemMatch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 10b80165dba31f99306f39e348e3a6335feec5ef)

https://bugzilla.redhat.com/show_bug.cgi?id=1697627

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0b829eb945561e54c1fc4d333c59af53759edf19.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/cpu/cpu_x86.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 1bb35ec4e8..11c023ac31 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -41,8 +41,6 @@ VIR_LOG_INIT("cpu.cpu_x86");
 
 #define VENDOR_STRING_LENGTH    12
 
-static const virCPUx86CPUID cpuidNull = { 0 };
-
 static const virArch archs[] = { VIR_ARCH_I686, VIR_ARCH_X86_64 };
 
 typedef struct _virCPUx86Vendor virCPUx86Vendor;
@@ -192,13 +190,13 @@ struct _virCPUx86DataIterator {
 
 
 static bool
-x86cpuidMatch(const virCPUx86CPUID *cpuid1,
-              const virCPUx86CPUID *cpuid2)
+virCPUx86DataItemMatch(const virCPUx86DataItem *item1,
+                       const virCPUx86DataItem *item2)
 {
-    return (cpuid1->eax == cpuid2->eax &&
-            cpuid1->ebx == cpuid2->ebx &&
-            cpuid1->ecx == cpuid2->ecx &&
-            cpuid1->edx == cpuid2->edx);
+    return (item1->cpuid.eax == item2->cpuid.eax &&
+            item1->cpuid.ebx == item2->cpuid.ebx &&
+            item1->cpuid.ecx == item2->cpuid.ecx &&
+            item1->cpuid.edx == item2->cpuid.edx);
 }
 
 
@@ -317,6 +315,7 @@ static virCPUx86DataItemPtr
 virCPUx86DataNext(virCPUx86DataIteratorPtr iterator)
 {
     const virCPUx86Data *data = iterator->data;
+    virCPUx86DataItem zero = { 0 };
 
     if (!data)
         return NULL;
@@ -324,7 +323,7 @@ virCPUx86DataNext(virCPUx86DataIteratorPtr iterator)
     while (++iterator->pos < data->len) {
         virCPUx86DataItemPtr item = data->items + iterator->pos;
 
-        if (!x86cpuidMatch(&item->cpuid, &cpuidNull))
+        if (!virCPUx86DataItemMatch(item, &zero))
             return item;
     }
 
@@ -1155,7 +1154,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
         virCPUx86CompareResult match = SUPERSET;
 
         if ((item2 = virCPUx86DataGet(&model2->data, item1))) {
-            if (x86cpuidMatch(&item1->cpuid, &item2->cpuid))
+            if (virCPUx86DataItemMatch(item1, item2))
                 continue;
             else if (!virCPUx86DataItemMatchMasked(item1, item2))
                 match = SUBSET;
@@ -1171,7 +1170,7 @@ x86ModelCompare(virCPUx86ModelPtr model1,
         virCPUx86CompareResult match = SUBSET;
 
         if ((item1 = virCPUx86DataGet(&model1->data, item2))) {
-            if (x86cpuidMatch(&item2->cpuid, &item1->cpuid))
+            if (virCPUx86DataItemMatch(item2, item1))
                 continue;
             else if (!virCPUx86DataItemMatchMasked(item2, item1))
                 match = SUPERSET;
-- 
2.22.0