61 lines
1.9 KiB
Diff
61 lines
1.9 KiB
Diff
From 5354c931f98f2d95d131bf4d490d0e5e057157fe Mon Sep 17 00:00:00 2001
|
|
Message-Id: <5354c931f98f2d95d131bf4d490d0e5e057157fe@dist-git>
|
|
From: Jiri Denemark <jdenemar@redhat.com>
|
|
Date: Fri, 21 Jun 2019 09:25:32 +0200
|
|
Subject: [PATCH] cpu_x86: Introduce virCPUx86DataCmp
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
virCPUx86DataSorter already compares two virCPUx86DataItem structs.
|
|
Let's add a tiny wrapper around it called virCPUx86DataCmp and use it
|
|
instead of open coded comparisons.
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
(cherry picked from commit 559ccd7815056af23de24b7a01e8f644d97b6a92)
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Message-Id: <9623fdd20059ec6abc7f09c5e7f1e13927c56944.1561068591.git.jdenemar@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
src/cpu/cpu_x86.c | 13 ++++++++++---
|
|
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
index 0582be63e2..5a09033d2a 100644
|
|
--- a/src/cpu/cpu_x86.c
|
|
+++ b/src/cpu/cpu_x86.c
|
|
@@ -304,6 +304,13 @@ virCPUx86DataSorter(const void *a, const void *b)
|
|
return 0;
|
|
}
|
|
|
|
+static int
|
|
+virCPUx86DataItemCmp(const virCPUx86DataItem *item1,
|
|
+ const virCPUx86DataItem *item2)
|
|
+{
|
|
+ return virCPUx86DataSorter(item1, item2);
|
|
+}
|
|
+
|
|
|
|
/* skips all zero CPUID leaves */
|
|
static virCPUx86DataItemPtr
|
|
@@ -332,9 +339,9 @@ virCPUx86DataGet(const virCPUx86Data *data,
|
|
size_t i;
|
|
|
|
for (i = 0; i < data->len; i++) {
|
|
- if (data->items[i].cpuid.eax_in == item->cpuid.eax_in &&
|
|
- data->items[i].cpuid.ecx_in == item->cpuid.ecx_in)
|
|
- return data->items + i;
|
|
+ virCPUx86DataItemPtr di = data->items + i;
|
|
+ if (virCPUx86DataItemCmp(di, item) == 0)
|
|
+ return di;
|
|
}
|
|
|
|
return NULL;
|
|
--
|
|
2.22.0
|
|
|