You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.0 KiB
109 lines
3.0 KiB
From 6a2bd2d2e74d8c07266558c62d3fb724e677e256 Mon Sep 17 00:00:00 2001
|
|
Message-ID: <6a2bd2d2e74d8c07266558c62d3fb724e677e256.1780571166.git.jdenemar@redhat.com>
|
|
From: Jiri Denemark <jdenemar@redhat.com>
|
|
Date: Fri, 29 May 2026 13:00:10 +0200
|
|
Subject: [PATCH] cpu_conf: Introduce virCPUDefSortFeatures
|
|
|
|
Separate the sorting code from virCPUExpandFeatures into a standalone
|
|
function.
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
(cherry picked from commit 0900cc4f2dca2c17e8854330d45dffa4cc7952c4)
|
|
|
|
https://redhat.atlassian.net/browse/RHEL-177364
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
---
|
|
src/conf/cpu_conf.c | 20 ++++++++++++++++++++
|
|
src/conf/cpu_conf.h | 3 +++
|
|
src/cpu/cpu.c | 15 +--------------
|
|
src/libvirt_private.syms | 1 +
|
|
4 files changed, 25 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
|
index 7aeedf64f5..f5a2004ee6 100644
|
|
--- a/src/conf/cpu_conf.c
|
|
+++ b/src/conf/cpu_conf.c
|
|
@@ -1277,3 +1277,23 @@ virCPUDefListFree(virCPUDef **cpus)
|
|
|
|
g_free(cpus);
|
|
}
|
|
+
|
|
+
|
|
+static int
|
|
+virCPUFeatureDefCompare(const void *p1,
|
|
+ const void *p2,
|
|
+ void *opaque G_GNUC_UNUSED)
|
|
+{
|
|
+ const virCPUFeatureDef *f1 = p1;
|
|
+ const virCPUFeatureDef *f2 = p2;
|
|
+
|
|
+ return strcmp(f1->name, f2->name);
|
|
+}
|
|
+
|
|
+
|
|
+void
|
|
+virCPUDefSortFeatures(virCPUDef *cpu)
|
|
+{
|
|
+ g_qsort_with_data(cpu->features, cpu->nfeatures, sizeof(*cpu->features),
|
|
+ virCPUFeatureDefCompare, NULL);
|
|
+}
|
|
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
|
|
index cfb8f1a461..0cac1a1489 100644
|
|
--- a/src/conf/cpu_conf.h
|
|
+++ b/src/conf/cpu_conf.h
|
|
@@ -280,3 +280,6 @@ virCPUDefListParse(const char **xmlCPUs,
|
|
virCPUType cpuType);
|
|
void
|
|
virCPUDefListFree(virCPUDef **cpus);
|
|
+
|
|
+void
|
|
+virCPUDefSortFeatures(virCPUDef *cpu);
|
|
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
|
|
index 233686485d..d81e620a1d 100644
|
|
--- a/src/cpu/cpu.c
|
|
+++ b/src/cpu/cpu.c
|
|
@@ -1125,18 +1125,6 @@ virCPUConvertLegacy(virArch arch,
|
|
}
|
|
|
|
|
|
-static int
|
|
-virCPUFeatureCompare(const void *p1,
|
|
- const void *p2,
|
|
- void *opaque G_GNUC_UNUSED)
|
|
-{
|
|
- const virCPUFeatureDef *f1 = p1;
|
|
- const virCPUFeatureDef *f2 = p2;
|
|
-
|
|
- return strcmp(f1->name, f2->name);
|
|
-}
|
|
-
|
|
-
|
|
/**
|
|
* virCPUExpandFeatures:
|
|
*
|
|
@@ -1168,8 +1156,7 @@ virCPUExpandFeatures(virArch arch,
|
|
driver->expandFeatures(cpu) < 0)
|
|
return -1;
|
|
|
|
- g_qsort_with_data(cpu->features, cpu->nfeatures, sizeof(*cpu->features),
|
|
- virCPUFeatureCompare, NULL);
|
|
+ virCPUDefSortFeatures(cpu);
|
|
|
|
VIR_DEBUG("nfeatures=%zu", cpu->nfeatures);
|
|
return 0;
|
|
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
index d2563e587a..1733286bad 100644
|
|
--- a/src/libvirt_private.syms
|
|
+++ b/src/libvirt_private.syms
|
|
@@ -118,6 +118,7 @@ virCPUDefNew;
|
|
virCPUDefParseXML;
|
|
virCPUDefParseXMLString;
|
|
virCPUDefRef;
|
|
+virCPUDefSortFeatures;
|
|
virCPUDefStealModel;
|
|
virCPUDefUpdateFeature;
|
|
virCPUMaxPhysAddrModeTypeFromString;
|
|
--
|
|
2.54.0
|
|
|