On Tue, Nov 05, 2019 at 02:27:16PM +0100, Jiri Denemark wrote:
We will need to keep some QEMU-specific data for each CPU model supported by a QEMU binary. Instead of complicating the generic virDomainCapsCPUModelsPtr, we can just directly store qemuMonitorCPUDefsPtr returned by the capabilities probing code. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- Notes: Version 2: - adapted to changes made by the new patches Version 3: - glib functions - implicit translation between virDomainCapsCPUUsable and virTristateBool is gone since "qemu: Use virDomainCapsCPUUsable in qemuMonitorCPUDefInfo" patch src/qemu/qemu_capabilities.c | 108 +++++++++++++++++------------------ 1 file changed, 52 insertions(+), 56 deletions(-) @@ -1855,25 +1846,36 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, virDomainCapsCPUUsable usable) { size_t i; - virDomainCapsCPUModelsPtr cpus = NULL; + size_t start; + qemuMonitorCPUDefsPtr defs = NULL; if (type == VIR_DOMAIN_VIRT_KVM && qemuCaps->kvmCPUModels) - cpus = qemuCaps->kvmCPUModels; + defs = qemuCaps->kvmCPUModels; else if (type == VIR_DOMAIN_VIRT_QEMU && qemuCaps->tcgCPUModels) - cpus = qemuCaps->tcgCPUModels; + defs = qemuCaps->tcgCPUModels; + + if (defs) { + start = defs->ncpus; - if (!cpus) { - if (!(cpus = virDomainCapsCPUModelsNew(count))) + if (VIR_EXPAND_N(defs->cpus, defs->ncpus, count) < 0) + return -1; + } else { + start = 0; + + if (!(defs = qemuMonitorCPUDefsNew(count))) return -1; if (type == VIR_DOMAIN_VIRT_KVM) - qemuCaps->kvmCPUModels = cpus; + qemuCaps->kvmCPUModels = defs; else - qemuCaps->tcgCPUModels = cpus; + qemuCaps->tcgCPUModels = defs; } for (i = 0; i < count; i++) { - if (virDomainCapsCPUModelsAdd(cpus, name[i], usable, NULL) < 0) + qemuMonitorCPUDefInfoPtr cpu = defs->cpus + start + i; + + cpu->usable = usable; + if (VIR_STRDUP(cpu->name, name[i]) < 0)
g_strdup
return -1; }
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