[libvirt] [PATCH v3 18/52] qemu: Switch qemuCaps to use qemuMonitorCPUDefs

Ján Tomko jtomko at redhat.com
Tue Nov 12 14:34:07 UTC 2019


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 at redhat.com>
>---
>
>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 at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20191112/79690fe5/attachment-0001.sig>


More information about the libvir-list mailing list