mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
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>
This commit is contained in:
1 parent
4984c5bd02
commit
0900cc4f2d
4 files changed
+25
-14
No files matched your search
@@ -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);
|
||||
}
|
||||
@@ -280,3 +280,6 @@ virCPUDefListParse(const char **xmlCPUs,
|
||||
virCPUType cpuType);
|
||||
void
|
||||
virCPUDefListFree(virCPUDef **cpus);
|
||||
|
||||
void
|
||||
virCPUDefSortFeatures(virCPUDef *cpu);
|
||||
+1
-14
@@ -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;
|
||||
|
||||
@@ -118,6 +118,7 @@ virCPUDefNew;
|
||||
virCPUDefParseXML;
|
||||
virCPUDefParseXMLString;
|
||||
virCPUDefRef;
|
||||
virCPUDefSortFeatures;
|
||||
virCPUDefStealModel;
|
||||
virCPUDefUpdateFeature;
|
||||
virCPUMaxPhysAddrModeTypeFromString;
|
||||
|
||||
Reference in new issue
Block a user