|
|
fbe740 |
From 7a293db132130fdda7b550d701fdb426de5257e3 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <7a293db132130fdda7b550d701fdb426de5257e3@dist-git>
|
|
|
fbe740 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Date: Tue, 26 May 2020 10:59:23 +0200
|
|
|
fbe740 |
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86UpdateLive
|
|
|
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 2748e91c548cbc48a5ea499e06e62de528c10d20)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Message-Id: <5c29b10ead2332033087fc6ed487c9ca53b7e3a4.1590483392.git.jdenemar@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/cpu/cpu_x86.c | 42 +++++++++++++++---------------------------
|
|
|
fbe740 |
1 file changed, 15 insertions(+), 27 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
fbe740 |
index 1f7a8802f6..e3a83061d0 100644
|
|
|
fbe740 |
--- a/src/cpu/cpu_x86.c
|
|
|
fbe740 |
+++ b/src/cpu/cpu_x86.c
|
|
|
fbe740 |
@@ -2897,26 +2897,25 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
{
|
|
|
fbe740 |
bool hostPassthrough = cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH;
|
|
|
fbe740 |
virCPUx86MapPtr map;
|
|
|
fbe740 |
- virCPUx86ModelPtr model = NULL;
|
|
|
fbe740 |
- virCPUx86ModelPtr modelDisabled = NULL;
|
|
|
fbe740 |
- virCPUx86Data enabled = VIR_CPU_X86_DATA_INIT;
|
|
|
fbe740 |
- virCPUx86Data disabled = VIR_CPU_X86_DATA_INIT;
|
|
|
fbe740 |
- virBuffer bufAdded = VIR_BUFFER_INITIALIZER;
|
|
|
fbe740 |
- virBuffer bufRemoved = VIR_BUFFER_INITIALIZER;
|
|
|
fbe740 |
- char *added = NULL;
|
|
|
fbe740 |
- char *removed = NULL;
|
|
|
fbe740 |
+ g_autoptr(virCPUx86Model) model = NULL;
|
|
|
fbe740 |
+ g_autoptr(virCPUx86Model) modelDisabled = NULL;
|
|
|
fbe740 |
+ g_auto(virCPUx86Data) enabled = VIR_CPU_X86_DATA_INIT;
|
|
|
fbe740 |
+ g_auto(virCPUx86Data) disabled = VIR_CPU_X86_DATA_INIT;
|
|
|
fbe740 |
+ g_auto(virBuffer) bufAdded = VIR_BUFFER_INITIALIZER;
|
|
|
fbe740 |
+ g_auto(virBuffer) bufRemoved = VIR_BUFFER_INITIALIZER;
|
|
|
fbe740 |
+ g_autofree char *added = NULL;
|
|
|
fbe740 |
+ g_autofree char *removed = NULL;
|
|
|
fbe740 |
size_t i;
|
|
|
fbe740 |
- int ret = -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(map = virCPUx86GetMap()))
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(model = x86ModelFromCPU(cpu, map, -1)))
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (hostPassthrough &&
|
|
|
fbe740 |
!(modelDisabled = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_DISABLE)))
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (dataEnabled)
|
|
|
fbe740 |
x86DataCopy(&enabled, &dataEnabled->data.x86);
|
|
|
fbe740 |
@@ -2941,7 +2940,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
virBufferAsprintf(&bufAdded, "%s,", feature->name);
|
|
|
fbe740 |
else if (virCPUDefUpdateFeature(cpu, feature->name,
|
|
|
fbe740 |
VIR_CPU_FEATURE_REQUIRE) < 0)
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
if (x86DataIsSubset(&disabled, &feature->data) ||
|
|
|
fbe740 |
@@ -2952,7 +2951,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
virBufferAsprintf(&bufRemoved, "%s,", feature->name);
|
|
|
fbe740 |
else if (virCPUDefUpdateFeature(cpu, feature->name,
|
|
|
fbe740 |
VIR_CPU_FEATURE_DISABLE) < 0)
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -2978,28 +2977,17 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
_("guest CPU doesn't match specification: "
|
|
|
fbe740 |
"missing features: %s"),
|
|
|
fbe740 |
removed);
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
if (cpu->check == VIR_CPU_CHECK_FULL &&
|
|
|
fbe740 |
!x86DataIsEmpty(&disabled)) {
|
|
|
fbe740 |
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
fbe740 |
_("guest CPU doesn't match specification"));
|
|
|
fbe740 |
- goto cleanup;
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
- ret = 0;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- cleanup:
|
|
|
fbe740 |
- x86ModelFree(model);
|
|
|
fbe740 |
- x86ModelFree(modelDisabled);
|
|
|
fbe740 |
- virCPUx86DataClear(&enabled);
|
|
|
fbe740 |
- virCPUx86DataClear(&disabled);
|
|
|
fbe740 |
- VIR_FREE(added);
|
|
|
fbe740 |
- VIR_FREE(removed);
|
|
|
fbe740 |
- virBufferFreeAndReset(&bufAdded);
|
|
|
fbe740 |
- virBufferFreeAndReset(&bufRemoved);
|
|
|
fbe740 |
- return ret;
|
|
|
fbe740 |
+ return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.26.2
|
|
|
fbe740 |
|