query-cpu-model-expansion may report an array of deprecated properties. This array is optional, and may not be supported for a particular architecture or reported for a particular CPU model. If the output is present, then capture it and store in a qemuMonitorCPUModelInfo struct for later use. Baseline does not intend to use this feature, so pass NULL in place of the respective parameter in the relevant functions. The deprecated features will be retained in qemuCaps->kvm->hostCPU.info and will be stored in the capabilities cache file under the <hostCPU> element using the following format: <deprecatedProperties> <property name='bpb'/> <property name='csske'/> <property name='cte'/> <property name='te'/> </deprecatedProperties> Signed-off-by: Collin Walling <walling@xxxxxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 30 ++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 29 ++++++++++++++++++++++++----- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 45525db803..5c36db27f8 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4028,6 +4028,24 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, } } + ctxt->node = hostCPUNode; + + if (virXPathNodeSet("./deprecatedProperties", ctxt, &nodes) > 0 && + (n = virXPathNodeSet("./property", ctxt, &nodes)) > 0) { + hostCPU->deprecated_props = g_new0(char *, n); + hostCPU->ndeprecated_props = n; + + for (i = 0; i < n; i++) { + ctxt->node = nodes[i]; + + if (!(hostCPU->deprecated_props[i] = virXMLPropString(ctxt->node, "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'name' attribute for a host CPU model deprecated property in QEMU capabilities cache")); + return -1; + } + } + } + caps->hostCPU.info = g_steal_pointer(&hostCPU); return 0; } @@ -4760,6 +4778,18 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); } + if (model->deprecated_props) { + virBufferAddLit(buf, "<deprecatedProperties>\n"); + virBufferAdjustIndent(buf, 2); + + for (i = 0; i < model->ndeprecated_props; i++) + virBufferAsprintf(buf, "<property name='%s'/>\n", + model->deprecated_props[i]); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</deprecatedProperties>\n"); + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</hostCPU>\n"); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6e81945201..1a2444b721 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1140,6 +1140,8 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUProperty *props; + size_t ndeprecated_props; + char **deprecated_props; bool migratability; }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index eb84a3d938..39dc709693 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5006,6 +5006,7 @@ qemuMonitorJSONParseCPUModelData(virJSONValue *data, bool fail_no_props, virJSONValue **cpu_model, virJSONValue **cpu_props, + virJSONValue **cpu_deprecated_props, const char **cpu_name) { if (!(*cpu_model = virJSONValueObjectGetObject(data, "model"))) { @@ -5027,6 +5028,12 @@ qemuMonitorJSONParseCPUModelData(virJSONValue *data, return -1; } + /* Unconditionally check for the deprecated-props array, as it is not + * a guarantee response even if QEMU supports it. */ + if (cpu_deprecated_props) + *cpu_deprecated_props = virJSONValueObjectGetArray(*cpu_model, + "deprecated-props"); + return 0; } @@ -5034,6 +5041,7 @@ qemuMonitorJSONParseCPUModelData(virJSONValue *data, static int qemuMonitorJSONParseCPUModel(const char *cpu_name, virJSONValue *cpu_props, + virJSONValue *cpu_deprecated_props, qemuMonitorCPUModelInfo **model_info) { g_autoptr(qemuMonitorCPUModelInfo) machine_model = NULL; @@ -5052,6 +5060,16 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, return -1; } + if (cpu_deprecated_props) { + size_t ndeprecated_props = virJSONValueArraySize(cpu_deprecated_props); + machine_model->deprecated_props = g_new0(char *, ndeprecated_props); + + if (!(machine_model->deprecated_props = virJSONValueArrayToStringList(cpu_deprecated_props))) + return -1; + + machine_model->ndeprecated_props = ndeprecated_props; + } + *model_info = g_steal_pointer(&machine_model); return 0; } @@ -5116,6 +5134,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, g_autoptr(virJSONValue) fullData = NULL; virJSONValue *cpu_model; virJSONValue *cpu_props = NULL; + virJSONValue *cpu_deprecated_props = NULL; const char *cpu_name = ""; int rc; @@ -5129,7 +5148,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) + &cpu_deprecated_props, &cpu_name) < 0) return -1; /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expansion @@ -5147,11 +5166,11 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if (qemuMonitorJSONParseCPUModelData(fullData, "query-cpu-model-expansion", fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) + &cpu_deprecated_props, &cpu_name) < 0) return -1; } - return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info); + return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, cpu_deprecated_props, model_info); } @@ -5188,10 +5207,10 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitor *mon, if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-baseline", false, &cpu_model, &cpu_props, - &cpu_name) < 0) + NULL, &cpu_name) < 0) return -1; - return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, baseline); + return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, NULL, baseline); } -- 2.43.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx