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