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