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