|
|
c480ed |
From 4111804c77930ebcda4fa5fae751074f75da4f1c Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <4111804c77930ebcda4fa5fae751074f75da4f1c@dist-git>
|
|
|
c480ed |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Date: Fri, 21 Jun 2019 09:24:54 +0200
|
|
|
c480ed |
Subject: [PATCH] cpu_x86: Separate ancestor model parsing from x86ModelParse
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
The code is separated into a new x86ModelParseAncestor function.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 2e1e2b910c6a9d31f2fb6d388ed72dc8f561b845)
|
|
|
c480ed |
|
|
|
c480ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Message-Id: <0e941dce0077eb7d7a31dffa60f7d647d66b95e6.1561068591.git.jdenemar@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/cpu/cpu_x86.c | 65 +++++++++++++++++++++++++++--------------------
|
|
|
c480ed |
1 file changed, 38 insertions(+), 27 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
c480ed |
index ce48ca6867..64788d60b3 100644
|
|
|
c480ed |
--- a/src/cpu/cpu_x86.c
|
|
|
c480ed |
+++ b/src/cpu/cpu_x86.c
|
|
|
c480ed |
@@ -1148,6 +1148,42 @@ x86ModelCompare(virCPUx86ModelPtr model1,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+x86ModelParseAncestor(virCPUx86ModelPtr model,
|
|
|
c480ed |
+ xmlXPathContextPtr ctxt,
|
|
|
c480ed |
+ virCPUx86MapPtr map)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) name = NULL;
|
|
|
c480ed |
+ virCPUx86ModelPtr ancestor;
|
|
|
c480ed |
+ int rc;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if ((rc = virXPathBoolean("boolean(./model)", ctxt)) <= 0)
|
|
|
c480ed |
+ return rc;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ name = virXPathString("string(./model/@name)", ctxt);
|
|
|
c480ed |
+ if (!name) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Missing ancestor's name in CPU model %s"),
|
|
|
c480ed |
+ model->name);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!(ancestor = x86ModelFind(map, name))) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Ancestor model %s not found for CPU model %s"),
|
|
|
c480ed |
+ name, model->name);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ model->vendor = ancestor->vendor;
|
|
|
c480ed |
+ model->signature = ancestor->signature;
|
|
|
c480ed |
+ if (x86DataCopy(&model->data, &ancestor->data) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
static int
|
|
|
c480ed |
x86ModelParse(xmlXPathContextPtr ctxt,
|
|
|
c480ed |
const char *name,
|
|
|
c480ed |
@@ -1167,33 +1203,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|
|
c480ed |
if (VIR_STRDUP(model->name, name) < 0)
|
|
|
c480ed |
goto cleanup;
|
|
|
c480ed |
|
|
|
c480ed |
- if (virXPathNode("./model", ctxt)) {
|
|
|
c480ed |
- virCPUx86ModelPtr ancestor;
|
|
|
c480ed |
- char *anname;
|
|
|
c480ed |
-
|
|
|
c480ed |
- anname = virXPathString("string(./model/@name)", ctxt);
|
|
|
c480ed |
- if (!anname) {
|
|
|
c480ed |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
- _("Missing ancestor's name in CPU model %s"),
|
|
|
c480ed |
- model->name);
|
|
|
c480ed |
- goto cleanup;
|
|
|
c480ed |
- }
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (!(ancestor = x86ModelFind(map, anname))) {
|
|
|
c480ed |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
- _("Ancestor model %s not found for CPU model %s"),
|
|
|
c480ed |
- anname, model->name);
|
|
|
c480ed |
- VIR_FREE(anname);
|
|
|
c480ed |
- goto cleanup;
|
|
|
c480ed |
- }
|
|
|
c480ed |
-
|
|
|
c480ed |
- VIR_FREE(anname);
|
|
|
c480ed |
-
|
|
|
c480ed |
- model->vendor = ancestor->vendor;
|
|
|
c480ed |
- model->signature = ancestor->signature;
|
|
|
c480ed |
- if (x86DataCopy(&model->data, &ancestor->data) < 0)
|
|
|
c480ed |
- goto cleanup;
|
|
|
c480ed |
- }
|
|
|
c480ed |
+ if (x86ModelParseAncestor(model, ctxt, map) < 0)
|
|
|
c480ed |
+ goto cleanup;
|
|
|
c480ed |
|
|
|
c480ed |
if (virXPathBoolean("boolean(./signature)", ctxt)) {
|
|
|
c480ed |
unsigned int sigFamily = 0;
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|