[PATCH v3 24/52] qemu: Introduce virQEMUCapsAccel structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is container for capabilities data that depend on the accelerator.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Notes:
    Version 3:
    - new patch

 src/qemu/qemu_capabilities.c | 66 ++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 54f2ecb7f4..c6a2f65239 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -576,6 +576,13 @@ struct _virQEMUCapsHostCPUData {
     virCPUDefPtr full;
 };
 
+typedef struct _virQEMUCapsAccel virQEMUCapsAccel;
+typedef virQEMUCapsAccel *virQEMUCapsAccelPtr;
+struct _virQEMUCapsAccel {
+    virQEMUCapsHostCPUData hostCPU;
+    qemuMonitorCPUDefsPtr cpuModels;
+};
+
 /*
  * Update the XML parser/formatter when adding more
  * information to this struct so that it gets cached
@@ -607,8 +614,6 @@ struct _virQEMUCaps {
     virArch arch;
 
     virHashTablePtr domCapsCache;
-    qemuMonitorCPUDefsPtr kvmCPUModels;
-    qemuMonitorCPUDefsPtr tcgCPUModels;
 
     size_t nmachineTypes;
     struct virQEMUCapsMachineType *machineTypes;
@@ -618,8 +623,9 @@ struct _virQEMUCaps {
 
     virSEVCapability *sevCapabilities;
 
-    virQEMUCapsHostCPUData kvmCPU;
-    virQEMUCapsHostCPUData tcgCPU;
+    /* Capabilities which may differ depending on the accelerator. */
+    virQEMUCapsAccel kvm;
+    virQEMUCapsAccel tcg;
 };
 
 struct virQEMUCapsSearchData {
@@ -1620,11 +1626,11 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
 
     ret->arch = qemuCaps->arch;
 
-    ret->kvmCPUModels = qemuMonitorCPUDefsCopy(qemuCaps->kvmCPUModels);
-    ret->tcgCPUModels = qemuMonitorCPUDefsCopy(qemuCaps->tcgCPUModels);
+    ret->kvm.cpuModels = qemuMonitorCPUDefsCopy(qemuCaps->kvm.cpuModels);
+    ret->tcg.cpuModels = qemuMonitorCPUDefsCopy(qemuCaps->tcg.cpuModels);
 
-    if (virQEMUCapsHostCPUDataCopy(&ret->kvmCPU, &qemuCaps->kvmCPU) < 0 ||
-        virQEMUCapsHostCPUDataCopy(&ret->tcgCPU, &qemuCaps->tcgCPU) < 0)
+    if (virQEMUCapsHostCPUDataCopy(&ret->kvm.hostCPU, &qemuCaps->kvm.hostCPU) < 0 ||
+        virQEMUCapsHostCPUDataCopy(&ret->tcg.hostCPU, &qemuCaps->tcg.hostCPU) < 0)
         goto error;
 
     if (VIR_ALLOC_N(ret->machineTypes, qemuCaps->nmachineTypes) < 0)
@@ -1670,8 +1676,8 @@ void virQEMUCapsDispose(void *obj)
     VIR_FREE(qemuCaps->machineTypes);
 
     virHashFree(qemuCaps->domCapsCache);
-    virObjectUnref(qemuCaps->kvmCPUModels);
-    virObjectUnref(qemuCaps->tcgCPUModels);
+    virObjectUnref(qemuCaps->kvm.cpuModels);
+    virObjectUnref(qemuCaps->tcg.cpuModels);
 
     virBitmapFree(qemuCaps->flags);
 
@@ -1683,8 +1689,8 @@ void virQEMUCapsDispose(void *obj)
 
     virSEVCapabilitiesFree(qemuCaps->sevCapabilities);
 
-    virQEMUCapsHostCPUDataClear(&qemuCaps->kvmCPU);
-    virQEMUCapsHostCPUDataClear(&qemuCaps->tcgCPU);
+    virQEMUCapsHostCPUDataClear(&qemuCaps->kvm.hostCPU);
+    virQEMUCapsHostCPUDataClear(&qemuCaps->tcg.hostCPU);
 }
 
 void
