|
|
b971b8 |
From 18b41d5bb489080b8be3c78d7f8436c9fb13087a Mon Sep 17 00:00:00 2001
|
|
|
b971b8 |
Message-Id: <18b41d5bb489080b8be3c78d7f8436c9fb13087a@dist-git>
|
|
|
b971b8 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b971b8 |
Date: Tue, 26 May 2020 10:59:03 +0200
|
|
|
b971b8 |
Subject: [PATCH] cpu_x86: Use glib allocation for virCPUx86Model
|
|
|
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 ccc0c2e4de58d62308e224076a7aa979ae97b520)
|
|
|
b971b8 |
|
|
|
b971b8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
|
|
|
b971b8 |
|
|
|
b971b8 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b971b8 |
Message-Id: <db624beaa5c879842c45b90269fb58a8f2fcfff2.1590483392.git.jdenemar@redhat.com>
|
|
|
b971b8 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
b971b8 |
---
|
|
|
b971b8 |
src/cpu/cpu_x86.c | 31 ++++++++-----------------------
|
|
|
b971b8 |
1 file changed, 8 insertions(+), 23 deletions(-)
|
|
|
b971b8 |
|
|
|
b971b8 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
b971b8 |
index 3a598e35d2..373c34a834 100644
|
|
|
b971b8 |
--- a/src/cpu/cpu_x86.c
|
|
|
b971b8 |
+++ b/src/cpu/cpu_x86.c
|
|
|
b971b8 |
@@ -1111,29 +1111,18 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
|
|
|
b971b8 |
}
|
|
|
b971b8 |
|
|
|
b971b8 |
|
|
|
b971b8 |
-static virCPUx86ModelPtr
|
|
|
b971b8 |
-x86ModelNew(void)
|
|
|
b971b8 |
-{
|
|
|
b971b8 |
- virCPUx86ModelPtr model;
|
|
|
b971b8 |
-
|
|
|
b971b8 |
- if (VIR_ALLOC(model) < 0)
|
|
|
b971b8 |
- return NULL;
|
|
|
b971b8 |
-
|
|
|
b971b8 |
- return model;
|
|
|
b971b8 |
-}
|
|
|
b971b8 |
-
|
|
|
b971b8 |
-
|
|
|
b971b8 |
static void
|
|
|
b971b8 |
x86ModelFree(virCPUx86ModelPtr model)
|
|
|
b971b8 |
{
|
|
|
b971b8 |
if (!model)
|
|
|
b971b8 |
return;
|
|
|
b971b8 |
|
|
|
b971b8 |
- VIR_FREE(model->name);
|
|
|
b971b8 |
- VIR_FREE(model->signatures);
|
|
|
b971b8 |
+ g_free(model->name);
|
|
|
b971b8 |
+ g_free(model->signatures);
|
|
|
b971b8 |
virCPUx86DataClear(&model->data);
|
|
|
b971b8 |
- VIR_FREE(model);
|
|
|
b971b8 |
+ g_free(model);
|
|
|
b971b8 |
}
|
|
|
b971b8 |
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUx86Model, x86ModelFree);
|
|
|
b971b8 |
|
|
|
b971b8 |
|
|
|
b971b8 |
static int
|
|
|
b971b8 |
@@ -1161,9 +1150,7 @@ x86ModelCopy(virCPUx86ModelPtr model)
|
|
|
b971b8 |
{
|
|
|
b971b8 |
virCPUx86ModelPtr copy;
|
|
|
b971b8 |
|
|
|
b971b8 |
- if (VIR_ALLOC(copy) < 0)
|
|
|
b971b8 |
- return NULL;
|
|
|
b971b8 |
-
|
|
|
b971b8 |
+ copy = g_new0(virCPUx86Model, 1);
|
|
|
b971b8 |
copy->name = g_strdup(model->name);
|
|
|
b971b8 |
|
|
|
b971b8 |
if (x86ModelCopySignatures(copy, model) < 0) {
|
|
|
b971b8 |
@@ -1216,7 +1203,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
|
|
|
b971b8 |
if (cpu->type == VIR_CPU_TYPE_HOST &&
|
|
|
b971b8 |
policy != VIR_CPU_FEATURE_REQUIRE &&
|
|
|
b971b8 |
policy != -1)
|
|
|
b971b8 |
- return x86ModelNew();
|
|
|
b971b8 |
+ return g_new0(virCPUx86Model, 1);
|
|
|
b971b8 |
|
|
|
b971b8 |
if (cpu->model &&
|
|
|
b971b8 |
(policy == VIR_CPU_FEATURE_REQUIRE || policy == -1)) {
|
|
|
b971b8 |
@@ -1228,7 +1215,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
|
|
|
b971b8 |
|
|
|
b971b8 |
model = x86ModelCopy(model);
|
|
|
b971b8 |
} else {
|
|
|
b971b8 |
- model = x86ModelNew();
|
|
|
b971b8 |
+ model = g_new0(virCPUx86Model, 1);
|
|
|
b971b8 |
}
|
|
|
b971b8 |
|
|
|
b971b8 |
if (!model)
|
|
|
b971b8 |
@@ -1540,9 +1527,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|
|
b971b8 |
goto cleanup;
|
|
|
b971b8 |
}
|
|
|
b971b8 |
|
|
|
b971b8 |
- if (!(model = x86ModelNew()))
|
|
|
b971b8 |
- goto cleanup;
|
|
|
b971b8 |
-
|
|
|
b971b8 |
+ model = g_new0(virCPUx86Model, 1);
|
|
|
b971b8 |
model->name = g_strdup(name);
|
|
|
b971b8 |
|
|
|
b971b8 |
if (x86ModelParseDecode(model, ctxt) < 0)
|
|
|
b971b8 |
--
|
|
|
b971b8 |
2.26.2
|
|
|
b971b8 |
|