On Tue, Oct 15, 2019 at 05:34:51PM +0200, Jiri Denemark wrote:
The function translates qemuMonitorCPUDefsPtr (used by QEMU caps probing code) into virDomainCapsCPUModelsPtr used by domain capabilities. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- Notes: Version 2: - trivial rebase src/qemu/qemu_capabilities.c | 71 +++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e38ad03ab5..87ac9bacdc 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1887,6 +1887,41 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, } +static virDomainCapsCPUModelsPtr +virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefsPtr defs, + const char **modelWhitelist, + const char **modelBlacklist) +{ + VIR_AUTOUNREF(virDomainCapsCPUModelsPtr) cpuModels = NULL;
g_autoptr
+ size_t i; + + if (!(cpuModels = virDomainCapsCPUModelsNew(defs->ncpus))) + return NULL; + + for (i = 0; i < defs->ncpus; i++) { + qemuMonitorCPUDefInfoPtr cpu = defs->cpus + i; + virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN; + + if (modelWhitelist && !virStringListHasString(modelWhitelist, cpu->name)) + continue; + + if (modelBlacklist && virStringListHasString(modelBlacklist, cpu->name)) + continue; + + if (cpu->usable == VIR_TRISTATE_BOOL_YES) + usable = VIR_DOMCAPS_CPU_USABLE_YES; + else if (cpu->usable == VIR_TRISTATE_BOOL_NO) + usable = VIR_DOMCAPS_CPU_USABLE_NO; + + if (virDomainCapsCPUModelsAdd(cpuModels, cpu->name, + usable, cpu->blockers) < 0) + return NULL; + } + + VIR_RETURN_PTR(cpuModels);
return g_steal_pointer(&cpuModels); Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx> Jano
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list