|
|
a41c76 |
From da1511d57b10d2cc1cb14d78c6911815ec7d9f64 Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <da1511d57b10d2cc1cb14d78c6911815ec7d9f64@dist-git>
|
|
|
a41c76 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
Date: Tue, 26 May 2020 10:59:20 +0200
|
|
|
a41c76 |
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86Baseline
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit 5efefe7d7eb129b72bcbbebfbba2d5750ffeeeff)
|
|
|
a41c76 |
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
Message-Id: <d93fb6757fd9ecd9ffe8634c422cc613c8d03e84.1590483392.git.jdenemar@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/cpu/cpu_x86.c | 46 +++++++++++++++++-----------------------------
|
|
|
a41c76 |
1 file changed, 17 insertions(+), 29 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
a41c76 |
index 1ade53a4a8..6e7311694d 100644
|
|
|
a41c76 |
--- a/src/cpu/cpu_x86.c
|
|
|
a41c76 |
+++ b/src/cpu/cpu_x86.c
|
|
|
a41c76 |
@@ -2697,21 +2697,20 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
|
|
|
a41c76 |
bool migratable)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
virCPUx86MapPtr map = NULL;
|
|
|
a41c76 |
- virCPUx86ModelPtr base_model = NULL;
|
|
|
a41c76 |
- virCPUDefPtr cpu = NULL;
|
|
|
a41c76 |
+ g_autoptr(virCPUx86Model) base_model = NULL;
|
|
|
a41c76 |
+ g_autoptr(virCPUDef) cpu = NULL;
|
|
|
a41c76 |
size_t i;
|
|
|
a41c76 |
virCPUx86VendorPtr vendor = NULL;
|
|
|
a41c76 |
- virCPUx86ModelPtr model = NULL;
|
|
|
a41c76 |
bool outputVendor = true;
|
|
|
a41c76 |
const char *modelName;
|
|
|
a41c76 |
bool matchingNames = true;
|
|
|
a41c76 |
- virCPUDataPtr featData = NULL;
|
|
|
a41c76 |
+ g_autoptr(virCPUData) featData = NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!(map = virCPUx86GetMap()))
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!(base_model = x86ModelFromCPU(cpus[0], map, -1)))
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
cpu = virCPUDefNew();
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -2723,11 +2722,12 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
|
|
|
a41c76 |
} else if (!(vendor = x86VendorFind(map, cpus[0]->vendor))) {
|
|
|
a41c76 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
a41c76 |
_("Unknown CPU vendor %s"), cpus[0]->vendor);
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
modelName = cpus[0]->model;
|
|
|
a41c76 |
for (i = 1; i < ncpus; i++) {
|
|
|
a41c76 |
+ g_autoptr(virCPUx86Model) model = NULL;
|
|
|
a41c76 |
const char *vn = NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (matchingNames && cpus[i]->model) {
|
|
|
a41c76 |
@@ -2740,14 +2740,14 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!(model = x86ModelFromCPU(cpus[i], map, -1)))
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (cpus[i]->vendor && model->vendor &&
|
|
|
a41c76 |
STRNEQ(cpus[i]->vendor, model->vendor->name)) {
|
|
|
a41c76 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
a41c76 |
_("CPU vendor %s of model %s differs from vendor %s"),
|
|
|
a41c76 |
model->vendor->name, model->name, cpus[i]->vendor);
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
if (cpus[i]->vendor) {
|
|
|
a41c76 |
@@ -2763,30 +2763,28 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
|
|
|
a41c76 |
if (!(vendor = x86VendorFind(map, vn))) {
|
|
|
a41c76 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
a41c76 |
_("Unknown CPU vendor %s"), vn);
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
} else if (STRNEQ(vendor->name, vn)) {
|
|
|
a41c76 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
a41c76 |
"%s", _("CPU vendors do not match"));
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
x86DataIntersect(&base_model->data, &model->data);
|
|
|
a41c76 |
- x86ModelFree(model);
|
|
|
a41c76 |
- model = NULL;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
if (features) {
|
|
|
a41c76 |
virCPUx86FeaturePtr feat;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!(featData = virCPUDataNew(archs[0])))
|
|
|
a41c76 |
- goto cleanup;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
for (i = 0; features[i]; i++) {
|
|
|
a41c76 |
if ((feat = x86FeatureFind(map, features[i])) &&
|
|
|
a41c76 |
x86DataAdd(&featData->data.x86, &feat->data) < 0)
|
|
|
a41c76 |
- goto cleanup;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
x86DataIntersect(&base_model->data, &featData->data.x86);
|
|
|
a41c76 |
@@ -2795,15 +2793,15 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
|
|
|
a41c76 |
if (x86DataIsEmpty(&base_model->data)) {
|
|
|
a41c76 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
a41c76 |
"%s", _("CPUs are incompatible"));
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
if (vendor &&
|
|
|
a41c76 |
virCPUx86DataAddItem(&base_model->data, &vendor->data) < 0)
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (x86Decode(cpu, &base_model->data, models, modelName, migratable) < 0)
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (STREQ_NULLABLE(cpu->model, modelName))
|
|
|
a41c76 |
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
|
|
|
a41c76 |
@@ -2811,17 +2809,7 @@ virCPUx86Baseline(virCPUDefPtr *cpus,
|
|
|
a41c76 |
if (!outputVendor)
|
|
|
a41c76 |
VIR_FREE(cpu->vendor);
|
|
|
a41c76 |
|
|
|
a41c76 |
- cleanup:
|
|
|
a41c76 |
- x86ModelFree(base_model);
|
|
|
a41c76 |
- virCPUx86DataFree(featData);
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- return cpu;
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- error:
|
|
|
a41c76 |
- x86ModelFree(model);
|
|
|
a41c76 |
- virCPUDefFree(cpu);
|
|
|
a41c76 |
- cpu = NULL;
|
|
|
a41c76 |
- goto cleanup;
|
|
|
a41c76 |
+ return g_steal_pointer(&cpu);
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.26.2
|
|
|
a41c76 |
|