[PATCHv2 06/11] qemu_monitor: Introduce qemuMonitorCPUModelInfoRemovePropByBoolValue

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

 



Filter out cpu properties in qemuMonitorCPUModelInfo structure based on
boolean value of true or false.

Goal is to form a list of "enabled" or "disabled" properties.

Required to convert between cpu model feature / property lists that
indicate if property is or isn't include in model and the form of cpu
model feature / property lists that only enumerate properties that are
actually included in the model.
---
 src/qemu/qemu_monitor.c | 29 +++++++++++++++++++++++++++++
 src/qemu/qemu_monitor.h |  4 ++++
 2 files changed, 33 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 91b946c8b4..dd8510fbab 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3766,6 +3766,35 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig)
     return NULL;
 }
 
+
+/* Squash CPU Model Info property list
+ * removing props of type boolean matching value */
+void
+qemuMonitorCPUModelInfoRemovePropByBoolValue(qemuMonitorCPUModelInfoPtr model,
+                                             bool value)
+{
+    qemuMonitorCPUPropertyPtr src, dst;
+    size_t i, dst_size = 0;
+
+    for (i = 0; i < model->nprops; i++) {
+        src = &(model->props[i]);
+        dst = &(model->props[dst_size]);
+
+        if ((src->type == QEMU_MONITOR_CPU_PROPERTY_BOOLEAN) &&
+            (src->value.boolean == value))
+            continue;
+
+        *dst = *src;
+
+        dst_size++;
+    }
+
+    model->nprops = dst_size;
+
+    ignore_value(VIR_REALLOC_N(model->props, dst_size)); /* not fatal */
+}
+
+
 int
 qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
                                qemuMonitorCPUModelInfoPtr model_a,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 6b4b527512..9841ab230c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1028,6 +1028,10 @@ int qemuMonitorCPUModelInfoInit(const char *name, qemuMonitorCPUModelInfoPtr mod
 qemuMonitorCPUModelInfoPtr
 qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);
 
+void qemuMonitorCPUModelInfoRemovePropByBoolValue( qemuMonitorCPUModelInfoPtr model,
+                                                   bool value)
+    ATTRIBUTE_NONNULL(1);
+
 int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
                                    qemuMonitorCPUModelInfoPtr model_a,
                                    qemuMonitorCPUModelInfoPtr model_b,
-- 
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