On Fri, May 29, 2026 at 16:12:16 +0200, Jiri Denemark via Devel wrote:
From: Jiri Denemark <jdenemar@redhat.com>
This new API can be used to update an existing CPU definition with features described by CPU data.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> ---
Notes: Version 2: - no change
src/cpu/cpu.c | 33 +++++++++++++++++++++++++++++++++ src/cpu/cpu.h | 12 ++++++++++++ src/cpu/cpu_x86.c | 23 +++++++++++++++++++++++ src/libvirt_private.syms | 1 + 4 files changed, 69 insertions(+)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index d81e620a1d..03174d5bad 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1359,6 +1359,39 @@ virCPUGetCanonicalModel(virArch arch, }
+/** virCPUUpdateFeatures: + * + * @arch: CPU architecture + * @cpu: CPU definition to update + * @cpuData: CPU data describing features + * @policy: to be used by the updated features + * + * Updates features described in @cpuData to use the specified @policy. Missing + * features will be automatically added to the CPU definition. + * + * Returns 0 on success, -1 otherwise. + */ +int +virCPUUpdateFeatures(virArch arch, + virCPUDef *cpu, + virCPUData *cpuData, + virCPUFeaturePolicy policy) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("arch=%s, cpu=%p, model=%s", + virArchToString(arch), cpu, NULLSTR(cpu->model));
Logging 'policy' seems more useful than logging the %p of 'cpu'.
+ + if (!(driver = cpuGetSubDriver(arch))) + return -1; + + if (!driver->updateFeatures) + return 0; + + return driver->updateFeatures(cpu, cpuData, policy);
Reviewed-by: Peter Krempa <pkrempa@redhat.com>