[PATCH v1 0/4] s390x CPU Models: Fix deprecated_features='on'
Currently, when setting the deprecated_features attribute to 'on', all known deprecated features will be enabled for the CPU model, including ones that are *not* supported by the model. These patches query an additional set of deprecated features by performing a CPU model expansion on host-model with type "static". The list of deprecated features reported from this command will reflect features that may be enabled on the model without error. Now, when a user specifies deprecated_features='on' in the domain XML, only the features that are still supported by the model are requested to be turned on for the guest. This can be helpful for e.g. tests that may wish to check CPU model compatability in certain environments. Collin Walling (4): qemu: rename modelinfo's deprecated_props to full_dep_props qemu: refactor load/format of deprecated features qemu: query and cache static/host deprecated features qemu: only allow enabling deprecated features that are supported src/qemu/qemu_capabilities.c | 106 ++++++++++++------ src/qemu/qemu_monitor.c | 6 +- src/qemu/qemu_monitor.h | 3 +- src/qemu/qemu_monitor_json.c | 17 ++- .../caps_10.0.0_s390x.xml | 6 + .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 + .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 + 7 files changed, 112 insertions(+), 38 deletions(-) -- 2.51.1
The current query of deprecated properties is the result of a full model expansion. Rename the field to reflect this. Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 22 +++++++++++----------- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 205bf3d0b8..bcc7c5b602 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3275,9 +3275,9 @@ virQEMUCapsProbeFullDeprecatedProperties(qemuMonitor *mon, cpu, true, false, false, &propsInfo) < 0) return -1; - if (propsInfo && propsInfo->deprecated_props) { + if (propsInfo && propsInfo->full_dep_props) { g_strfreev(*props); - *props = g_steal_pointer(&propsInfo->deprecated_props); + *props = g_steal_pointer(&propsInfo->full_dep_props); } return 0; @@ -3366,7 +3366,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS) && - virQEMUCapsProbeFullDeprecatedProperties(mon, cpu, &modelInfo->deprecated_props) < 0) + virQEMUCapsProbeFullDeprecatedProperties(mon, cpu, &modelInfo->full_dep_props) < 0) return -1; if (virQEMUCapsTypeIsAccelerated(virtType) && @@ -3441,11 +3441,11 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType); - if (!modelInfo || !modelInfo->deprecated_props) + if (!modelInfo || !modelInfo->full_dep_props) return; - for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { - virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], policy); + for (i = 0; i < g_strv_length(modelInfo->full_dep_props); i++) { + virCPUDefUpdateFeature(cpu, modelInfo->full_dep_props[i], policy); } } @@ -4210,12 +4210,12 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, if ((deprecated_props = virXPathNode("./deprecatedFeatures", ctxt))) { g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(deprecated_props, NULL); - hostCPU->deprecated_props = g_new0(char *, props->len + 1); + hostCPU->full_dep_props = g_new0(char *, props->len + 1); for (i = 0; i < props->len; i++) { xmlNodePtr prop = g_ptr_array_index(props, i); - if (!(hostCPU->deprecated_props[i] = virXMLPropString(prop, "name"))) { + if (!(hostCPU->full_dep_props[i] = virXMLPropString(prop, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing 'name' attribute for a host CPU model deprecated property in QEMU capabilities cache")); return -1; @@ -4979,13 +4979,13 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); } - if (model->deprecated_props) { + if (model->full_dep_props) { virBufferAddLit(buf, "<deprecatedFeatures>\n"); virBufferAdjustIndent(buf, 2); - for (i = 0; i < g_strv_length(model->deprecated_props); i++) + for (i = 0; i < g_strv_length(model->full_dep_props); i++) virBufferAsprintf(buf, "<property name='%s'/>\n", - model->deprecated_props[i]); + model->full_dep_props[i]); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</deprecatedFeatures>\n"); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 0f1a9d13f5..bcedd96f4e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3374,7 +3374,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *model_info) g_free(model_info->props[i].value.string); } - g_strfreev(model_info->deprecated_props); + g_strfreev(model_info->full_dep_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3419,7 +3419,7 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) } } - copy->deprecated_props = g_strdupv(orig->deprecated_props); + copy->full_dep_props = g_strdupv(orig->full_dep_props); return copy; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index dd038f2775..6cd9329787 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1430,7 +1430,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUProperty *props; - GStrv deprecated_props; + GStrv full_dep_props; /* deprecated properties resulting from a full model expansion */ bool migratability; }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a4cbc222a8..e911c1929c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5401,7 +5401,7 @@ qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, if (cpu_deprecated_props && virJSONValueArraySize(cpu_deprecated_props) && - (!(expanded_model->deprecated_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { + (!(expanded_model->full_dep_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { return -1; } -- 2.51.1
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> On 11/20/25 23:34, Collin Walling wrote:
The current query of deprecated properties is the result of a full model expansion. Rename the field to reflect this.
Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 22 +++++++++++----------- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 205bf3d0b8..bcc7c5b602 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3275,9 +3275,9 @@ virQEMUCapsProbeFullDeprecatedProperties(qemuMonitor *mon, cpu, true, false, false, &propsInfo) < 0) return -1;
- if (propsInfo && propsInfo->deprecated_props) { + if (propsInfo && propsInfo->full_dep_props) { g_strfreev(*props); - *props = g_steal_pointer(&propsInfo->deprecated_props); + *props = g_steal_pointer(&propsInfo->full_dep_props); }
return 0; @@ -3366,7 +3366,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, }
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS) && - virQEMUCapsProbeFullDeprecatedProperties(mon, cpu, &modelInfo->deprecated_props) < 0) + virQEMUCapsProbeFullDeprecatedProperties(mon, cpu, &modelInfo->full_dep_props) < 0) return -1;
if (virQEMUCapsTypeIsAccelerated(virtType) && @@ -3441,11 +3441,11 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps,
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
- if (!modelInfo || !modelInfo->deprecated_props) + if (!modelInfo || !modelInfo->full_dep_props) return;
- for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { - virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], policy); + for (i = 0; i < g_strv_length(modelInfo->full_dep_props); i++) { + virCPUDefUpdateFeature(cpu, modelInfo->full_dep_props[i], policy); } }
@@ -4210,12 +4210,12 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, if ((deprecated_props = virXPathNode("./deprecatedFeatures", ctxt))) { g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(deprecated_props, NULL);
- hostCPU->deprecated_props = g_new0(char *, props->len + 1); + hostCPU->full_dep_props = g_new0(char *, props->len + 1);
for (i = 0; i < props->len; i++) { xmlNodePtr prop = g_ptr_array_index(props, i);
- if (!(hostCPU->deprecated_props[i] = virXMLPropString(prop, "name"))) { + if (!(hostCPU->full_dep_props[i] = virXMLPropString(prop, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing 'name' attribute for a host CPU model deprecated property in QEMU capabilities cache")); return -1; @@ -4979,13 +4979,13 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); }
- if (model->deprecated_props) { + if (model->full_dep_props) { virBufferAddLit(buf, "<deprecatedFeatures>\n"); virBufferAdjustIndent(buf, 2);
- for (i = 0; i < g_strv_length(model->deprecated_props); i++) + for (i = 0; i < g_strv_length(model->full_dep_props); i++) virBufferAsprintf(buf, "<property name='%s'/>\n", - model->deprecated_props[i]); + model->full_dep_props[i]);
virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</deprecatedFeatures>\n"); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 0f1a9d13f5..bcedd96f4e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3374,7 +3374,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *model_info) g_free(model_info->props[i].value.string); }
- g_strfreev(model_info->deprecated_props); + g_strfreev(model_info->full_dep_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3419,7 +3419,7 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) } }
- copy->deprecated_props = g_strdupv(orig->deprecated_props); + copy->full_dep_props = g_strdupv(orig->full_dep_props);
return copy; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index dd038f2775..6cd9329787 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1430,7 +1430,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUProperty *props; - GStrv deprecated_props; + GStrv full_dep_props; /* deprecated properties resulting from a full model expansion */ bool migratability; };
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a4cbc222a8..e911c1929c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5401,7 +5401,7 @@ qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name,
if (cpu_deprecated_props && virJSONValueArraySize(cpu_deprecated_props) && - (!(expanded_model->deprecated_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { + (!(expanded_model->full_dep_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { return -1; }
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 81 ++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index bcc7c5b602..3243ba8ad3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4106,13 +4106,40 @@ virQEMUCapsSetCPUModelInfo(virQEMUCaps *qemuCaps, } +static int +virQEMUCapsParseHostCPUModelInfoDepFeats(xmlXPathContextPtr ctxt, + GStrv *dep_props, + const char *xpath) +{ + xmlNodePtr node; + size_t i; + + if ((node = virXPathNode(xpath, ctxt))) { + g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(node, NULL); + + *dep_props = g_new0(char *, props->len + 1); + + for (i = 0; i < props->len; i++) { + xmlNodePtr prop = g_ptr_array_index(props, i); + + if (!((*dep_props)[i] = virXMLPropString(prop, "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'name' attribute for a host CPU model deprecated property in QEMU capabilities cache")); + return -1; + } + } + } + + return 0; +} + + static int virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, xmlXPathContextPtr ctxt, const char *typeStr) { xmlNodePtr hostCPUNode; - xmlNodePtr deprecated_props; g_autofree xmlNodePtr *nodes = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU = NULL; @@ -4206,21 +4233,9 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, } ctxt->node = hostCPUNode; - - if ((deprecated_props = virXPathNode("./deprecatedFeatures", ctxt))) { - g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(deprecated_props, NULL); - - hostCPU->full_dep_props = g_new0(char *, props->len + 1); - - for (i = 0; i < props->len; i++) { - xmlNodePtr prop = g_ptr_array_index(props, i); - - if (!(hostCPU->full_dep_props[i] = virXMLPropString(prop, "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing 'name' attribute for a host CPU model deprecated property in QEMU capabilities cache")); - return -1; - } - } + if (virQEMUCapsParseHostCPUModelInfoDepFeats(ctxt, &hostCPU->full_dep_props, + "./deprecatedFeatures") < 0) { + return -1; } caps->hostCPU.info = g_steal_pointer(&hostCPU); @@ -4930,6 +4945,27 @@ virQEMUCapsLoadCache(virArch hostArch, } +static void +virQEMUCapsFormatHostCPUModelInfoDepFeats(virBuffer *buf, + GStrv props, + const char *xmlStr) +{ + size_t i; + + if (!props) + return; + + virBufferAsprintf(buf, "<%s>\n", xmlStr); + virBufferAdjustIndent(buf, 2); + + for (i = 0; i < g_strv_length(props); i++) + virBufferAsprintf(buf, "<property name='%s'/>\n", props[i]); + + virBufferAdjustIndent(buf, -2); + virBufferAsprintf(buf, "</%s>\n", xmlStr); +} + + static void virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBuffer *buf, @@ -4979,17 +5015,8 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); } - if (model->full_dep_props) { - virBufferAddLit(buf, "<deprecatedFeatures>\n"); - virBufferAdjustIndent(buf, 2); - - for (i = 0; i < g_strv_length(model->full_dep_props); i++) - virBufferAsprintf(buf, "<property name='%s'/>\n", - model->full_dep_props[i]); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "</deprecatedFeatures>\n"); - } + virQEMUCapsFormatHostCPUModelInfoDepFeats(buf, model->full_dep_props, + "deprecatedFeatures"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</hostCPU>\n"); -- 2.51.1
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> On 11/20/25 23:34, Collin Walling wrote:
Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 81 ++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 27 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index bcc7c5b602..3243ba8ad3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4106,13 +4106,40 @@ virQEMUCapsSetCPUModelInfo(virQEMUCaps *qemuCaps, }
+static int +virQEMUCapsParseHostCPUModelInfoDepFeats(xmlXPathContextPtr ctxt, + GStrv *dep_props, + const char *xpath) +{ + xmlNodePtr node; + size_t i; + + if ((node = virXPathNode(xpath, ctxt))) { + g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(node, NULL); + + *dep_props = g_new0(char *, props->len + 1); + + for (i = 0; i < props->len; i++) { + xmlNodePtr prop = g_ptr_array_index(props, i); + + if (!((*dep_props)[i] = virXMLPropString(prop, "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'name' attribute for a host CPU model deprecated property in QEMU capabilities cache")); + return -1; + } + } + } + + return 0; +} + + static int virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, xmlXPathContextPtr ctxt, const char *typeStr) { xmlNodePtr hostCPUNode; - xmlNodePtr deprecated_props; g_autofree xmlNodePtr *nodes = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU = NULL; @@ -4206,21 +4233,9 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, }
ctxt->node = hostCPUNode; - - if ((deprecated_props = virXPathNode("./deprecatedFeatures", ctxt))) { - g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(deprecated_props, NULL); - - hostCPU->full_dep_props = g_new0(char *, props->len + 1); - - for (i = 0; i < props->len; i++) { - xmlNodePtr prop = g_ptr_array_index(props, i); - - if (!(hostCPU->full_dep_props[i] = virXMLPropString(prop, "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing 'name' attribute for a host CPU model deprecated property in QEMU capabilities cache")); - return -1; - } - } + if (virQEMUCapsParseHostCPUModelInfoDepFeats(ctxt, &hostCPU->full_dep_props, + "./deprecatedFeatures") < 0) { + return -1; }
caps->hostCPU.info = g_steal_pointer(&hostCPU); @@ -4930,6 +4945,27 @@ virQEMUCapsLoadCache(virArch hostArch, }
+static void +virQEMUCapsFormatHostCPUModelInfoDepFeats(virBuffer *buf, + GStrv props, + const char *xmlStr) +{ + size_t i; + + if (!props) + return; + + virBufferAsprintf(buf, "<%s>\n", xmlStr); + virBufferAdjustIndent(buf, 2); + + for (i = 0; i < g_strv_length(props); i++) + virBufferAsprintf(buf, "<property name='%s'/>\n", props[i]); + + virBufferAdjustIndent(buf, -2); + virBufferAsprintf(buf, "</%s>\n", xmlStr); +} + + static void virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBuffer *buf, @@ -4979,17 +5015,8 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); }
- if (model->full_dep_props) { - virBufferAddLit(buf, "<deprecatedFeatures>\n"); - virBufferAdjustIndent(buf, 2); - - for (i = 0; i < g_strv_length(model->full_dep_props); i++) - virBufferAsprintf(buf, "<property name='%s'/>\n", - model->full_dep_props[i]); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "</deprecatedFeatures>\n"); - } + virQEMUCapsFormatHostCPUModelInfoDepFeats(buf, model->full_dep_props, + "deprecatedFeatures");
virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</hostCPU>\n");
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
When performing a static CPU model expansion, the reported list of deprecated features will reflect the features which are currently enabled on the CPU model. Retrieve this subset and store them as static deprecated properties for the model info, and as host deprecated features in the cache. Note that this list may exclude items that are shown in the <deprecatedFeatures> list, as some feature support has been dropped by hardware (e.g. csske). Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 6 +++++- src/qemu/qemu_monitor.c | 2 ++ src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 17 +++++++++++++++-- .../qemucapabilitiesdata/caps_10.0.0_s390x.xml | 6 ++++++ tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 ++++++ tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 ++++++ 7 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3243ba8ad3..2dfdedfa1a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4234,7 +4234,9 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, ctxt->node = hostCPUNode; if (virQEMUCapsParseHostCPUModelInfoDepFeats(ctxt, &hostCPU->full_dep_props, - "./deprecatedFeatures") < 0) { + "./deprecatedFeatures") < 0 || + virQEMUCapsParseHostCPUModelInfoDepFeats(ctxt, &hostCPU->static_dep_props, + "./hostDeprecatedFeatures") < 0) { return -1; } @@ -5017,6 +5019,8 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virQEMUCapsFormatHostCPUModelInfoDepFeats(buf, model->full_dep_props, "deprecatedFeatures"); + virQEMUCapsFormatHostCPUModelInfoDepFeats(buf, model->static_dep_props, + "hostDeprecatedFeatures"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</hostCPU>\n"); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index bcedd96f4e..504500c864 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3375,6 +3375,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *model_info) } g_strfreev(model_info->full_dep_props); + g_strfreev(model_info->static_dep_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3420,6 +3421,7 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) } copy->full_dep_props = g_strdupv(orig->full_dep_props); + copy->static_dep_props = g_strdupv(orig->static_dep_props); return copy; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6cd9329787..d096f474c1 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1431,6 +1431,7 @@ struct _qemuMonitorCPUModelInfo { size_t nprops; qemuMonitorCPUProperty *props; GStrv full_dep_props; /* deprecated properties resulting from a full model expansion */ + GStrv static_dep_props; /* deprecated properties resulting from a static model expansion */ bool migratability; }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e911c1929c..494d7ef515 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5392,19 +5392,32 @@ static int qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, virJSONValue *cpu_props, virJSONValue *cpu_deprecated_props, + qemuMonitorCPUModelExpansionType type, qemuMonitorCPUModelInfo **model_info) { g_autoptr(qemuMonitorCPUModelInfo) expanded_model = NULL; + GStrv dep_props = NULL; if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model) < 0) return -1; if (cpu_deprecated_props && virJSONValueArraySize(cpu_deprecated_props) && - (!(expanded_model->full_dep_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { + (!(dep_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { return -1; } + switch (type) { + case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC: + expanded_model->static_dep_props = dep_props; + break; + + case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL: + case QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL: + expanded_model->full_dep_props = dep_props; + break; + } + *model_info = g_steal_pointer(&expanded_model); return 0; } @@ -5509,7 +5522,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props, cpu_deprecated_props, - model_info); + type, model_info); } diff --git a/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml b/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml index 0e834544af..82a66a6524 100644 --- a/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml @@ -202,6 +202,12 @@ <property name='cte'/> <property name='csske'/> </deprecatedFeatures> + <hostDeprecatedFeatures> + <property name='bpb'/> + <property name='te'/> + <property name='cte'/> + <property name='csske'/> + </hostDeprecatedFeatures> </hostCPU> <cpu type='kvm' name='z13' typename='z13-s390x-cpu' usable='yes'/> <cpu type='kvm' name='z990.3' typename='z990.3-s390x-cpu' usable='yes'/> diff --git a/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml b/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml index bdbb60a097..b961f79808 100644 --- a/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml @@ -192,6 +192,12 @@ <property name='cte'/> <property name='csske'/> </deprecatedFeatures> + <hostDeprecatedFeatures> + <property name='bpb'/> + <property name='te'/> + <property name='cte'/> + <property name='csske'/> + </hostDeprecatedFeatures> </hostCPU> <cpu type='kvm' name='z13' typename='z13-s390x-cpu' usable='yes'/> <cpu type='kvm' name='z990.3' typename='z990.3-s390x-cpu' usable='yes'/> diff --git a/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml b/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml index 8da55b1c4e..e9f79261f7 100644 --- a/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml @@ -195,6 +195,12 @@ <property name='cte'/> <property name='csske'/> </deprecatedFeatures> + <hostDeprecatedFeatures> + <property name='bpb'/> + <property name='te'/> + <property name='cte'/> + <property name='csske'/> + </hostDeprecatedFeatures> </hostCPU> <cpu type='kvm' name='z13' typename='z13-s390x-cpu' usable='yes'/> <cpu type='kvm' name='z990.3' typename='z990.3-s390x-cpu' usable='yes'/> -- 2.51.1
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> On 11/20/25 23:34, Collin Walling wrote:
When performing a static CPU model expansion, the reported list of deprecated features will reflect the features which are currently enabled on the CPU model.
Retrieve this subset and store them as static deprecated properties for the model info, and as host deprecated features in the cache.
Note that this list may exclude items that are shown in the <deprecatedFeatures> list, as some feature support has been dropped by hardware (e.g. csske).
Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 6 +++++- src/qemu/qemu_monitor.c | 2 ++ src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 17 +++++++++++++++-- .../qemucapabilitiesdata/caps_10.0.0_s390x.xml | 6 ++++++ tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 ++++++ tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 ++++++ 7 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3243ba8ad3..2dfdedfa1a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4234,7 +4234,9 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
ctxt->node = hostCPUNode; if (virQEMUCapsParseHostCPUModelInfoDepFeats(ctxt, &hostCPU->full_dep_props, - "./deprecatedFeatures") < 0) { + "./deprecatedFeatures") < 0 || + virQEMUCapsParseHostCPUModelInfoDepFeats(ctxt, &hostCPU->static_dep_props, + "./hostDeprecatedFeatures") < 0) { return -1; }
@@ -5017,6 +5019,8 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps,
virQEMUCapsFormatHostCPUModelInfoDepFeats(buf, model->full_dep_props, "deprecatedFeatures"); + virQEMUCapsFormatHostCPUModelInfoDepFeats(buf, model->static_dep_props, + "hostDeprecatedFeatures");
virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</hostCPU>\n"); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index bcedd96f4e..504500c864 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3375,6 +3375,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *model_info) }
g_strfreev(model_info->full_dep_props); + g_strfreev(model_info->static_dep_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3420,6 +3421,7 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) }
copy->full_dep_props = g_strdupv(orig->full_dep_props); + copy->static_dep_props = g_strdupv(orig->static_dep_props);
return copy; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6cd9329787..d096f474c1 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1431,6 +1431,7 @@ struct _qemuMonitorCPUModelInfo { size_t nprops; qemuMonitorCPUProperty *props; GStrv full_dep_props; /* deprecated properties resulting from a full model expansion */ + GStrv static_dep_props; /* deprecated properties resulting from a static model expansion */ bool migratability; };
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e911c1929c..494d7ef515 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5392,19 +5392,32 @@ static int qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, virJSONValue *cpu_props, virJSONValue *cpu_deprecated_props, + qemuMonitorCPUModelExpansionType type, qemuMonitorCPUModelInfo **model_info) { g_autoptr(qemuMonitorCPUModelInfo) expanded_model = NULL; + GStrv dep_props = NULL;
if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model) < 0) return -1;
if (cpu_deprecated_props && virJSONValueArraySize(cpu_deprecated_props) && - (!(expanded_model->full_dep_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { + (!(dep_props = virJSONValueArrayToStringList(cpu_deprecated_props)))) { return -1; }
+ switch (type) { + case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC: + expanded_model->static_dep_props = dep_props; + break; + + case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL: + case QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL: + expanded_model->full_dep_props = dep_props; + break; + } + *model_info = g_steal_pointer(&expanded_model); return 0; } @@ -5509,7 +5522,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon,
return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props, cpu_deprecated_props, - model_info); + type, model_info); }
diff --git a/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml b/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml index 0e834544af..82a66a6524 100644 --- a/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_10.0.0_s390x.xml @@ -202,6 +202,12 @@ <property name='cte'/> <property name='csske'/> </deprecatedFeatures> + <hostDeprecatedFeatures> + <property name='bpb'/> + <property name='te'/> + <property name='cte'/> + <property name='csske'/> + </hostDeprecatedFeatures> </hostCPU> <cpu type='kvm' name='z13' typename='z13-s390x-cpu' usable='yes'/> <cpu type='kvm' name='z990.3' typename='z990.3-s390x-cpu' usable='yes'/> diff --git a/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml b/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml index bdbb60a097..b961f79808 100644 --- a/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml @@ -192,6 +192,12 @@ <property name='cte'/> <property name='csske'/> </deprecatedFeatures> + <hostDeprecatedFeatures> + <property name='bpb'/> + <property name='te'/> + <property name='cte'/> + <property name='csske'/> + </hostDeprecatedFeatures> </hostCPU> <cpu type='kvm' name='z13' typename='z13-s390x-cpu' usable='yes'/> <cpu type='kvm' name='z990.3' typename='z990.3-s390x-cpu' usable='yes'/> diff --git a/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml b/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml index 8da55b1c4e..e9f79261f7 100644 --- a/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml @@ -195,6 +195,12 @@ <property name='cte'/> <property name='csske'/> </deprecatedFeatures> + <hostDeprecatedFeatures> + <property name='bpb'/> + <property name='te'/> + <property name='cte'/> + <property name='csske'/> + </hostDeprecatedFeatures> </hostCPU> <cpu type='kvm' name='z13' typename='z13-s390x-cpu' usable='yes'/> <cpu type='kvm' name='z990.3' typename='z990.3-s390x-cpu' usable='yes'/>
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
When updating the guest CPU model and the deprecated_features attribute is set to on, only enable the features the model can actually enable. While host-model would normally just enable these features without intervention (and without the presence of the deprecated_features attribute), custom models would see no changes to their feature set without these changes. This is useful for e.g. testing CPU models. Fixes: f279ea36 (qemu: process: refactor deprecated features code) Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2dfdedfa1a..cee7a0f5ef 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3437,15 +3437,24 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virCPUFeaturePolicy policy) { qemuMonitorCPUModelInfo *modelInfo; + GStrv props; size_t i; modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType); - if (!modelInfo || !modelInfo->full_dep_props) + if (!modelInfo) return; - for (i = 0; i < g_strv_length(modelInfo->full_dep_props); i++) { - virCPUDefUpdateFeature(cpu, modelInfo->full_dep_props[i], policy); + /* Only allow policy "require" on features that are actually + * supported on the CPU model */ + if (policy == VIR_CPU_FEATURE_REQUIRE) { + props = modelInfo->static_dep_props; + } else { + props = modelInfo->full_dep_props; + } + + for (i = 0; i < g_strv_length(props); i++) { + virCPUDefUpdateFeature(cpu, props[i], policy); } } -- 2.51.1
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> On 11/20/25 23:34, Collin Walling wrote:
When updating the guest CPU model and the deprecated_features attribute is set to on, only enable the features the model can actually enable.
While host-model would normally just enable these features without intervention (and without the presence of the deprecated_features attribute), custom models would see no changes to their feature set without these changes.
This is useful for e.g. testing CPU models.
Fixes: f279ea36 (qemu: process: refactor deprecated features code) Signed-off-by: Collin Walling <walling@linux.ibm.com> --- src/qemu/qemu_capabilities.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2dfdedfa1a..cee7a0f5ef 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3437,15 +3437,24 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virCPUFeaturePolicy policy) { qemuMonitorCPUModelInfo *modelInfo; + GStrv props; size_t i;
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
- if (!modelInfo || !modelInfo->full_dep_props) + if (!modelInfo) return;
- for (i = 0; i < g_strv_length(modelInfo->full_dep_props); i++) { - virCPUDefUpdateFeature(cpu, modelInfo->full_dep_props[i], policy); + /* Only allow policy "require" on features that are actually + * supported on the CPU model */ + if (policy == VIR_CPU_FEATURE_REQUIRE) { + props = modelInfo->static_dep_props; + } else { + props = modelInfo->full_dep_props; + } + + for (i = 0; i < g_strv_length(props); i++) { + virCPUDefUpdateFeature(cpu, props[i], policy); } }
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
On Thu, Nov 20, 2025 at 17:34:39 -0500, Collin Walling wrote:
Currently, when setting the deprecated_features attribute to 'on', all known deprecated features will be enabled for the CPU model, including ones that are *not* supported by the model.
These patches query an additional set of deprecated features by performing a CPU model expansion on host-model with type "static". The list of deprecated features reported from this command will reflect features that may be enabled on the model without error. Now, when a user specifies deprecated_features='on' in the domain XML, only the features that are still supported by the model are requested to be turned on for the guest.
This can be helpful for e.g. tests that may wish to check CPU model compatability in certain environments.
Collin Walling (4): qemu: rename modelinfo's deprecated_props to full_dep_props qemu: refactor load/format of deprecated features qemu: query and cache static/host deprecated features qemu: only allow enabling deprecated features that are supported
src/qemu/qemu_capabilities.c | 106 ++++++++++++------ src/qemu/qemu_monitor.c | 6 +- src/qemu/qemu_monitor.h | 3 +- src/qemu/qemu_monitor_json.c | 17 ++- .../caps_10.0.0_s390x.xml | 6 + .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 + .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 + 7 files changed, 112 insertions(+), 38 deletions(-)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
participants (3)
-
Boris Fiuczynski -
Collin Walling -
Jiri Denemark