|
Pablo Greco |
40546a |
From 14c5258d4227930fdadcd0bc9de3cae547b56b70 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <14c5258d4227930fdadcd0bc9de3cae547b56b70@dist-git>
|
|
Pablo Greco |
40546a |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Fri, 21 Jun 2019 09:26:07 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] cpu_x86: Turn virCPUx86DataIteratorInit into a function
|
|
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 |
Until now, this was a macro usable for direct initialization when a
|
|
Pablo Greco |
40546a |
variable is defined. Turning the macro into a function makes it more
|
|
Pablo Greco |
40546a |
general.
|
|
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 b8e086a570b14b1f83fc07e25df6da758abe7706)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Conflicts:
|
|
Pablo Greco |
40546a |
src/cpu/cpu_x86.c
|
|
Pablo Greco |
40546a |
- commit c9ed87a6103fd4f09e0714f3a2b94c4c975477cd was not
|
|
Pablo Greco |
40546a |
backported
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <eb52120d5047b6581f645dc334a327530261f5ed.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 | 35 ++++++++++++++++++++++++-----------
|
|
Pablo Greco |
40546a |
1 file changed, 24 insertions(+), 11 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 ead962ae06..75527fd28f 100644
|
|
Pablo Greco |
40546a |
--- a/src/cpu/cpu_x86.c
|
|
Pablo Greco |
40546a |
+++ b/src/cpu/cpu_x86.c
|
|
Pablo Greco |
40546a |
@@ -187,8 +187,13 @@ struct _virCPUx86DataIterator {
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
-#define virCPUx86DataIteratorInit(data) \
|
|
Pablo Greco |
40546a |
- { data, -1 }
|
|
Pablo Greco |
40546a |
+static void
|
|
Pablo Greco |
40546a |
+virCPUx86DataIteratorInit(virCPUx86DataIteratorPtr iterator,
|
|
Pablo Greco |
40546a |
+ const virCPUx86Data *data)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter = { data, -1 };
|
|
Pablo Greco |
40546a |
+ *iterator = iter;
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
static bool
|
|
Pablo Greco |
40546a |
@@ -538,9 +543,10 @@ static int
|
|
Pablo Greco |
40546a |
x86DataAdd(virCPUx86Data *data1,
|
|
Pablo Greco |
40546a |
const virCPUx86Data *data2)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data2);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter, data2);
|
|
Pablo Greco |
40546a |
while ((item = virCPUx86DataNext(&iter))) {
|
|
Pablo Greco |
40546a |
if (virCPUx86DataAddItem(data1, item) < 0)
|
|
Pablo Greco |
40546a |
return -1;
|
|
Pablo Greco |
40546a |
@@ -554,10 +560,11 @@ static void
|
|
Pablo Greco |
40546a |
x86DataSubtract(virCPUx86Data *data1,
|
|
Pablo Greco |
40546a |
const virCPUx86Data *data2)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item1;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item2;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter, data1);
|
|
Pablo Greco |
40546a |
while ((item1 = virCPUx86DataNext(&iter))) {
|
|
Pablo Greco |
40546a |
item2 = virCPUx86DataGet(data2, item1);
|
|
Pablo Greco |
40546a |
virCPUx86DataItemClearBits(item1, item2);
|
|
Pablo Greco |
40546a |
@@ -569,10 +576,11 @@ static void
|
|
Pablo Greco |
40546a |
x86DataIntersect(virCPUx86Data *data1,
|
|
Pablo Greco |
40546a |
const virCPUx86Data *data2)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item1;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item2;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter, data1);
|
|
Pablo Greco |
40546a |
while ((item1 = virCPUx86DataNext(&iter))) {
|
|
Pablo Greco |
40546a |
item2 = virCPUx86DataGet(data2, item1);
|
|
Pablo Greco |
40546a |
if (item2)
|
|
Pablo Greco |
40546a |
@@ -586,8 +594,9 @@ x86DataIntersect(virCPUx86Data *data1,
|
|
Pablo Greco |
40546a |
static bool
|
|
Pablo Greco |
40546a |
x86DataIsEmpty(virCPUx86Data *data)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter, data);
|
|
Pablo Greco |
40546a |
return !virCPUx86DataNext(&iter);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -596,11 +605,11 @@ static bool
|
|
Pablo Greco |
40546a |
x86DataIsSubset(const virCPUx86Data *data,
|
|
Pablo Greco |
40546a |
const virCPUx86Data *subset)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit((virCPUx86Data *)subset);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter;
|
|
Pablo Greco |
40546a |
const virCPUx86DataItem *item;
|
|
Pablo Greco |
40546a |
const virCPUx86DataItem *itemSubset;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter, subset);
|
|
Pablo Greco |
40546a |
while ((itemSubset = virCPUx86DataNext(&iter))) {
|
|
Pablo Greco |
40546a |
if (!(item = virCPUx86DataGet(data, itemSubset)) ||
|
|
Pablo Greco |
40546a |
!virCPUx86DataItemMatchMasked(item, itemSubset))
|
|
Pablo Greco |
40546a |
@@ -1313,11 +1322,13 @@ x86ModelCompare(virCPUx86ModelPtr model1,
|
|
Pablo Greco |
40546a |
virCPUx86ModelPtr model2)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
virCPUx86CompareResult result = EQUAL;
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter1 = virCPUx86DataIteratorInit(&model1->data);
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter2 = virCPUx86DataIteratorInit(&model2->data);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter1;
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter2;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item1;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item2;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter1, &model1->data);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter2, &model2->data);
|
|
Pablo Greco |
40546a |
while ((item1 = virCPUx86DataNext(&iter1))) {
|
|
Pablo Greco |
40546a |
virCPUx86CompareResult match = SUPERSET;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1623,10 +1634,12 @@ virCPUx86GetMap(void)
|
|
Pablo Greco |
40546a |
static char *
|
|
Pablo Greco |
40546a |
virCPUx86DataFormat(const virCPUData *data)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- virCPUx86DataIterator iter = virCPUx86DataIteratorInit(&data->data.x86);
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIterator iter;
|
|
Pablo Greco |
40546a |
virCPUx86DataItemPtr item;
|
|
Pablo Greco |
40546a |
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ virCPUx86DataIteratorInit(&iter, &data->data.x86);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
virBufferAddLit(&buf, "<cpudata arch='x86'>\n");
|
|
Pablo Greco |
40546a |
while ((item = virCPUx86DataNext(&iter))) {
|
|
Pablo Greco |
40546a |
virCPUx86CPUIDPtr cpuid;
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|