@@ -1849,10 +1855,10 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
     size_t start;
     qemuMonitorCPUDefsPtr defs = NULL;
 
-    if (type == VIR_DOMAIN_VIRT_KVM && qemuCaps->kvmCPUModels)
-        defs = qemuCaps->kvmCPUModels;
-    else if (type == VIR_DOMAIN_VIRT_QEMU && qemuCaps->tcgCPUModels)
-        defs = qemuCaps->tcgCPUModels;
+    if (type == VIR_DOMAIN_VIRT_KVM && qemuCaps->kvm.cpuModels)
+        defs = qemuCaps->kvm.cpuModels;
+    else if (type == VIR_DOMAIN_VIRT_QEMU && qemuCaps->tcg.cpuModels)
+        defs = qemuCaps->tcg.cpuModels;
 
     if (defs) {
         start = defs->ncpus;
@@ -1866,9 +1872,9 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
             return -1;
 
         if (type == VIR_DOMAIN_VIRT_KVM)
-            qemuCaps->kvmCPUModels = defs;
+            qemuCaps->kvm.cpuModels = defs;
         else
-            qemuCaps->tcgCPUModels = defs;
+            qemuCaps->tcg.cpuModels = defs;
     }
 
     for (i = 0; i < count; i++) {
@@ -1921,9 +1927,9 @@ virQEMUCapsGetCPUModels(virQEMUCapsPtr qemuCaps,
     qemuMonitorCPUDefsPtr defs;
 
     if (type == VIR_DOMAIN_VIRT_KVM)
-        defs = qemuCaps->kvmCPUModels;
+        defs = qemuCaps->kvm.cpuModels;
     else
-        defs = qemuCaps->tcgCPUModels;
+        defs = qemuCaps->tcg.cpuModels;
 
     if (!defs)
         return NULL;
@@ -1937,9 +1943,9 @@ virQEMUCapsGetHostCPUData(virQEMUCapsPtr qemuCaps,
                           virDomainVirtType type)
 {
     if (type == VIR_DOMAIN_VIRT_KVM)
-        return &qemuCaps->kvmCPU;
+        return &qemuCaps->kvm.hostCPU;
     else
-        return &qemuCaps->tcgCPU;
+        return &qemuCaps->tcg.hostCPU;
 }
 
 
@@ -2001,9 +2007,9 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
 
     case VIR_CPU_MODE_CUSTOM:
         if (type == VIR_DOMAIN_VIRT_KVM)
-            cpus = qemuCaps->kvmCPUModels;
+            cpus = qemuCaps->kvm.cpuModels;
         else
-            cpus = qemuCaps->tcgCPUModels;
+            cpus = qemuCaps->tcg.cpuModels;
         return cpus && cpus->ncpus > 0;
 
     case VIR_CPU_MODE_LAST:
@@ -2532,9 +2538,9 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
         return -1;
 
     if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
-        qemuCaps->tcgCPUModels = defs;
+        qemuCaps->tcg.cpuModels = defs;
     else
-        qemuCaps->kvmCPUModels = defs;
+        qemuCaps->kvm.cpuModels = defs;
 
     return 0;
 }
@@ -3547,9 +3553,9 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps,
     }
 
     if (type == VIR_DOMAIN_VIRT_KVM)
-        qemuCaps->kvmCPUModels = g_steal_pointer(&defs);
+        qemuCaps->kvm.cpuModels = g_steal_pointer(&defs);
     else
-        qemuCaps->tcgCPUModels = g_steal_pointer(&defs);
+        qemuCaps->tcg.cpuModels = g_steal_pointer(&defs);
 
     return 0;
 }
@@ -3976,10 +3982,10 @@ virQEMUCapsFormatCPUModels(virQEMUCapsPtr qemuCaps,
 
     if (type == VIR_DOMAIN_VIRT_KVM) {
         typeStr = "kvm";
-        defs = qemuCaps->kvmCPUModels;
+        defs = qemuCaps->kvm.cpuModels;
     } else {
         typeStr = "tcg";
-        defs = qemuCaps->tcgCPUModels;
+        defs = qemuCaps->tcg.cpuModels;
     }
 
     if (!defs)
-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux