|
|
bba56f |
From 054fbe2bdd426eb9f3346513ac7d39f0b843a04e Mon Sep 17 00:00:00 2001
|
|
|
bba56f |
Message-Id: <054fbe2bdd426eb9f3346513ac7d39f0b843a04e@dist-git>
|
|
|
bba56f |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
bba56f |
Date: Wed, 20 Mar 2019 14:55:20 +0100
|
|
|
bba56f |
Subject: [PATCH] cpu_x86: Separate signature parsing from x86ModelParse
|
|
|
bba56f |
MIME-Version: 1.0
|
|
|
bba56f |
Content-Type: text/plain; charset=UTF-8
|
|
|
bba56f |
Content-Transfer-Encoding: 8bit
|
|
|
bba56f |
|
|
|
bba56f |
The code is separated into a new x86ModelParseSignature function.
|
|
|
bba56f |
|
|
|
bba56f |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
bba56f |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
bba56f |
(cherry picked from commit fe78d2fda9f2dd67eb9daa98e48fbffa468d271e)
|
|
|
bba56f |
|
|
|
bba56f |
https://bugzilla.redhat.com/show_bug.cgi?id=1558558
|
|
|
bba56f |
https://bugzilla.redhat.com/show_bug.cgi?id=1687515
|
|
|
bba56f |
|
|
|
bba56f |
Conflicts:
|
|
|
bba56f |
src/cpu/cpu_x86.c
|
|
|
bba56f |
- other patches separating parts of x86ModelParse into
|
|
|
bba56f |
smaller functions were not backported due to conflicts
|
|
|
bba56f |
with older refactoring which is missing in RHEL-7
|
|
|
bba56f |
- commit 118fcdd480ad38a3e8477f466f6a876dce7e9fa6 changing
|
|
|
bba56f |
goto labels from "cleanup" to "error" was not backported
|
|
|
bba56f |
because the goto statement is removed in this patch anyway
|
|
|
bba56f |
|
|
|
bba56f |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
bba56f |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
bba56f |
---
|
|
|
bba56f |
src/cpu/cpu_x86.c | 58 ++++++++++++++++++++++++++++-------------------
|
|
|
bba56f |
1 file changed, 35 insertions(+), 23 deletions(-)
|
|
|
bba56f |
|
|
|
bba56f |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
bba56f |
index 809da94117..668e8aa3f0 100644
|
|
|
bba56f |
--- a/src/cpu/cpu_x86.c
|
|
|
bba56f |
+++ b/src/cpu/cpu_x86.c
|
|
|
bba56f |
@@ -1184,6 +1184,39 @@ x86ModelCompare(virCPUx86ModelPtr model1,
|
|
|
bba56f |
}
|
|
|
bba56f |
|
|
|
bba56f |
|
|
|
bba56f |
+static int
|
|
|
bba56f |
+x86ModelParseSignature(virCPUx86ModelPtr model,
|
|
|
bba56f |
+ xmlXPathContextPtr ctxt)
|
|
|
bba56f |
+{
|
|
|
bba56f |
+
|
|
|
bba56f |
+ if (virXPathBoolean("boolean(./signature)", ctxt)) {
|
|
|
bba56f |
+ unsigned int sigFamily = 0;
|
|
|
bba56f |
+ unsigned int sigModel = 0;
|
|
|
bba56f |
+ int rc;
|
|
|
bba56f |
+
|
|
|
bba56f |
+ rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
|
|
|
bba56f |
+ if (rc < 0 || sigFamily == 0) {
|
|
|
bba56f |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
bba56f |
+ _("Invalid CPU signature family in model %s"),
|
|
|
bba56f |
+ model->name);
|
|
|
bba56f |
+ return -1;
|
|
|
bba56f |
+ }
|
|
|
bba56f |
+
|
|
|
bba56f |
+ rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
|
|
|
bba56f |
+ if (rc < 0 || sigModel == 0) {
|
|
|
bba56f |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
bba56f |
+ _("Invalid CPU signature model in model %s"),
|
|
|
bba56f |
+ model->name);
|
|
|
bba56f |
+ return -1;
|
|
|
bba56f |
+ }
|
|
|
bba56f |
+
|
|
|
bba56f |
+ model->signature = x86MakeSignature(sigFamily, sigModel, 0);
|
|
|
bba56f |
+ }
|
|
|
bba56f |
+
|
|
|
bba56f |
+ return 0;
|
|
|
bba56f |
+}
|
|
|
bba56f |
+
|
|
|
bba56f |
+
|
|
|
bba56f |
static virCPUx86ModelPtr
|
|
|
bba56f |
x86ModelParse(xmlXPathContextPtr ctxt,
|
|
|
bba56f |
virCPUx86MapPtr map)
|
|
|
bba56f |
@@ -1232,29 +1265,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|
|
bba56f |
goto error;
|
|
|
bba56f |
}
|
|
|
bba56f |
|
|
|
bba56f |
- if (virXPathBoolean("boolean(./signature)", ctxt)) {
|
|
|
bba56f |
- unsigned int sigFamily = 0;
|
|
|
bba56f |
- unsigned int sigModel = 0;
|
|
|
bba56f |
- int rc;
|
|
|
bba56f |
-
|
|
|
bba56f |
- rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
|
|
|
bba56f |
- if (rc < 0 || sigFamily == 0) {
|
|
|
bba56f |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
bba56f |
- _("Invalid CPU signature family in model %s"),
|
|
|
bba56f |
- model->name);
|
|
|
bba56f |
- goto cleanup;
|
|
|
bba56f |
- }
|
|
|
bba56f |
-
|
|
|
bba56f |
- rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
|
|
|
bba56f |
- if (rc < 0 || sigModel == 0) {
|
|
|
bba56f |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
bba56f |
- _("Invalid CPU signature model in model %s"),
|
|
|
bba56f |
- model->name);
|
|
|
bba56f |
- goto cleanup;
|
|
|
bba56f |
- }
|
|
|
bba56f |
-
|
|
|
bba56f |
- model->signature = x86MakeSignature(sigFamily, sigModel, 0);
|
|
|
bba56f |
- }
|
|
|
bba56f |
+ if (x86ModelParseSignature(model, ctxt) < 0)
|
|
|
bba56f |
+ goto error;
|
|
|
bba56f |
|
|
|
bba56f |
if (virXPathBoolean("boolean(./vendor)", ctxt)) {
|
|
|
bba56f |
vendor = virXPathString("string(./vendor/@name)", ctxt);
|
|
|
bba56f |
--
|
|
|
bba56f |
2.21.0
|
|
|
bba56f |
|