From e373f870345bc5fcb47873e804d92a01b42aafad Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Tue, 15 Oct 2024 18:18:01 +0200 Subject: [PATCH] qemu: Introduce virQEMUCapsGetCPUBlockers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A function for accessing a list of features blocking CPU model usability. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- src/qemu/qemu_capabilities.c | 38 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 4 ++++ 2 files changed, 42 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e1e28e5cd1..b5fa738bd8 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2507,6 +2507,44 @@ virQEMUCapsIsCPUUsable(virQEMUCaps *qemuCaps, } +/** + * virQEMUCapsGetCPUBlockers: + * @qemuCaps: QEMU capabilities + * @type: virtualization type + * @cpu: CPU model + * @blockers: where to store the list of features + * + * Get a list of features that prevent @cpu from being usable. The pointer to + * the list will be stored in @blockers and the caller must not free it. The + * pointer is valid as long as there is an active reference to @qemuCaps. + * + * Returns 0 on success, -1 when @cpu is not found in @qemuCaps. + */ +int +virQEMUCapsGetCPUBlockers(virQEMUCaps *qemuCaps, + virDomainVirtType type, + const char *cpu, + char ***blockers) +{ + qemuMonitorCPUDefs *defs; + size_t i; + + defs = virQEMUCapsGetAccel(qemuCaps, type)->cpuModels; + + if (!defs) + return -1; + + for (i = 0; i < defs->ncpus; i++) { + if (STREQ(defs->cpus[i].name, cpu)) { + *blockers = defs->cpus[i].blockers; + return 0; + } + } + + return -1; +} + + bool virQEMUCapsIsMachineDeprecated(virQEMUCaps *qemuCaps, virDomainVirtType type, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 284b07b64e..54c7e30903 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -795,6 +795,10 @@ bool virQEMUCapsIsCPUDeprecated(virQEMUCaps *qemuCaps, bool virQEMUCapsIsCPUUsable(virQEMUCaps *qemuCaps, virDomainVirtType type, virCPUDef *cpu); +int virQEMUCapsGetCPUBlockers(virQEMUCaps *qemuCaps, + virDomainVirtType type, + const char *cpu, + char ***blockers); bool virQEMUCapsIsMachineDeprecated(virQEMUCaps *qemuCaps, virDomainVirtType type, const char *machine);