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