[PATCH v6 32/33] qemu_driver: Support feature expansion via QEMU when baselining cpu

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

 



Support using QEMU to do feature expansion when also using QEMU to
compute hypervisor baseline.

A QEMU process is already created to send the QMP messages to baseline
using QEMU.
The same QEMU process is used for the CPU feature expansion.

QEMU only returns migratable features when expanding CPU model in
architectures where QEMU is used for baseline so no attempt is made to
ask for non-migratable features in expansions when using QEMU for
baseline.

Signed-off-by: Chris Venteicher <cventeic@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c  | 25 +++++++++++++++++++++++++
 src/qemu/qemu_monitor.c | 30 ++++++++++++++++++++++++++++++
 src/qemu/qemu_monitor.h |  4 ++++
 3 files changed, 59 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5068805f51..b57123b585 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13897,6 +13897,31 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn,
     if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) {
         if (useLibvirt && virCPUExpandFeatures(arch, cpu) < 0) {
             goto cleanup;
+        } else if (useQemu &&
+                   virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) {
+
+            if (!(modelInfo = virQEMUCapsCPUModelInfoFromCPUDef(cpu)))
+                goto cleanup;
+
+            virCPUDefFree(cpu);
+            cpu = NULL;
+
+            /* QEMU can only include migratable features
+               for all archs that use QEMU for baseline calculation */
+            migratable = true;
+
+            if (qemuMonitorGetCPUModelExpansion(proc->mon,
+                                                QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
+                                                modelInfo, migratable, &expansion) < 0)
+                goto cleanup;
+
+            /* Expansion enumerates all features
+             * Baselines output enumerates only in-model (true) features */
+            qemuMonitorCPUModelInfoRemovePropByBoolValue(expansion, false);
+
+            if (!(cpu = virQEMUCapsCPUModelInfoToCPUDef(expansion, migratable)))
+                goto cleanup;
+
         } else {
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
                            _("expand features while "
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7d82f25fc2..56a3bbcea1 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3785,6 +3785,36 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig)
 }
 
 
+/* Squash CPU Model Info property list
+ * removing props of type boolean matching value */
+void
+qemuMonitorCPUModelInfoRemovePropByBoolValue(qemuMonitorCPUModelInfoPtr model,
+                                             bool value)
+{
+    qemuMonitorCPUPropertyPtr src;
+    qemuMonitorCPUPropertyPtr dst;
+    size_t i;
+    size_t dst_nprops = 0;
+
+    for (i = 0; i < model->nprops; i++) {
+        src = &(model->props[i]);
+        dst = &(model->props[dst_nprops]);
+
+        if (src->type == QEMU_MONITOR_CPU_PROPERTY_BOOLEAN &&
+            src->value.boolean == value)
+            continue;
+
+        *dst = *src;
+
+        dst_nprops++;
+    }
+
+    model->nprops = dst_nprops;
+
+    ignore_value(VIR_REALLOC_N_QUIET(model->props, dst_nprops));
+}
+
+
 int
 qemuMonitorCPUModelInfoBoolPropAdd(qemuMonitorCPUModelInfoPtr model,
                                    const char *prop_name,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 2b3ea6ab8e..c54f311632 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1078,6 +1078,10 @@ int qemuMonitorCPUModelInfoBoolPropAdd(qemuMonitorCPUModelInfoPtr model,
                                        bool prop_value)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
+void qemuMonitorCPUModelInfoRemovePropByBoolValue(qemuMonitorCPUModelInfoPtr model,
+                                                  bool value)
+    ATTRIBUTE_NONNULL(1);
+
 int qemuMonitorGetCommands(qemuMonitorPtr mon,
                            char ***commands);
 int qemuMonitorGetEvents(qemuMonitorPtr mon,
-- 
2.17.1

--
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