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