[RFC PATCH 0/1] support deprecated-props from query-cpu-model-expansion
Overview QEMU will soon support reporting an optional array of deprecated features for an expanded CPU model via the query-cpu-model-expansion command. The intended use of this data is to make it easier for a user to define a CPU model with features flagged as deprecated set to disabled, thus rendering the guest migratable to future hardware that will out-right drop support for said features. Attached to this cover letter is only half of the bigger picture. I've updated the CPU model expansion ABI to parse the new array (if it's available) and store the result in a string list within the qemuMonitorCPUModelInfo struct. I also propose an approach on how to store/retrieve the list of deprecated features in the qemuCaps cache file. All feedback on this patch is certainly welcome. Please note: I do not provide any updates to the respective qemuCaps tests right now. The main goal of this post is to discuss the other half of the design: reporting and enabling a CPU model with deprecated features disabled. I believe the ideal solution involves a way for the user to easily configure their guest with this new data. Two ideas I currently have are outlined below. Other approaches are encouraged. Notes = - In my example below, I am running on a z14.2 machine. - The features that are flagged as deprecated for this model are: bpb, csske, cte, te. - The discussion regarding the QEMU changes can be found here: https://mail.gnu.org/archive/html/qemu-devel/2024-04/msg04605.html Example of Desired Changes == Here is what I'd like the resulting guest's transient XML to look like for the section (I have trimmed the features list for brevity): ... z14.2-base ... *** *** *** *** ... Ideas = New Host CPU Model -- Create a new CPU model that is a mirror of the host CPU model with deprecated features turned off. Let's call this model "host-recommended". A user may define this model in the guest XML as they would any other CPU model: Just as how host-model works, anything defined nested in the tag will be ignored. This model could potentially be listed in the domcapabilities output after the host-model: ... ... ... ... New Nested Element Under -- Create a new optional XML element nested under the tag that may be used to disable deprecated features. This approach is more explicit compared to creating a new CPU model, and allows the user to disable these features when defining a specific model other than host-model. Here is an example of what the guest's defined XML for the CPU could look like: off However, a conflict arises with this approach: parameter priority. It would need to be discussed what the expected behavior should be if a user defines a guest with both a mode to disable deprecated features and any deprecated features listed with the 'require' policy, e.g.: z13.2-base off Another conflict is setting this option to "on" would have no effect on the CPU model (I can't think of a reason why someone would want to explicitly enable these features). This may not communicate well to the user. To report these features, a tag could be added to the domcapabilities output using the same format I use in my proposed patch for the qemu capabilities file: ... ... ... Please let me know your thoughts. Once an approach is agreed upon, I will begin development. Collin Walling (1): qemu: monitor: parse deprecated-props from query-cpu-model-expansion response 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(-) -- 2.43.0 ___ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-le...@lists.libvirt.org
[RFC PATCH 1/1] qemu: monitor: parse deprecated-props from query-cpu-model-expansion response
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 element using the following format: Signed-off-by: Collin Walling --- 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, "\n"); +virBufferAdjustIndent(buf, 2); + +for (i = 0; i < model->ndeprecated_props; i++) +virBufferAsprintf(buf, "\n", +model->deprecated_props[i]); + +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, "\n"); +} + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\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
Re: [RFC PATCH 0/1] support deprecated-props from query-cpu-model-expansion
Polite ping. Would like some feedback / discussion on this before I move forward. Thanks! :)
Re: [RFC PATCH 0/1] support deprecated-props from query-cpu-model-expansion
On 6/3/24 10:40 AM, Jiri Denemark wrote: > On Tue, May 07, 2024 at 18:24:20 -0400, Collin Walling wrote: >> QEMU will soon support reporting an optional array of deprecated >> features for an expanded CPU model via the query-cpu-model-expansion >> command. The intended use of this data is to make it easier for a >> user to define a CPU model with features flagged as deprecated set to >> disabled, thus rendering the guest migratable to future hardware that >> will out-right drop support for said features. > > So is the list of deprecated features a static list common to all CPU > models or does it depend on the CPU model? If it's static getting the > list via another QMP command (in addition to query-cpu-model-expansion) > would make sense. I would expect the query-cpu-model-expansion to limit > deprecated features to only those actually used by the expanded CPU > model, which would make constructing a complete list quite hard. > > On the other hand, if the deprecated features depend on a CPU model, > we'd need a way to list all CPU models and their deprecated features to > be able to report such info in domain capabilities XML. Ideally without > having to call query-cpu-model-expansion on every single CPU model. > >> Notes >> = >> >> - In my example below, I am running on a z14.2 machine. >> >> - The features that are flagged as deprecated for this model are: bpb, >> csske, cte, te. > > OK, so the deprecated features seem to depend on a specific CPU model. > Does query-cpu-model-expansion list them even if they are not specified > in the CPU model we want to expand? If not, we need another interface to > be able to report this info. > The QEMU portion is designed for s390x such that there is a static list of hardcoded feature bits that are flagged for deprecation. This list can be updated in follow-up patches as more features need to be flagged. The query-cpu-model-expansion *response* has been modified to now include an /optional/ "deprecated props" string array (no additional parameter is required in the query JSON). This array will be present if and only if there is data to be reported. If an architecture does not support reporting deprecated features, or if there are no deprecated features to report, then array is simply omitted from the response. The deprecated features are filtered against the full-expansion features for the particular CPU model. In the example for a z14, we would expect all four currently deprecated features reported: bpb, csske, cte, and te, since those features are part of the z14 full expansion. On an older model, say a z900, you'd only see bpb because the others are not present in the full-expansion. >> Ideas >> = >> >> New Host CPU Model >> -- >> >> Create a new CPU model that is a mirror of the host CPU model with >> deprecated features turned off. Let's call this model "host-recommended". >> A user may define this model in the guest XML as they would any other CPU >> model: >> >> >> >> Just as how host-model works, anything defined nested in the tag will >> be ignored. >> >> This model could potentially be listed in the domcapabilities output after >> the host-model: >> >> >> >> ... >> >> ... >> >> ... >> >> >> ... >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> New Nested Element Under >> -- >> >> Create a new optional XML element nested under the tag that may be >> used to disable deprecated features. This approach is more explicit >> compared to creating a new CPU model, and allows the user to disable these >> features when defining a specific model other than host-model. Here is an >> example of what the guest's defined XML for the CPU could look like: >> >> >> off >> >> >> However, a conflict arises with this approach: parameter priority. It would >> need to be discussed what the expected behavior should be if a user defines >> a guest with both a mode to disable deprecated features and any deprecated >> features listed with the 'require' policy, e.g.: >> >> >> z13.2-base >> >> off >> >> >> >> Another conflict is setting this option to "on" would have no effect on the >> CPU model (I can't think o
Re: [RFC PATCH 0/1] support deprecated-props from query-cpu-model-expansion
On 6/3/24 1:53 PM, Daniel P. Berrangé wrote: > On Tue, May 07, 2024 at 06:24:20PM -0400, Collin Walling wrote: >> Notes >> = >> >> - In my example below, I am running on a z14.2 machine. >> >> - The features that are flagged as deprecated for this model are: bpb, >> csske, cte, te. >> >> - The discussion regarding the QEMU changes can be found here: >> https://mail.gnu.org/archive/html/qemu-devel/2024-04/msg04605.html >> >> >> Example of Desired Changes >> == >> >> Here is what I'd like the resulting guest's transient XML to look like for >> the section (I have trimmed the features list for brevity): >> >> ... >> >> z14.2-base >> >> >> >> ... >> *** >> >> *** >> >> >> >> >> >>*** >> >> *** >> >> ... > >> New Host CPU Model >> -- >> >> Create a new CPU model that is a mirror of the host CPU model with >> deprecated features turned off. Let's call this model "host-recommended". >> A user may define this model in the guest XML as they would any other >> CPU model: >> >> >> >> Just as how host-model works, anything defined nested in the tag will >> be ignored. >> >> This model could potentially be listed in the domcapabilities output after >> the host-model: >> >> >> >> ... >> >> ... >> >> ... >> >> >> ... >> >> >> >> >> >> >> >> >> >> >> >> > > Downside of a new "host-recommended" model is that we now have the > task of wiring it up into various mgmt applications. > Fair. I believe Jiri as also against this new model as well. Let's nix adding a new model and discuss other approaches. >> New Nested Element Under >> -- >> >> Create a new optional XML element nested under the tag that may be >> used to disable deprecated features. This approach is more explicit >> compared to creating a new CPU model, and allows the user to disable these >> features when defining a specific model other than host-model. Here is an >> example of what the guest's defined XML for the CPU could look like: >> >> >> off >> >> >> However, a conflict arises with this approach: parameter priority. It would >> need to be discussed what the expected behavior should be if a user defines >> a guest with both a mode to disable deprecated features and any deprecated >> features listed with the 'require' policy, e.g.: >> >> >> z13.2-base >> >> off >> >> > > IMHO 'deprecate_features' controls the initial expansion > of the 'host-model', and then '' fine tunes it. > > IOW, your example here disables all the deprecated features > by default, and the user has then turned back on the csske > deprecated feature. > > I wouldn't call this a conflict - its just a documentation > task to clarify the prioritization. > Fair enough. As long as it the behavior is consistent and documented, then all should be well with the world. >> Another conflict is setting this option to "on" would have >> no effect on the CPU model (I can't think of a reason why >> someone would want to explicitly enable these features). >> This may not communicate well to the user. > > Well it depends on what we declare the "default" behaviour > to be. > > We only guarantee the host-model -> custom expansion within > the scope of a running guest. > > IOW, if you boot a guest, shut it down, boot it again, we > do NOT guarantee that you'll get the same expansion both > times. > > With this in mind, we could take the view that disabling > deprecated features should be the default behaviour, and > thus an option to turn "on" deprecated features becomes > relevant. > > In theory this could even be a host level tunable in > qemu.conf of whether the host admin wants deprecated > features skipped by default or not. > > Either way, the existance of the > field on the *live* XML, will give a clear statement of > what behaviour libv
Re: [RFC PATCH 0/1] support deprecated-props from query-cpu-model-expansion
On 6/13/24 7:22 AM, Jiri Denemark wrote: > On Tue, Jun 04, 2024 at 11:42:25 -0400, Collin Walling wrote: >> The QEMU portion is designed for s390x such that there is a static list >> of hardcoded feature bits that are flagged for deprecation. This list >> can be updated in follow-up patches as more features need to be flagged. > > Good, a single static list should definitely be easier to handle. > >> The query-cpu-model-expansion *response* has been modified to now >> include an /optional/ "deprecated props" string array (no additional >> parameter is required in the query JSON). This array will be present if >> and only if there is data to be reported. If an architecture does not >> support reporting deprecated features, or if there are no deprecated >> features to report, then array is simply omitted from the response. >> >> The deprecated features are filtered against the full-expansion features >> for the particular CPU model. In the example for a z14, we would expect >> all four currently deprecated features reported: bpb, csske, cte, and >> te, since those features are part of the z14 full expansion. On an >> older model, say a z900, you'd only see bpb because the others are not >> present in the full-expansion. > > In that case I think it would be nice if QEMU provided a way of getting > the list itself without any filtering. Mainly to make sure we're > providing a completely list for users which may decide to avoid using > such features in their non-host-model CPU definitions. And I can imagine > management layers might want to get a complete list too. > Okay. I will need to bring this up on the QEMU devel list to figure out the best approach to report this list. I do not believe this hinders development for designing a way for a user to specify host-model with deprecated features disabled, but I understand that this would be valuable to users who want to define a custom model with deprecated features off and management applications may want this list. I'll mention the action items for this request at the bottom of this email. >>>> Another conflict is setting this option to "on" would have no >>>> effect on the CPU model (I can't think of a reason why someone >>>> would want to explicitly enable these features). This may not >>>> communicate well to the user. >>> >>> I think have a separate configuration is better as it does not limit the >>> used to just a single CPU model. But a nested element with a text node >>> looks strange. An optional attribute for the element would be >>> better. >>>> For host-model the expected behavior would be to either keep or >>> drop deprecated features from the CPU definition. When combined with >>> custom CPU mode where such feature may be already present I can imagine >>> three different options. Either keep deprecated features (that is do >>> nothing, just like we do now), drop such features silently, or fail to >>> start a domain in case the definition uses a deprecated feature. >> >> I fear the last option may break some things? > > The idea is the behavior would be controllable via a special value in > that attribute, which a used would have to explicitly specify to get > such behavior. In other words, a user would provide a custom CPU > definition and ask for deprecated features to be removed no matter what > they are currently. But I don't think we need to care about it now > because... > >>> We could even create the attribute, but limit it only to host-model, >>> which would be mostly equivalent to your "host-recomended" mode, but >>> extensible to other modes in the future. >> >> I think this is the better approach. > > Agreed. Just do the minimal required thing while making it extensible. > Sounds good! >> In tandem to your suggestion to add a new attribute to the cpu element, >> a quick mock-up of it could look like this: >> >> > > Right. Although you may have fun coming with an attribute name, because > we are not very consistent with naming multi-word attributes. Some > people don't like underscores while others don't like camelCase :-) > Anyway, I think you should at least be consistent and use a single name > for the attribute in domain XML and the element in domcapabilities XML. > Sounds fun! I'll try to come up with a reasonable name on the first run and discuss afterwards. >>>> To report these features, a tag could be >>>> added to the domcapabilities output using the same format I use in >>>> my proposed pat
[PATCH v1 0/5] Allow Guest CPU Model with Deprecated Features Disabled
Add support for libvirt to query and cache an array of deprecated CPU features (aka CPU properties) for the host-model. This data is queried via a full query-cpu-model-expansion and cached in the QEMU capabilities file. This model expansion will depend on the availability of the "deprecated-props" field resulting from a query-cpu-model-expansion command. Currently, only s390x supports this field. The purpose of these patches is to make it easy for users to create guests with a CPU model that will be compatible & migratable with future hardware. An updated host CPU model with deprecated features paired with the policy "disable" may be visable via an update to the virsh domcapabilities command with the --disable-deprecated-features flag. An example is shown below. Note: other CPU model queries (e.g. baseline and comparison) currently do not consider deprecated features, as their outputs do not consider feature policy. If implementation is desired, it will require a discussion on how these commands should report policies. Examples: virsh domcapabilities --disable-deprecated-features e.g. output (trimmed): z14.2-base A domain may be defined with a new XML attribute, deprecated_features='on|off': e.g. after guest has started (trimmed): z14.2-base Collin Walling (5): qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions qemu: parse deprecated-props from query-cpu-model-expansion response qemu_capabilities: query deprecated features for host-model virsh: add --disable-deprecated-features flag to domcapabilities conf: add deprecated_features attribute docs/manpages/virsh.rst | 6 + include/libvirt/libvirt-domain.h | 12 + src/conf/cpu_conf.c | 10 + src/conf/cpu_conf.h | 1 + src/conf/schemas/cputypes.rng | 12 + src/libvirt-domain.c | 2 +- src/qemu/qemu_capabilities.c | 89 + src/qemu/qemu_capabilities.h | 4 + src/qemu/qemu_driver.c| 8 +- src/qemu/qemu_monitor.c | 10 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 64 +++- src/qemu/qemu_process.c | 4 + .../caps_9.1.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 13 + .../caps_9.2.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 13 + tools/virsh-host.c| 9 +- 18 files changed, 940 insertions(+), 14 deletions(-) -- 2.45.1
[PATCH v1 5/5] conf: add deprecated_features attribute
Add a new a attribute, deprecated_features='on|off' to the element. This is used to toggle features flagged as deprecated on the CPU model on or off. When this attribute is paired with 'on', deprecated features will not be filtered. When paired with 'off', any CPU features that are flagged as deprecated will be listed under the CPU model with the 'disable' policy. Example: The absence of this attribute is equivalent to the 'on' option. The deprecated features that will populate the domain XML are the same features that result in the virsh domcapabilities command with the --disable-deprecated-features argument present. It is recommended to define a domain XML with this attribute set to 'off' to ensure migration to machines that may outright drop these features in the future. Signed-off-by: Collin Walling --- src/conf/cpu_conf.c | 10 ++ src/conf/cpu_conf.h | 1 + src/conf/schemas/cputypes.rng | 12 src/qemu/qemu_process.c | 4 4 files changed, 27 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index dcc164d165..a9910e2195 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -238,6 +238,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) copy->mode = cpu->mode; copy->match = cpu->match; copy->check = cpu->check; +copy->deprecated_feats = cpu->deprecated_feats; copy->fallback = cpu->fallback; copy->sockets = cpu->sockets; copy->dies = cpu->dies; @@ -450,6 +451,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, if (virXMLPropEnum(ctxt->node, "check", virCPUCheckTypeFromString, VIR_XML_PROP_NONE, &def->check) < 0) return -1; + +if (virXMLPropTristateSwitch(ctxt->node, "deprecated_features", + VIR_XML_PROP_NONE, + &def->deprecated_feats) < 0) +return -1; } if (def->type == VIR_CPU_TYPE_HOST) { @@ -748,6 +754,10 @@ virCPUDefFormatBufFull(virBuffer *buf, virBufferAsprintf(&attributeBuf, " migratable='%s'", virTristateSwitchTypeToString(def->migratable)); } + +if (def->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { +virBufferAddLit(&attributeBuf, " deprecated_features='off'"); +} } /* Format children */ diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index f71d942ce6..28e26303ef 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -161,6 +161,7 @@ struct _virCPUDef { virCPUMaxPhysAddrDef *addr; virHostCPUTscInfo *tsc; virTristateSwitch migratable; /* for host-passthrough mode */ +virTristateSwitch deprecated_feats; }; virCPUDef *virCPUDefNew(void); diff --git a/src/conf/schemas/cputypes.rng b/src/conf/schemas/cputypes.rng index 3a8910e09f..b94b08eb5a 100644 --- a/src/conf/schemas/cputypes.rng +++ b/src/conf/schemas/cputypes.rng @@ -34,6 +34,15 @@ + + + +on +off + + + + @@ -439,6 +448,9 @@ + + + diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0815bffe3c..93376c6e6b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6302,6 +6302,10 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu); +} + return 0; } -- 2.45.1
[PATCH v1 4/5] virsh: add --disable-deprecated-features flag to domcapabilities
Add a new flag, --disable-deprecated-features, to the domcapabilities command. This will modify the output to show the 'host-model' CPU with features flagged as deprecated paired with the 'disable' policy. virsh domcapabilities --disable-deprecated-features Signed-off-by: Collin Walling --- docs/manpages/virsh.rst | 6 ++ include/libvirt/libvirt-domain.h | 12 src/libvirt-domain.c | 2 +- src/qemu/qemu_capabilities.c | 20 src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_driver.c | 8 +++- tools/virsh-host.c | 9 - 7 files changed, 57 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 6776ea53d0..2700434dc4 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -568,6 +568,7 @@ domcapabilities domcapabilities [virttype] [emulatorbin] [arch] [machine] [--xpath EXPRESSION] [--wrap] + [--disabled-deprecated-features] Print an XML document describing the domain capabilities for the @@ -609,6 +610,11 @@ a standalone document, however, for ease of additional processing, the **--wrap** argument will cause the matching node to be wrapped in a common root node. +The **--disabled-deprecated-features** argument will modify the contents +of host-model CPU XML, updating the features list with any features +flagged as deprecated for the CPU model by the hypervisor. These +features will be paired with the "disable" policy. + pool-capabilities - diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 9232ce2e6b..47e06fe68e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1478,6 +1478,18 @@ int virDomainMigrateGetMaxSpeed(virDomainPtr domain, int virDomainMigrateStartPostCopy(virDomainPtr domain, unsigned int flags); +/** + * virConnectGetDomainCapabilitiesFlags: + * + * Domain capabilities flags. + * + * Since: 10.10.0 + */ +typedef enum { +/* Report host model with deprecated features disabled. (Since: 10.10.0) */ +VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES = (1 << 0), +} virConnectGetDomainCapabilitiesFlags; + char * virConnectGetDomainCapabilities(virConnectPtr conn, const char *emulatorbin, const char *arch, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7c6b93963c..e8e5379672 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12166,7 +12166,7 @@ virDomainSetUserPassword(virDomainPtr dom, * @arch: domain architecture * @machine: machine type * @virttype: virtualization type - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: extra flags; bitwise-OR of virConnectGetDomainCapabilitiesFlags * * Prior creating a domain (for instance via virDomainCreateXML * or virDomainDefineXML) it may be suitable to know what the diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8a10816757..8f2c0c8f93 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3324,6 +3324,26 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, } +void +virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, + virDomainVirtType virtType, + virCPUDef *cpu) +{ +qemuMonitorCPUModelInfo *modelInfo; +size_t i; + +modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType); + +if (!modelInfo || !modelInfo->deprecated_props) +return; + +for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], + VIR_CPU_FEATURE_DISABLE); +} +} + + struct tpmTypeToCaps { int type; virQEMUCapsFlags caps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3acb903478..735db2b9af 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -763,6 +763,9 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, bool migratable, char ***features); +void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, +virDomainVirtType virtType, +virCPUDef *cpu); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 72a9542c0b..57e553cef3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16524,7 +16524,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, virDomai
[PATCH v1 1/5] qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions
Refactor the CPU Model parsing functions within qemuMonitorJSONGetCPUModelExpansion. The new functions, qemuMonitorJSONParseCPUModelExpansionData and qemuMonitorJSONParseCPUModelExpansion invoke the functions they replace and leave room for a subsequent patch to handle parsing the (optional) deprecated_props field resulting from the command. Signed-off-by: Collin Walling --- src/qemu/qemu_monitor_json.c | 46 ++-- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index c594b33106..7c916efacf 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5090,6 +5090,37 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, } +static int +qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data, + bool fail_no_props, + virJSONValue **cpu_model, + virJSONValue **cpu_props, + const char **cpu_name) +{ +if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", + fail_no_props, cpu_model, cpu_props, + cpu_name) < 0) +return -1; + +return 0; +} + + +static int +qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, + virJSONValue *cpu_props, + qemuMonitorCPUModelInfo **model_info) +{ +g_autoptr(qemuMonitorCPUModelInfo) expanded_model = NULL; + +if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model) < 0) +return -1; + +*model_info = g_steal_pointer(&expanded_model); +return 0; +} + + static int qemuMonitorJSONQueryCPUModelExpansionOne(qemuMonitor *mon, qemuMonitorCPUModelExpansionType type, @@ -5160,9 +5191,9 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &model, &data)) <= 0) return rc; -if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", - fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) +if (qemuMonitorJSONParseCPUModelExpansionData(data, fail_no_props, + &cpu_model, &cpu_props, + &cpu_name) < 0) return -1; /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expansion @@ -5178,13 +5209,14 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &fullModel, &fullData)) <= 0) return rc; -if (qemuMonitorJSONParseCPUModelData(fullData, "query-cpu-model-expansion", - fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) +if (qemuMonitorJSONParseCPUModelExpansionData(fullData, fail_no_props, + &cpu_model, &cpu_props, + &cpu_name) < 0) return -1; } -return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info); +return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props, + model_info); } -- 2.45.1
[PATCH v1 3/5] qemu_capabilities: query deprecated features for host-model
Add QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS for detecting if query-cpu-model-expansion can report deprecated CPU model properties. QEMU introduced this capability in 9.1 release. Add flag and deprecated features to the capabilities test data for QEMU 9.1 and 9.2 replies/XML since it can now be accounted for. When probing for the host CPU, perform a full CPU model expansion to retrieve the list of features deprecated across the entire architecture. The list and count are stored in the host's CPU model info within the QEMU capabilities. Other info resulting from this query (e.g. model name, etc) is ignored. The new capabilities flag is used to fence off the extra query for architectures/QEMU binaries that do not report deprecated CPU model features. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 38 ++ src/qemu/qemu_capabilities.h | 1 + .../caps_9.1.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 7 + .../caps_9.2.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 7 + 6 files changed, 745 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9850ed8458..8a10816757 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -720,6 +720,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "snapshot-internal-qmp", /* QEMU_CAPS_SNAPSHOT_INTERNAL_QMP */ "chardev-reconnect-miliseconds", /* QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS */ "virtio-ccw.loadparm", /* QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM */ + "query-cpu-model-expansion.deprecated-props", /* QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS */ ); @@ -1592,6 +1593,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = { { "query-migrate/ret-type/blocked-reasons", QEMU_CAPS_MIGRATION_BLOCKED_REASONS }, { "screendump/arg-type/format/^png", QEMU_CAPS_SCREENSHOT_FORMAT_PNG }, { "netdev_add/arg-type/+user", QEMU_CAPS_NETDEV_USER }, +{ "query-cpu-model-expansion/ret-type/deprecated-props", QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS }, }; typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; @@ -3144,6 +3146,38 @@ virQEMUCapsProbeHypervCapabilities(virQEMUCaps *qemuCaps, } +/** + * virQEMUCapsProbeFullDeprecatedProperties + * @mon: QEMU monitor + * @cpu: CPU definition to be expanded + * @props: the array to be filled with deprecated features + * + * Performs a full CPU model expansion to retrieve an array of deprecated + * properties. If the expansion succeeds, then data previously stored in + * @props is freed. + * + * Returns: -1 if the expansion failed; otherwise 0. + */ +static int +virQEMUCapsProbeFullDeprecatedProperties(qemuMonitor *mon, + virCPUDef *cpu, + GStrv *props) +{ +g_autoptr(qemuMonitorCPUModelInfo) propsInfo = NULL; + +if (qemuMonitorGetCPUModelExpansion(mon, QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL, +cpu, true, false, false, &propsInfo) < 0) +return -1; + +if (propsInfo && propsInfo->deprecated_props) { +g_free(*props); +*props = g_steal_pointer(&propsInfo->deprecated_props); +} + +return 0; +} + + static int virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, virQEMUCapsAccel *accel, @@ -3225,6 +3259,10 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, modelInfo->migratability = true; } +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS) && +virQEMUCapsProbeFullDeprecatedProperties(mon, cpu, &modelInfo->deprecated_props) < 0) +return -1; + if (virQEMUCapsTypeIsAccelerated(virtType) && (ARCH_IS_X86(qemuCaps->arch) || ARCH_IS_ARM(qemuCaps->arch))) { g_autoptr(qemuMonitorCPUModelInfo) fullQEMU = NULL; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e49fda6721..3acb903478 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -699,6 +699,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_SNAPSHOT_INTERNAL_QMP, /* internal snapshot support via QMP commands 'snapshot-save'/'snapshot-delete' */ QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS, /* 'reconnect-ms' option for chardevs supported */ QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM, /* loadparm available on CCW device for multi device boot */ +QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS, /* query-cpu-model-expansion may report deprecated
[PATCH v1 2/5] qemu: parse deprecated-props from query-cpu-model-expansion response
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. The deprecated features will be retained in qemuCaps->kvm->hostCPU.info and will be stored in the capabilities cache file under the element using the following format: At this time the data is only queried, parsed, and cached. The data will be utilized in a subsequent patch. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 31 +++ src/qemu/qemu_monitor.c | 10 ++ src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 18 +++ .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 6 files changed, 72 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6b67da30ec..9850ed8458 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4013,6 +4013,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, const char *typeStr) { xmlNodePtr hostCPUNode; +xmlNodePtr deprecated_props; g_autofree xmlNodePtr *nodes = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU = NULL; @@ -4105,6 +4106,24 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, } } +ctxt->node = hostCPUNode; + +if ((deprecated_props = virXPathNode("./deprecatedFeatures", ctxt))) { +g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(deprecated_props, NULL); + +hostCPU->deprecated_props = g_new0(char *, props->len); + +for (i = 0; i < props->len; i++) { +xmlNodePtr prop = g_ptr_array_index(props, i); + +if (!(hostCPU->deprecated_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; +} +} +} + caps->hostCPU.info = g_steal_pointer(&hostCPU); return 0; } @@ -4837,6 +4856,18 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); } +if (model->deprecated_props) { +virBufferAddLit(buf, "\n"); +virBufferAdjustIndent(buf, 2); + +for (i = 0; i < g_strv_length(model->deprecated_props); i++) +virBufferAsprintf(buf, "\n", + model->deprecated_props[i]); + +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, "\n"); +} + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fd888e2468..e5d231a867 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3290,6 +3290,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *model_info) g_free(model_info->props[i].value.string); } +g_strfreev(model_info->deprecated_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3334,6 +3335,15 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) } } +if (orig->deprecated_props) { +copy->deprecated_props = g_new0(char *, +g_strv_length(orig->deprecated_props)); + +for (i = 0; i < g_strv_length(orig->deprecated_props); i++) { +copy->deprecated_props[i] = g_strdup(orig->deprecated_props[i]); +} +} + return copy; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 4341519cfe..97bc1d9a2c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1146,6 +1146,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUProperty *props; +GStrv deprecated_props; bool migratability; }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7c916efacf..5216284c31 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5095,6 +5095,7 @@ qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data, bool fail_no_props, virJSONValue **cpu_model, virJSONValue **cpu_props, +
[PATCH v2 2/5] qemu: parse deprecated-props from query-cpu-model-expansion response
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. The deprecated features will be retained in qemuCaps->kvm->hostCPU.info and will be stored in the capabilities cache file under the element using the following format: At this time the data is only queried, parsed, and cached. The data will be utilized in a subsequent patch. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 31 +++ src/qemu/qemu_monitor.c | 10 ++ src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 18 +++ .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 6 files changed, 72 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5ac9f306f5..9fa868c8b7 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4015,6 +4015,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, const char *typeStr) { xmlNodePtr hostCPUNode; +xmlNodePtr deprecated_props; g_autofree xmlNodePtr *nodes = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU = NULL; @@ -4107,6 +4108,24 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, } } +ctxt->node = hostCPUNode; + +if ((deprecated_props = virXPathNode("./deprecatedFeatures", ctxt))) { +g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(deprecated_props, NULL); + +hostCPU->deprecated_props = g_new0(char *, props->len); + +for (i = 0; i < props->len; i++) { +xmlNodePtr prop = g_ptr_array_index(props, i); + +if (!(hostCPU->deprecated_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; +} +} +} + caps->hostCPU.info = g_steal_pointer(&hostCPU); return 0; } @@ -4839,6 +4858,18 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); } +if (model->deprecated_props) { +virBufferAddLit(buf, "\n"); +virBufferAdjustIndent(buf, 2); + +for (i = 0; i < g_strv_length(model->deprecated_props); i++) +virBufferAsprintf(buf, "\n", + model->deprecated_props[i]); + +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, "\n"); +} + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 73f37d26eb..94089e1c1c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3306,6 +3306,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *model_info) g_free(model_info->props[i].value.string); } +g_strfreev(model_info->deprecated_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3350,6 +3351,15 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) } } +if (orig->deprecated_props) { +copy->deprecated_props = g_new0(char *, +g_strv_length(orig->deprecated_props)); + +for (i = 0; i < g_strv_length(orig->deprecated_props); i++) { +copy->deprecated_props[i] = g_strdup(orig->deprecated_props[i]); +} +} + return copy; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 89a59dfd27..d4d9b98ba7 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1150,6 +1150,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUProperty *props; +GStrv deprecated_props; bool migratability; }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index fa8c5b1aea..6500e01d3f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5105,6 +5105,7 @@ qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data, bool fail_no_props, virJSONValue **cpu_model, virJSONValue **cpu_props, +
[PATCH v2 0/5] Allow Guest CPU Model with Deprecated Features Disabled
# Changelog v2 - rebased on latest master changes # Description Add support for libvirt to query and cache an array of deprecated CPU features (aka CPU properties) for the host-model. This data is queried via a full query-cpu-model-expansion and cached in the QEMU capabilities file. This model expansion will depend on the availability of the "deprecated-props" field resulting from a query-cpu-model-expansion command. Currently, only s390x supports this field. The purpose of these patches is to make it easy for users to create guests with a CPU model that will be compatible & migratable with future hardware. An updated host CPU model with deprecated features paired with the policy "disable" may be visable via an update to the virsh domcapabilities command with the --disable-deprecated-features flag. An example is shown below. Note: other CPU model queries (e.g. baseline and comparison) currently do not consider deprecated features, as their outputs do not consider feature policy. If implementation is desired, it will require a discussion on how these commands should report policies. Examples: virsh domcapabilities --disable-deprecated-features e.g. output (trimmed): z14.2-base A domain may be defined with a new XML attribute, deprecated_features='on|off': e.g. after guest has started (trimmed): z14.2-base Collin Walling (5): qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions qemu: parse deprecated-props from query-cpu-model-expansion response qemu_capabilities: query deprecated features for host-model virsh: add --disable-deprecated-features flag to domcapabilities conf: add deprecated_features attribute docs/manpages/virsh.rst | 6 + include/libvirt/libvirt-domain.h | 12 + src/conf/cpu_conf.c | 10 + src/conf/cpu_conf.h | 1 + src/conf/schemas/cputypes.rng | 12 + src/libvirt-domain.c | 2 +- src/qemu/qemu_capabilities.c | 89 + src/qemu/qemu_capabilities.h | 4 + src/qemu/qemu_driver.c| 8 +- src/qemu/qemu_monitor.c | 10 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 64 +++- src/qemu/qemu_process.c | 4 + .../caps_9.1.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 13 + .../caps_9.2.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 13 + tools/virsh-host.c| 9 +- 18 files changed, 940 insertions(+), 14 deletions(-) -- 2.45.1
[PATCH v2 4/5] virsh: add --disable-deprecated-features flag to domcapabilities
Add a new flag, --disable-deprecated-features, to the domcapabilities command. This will modify the output to show the 'host-model' CPU with features flagged as deprecated paired with the 'disable' policy. virsh domcapabilities --disable-deprecated-features Signed-off-by: Collin Walling --- docs/manpages/virsh.rst | 6 ++ include/libvirt/libvirt-domain.h | 12 src/libvirt-domain.c | 2 +- src/qemu/qemu_capabilities.c | 20 src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_driver.c | 8 +++- tools/virsh-host.c | 9 - 7 files changed, 57 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 2e525d3fac..d3b8ff4e1c 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -568,6 +568,7 @@ domcapabilities domcapabilities [virttype] [emulatorbin] [arch] [machine] [--xpath EXPRESSION] [--wrap] + [--disabled-deprecated-features] Print an XML document describing the domain capabilities for the @@ -609,6 +610,11 @@ a standalone document, however, for ease of additional processing, the **--wrap** argument will cause the matching node to be wrapped in a common root node. +The **--disabled-deprecated-features** argument will modify the contents +of host-model CPU XML, updating the features list with any features +flagged as deprecated for the CPU model by the hypervisor. These +features will be paired with the "disable" policy. + pool-capabilities - diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index d4f1573954..0d7e54a3dc 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1491,6 +1491,18 @@ int virDomainMigrateGetMaxSpeed(virDomainPtr domain, int virDomainMigrateStartPostCopy(virDomainPtr domain, unsigned int flags); +/** + * virConnectGetDomainCapabilitiesFlags: + * + * Domain capabilities flags. + * + * Since: 10.10.0 + */ +typedef enum { +/* Report host model with deprecated features disabled. (Since: 10.10.0) */ +VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES = (1 << 0), +} virConnectGetDomainCapabilitiesFlags; + char * virConnectGetDomainCapabilities(virConnectPtr conn, const char *emulatorbin, const char *arch, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7c6b93963c..e8e5379672 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12166,7 +12166,7 @@ virDomainSetUserPassword(virDomainPtr dom, * @arch: domain architecture * @machine: machine type * @virttype: virtualization type - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: extra flags; bitwise-OR of virConnectGetDomainCapabilitiesFlags * * Prior creating a domain (for instance via virDomainCreateXML * or virDomainDefineXML) it may be suitable to know what the diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 50905750fb..0701b2f4b0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3326,6 +3326,26 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, } +void +virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, + virDomainVirtType virtType, + virCPUDef *cpu) +{ +qemuMonitorCPUModelInfo *modelInfo; +size_t i; + +modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType); + +if (!modelInfo || !modelInfo->deprecated_props) +return; + +for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], + VIR_CPU_FEATURE_DISABLE); +} +} + + struct tpmTypeToCaps { int type; virQEMUCapsFlags caps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 8347fd7fbb..6bfe99fce4 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -764,6 +764,9 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, bool migratable, char ***features); +void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, +virDomainVirtType virtType, +virCPUDef *cpu); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5b9c55f704..86ab0bd39a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16521,7 +16521,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, virDomai
[PATCH v2 3/5] qemu_capabilities: query deprecated features for host-model
Add QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS for detecting if query-cpu-model-expansion can report deprecated CPU model properties. QEMU introduced this capability in 9.1 release. Add flag and deprecated features to the capabilities test data for QEMU 9.1 and 9.2 replies/XML since it can now be accounted for. When probing for the host CPU, perform a full CPU model expansion to retrieve the list of features deprecated across the entire architecture. The list and count are stored in the host's CPU model info within the QEMU capabilities. Other info resulting from this query (e.g. model name, etc) is ignored. The new capabilities flag is used to fence off the extra query for architectures/QEMU binaries that do not report deprecated CPU model features. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 38 ++ src/qemu/qemu_capabilities.h | 1 + .../caps_9.1.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 7 + .../caps_9.2.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 7 + 6 files changed, 745 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9fa868c8b7..50905750fb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -721,6 +721,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "chardev-reconnect-miliseconds", /* QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS */ "virtio-ccw.loadparm", /* QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM */ "netdev-stream-reconnect-miliseconds", /* QEMU_CAPS_NETDEV_STREAM_RECONNECT_MILISECONDS */ + "query-cpu-model-expansion.deprecated-props", /* QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS */ ); @@ -1594,6 +1595,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = { { "screendump/arg-type/device", QEMU_CAPS_SCREENDUMP_DEVICE }, { "screendump/arg-type/format/^png", QEMU_CAPS_SCREENSHOT_FORMAT_PNG }, { "set-numa-node/arg-type/+hmat-lb", QEMU_CAPS_NUMA_HMAT }, +{ "query-cpu-model-expansion/ret-type/deprecated-props", QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS }, }; typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; @@ -3146,6 +3148,38 @@ virQEMUCapsProbeHypervCapabilities(virQEMUCaps *qemuCaps, } +/** + * virQEMUCapsProbeFullDeprecatedProperties + * @mon: QEMU monitor + * @cpu: CPU definition to be expanded + * @props: the array to be filled with deprecated features + * + * Performs a full CPU model expansion to retrieve an array of deprecated + * properties. If the expansion succeeds, then data previously stored in + * @props is freed. + * + * Returns: -1 if the expansion failed; otherwise 0. + */ +static int +virQEMUCapsProbeFullDeprecatedProperties(qemuMonitor *mon, + virCPUDef *cpu, + GStrv *props) +{ +g_autoptr(qemuMonitorCPUModelInfo) propsInfo = NULL; + +if (qemuMonitorGetCPUModelExpansion(mon, QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL, +cpu, true, false, false, &propsInfo) < 0) +return -1; + +if (propsInfo && propsInfo->deprecated_props) { +g_free(*props); +*props = g_steal_pointer(&propsInfo->deprecated_props); +} + +return 0; +} + + static int virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, virQEMUCapsAccel *accel, @@ -3227,6 +3261,10 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, modelInfo->migratability = true; } +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS) && +virQEMUCapsProbeFullDeprecatedProperties(mon, cpu, &modelInfo->deprecated_props) < 0) +return -1; + if (virQEMUCapsTypeIsAccelerated(virtType) && (ARCH_IS_X86(qemuCaps->arch) || ARCH_IS_ARM(qemuCaps->arch))) { g_autoptr(qemuMonitorCPUModelInfo) fullQEMU = NULL; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 48e4530c95..8347fd7fbb 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -700,6 +700,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS, /* 'reconnect-ms' option for chardevs supported */ QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM, /* loadparm available on CCW device for multi device boot */ QEMU_CAPS_NETDEV_STREAM_RECONNECT_MILISECONDS, /* 'reconnect-ms' option for netdev stream supported */ +QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS, /* query-cpu-model-expansion may report deprecated CPU prope
[PATCH v2 5/5] conf: add deprecated_features attribute
Add a new a attribute, deprecated_features='on|off' to the element. This is used to toggle features flagged as deprecated on the CPU model on or off. When this attribute is paired with 'on', deprecated features will not be filtered. When paired with 'off', any CPU features that are flagged as deprecated will be listed under the CPU model with the 'disable' policy. Example: The absence of this attribute is equivalent to the 'on' option. The deprecated features that will populate the domain XML are the same features that result in the virsh domcapabilities command with the --disable-deprecated-features argument present. It is recommended to define a domain XML with this attribute set to 'off' to ensure migration to machines that may outright drop these features in the future. Signed-off-by: Collin Walling --- src/conf/cpu_conf.c | 10 ++ src/conf/cpu_conf.h | 1 + src/conf/schemas/cputypes.rng | 12 src/qemu/qemu_process.c | 4 4 files changed, 27 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index dcc164d165..a9910e2195 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -238,6 +238,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) copy->mode = cpu->mode; copy->match = cpu->match; copy->check = cpu->check; +copy->deprecated_feats = cpu->deprecated_feats; copy->fallback = cpu->fallback; copy->sockets = cpu->sockets; copy->dies = cpu->dies; @@ -450,6 +451,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, if (virXMLPropEnum(ctxt->node, "check", virCPUCheckTypeFromString, VIR_XML_PROP_NONE, &def->check) < 0) return -1; + +if (virXMLPropTristateSwitch(ctxt->node, "deprecated_features", + VIR_XML_PROP_NONE, + &def->deprecated_feats) < 0) +return -1; } if (def->type == VIR_CPU_TYPE_HOST) { @@ -748,6 +754,10 @@ virCPUDefFormatBufFull(virBuffer *buf, virBufferAsprintf(&attributeBuf, " migratable='%s'", virTristateSwitchTypeToString(def->migratable)); } + +if (def->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { +virBufferAddLit(&attributeBuf, " deprecated_features='off'"); +} } /* Format children */ diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index f71d942ce6..28e26303ef 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -161,6 +161,7 @@ struct _virCPUDef { virCPUMaxPhysAddrDef *addr; virHostCPUTscInfo *tsc; virTristateSwitch migratable; /* for host-passthrough mode */ +virTristateSwitch deprecated_feats; }; virCPUDef *virCPUDefNew(void); diff --git a/src/conf/schemas/cputypes.rng b/src/conf/schemas/cputypes.rng index 3a8910e09f..b94b08eb5a 100644 --- a/src/conf/schemas/cputypes.rng +++ b/src/conf/schemas/cputypes.rng @@ -34,6 +34,15 @@ + + + +on +off + + + + @@ -439,6 +448,9 @@ + + + diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index bee7a39e4e..c06ca1a833 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6399,6 +6399,10 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu); +} + return 0; } -- 2.45.1
[PATCH v2 1/5] qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions
Refactor the CPU Model parsing functions within qemuMonitorJSONGetCPUModelExpansion. The new functions, qemuMonitorJSONParseCPUModelExpansionData and qemuMonitorJSONParseCPUModelExpansion invoke the functions they replace and leave room for a subsequent patch to handle parsing the (optional) deprecated_props field resulting from the command. Signed-off-by: Collin Walling --- src/qemu/qemu_monitor_json.c | 46 ++-- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1b4288b744..fa8c5b1aea 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5100,6 +5100,37 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, } +static int +qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data, + bool fail_no_props, + virJSONValue **cpu_model, + virJSONValue **cpu_props, + const char **cpu_name) +{ +if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", + fail_no_props, cpu_model, cpu_props, + cpu_name) < 0) +return -1; + +return 0; +} + + +static int +qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, + virJSONValue *cpu_props, + qemuMonitorCPUModelInfo **model_info) +{ +g_autoptr(qemuMonitorCPUModelInfo) expanded_model = NULL; + +if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model) < 0) +return -1; + +*model_info = g_steal_pointer(&expanded_model); +return 0; +} + + static int qemuMonitorJSONQueryCPUModelExpansionOne(qemuMonitor *mon, qemuMonitorCPUModelExpansionType type, @@ -5170,9 +5201,9 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &model, &data)) <= 0) return rc; -if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", - fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) +if (qemuMonitorJSONParseCPUModelExpansionData(data, fail_no_props, + &cpu_model, &cpu_props, + &cpu_name) < 0) return -1; /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expansion @@ -5188,13 +5219,14 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &fullModel, &fullData)) <= 0) return rc; -if (qemuMonitorJSONParseCPUModelData(fullData, "query-cpu-model-expansion", - fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) +if (qemuMonitorJSONParseCPUModelExpansionData(fullData, fail_no_props, + &cpu_model, &cpu_props, + &cpu_name) < 0) return -1; } -return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info); +return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props, + model_info); } -- 2.45.1
Re: [PATCH v2 0/5] Allow Guest CPU Model with Deprecated Features Disabled
On 11/26/24 11:59 AM, Jiri Denemark wrote: > On Mon, Nov 25, 2024 at 14:46:34 -0500, Collin Walling wrote: >> # Changelog >> >> v2 >> - rebased on latest master changes > > I started reviewing the v1 yesterday with a plan to push this in time > for the release, but I found a few issues and got sidetracked by > investigating why the issues were not caught by our unit tests. They are > actually visible when running qemucapabilitiestest in valgrind, normally > everything passes just fine :-/ I'm copying my notes for v1 here. > > Jirka Whoops, thought I had replied! Apologies. Thanks for taking the due-diligence to check on this. I'll have the next iteration that addresses this and other review soon. -- Regards, Collin
[PATCH v3 0/7] Allow Guest CPU Model with Deprecated Features Disabled
# Changelog v3 - added reviewed-by's on appropriate patches - split patch #4 into three: - domain API (libvirt-domain: introduce VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) - qemu (qemu_capabilities: filter deprecated features if requested) - virsh (virsh: add --disable-deprecated-features flag to domcapabilities) - Note: no functional change, patches were split based on changes to certain files - @Jiri, let me know if this is what you had in mind, I found it difficult to find a good reference - fixed deprecated_props array missing +1 in qemuJSONMonitor* functions - condensed cputypes schema for deprecated_features - added validation in qemu_process to check if QEMU cap is present - added qemuxmlconf tests - updated version tags to 11.0.0 v2 - rebased on latest master changes # Description Add support for libvirt to query and cache an array of deprecated CPU features (aka CPU properties) for the host-model. This data is queried via a full query-cpu-model-expansion and cached in the QEMU capabilities file. This model expansion will depend on the availability of the "deprecated-props" field resulting from a query-cpu-model-expansion command. Currently, only s390x supports this field. The purpose of these patches is to make it easy for users to create guests with a CPU model that will be compatible & migratable with future hardware. An updated host CPU model with deprecated features paired with the policy "disable" may be visable via an update to the virsh domcapabilities command with the --disable-deprecated-features flag. An example is shown below. Note: other CPU model queries (e.g. baseline and comparison) currently do not consider deprecated features, as their outputs do not consider feature policy. If implementation is desired, it will require a discussion on how these commands should report policies. Examples: virsh domcapabilities --disable-deprecated-features e.g. output (trimmed): z14.2-base A domain may be defined with a new XML attribute, deprecated_features='on|off': e.g. after guest has started (trimmed): z14.2-base Collin Walling (7): qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions qemu: parse deprecated-props from query-cpu-model-expansion response qemu_capabilities: query deprecated features for host-model libvirt-domain: introduce VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES qemu_capabilities: filter deprecated features if requested virsh: add --disable-deprecated-features flag to domcapabilities conf: add deprecated_features attribute docs/manpages/virsh.rst | 6 + include/libvirt/libvirt-domain.h | 12 + src/conf/cpu_conf.c | 11 + src/conf/cpu_conf.h | 1 + src/conf/schemas/cputypes.rng | 5 + src/libvirt-domain.c | 2 +- src/qemu/qemu_capabilities.c | 89 + src/qemu/qemu_capabilities.h | 4 + src/qemu/qemu_driver.c| 8 +- src/qemu/qemu_monitor.c | 7 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 64 +++- src/qemu/qemu_process.c | 11 + .../caps_9.1.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 13 + .../caps_9.2.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 13 + ...el-deprecated-features-off.s390x-8.2.0.err | 1 + ...el-deprecated-features-off.s390x-8.2.0.xml | 25 ++ ...-deprecated-features-off.s390x-latest.args | 32 ++ ...l-deprecated-features-off.s390x-latest.xml | 25 ++ .../cpu-model-deprecated-features-off.xml | 15 + tests/qemuxmlconftest.c | 3 + tools/virsh-host.c| 9 +- 24 files changed, 1039 insertions(+), 14 deletions(-) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.err create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-d
[PATCH v3 1/7] qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions
Refactor the CPU Model parsing functions within qemuMonitorJSONGetCPUModelExpansion. The new functions, qemuMonitorJSONParseCPUModelExpansionData and qemuMonitorJSONParseCPUModelExpansion invoke the functions they replace and leave room for a subsequent patch to handle parsing the (optional) deprecated_props field resulting from the command. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski Reviewed-by: Jiri Denemark --- src/qemu/qemu_monitor_json.c | 46 ++-- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1b4288b744..fa8c5b1aea 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5100,6 +5100,37 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, } +static int +qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data, + bool fail_no_props, + virJSONValue **cpu_model, + virJSONValue **cpu_props, + const char **cpu_name) +{ +if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", + fail_no_props, cpu_model, cpu_props, + cpu_name) < 0) +return -1; + +return 0; +} + + +static int +qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, + virJSONValue *cpu_props, + qemuMonitorCPUModelInfo **model_info) +{ +g_autoptr(qemuMonitorCPUModelInfo) expanded_model = NULL; + +if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model) < 0) +return -1; + +*model_info = g_steal_pointer(&expanded_model); +return 0; +} + + static int qemuMonitorJSONQueryCPUModelExpansionOne(qemuMonitor *mon, qemuMonitorCPUModelExpansionType type, @@ -5170,9 +5201,9 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &model, &data)) <= 0) return rc; -if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", - fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) +if (qemuMonitorJSONParseCPUModelExpansionData(data, fail_no_props, + &cpu_model, &cpu_props, + &cpu_name) < 0) return -1; /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expansion @@ -5188,13 +5219,14 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &fullModel, &fullData)) <= 0) return rc; -if (qemuMonitorJSONParseCPUModelData(fullData, "query-cpu-model-expansion", - fail_no_props, &cpu_model, &cpu_props, - &cpu_name) < 0) +if (qemuMonitorJSONParseCPUModelExpansionData(fullData, fail_no_props, + &cpu_model, &cpu_props, + &cpu_name) < 0) return -1; } -return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info); +return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props, + model_info); } -- 2.47.1
[PATCH v3 3/7] qemu_capabilities: query deprecated features for host-model
Add QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS for detecting if query-cpu-model-expansion can report deprecated CPU model properties. QEMU introduced this capability in 9.1 release. Add flag and deprecated features to the capabilities test data for QEMU 9.1 and 9.2 replies/XML since it can now be accounted for. When probing for the host CPU, perform a full CPU model expansion to retrieve the list of features deprecated across the entire architecture. The list and count are stored in the host's CPU model info within the QEMU capabilities. Other info resulting from this query (e.g. model name, etc) is ignored. The new capabilities flag is used to fence off the extra query for architectures/QEMU binaries that do not report deprecated CPU model features. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski Reviewed-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 38 ++ src/qemu/qemu_capabilities.h | 1 + .../caps_9.1.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 7 + .../caps_9.2.0_s390x.replies | 348 +- .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 7 + 6 files changed, 745 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e7dacb5570..04017ceda7 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -721,6 +721,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "chardev-reconnect-miliseconds", /* QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS */ "virtio-ccw.loadparm", /* QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM */ "netdev-stream-reconnect-miliseconds", /* QEMU_CAPS_NETDEV_STREAM_RECONNECT_MILISECONDS */ + "query-cpu-model-expansion.deprecated-props", /* QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS */ ); @@ -1594,6 +1595,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = { { "screendump/arg-type/device", QEMU_CAPS_SCREENDUMP_DEVICE }, { "screendump/arg-type/format/^png", QEMU_CAPS_SCREENSHOT_FORMAT_PNG }, { "set-numa-node/arg-type/+hmat-lb", QEMU_CAPS_NUMA_HMAT }, +{ "query-cpu-model-expansion/ret-type/deprecated-props", QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS }, }; typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; @@ -3150,6 +3152,38 @@ virQEMUCapsProbeHypervCapabilities(virQEMUCaps *qemuCaps, } +/** + * virQEMUCapsProbeFullDeprecatedProperties + * @mon: QEMU monitor + * @cpu: CPU definition to be expanded + * @props: the array to be filled with deprecated features + * + * Performs a full CPU model expansion to retrieve an array of deprecated + * properties. If the expansion succeeds, then data previously stored in + * @props is freed. + * + * Returns: -1 if the expansion failed; otherwise 0. + */ +static int +virQEMUCapsProbeFullDeprecatedProperties(qemuMonitor *mon, + virCPUDef *cpu, + GStrv *props) +{ +g_autoptr(qemuMonitorCPUModelInfo) propsInfo = NULL; + +if (qemuMonitorGetCPUModelExpansion(mon, QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL, +cpu, true, false, false, &propsInfo) < 0) +return -1; + +if (propsInfo && propsInfo->deprecated_props) { +g_free(*props); +*props = g_steal_pointer(&propsInfo->deprecated_props); +} + +return 0; +} + + static int virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, virQEMUCapsAccel *accel, @@ -3231,6 +3265,10 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, modelInfo->migratability = true; } +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS) && +virQEMUCapsProbeFullDeprecatedProperties(mon, cpu, &modelInfo->deprecated_props) < 0) +return -1; + if (virQEMUCapsTypeIsAccelerated(virtType) && (ARCH_IS_X86(qemuCaps->arch) || ARCH_IS_ARM(qemuCaps->arch))) { g_autoptr(qemuMonitorCPUModelInfo) fullQEMU = NULL; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 48e4530c95..8347fd7fbb 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -700,6 +700,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS, /* 'reconnect-ms' option for chardevs supported */ QEMU_CAPS_VIRTIO_CCW_DEVICE_LOADPARM, /* loadparm available on CCW device for multi device boot */ QEMU_CAPS_NETDEV_STREAM_RECONNECT_MILISECONDS, /* 'reconnect-ms' option for netdev stream supported */ +QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS, /* qu
[PATCH v3 2/7] qemu: parse deprecated-props from query-cpu-model-expansion response
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. The deprecated features will be retained in qemuCaps->kvm->hostCPU.info and will be stored in the capabilities cache file under the element using the following format: At this time the data is only queried, parsed, and cached. The data will be utilized in a subsequent patch. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_capabilities.c | 31 +++ src/qemu/qemu_monitor.c | 7 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 18 +++ .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 6 files changed, 69 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index dec3199fce..e7dacb5570 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4019,6 +4019,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, const char *typeStr) { xmlNodePtr hostCPUNode; +xmlNodePtr deprecated_props; g_autofree xmlNodePtr *nodes = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU = NULL; @@ -4111,6 +4112,24 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps, } } +ctxt->node = hostCPUNode; + +if ((deprecated_props = virXPathNode("./deprecatedFeatures", ctxt))) { +g_autoptr(GPtrArray) props = virXMLNodeGetSubelementList(deprecated_props, NULL); + +hostCPU->deprecated_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"))) { +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; } @@ -4843,6 +4862,18 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBufferAddLit(buf, "/>\n"); } +if (model->deprecated_props) { +virBufferAddLit(buf, "\n"); +virBufferAdjustIndent(buf, 2); + +for (i = 0; i < g_strv_length(model->deprecated_props); i++) +virBufferAsprintf(buf, "\n", + model->deprecated_props[i]); + +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, "\n"); +} + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 73f37d26eb..8590a1a0a5 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3306,6 +3306,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *model_info) g_free(model_info->props[i].value.string); } +g_strfreev(model_info->deprecated_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3350,6 +3351,12 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) } } +if (orig->deprecated_props) { +copy->deprecated_props = g_new0(char *, +g_strv_length(orig->deprecated_props)); +copy->deprecated_props = g_strdupv(orig->deprecated_props); +} + return copy; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 89a59dfd27..d4d9b98ba7 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1150,6 +1150,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUProperty *props; +GStrv deprecated_props; bool migratability; }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index fa8c5b1aea..6500e01d3f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5105,6 +5105,7 @@ qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data, bool fail_no_props, virJSONValue **cpu_model, virJSONValue **cpu_props, + virJSONValue **cpu_deprecated
[PATCH v3 6/7] virsh: add --disable-deprecated-features flag to domcapabilities
Add a new flag, --disable-deprecated-features, to the domcapabilities command. This will modify the output to show the 'host-model' CPU with features flagged as deprecated paired with the 'disable' policy. virsh domcapabilities --disable-deprecated-features Signed-off-by: Collin Walling --- docs/manpages/virsh.rst | 6 ++ tools/virsh-host.c | 9 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 2e525d3fac..e801037c04 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -568,6 +568,7 @@ domcapabilities domcapabilities [virttype] [emulatorbin] [arch] [machine] [--xpath EXPRESSION] [--wrap] + [--disable-deprecated-features] Print an XML document describing the domain capabilities for the @@ -609,6 +610,11 @@ a standalone document, however, for ease of additional processing, the **--wrap** argument will cause the matching node to be wrapped in a common root node. +The **--disable-deprecated-features** argument will modify the contents +of host-model CPU XML, updating the features list with any features +flagged as deprecated for the CPU model by the hypervisor. These +features will be paired with the "disable" policy. + pool-capabilities - diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 2fe64e415f..f4e7324f42 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -114,6 +114,10 @@ static const vshCmdOptDef opts_domcapabilities[] = { .type = VSH_OT_BOOL, .help = N_("wrap xpath results in an common root element"), }, +{.name = "disable-deprecated-features", + .type = VSH_OT_BOOL, + .help = N_("report host CPU model with deprecated features disabled"), +}, {.name = NULL} }; @@ -126,10 +130,13 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) const char *arch = NULL; const char *machine = NULL; const char *xpath = NULL; -const unsigned int flags = 0; /* No flags so far */ +unsigned int flags = 0; bool wrap = vshCommandOptBool(cmd, "wrap"); virshControl *priv = ctl->privData; +if (vshCommandOptBool(cmd, "disable-deprecated-features")) +flags |= VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES; + if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || vshCommandOptString(ctl, cmd, "emulatorbin", &emulatorbin) < 0 || vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || -- 2.47.1
[PATCH v3 5/7] qemu_capabilities: filter deprecated features if requested
If flag VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES is passed to qemuConnectGetDomainCapabilities, then the domain's CPU model features will be updated to set any deprecated features to the 'disabled' policy. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 20 src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_driver.c | 8 +++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 04017ceda7..eda3e6a4df 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3330,6 +3330,26 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, } +void +virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, + virDomainVirtType virtType, + virCPUDef *cpu) +{ +qemuMonitorCPUModelInfo *modelInfo; +size_t i; + +modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType); + +if (!modelInfo || !modelInfo->deprecated_props) +return; + +for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], + VIR_CPU_FEATURE_DISABLE); +} +} + + struct tpmTypeToCaps { int type; virQEMUCapsFlags caps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 8347fd7fbb..6bfe99fce4 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -764,6 +764,9 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, bool migratable, char ***features); +void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, +virDomainVirtType virtType, +virCPUDef *cpu); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f1a633fdd3..672b42b44e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16530,7 +16530,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, virDomainVirtType virttype; g_autoptr(virDomainCaps) domCaps = NULL; -virCheckFlags(0, NULL); + virCheckFlags(VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES, + NULL); if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0) return NULL; @@ -16549,6 +16550,11 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, arch, virttype))) return NULL; +if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) { +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, + domCaps->cpu.hostModel); +} + return virDomainCapsFormat(domCaps); } -- 2.47.1
[PATCH v3 4/7] libvirt-domain: introduce VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES
Introduce domain flag used to filter deprecated features from the domain's CPU model. Signed-off-by: Collin Walling --- include/libvirt/libvirt-domain.h | 12 src/libvirt-domain.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index d4f1573954..2a4b81f4df 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1491,6 +1491,18 @@ int virDomainMigrateGetMaxSpeed(virDomainPtr domain, int virDomainMigrateStartPostCopy(virDomainPtr domain, unsigned int flags); +/** + * virConnectGetDomainCapabilitiesFlags: + * + * Domain capabilities flags. + * + * Since: 11.0.0 + */ +typedef enum { +/* Report host model with deprecated features disabled. (Since: 11.0.0) */ +VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES = (1 << 0), +} virConnectGetDomainCapabilitiesFlags; + char * virConnectGetDomainCapabilities(virConnectPtr conn, const char *emulatorbin, const char *arch, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7c6b93963c..e8e5379672 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12166,7 +12166,7 @@ virDomainSetUserPassword(virDomainPtr dom, * @arch: domain architecture * @machine: machine type * @virttype: virtualization type - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: extra flags; bitwise-OR of virConnectGetDomainCapabilitiesFlags * * Prior creating a domain (for instance via virDomainCreateXML * or virDomainDefineXML) it may be suitable to know what the -- 2.47.1
[PATCH v3 7/7] conf: add deprecated_features attribute
Add a new a attribute, deprecated_features='on|off' to the element. This is used to toggle features flagged as deprecated on the CPU model on or off. When this attribute is paired with 'on', deprecated features will not be filtered. When paired with 'off', any CPU features that are flagged as deprecated will be listed under the CPU model with the 'disable' policy. Example: The absence of this attribute is equivalent to the 'on' option. The deprecated features that will populate the domain XML are the same features that result in the virsh domcapabilities command with the --disable-deprecated-features argument present. It is recommended to define a domain XML with this attribute set to 'off' to ensure migration to machines that may outright drop these features in the future. Signed-off-by: Collin Walling --- src/conf/cpu_conf.c | 11 +++ src/conf/cpu_conf.h | 1 + src/conf/schemas/cputypes.rng | 5 +++ src/qemu/qemu_process.c | 11 +++ ...el-deprecated-features-off.s390x-8.2.0.err | 1 + ...el-deprecated-features-off.s390x-8.2.0.xml | 25 +++ ...-deprecated-features-off.s390x-latest.args | 32 +++ ...l-deprecated-features-off.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-off.xml | 15 + tests/qemuxmlconftest.c | 3 ++ 10 files changed, 129 insertions(+) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.err create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-8.2.0.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.xml diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index dcc164d165..31425783ba 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -238,6 +238,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) copy->mode = cpu->mode; copy->match = cpu->match; copy->check = cpu->check; +copy->deprecated_feats = cpu->deprecated_feats; copy->fallback = cpu->fallback; copy->sockets = cpu->sockets; copy->dies = cpu->dies; @@ -450,6 +451,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, if (virXMLPropEnum(ctxt->node, "check", virCPUCheckTypeFromString, VIR_XML_PROP_NONE, &def->check) < 0) return -1; + +if (virXMLPropTristateSwitch(ctxt->node, "deprecated_features", + VIR_XML_PROP_NONE, + &def->deprecated_feats) < 0) +return -1; } if (def->type == VIR_CPU_TYPE_HOST) { @@ -748,6 +754,11 @@ virCPUDefFormatBufFull(virBuffer *buf, virBufferAsprintf(&attributeBuf, " migratable='%s'", virTristateSwitchTypeToString(def->migratable)); } + +if (def->deprecated_feats) { +virBufferAsprintf(&attributeBuf, " deprecated_features='%s'", + virTristateSwitchTypeToString(def->deprecated_feats)); +} } /* Format children */ diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index f71d942ce6..28e26303ef 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -161,6 +161,7 @@ struct _virCPUDef { virCPUMaxPhysAddrDef *addr; virHostCPUTscInfo *tsc; virTristateSwitch migratable; /* for host-passthrough mode */ +virTristateSwitch deprecated_feats; }; virCPUDef *virCPUDefNew(void); diff --git a/src/conf/schemas/cputypes.rng b/src/conf/schemas/cputypes.rng index 3a8910e09f..8edf1d14e3 100644 --- a/src/conf/schemas/cputypes.rng +++ b/src/conf/schemas/cputypes.rng @@ -439,6 +439,11 @@ + + + + + diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index bee7a39e4e..5f2e278156 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6399,6 +6399,17 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; +if (def->cpu->deprecated_feats && +!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("toggling deprecated features for CPU model is unsupported")); +return -1; +} + +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF
Re: [PATCH v3 0/7] Allow Guest CPU Model with Deprecated Features Disabled
On 12/17/24 5:46 AM, Jiri Denemark wrote: > On Mon, Dec 16, 2024 at 18:03:51 -0500, Collin Walling wrote: >> # Changelog >> >> v3 >> - added reviewed-by's on appropriate patches >> - split patch #4 into three: >> - domain API (libvirt-domain: introduce >> VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) >> - qemu (qemu_capabilities: filter deprecated features if requested) >> - virsh (virsh: add --disable-deprecated-features flag to >> domcapabilities) >> - Note: no functional change, patches were split based on changes to >> certain files >> - @Jiri, let me know if this is what you had in mind, I found it >> difficult to find a good reference >> - fixed deprecated_props array missing +1 in qemuJSONMonitor* functions >> - condensed cputypes schema for deprecated_features >> - added validation in qemu_process to check if QEMU cap is present >> - added qemuxmlconf tests >> - updated version tags to 11.0.0 > > Reviewed-by: Jiri Denemark > > I fixed the small issue in 2/7 with the following diff and pushed the > series, thanks. > > diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c > index 8590a1a0a5..df7e0d8997 100644 > --- a/src/qemu/qemu_monitor.c > +++ b/src/qemu/qemu_monitor.c > @@ -3351,11 +3351,7 @@ qemuMonitorCPUModelInfoCopy(const > qemuMonitorCPUModelInfo *orig) > } > } > > -if (orig->deprecated_props) { > -copy->deprecated_props = g_new0(char *, > - > g_strv_length(orig->deprecated_props)); > -copy->deprecated_props = g_strdupv(orig->deprecated_props); > -} > +copy->deprecated_props = g_strdupv(orig->deprecated_props); > > return copy; > } Much appreciated, thank you! -- Regards, Collin
Re: [PATCH 0/4] Implement virsh hypervisor-cpu-models
On 1/17/25 11:15 AM, Daniel P. Berrangé wrote: > On Fri, Jan 17, 2025 at 04:08:40PM -, wall...@linux.ibm.com wrote: >>> Indeed I did say that a virsh command based on GetDomainCapabilities >>> was OK, but that is not what this series is doing. >>> >>> This is essentially the same as the old series, adding a new public >>> virConnectGetHypervisorCPUModelNames API, which virsh then calls. >>> >>> virsh needs to call virConnectGetDomainCapabilities directly if we >>> want a 'hypervisor-cpu-models' command. >> >> Thanks for your feedback. It seems we have a disconnect with respect to >> how this should be designed. >> >> The first iteration I posted some time back pulled the CPU models >> directly from the qemuCaps. This iteration instead pulls from the >> domCaps, which I thought met the requirements of the feedback since both >> the proposed API and existing virConnectGetDomainCapabilities interface >> extract data from this structure. From my perspective, it makes sense >> to extract the CPU models directly from the data structure and format >> the output as desired versus adding an extra step to parse the XML. > > Adding new public APIs is an expensive task, especially as it ripples > out through many language bindings and/or 3rd party protocol impls. > > We try to design APIs to be extensible to minimize the number of new > APIs we must add in future. The virConnectGetDomainCapabilities API > used XML format because we knew we have a huge amount of info to > return that is growing all the time and we didn't want APIs for each > different bit of information. > > Thus the idea of adding a virConnectGetHypervisorCPUModelNames API is > contrary to our desired design approach and not acceptable. > Thanks for explaining this. It helps to gain insight into libvirt's approach to these things. I never considered the 3rd party implementations (even though the remote/* code eludes to this). >> >> This is my understanding of the operations of both approaches if the >> steps were to be unfurled: >> >> 1. proposed API operations: >> Retrieve hypervisor caps -> extract domain caps -> extract CPU >> models -> print to stdout >> >> 2. virConnectGetDomainCapabilities operations: >> Retrieve hypervisor caps -> extract domain caps -> format into XML >> -> parse CPU models -> print to stdout >> >> My goal is to work together to clear up any misunderstandings by laying >> out the design as much as possible so we can agree on the approach for >> the next iteration. > > To be clear if you want such a command in virsh, the expectation is that > virsh calls virConnectGetDomainCapabilities, and parses the XML it gets > back to extract the CPU model names. This shouldn't actually be that > difficult, as you don't really need to parse the XML manually, just invoke > an XPath expression to directly extract the CPU model names, letting the > xpath library do the hard work. > We'll do this for v2. > With regards, > Daniel -- Regards, Collin
Re: [PATCH] virsh: Introduce new hypervisor-cpu-models command
On 3/6/25 2:07 PM, Collin Walling wrote: Ping and adding Daniel et al on CC :) > From: David Judkovics > > Add new virsh command 'hypervisor-cpu-models'. Command pulls from the > existing domcapabilities XML and uses xpath to parse CPU model strings. > By default, only models reported as usable by the hypervisor on the > host system are printed. User may specify "--all" to also print > models which are not supported on the host. > > Signed-off-by: David Judkovics > Signed-off-by: Boris Fiuczynski > Signed-off-by: Collin Walling > --- > > This is a continuation of a previous series found here: > > https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/I4YKUBDJDMLFJ6767ZPP2NP6Y4COEMBW/ > > --- > docs/manpages/virsh.rst | 24 + > tools/virsh-host.c | 74 + > 2 files changed, 98 insertions(+) > > diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst > index baced15dec..48b667736d 100644 > --- a/docs/manpages/virsh.rst > +++ b/docs/manpages/virsh.rst > @@ -1034,6 +1034,30 @@ listed in the XML description. If *--migratable* is > specified, features that > block migration will not be included in the resulting CPU. > > > +hypervisor-cpu-models > +- > + > +**Syntax:** > + > +:: > + > + hypervisor-cpu-models [virttype] [emulator] [arch] [machine] [--all] > + > +Print the list of CPU models known by the hypervisor for the specified > architecture. > +It is not guaranteed that a listed CPU will run on the host. To determine CPU > +model compatibility with the host, see ``virsh hypervisor-cpu-baseline`` and > +``virsh hypervisor-cpu-compare``. > + > +The *virttype* option specifies the virtualization type (usable in the 'type' > +attribute of the top level element from the domain XML). *emulator* > +specifies the path to the emulator, *arch* specifies the CPU architecture, > and > +*machine* specifies the machine type. > + > +By default, only the models that are claimed to be "usable" by the hypervisor > +on the host are reported. The option *--all* will report every CPU model > known > +to the hypervisor, including ones that are not supported on the hypervisor > (e.g. > +newer generation models). > + > DOMAIN COMMANDS > === > > diff --git a/tools/virsh-host.c b/tools/virsh-host.c > index 9e8f542c96..2884067bbb 100644 > --- a/tools/virsh-host.c > +++ b/tools/virsh-host.c > @@ -1766,6 +1766,74 @@ cmdHypervisorCPUBaseline(vshControl *ctl, > } > > > +/* > + * "hypervisor-cpu-models" command > + */ > +static const vshCmdInfo info_hypervisor_cpu_models = { > +.help = N_("Hypervisor reported CPU models"), > +.desc = N_("Get the CPU models reported by the hypervisor."), > +}; > + > +static const vshCmdOptDef opts_hypervisor_cpu_models[] = { > +{.name = "virttype", > + .type = VSH_OT_STRING, > + .completer = virshDomainVirtTypeCompleter, > + .help = N_("virtualization type (/domain/@type)"), > +}, > +{.name = "emulator", > + .type = VSH_OT_STRING, > + .unwanted_positional = true, > + .help = N_("path to emulator binary (/domain/devices/emulator)"), > +}, > +{.name = "arch", > + .type = VSH_OT_STRING, > + .completer = virshArchCompleter, > + .help = N_("CPU architecture (/domain/os/type/@arch)"), > +}, > +{.name = "machine", > + .type = VSH_OT_STRING, > + .help = N_("machine type (/domain/os/type/@machine)"), > +}, > +{.name = "all", > + .type = VSH_OT_BOOL, > + .help = N_("include all CPU models known to the hypervisor for the > architecture") > +}, > +{.name = NULL} > +}; > + > +static bool > +cmdHypervisorCPUModelNames(vshControl *ctl, > + const vshCmd *cmd) > +{ > +g_autofree char *caps_xml = NULL; > +const char *virttype = NULL; > +const char *emulator = NULL; > +const char *arch = NULL; > +const char *machine = NULL; > +const char *xpath_all = "//cpu//model[@usable]/text()"; > +const char *xpath_usable = "//cpu//model[@usable='yes']/text()"; > +virshControl *priv = ctl->privData; > + > +if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || > +vshCommandOptString(ctl, cmd, "emulator", &emulator) < 0 || > +vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || > +
Re: [PATCH] virsh: Introduce new hypervisor-cpu-models command
On 3/18/25 1:13 PM, Ján Tomko wrote: > On a Thursday in 2025, Collin Walling wrote: >> From: David Judkovics >> >> Add new virsh command 'hypervisor-cpu-models'. Command pulls from the >> existing domcapabilities XML and uses xpath to parse CPU model strings. >> By default, only models reported as usable by the hypervisor on the >> host system are printed. User may specify "--all" to also print >> models which are not supported on the host. >> >> Signed-off-by: David Judkovics >> Signed-off-by: Boris Fiuczynski >> Signed-off-by: Collin Walling >> --- >> >> This is a continuation of a previous series found here: >> >> https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/I4YKUBDJDMLFJ6767ZPP2NP6Y4COEMBW/ >> >> --- >> docs/manpages/virsh.rst | 24 + >> tools/virsh-host.c | 74 + >> 2 files changed, 98 insertions(+) >> >> diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst >> index baced15dec..48b667736d 100644 >> --- a/docs/manpages/virsh.rst >> +++ b/docs/manpages/virsh.rst >> @@ -1034,6 +1034,30 @@ listed in the XML description. If *--migratable* is >> specified, features that >> block migration will not be included in the resulting CPU. >> >> >> +hypervisor-cpu-models >> +- >> + >> +**Syntax:** >> + >> +:: >> + >> + hypervisor-cpu-models [virttype] [emulator] [arch] [machine] [--all] >> + > > The actualy syntax for this (as reported by virsh hypervisor-cpu-models > --help) is: > > hypervisor-cpu-models [--virttype ] [--emulator ] > [--arch ] [--machine ] [--all] > > i.e. specifying the option name is mandatory > Okay, I'll change the doc in virsh.rst to: hypervisor-cpu-models [--virttype virttype] [--emulator emulator] [--arch arch] [--machine machine] [--all] >> +Print the list of CPU models known by the hypervisor for the specified >> architecture. >> +It is not guaranteed that a listed CPU will run on the host. To determine >> CPU >> +model compatibility with the host, see ``virsh hypervisor-cpu-baseline`` and >> +``virsh hypervisor-cpu-compare``. >> + >> +The *virttype* option specifies the virtualization type (usable in the >> 'type' >> +attribute of the top level element from the domain XML). *emulator* >> +specifies the path to the emulator, *arch* specifies the CPU architecture, >> and >> +*machine* specifies the machine type. >> + >> +By default, only the models that are claimed to be "usable" by the >> hypervisor >> +on the host are reported. The option *--all* will report every CPU model >> known >> +to the hypervisor, including ones that are not supported on the hypervisor >> (e.g. >> +newer generation models). >> + >> DOMAIN COMMANDS >> === >> >> diff --git a/tools/virsh-host.c b/tools/virsh-host.c >> index 9e8f542c96..2884067bbb 100644 >> --- a/tools/virsh-host.c >> +++ b/tools/virsh-host.c >> @@ -1766,6 +1766,74 @@ cmdHypervisorCPUBaseline(vshControl *ctl, >> } >> >> >> +/* >> + * "hypervisor-cpu-models" command >> + */ >> +static const vshCmdInfo info_hypervisor_cpu_models = { >> +.help = N_("Hypervisor reported CPU models"), >> +.desc = N_("Get the CPU models reported by the hypervisor."), >> +}; >> + >> +static const vshCmdOptDef opts_hypervisor_cpu_models[] = { >> +{.name = "virttype", >> + .type = VSH_OT_STRING, >> + .completer = virshDomainVirtTypeCompleter, >> + .help = N_("virtualization type (/domain/@type)"), >> +}, >> +{.name = "emulator", >> + .type = VSH_OT_STRING, >> + .unwanted_positional = true, > > The use of this option is discouraged, see: > > commit a67f737ddfc59b0f5b3905bd1c0935ced82de3d0 > Author: Peter Krempa > AuthorDate: 2024-03-14 17:17:19 +0100 > Commit: Peter Krempa > CommitDate: 2024-04-02 14:24:30 +0200 > > virt-admin: Annodate 'unwanted_positional' arguments > > https://gitlab.com/libvirt/libvirt/-/commit/a67f737ddfc59b0f5b3905bd1c0935ced82de3d0 > I'll remove it. >> + .help = N_("path to emulator binary (/domain/devices/emulator)"), >> +}, >> +{.name = "arch", >> + .type = VSH_OT_STRING, >> + .completer = virshArchCompleter, >> + .help = N_("CPU architec
Re: [PATCH] virsh: Introduce new hypervisor-cpu-models command
On 3/19/25 4:15 AM, Peter Krempa via Devel wrote: > On Tue, Mar 18, 2025 at 18:13:57 +0100, Ján Tomko via Devel wrote: >> On a Thursday in 2025, Collin Walling wrote: >>> From: David Judkovics >>> >>> Add new virsh command 'hypervisor-cpu-models'. Command pulls from the >>> existing domcapabilities XML and uses xpath to parse CPU model strings. >>> By default, only models reported as usable by the hypervisor on the >>> host system are printed. User may specify "--all" to also print >>> models which are not supported on the host. >>> >>> Signed-off-by: David Judkovics >>> Signed-off-by: Boris Fiuczynski >>> Signed-off-by: Collin Walling >>> --- > > [...] > >>> diff --git a/tools/virsh-host.c b/tools/virsh-host.c >>> index 9e8f542c96..2884067bbb 100644 >>> --- a/tools/virsh-host.c >>> +++ b/tools/virsh-host.c >>> @@ -1766,6 +1766,74 @@ cmdHypervisorCPUBaseline(vshControl *ctl, >>> } >>> >>> >>> +/* >>> + * "hypervisor-cpu-models" command >>> + */ >>> +static const vshCmdInfo info_hypervisor_cpu_models = { >>> +.help = N_("Hypervisor reported CPU models"), >>> +.desc = N_("Get the CPU models reported by the hypervisor."), >>> +}; >>> + >>> +static const vshCmdOptDef opts_hypervisor_cpu_models[] = { >>> +{.name = "virttype", >>> + .type = VSH_OT_STRING, >>> + .completer = virshDomainVirtTypeCompleter, >>> + .help = N_("virtualization type (/domain/@type)"), >>> +}, >>> +{.name = "emulator", >>> + .type = VSH_OT_STRING, >>> + .unwanted_positional = true, >> >> The use of this option is discouraged, see: > > I'd say forbidden. The idea of the flag was that no new code would ever > use it. > > In fact in waranted cases, where the options were conflicting or new > options were added in between existing options I even changed old code > to require the options instead of filling them to unwanted fields. > >> commit a67f737ddfc59b0f5b3905bd1c0935ced82de3d0 >> Author: Peter Krempa >> AuthorDate: 2024-03-14 17:17:19 +0100 >> Commit: Peter Krempa >> CommitDate: 2024-04-02 14:24:30 +0200 >> >> virt-admin: Annodate 'unwanted_positional' arguments >> >> https://gitlab.com/libvirt/libvirt/-/commit/a67f737ddfc59b0f5b3905bd1c0935ced82de3d0 > > Commits 348010ac937fd9a71d81cd3d4154dd46bdbb6a87 and > a7b10919e7d371b9e76ccec2956ba74773de6943 illustrate the problem further: > > Specifically some of the arguments would be handled differently > regardless of documentation based on position. > > In case of some other commands new options which were parsed this way > were added before pre-existing options thus would break how the > arguments were filled. > > We do not want that to happen again. > > Commands now can have at most one positional optional option, any > further optional argument must use explicit option string. Thanks for the detailed explanation. I merely copied a the emulator parameter from the other virsh hypervisor-cpu-* commands, but did not understand the significance of this option. I will omit it in v2. -- Regards, Collin
[PATCH v2] virsh: Introduce new hypervisor-cpu-models command
From: David Judkovics Add new virsh command 'hypervisor-cpu-models'. Command pulls from the existing domcapabilities XML and uses xpath to parse CPU model strings. By default, only models reported as usable by the hypervisor on the host system are printed. User may specify "--all" to also print models which are not supported on the host. Signed-off-by: David Judkovics Signed-off-by: Boris Fiuczynski Signed-off-by: Collin Walling Reviewed-by: Ján Tomko --- Changelog: v2 - Corrected virsh.rst documentation - Removed unwanted_positional from emulator option - Adjusted xpath string based on feedback --- docs/manpages/virsh.rst | 25 ++ tools/virsh-host.c | 75 + 2 files changed, 100 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index baced15dec..612c567ff4 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1034,6 +1034,31 @@ listed in the XML description. If *--migratable* is specified, features that block migration will not be included in the resulting CPU. +hypervisor-cpu-models +- + +**Syntax:** + +:: + + hypervisor-cpu-models [--virttype virttype] [--emulator emulator] + [--arch arch] [--machine machine] [--all] + +Print the list of CPU models known by the hypervisor for the specified architecture. +It is not guaranteed that a listed CPU will run on the host. To determine CPU +model compatibility with the host, see ``virsh hypervisor-cpu-baseline`` and +``virsh hypervisor-cpu-compare``. + +The *virttype* option specifies the virtualization type (usable in the 'type' +attribute of the top level element from the domain XML). *emulator* +specifies the path to the emulator, *arch* specifies the CPU architecture, and +*machine* specifies the machine type. + +By default, only the models that are claimed to be "usable" by the hypervisor +on the host are reported. The option *--all* will report every CPU model known +to the hypervisor, including ones that are not supported on the hypervisor (e.g. +newer generation models). + DOMAIN COMMANDS === diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 9e8f542c96..f4e34fb146 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1766,6 +1766,75 @@ cmdHypervisorCPUBaseline(vshControl *ctl, } +/* + * "hypervisor-cpu-models" command + */ +static const vshCmdInfo info_hypervisor_cpu_models = { +.help = N_("Hypervisor reported CPU models"), +.desc = N_("Get the CPU models reported by the hypervisor."), +}; + +static const vshCmdOptDef opts_hypervisor_cpu_models[] = { +{.name = "virttype", + .type = VSH_OT_STRING, + .completer = virshDomainVirtTypeCompleter, + .help = N_("virtualization type (/domain/@type)"), +}, +{.name = "emulator", + .type = VSH_OT_STRING, + .help = N_("path to emulator binary (/domain/devices/emulator)"), +}, +{.name = "arch", + .type = VSH_OT_STRING, + .completer = virshArchCompleter, + .help = N_("CPU architecture (/domain/os/type/@arch)"), +}, +{.name = "machine", + .type = VSH_OT_STRING, + .help = N_("machine type (/domain/os/type/@machine)"), +}, +{.name = "all", + .type = VSH_OT_BOOL, + .help = N_("include all CPU models known to the hypervisor for the architecture") +}, +{.name = NULL} +}; + +static bool +cmdHypervisorCPUModelNames(vshControl *ctl, + const vshCmd *cmd) +{ +g_autofree char *caps_xml = NULL; +const char *virttype = NULL; +const char *emulator = NULL; +const char *arch = NULL; +const char *machine = NULL; +const char *xpath = NULL; +virshControl *priv = ctl->privData; + +if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || +vshCommandOptString(ctl, cmd, "emulator", &emulator) < 0 || +vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || +vshCommandOptString(ctl, cmd, "machine", &machine) < 0) +return false; + +if (vshCommandOptBool(cmd, "all")) +xpath = "//cpu//model[@usable]/text()"; +else +xpath = "//cpu//model[@usable='yes']/text()"; + +caps_xml = virConnectGetDomainCapabilities(priv->conn, emulator, arch, + machine, virttype, 0); + +if (!caps_xml) { +vshError(ctl, "%s", _("failed to get hypervisor CPU model names")); +return false; +} + +return virshDumpXML(ctl, caps_xml, "domcapabilities", xpath, false); +} + + const vshCmdDef hostAndHypervisorCmds[] = { {.name = "allocpages", .handler = cmdAlloc
Re: [PATCH] virsh: Introduce new hypervisor-cpu-models command
On 3/17/25 2:49 AM, Collin Walling wrote: > On 3/6/25 2:07 PM, Collin Walling wrote: > > Ping and adding Daniel et al on CC :) > Take-two. Apparently my CC list didn't take Daniel's email. Apologies. -- Regards, Collin
[PATCH v1 0/2] Disable Deprecated Features by Default on s390 CPU Models
The intention of reporting deprecated features and modifying the guest CPU model was to alleviate the user from the burden of preparing a guest with the necessary amendments to assure migration to newer hardware. While that goal was met by way of the "deprecated_features='on|off'" attribute, it still adds an extra step that the user must be aware to prepare a guest for migration and the errors that stem from an unsuccessful migration (due to feature incompatibility) is not always clear how to resolve. These patches make s390 CPU host models migration ready from the get-go by disabling deprecated features by default. They may still be disabled for other model types via the respective attribute, or reenabled if desired. Collin Walling (2): qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures qemu: caps: disable deprecated features for s390 models by default src/qemu/qemu_capabilities.c | 10 +++--- src/qemu/qemu_capabilities.h | 3 ++- src/qemu/qemu_driver.c| 3 ++- src/qemu/qemu_process.c | 19 --- tests/domaincapsdata/qemu_10.0.0.s390x.xml| 8 tests/domaincapsdata/qemu_9.1.0.s390x.xml | 8 tests/domaincapsdata/qemu_9.2.0.s390x.xml | 8 ...default-video-type-s390x.s390x-latest.args | 2 +- ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- .../s390-panic.s390x-latest.args | 2 +- 13 files changed, 41 insertions(+), 30 deletions(-) -- 2.47.1
[PATCH v1 1/2] qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures
Currently, virQEMUCapsUpdateCPUDeprecatedFeatures only allows for disabling deprecated features. This locks the deprecated_features attribute to only do something if set to 'off'. Let's add a virCPUFeaturePolicy to the function's parameters which will allow the caller to decide what happens to these features. Additionally, group the relevant code in qemu_process.c. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 6 +++--- src/qemu/qemu_capabilities.h | 3 ++- src/qemu/qemu_driver.c | 3 ++- src/qemu/qemu_process.c | 19 --- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a804335c85..5f94863818 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3341,7 +3341,8 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, - virCPUDef *cpu) + virCPUDef *cpu, + virCPUFeaturePolicy policy) { qemuMonitorCPUModelInfo *modelInfo; size_t i; @@ -3352,8 +3353,7 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, return; for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { -virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], - VIR_CPU_FEATURE_DISABLE); +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], policy); } } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index ea7c14daa9..e4d8b0b6b6 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -778,7 +778,8 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, char ***features); void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, -virCPUDef *cpu); +virCPUDef *cpu, +virCPUFeaturePolicy policy); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a34d6f1437..677b4b72a8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16722,7 +16722,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) { virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, - domCaps->cpu.hostModel); + domCaps->cpu.hostModel, + VIR_CPU_FEATURE_DISABLE); } return virDomainCapsFormat(domCaps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1af91c5909..5820499710 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6588,15 +6588,20 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; -if (def->cpu->deprecated_feats && -!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +if (def->cpu->deprecated_feats) { +virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; + +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) +policy = VIR_CPU_FEATURE_DISABLE; + +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("toggling deprecated features for CPU model is unsupported")); -return -1; -} +return -1; +} -if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { -virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu); +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, + def->cpu, policy); } return 0; -- 2.47.1
[PATCH v1 2/2] qemu: caps: disable deprecated features for s390 models by default
To ease the user with defining a guest with a migratable CPU model, let's disable the deprecated features from the get-go. If these features are still desired, they may be reenabled via the deprecated_features='on' attribute. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 4 tests/domaincapsdata/qemu_10.0.0.s390x.xml| 8 tests/domaincapsdata/qemu_9.1.0.s390x.xml | 8 tests/domaincapsdata/qemu_9.2.0.s390x.xml | 8 .../default-video-type-s390x.s390x-latest.args| 2 +- .../hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args| 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- .../s390-default-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../qemuxmlconfdata/s390-defaultconsole.s390x-latest.args | 2 +- tests/qemuxmlconfdata/s390-panic.s390x-latest.args| 2 +- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5f94863818..6d2ab41901 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3813,6 +3813,10 @@ virQEMUCapsInitCPUModelS390(virQEMUCaps *qemuCaps, cpu->nfeatures++; } +/* Disable deprecated features by default */ +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, type, cpu, + VIR_CPU_FEATURE_DISABLE); + return 0; } diff --git a/tests/domaincapsdata/qemu_10.0.0.s390x.xml b/tests/domaincapsdata/qemu_10.0.0.s390x.xml index d66240307e..5fb38b5ed5 100644 --- a/tests/domaincapsdata/qemu_10.0.0.s390x.xml +++ b/tests/domaincapsdata/qemu_10.0.0.s390x.xml @@ -43,7 +43,7 @@ - + @@ -79,9 +79,9 @@ - + - + @@ -89,7 +89,7 @@ - + diff --git a/tests/domaincapsdata/qemu_9.1.0.s390x.xml b/tests/domaincapsdata/qemu_9.1.0.s390x.xml index b73e0d0688..77a35bc20d 100644 --- a/tests/domaincapsdata/qemu_9.1.0.s390x.xml +++ b/tests/domaincapsdata/qemu_9.1.0.s390x.xml @@ -43,7 +43,7 @@ - + @@ -79,9 +79,9 @@ - + - + @@ -89,7 +89,7 @@ - + diff --git a/tests/domaincapsdata/qemu_9.2.0.s390x.xml b/tests/domaincapsdata/qemu_9.2.0.s390x.xml index 605a3af5c7..94c0311de7 100644 --- a/tests/domaincapsdata/qemu_9.2.0.s390x.xml +++ b/tests/domaincapsdata/qemu_9.2.0.s390x.xml @@ -43,7 +43,7 @@ - + @@ -79,9 +79,9 @@ - + - + @@ -89,7 +89,7 @@ - + diff --git a/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args b/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args index 1c1a1066e4..ff71f5b872 100644 --- a/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args +++ b/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-default-video-type-s/.config \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-default-video-type-s/master-key.aes"}' \ -machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \ -accel kvm \ --cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=on,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=on,ais=on,bpb=on,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=on,cmm=on,vxpdeh2=on \ +-cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=off,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=off,ais=on,bpb=off,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=off,cmm=on,vxpdeh2=on \ -m size=1048576k \ -object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":1073741824}' \ -overcommit mem-lock=off \ diff --git a/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-
[PATCH] virsh: Introduce new hypervisor-cpu-models command
From: David Judkovics Add new virsh command 'hypervisor-cpu-models'. Command pulls from the existing domcapabilities XML and uses xpath to parse CPU model strings. By default, only models reported as usable by the hypervisor on the host system are printed. User may specify "--all" to also print models which are not supported on the host. Signed-off-by: David Judkovics Signed-off-by: Boris Fiuczynski Signed-off-by: Collin Walling --- This is a continuation of a previous series found here: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/I4YKUBDJDMLFJ6767ZPP2NP6Y4COEMBW/ --- docs/manpages/virsh.rst | 24 + tools/virsh-host.c | 74 + 2 files changed, 98 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index baced15dec..48b667736d 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1034,6 +1034,30 @@ listed in the XML description. If *--migratable* is specified, features that block migration will not be included in the resulting CPU. +hypervisor-cpu-models +- + +**Syntax:** + +:: + + hypervisor-cpu-models [virttype] [emulator] [arch] [machine] [--all] + +Print the list of CPU models known by the hypervisor for the specified architecture. +It is not guaranteed that a listed CPU will run on the host. To determine CPU +model compatibility with the host, see ``virsh hypervisor-cpu-baseline`` and +``virsh hypervisor-cpu-compare``. + +The *virttype* option specifies the virtualization type (usable in the 'type' +attribute of the top level element from the domain XML). *emulator* +specifies the path to the emulator, *arch* specifies the CPU architecture, and +*machine* specifies the machine type. + +By default, only the models that are claimed to be "usable" by the hypervisor +on the host are reported. The option *--all* will report every CPU model known +to the hypervisor, including ones that are not supported on the hypervisor (e.g. +newer generation models). + DOMAIN COMMANDS === diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 9e8f542c96..2884067bbb 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1766,6 +1766,74 @@ cmdHypervisorCPUBaseline(vshControl *ctl, } +/* + * "hypervisor-cpu-models" command + */ +static const vshCmdInfo info_hypervisor_cpu_models = { +.help = N_("Hypervisor reported CPU models"), +.desc = N_("Get the CPU models reported by the hypervisor."), +}; + +static const vshCmdOptDef opts_hypervisor_cpu_models[] = { +{.name = "virttype", + .type = VSH_OT_STRING, + .completer = virshDomainVirtTypeCompleter, + .help = N_("virtualization type (/domain/@type)"), +}, +{.name = "emulator", + .type = VSH_OT_STRING, + .unwanted_positional = true, + .help = N_("path to emulator binary (/domain/devices/emulator)"), +}, +{.name = "arch", + .type = VSH_OT_STRING, + .completer = virshArchCompleter, + .help = N_("CPU architecture (/domain/os/type/@arch)"), +}, +{.name = "machine", + .type = VSH_OT_STRING, + .help = N_("machine type (/domain/os/type/@machine)"), +}, +{.name = "all", + .type = VSH_OT_BOOL, + .help = N_("include all CPU models known to the hypervisor for the architecture") +}, +{.name = NULL} +}; + +static bool +cmdHypervisorCPUModelNames(vshControl *ctl, + const vshCmd *cmd) +{ +g_autofree char *caps_xml = NULL; +const char *virttype = NULL; +const char *emulator = NULL; +const char *arch = NULL; +const char *machine = NULL; +const char *xpath_all = "//cpu//model[@usable]/text()"; +const char *xpath_usable = "//cpu//model[@usable='yes']/text()"; +virshControl *priv = ctl->privData; + +if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || +vshCommandOptString(ctl, cmd, "emulator", &emulator) < 0 || +vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || +vshCommandOptString(ctl, cmd, "machine", &machine) < 0) +return false; + +caps_xml = virConnectGetDomainCapabilities(priv->conn, emulator, arch, + machine, virttype, 0); + +if (!caps_xml) { +vshError(ctl, "%s", _("failed to get hypervisor CPU model names")); +return false; +} + +return virshDumpXML(ctl, caps_xml, "domcapabilities", +vshCommandOptBool(cmd, "all") ? xpath_all : xpath_usable, +false); +} + + const vshCmdDef hostAndHypervisorCmds[] = { {.name = "allocpages", .hand
Re: [PATCH v5 0/5] Disable Deprecated Features by Default on s390 CPU Models
On 6/29/25 11:19 PM, Collin Walling wrote: Pinging this series once. Would like to know if there's any further feedback or if these patches are good enough. Thanks for your time. [...] -- Regards, Collin
[PATCH v5 0/5] Disable Deprecated Features by Default on s390 CPU Models
Changelog v5 - dropped the "none" test in qemuxmlactivetest (see commit for details) - reordered patches to introduce some tests first, then add qemu.conf changes v4 - added qemu.conf option to dictate the default behavior for the deprecated_features attribute (Boris) - added qemuxmlactivetests (Boris) - snuck in missing documentation for deprecated_features in formatdomain.rst v3 - added qemu caps check to avoid breaking s390 guests trying to default deprecated_features='off' on QEMU versions that do not support reporting these features v2 - changed behavior from disabling features on the host model to instead flagging the guest CPU to disable deprecated features - removed disabling deprecated features on host model in virQEMUCapsInitCPUModelS390 - added flagging deprecated_feats in qemuProcessUpdateGuestCPU - added tests for deprecated_features='on' - split virQEMUCapsUpdateCPUDeprecatedFeatures update and qemuProcessUpdateGuestCPU changes The intention of reporting deprecated features and modifying the guest CPU model was to alleviate the user from the burden of preparing a guest with the necessary amendments to assure migration to newer hardware. While that goal was met by way of the "deprecated_features='on|off'" attribute, it still adds an extra step that the user must be aware to prepare a guest for migration and the errors that stem from an unsuccessful migration (due to feature incompatibility) is not always clear how to resolve. These patches make s390 CPU *host models* migration ready from the get-go by introducing a qemu.conf option for disabling deprecated features by default. They may still be disabled for other model types via the respective attribute, or reenabled if desired. The configured behavior may be overridden by explicitly providing the attribute within the guest XML. Boris Fiuczynski (2): tests: new qemuxmlactive tests for s390x qemu: add default_cpu_deprecated_features configuration option Collin Walling (3): docs: domain: document deprecated_features attribute qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures qemu: process: refactor deprecated features code docs/formatdomain.rst | 8 src/qemu/libvirtd_qemu.aug| 3 ++ src/qemu/qemu.conf.in | 14 ++ src/qemu/qemu_capabilities.c | 6 +-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_conf.c | 33 + src/qemu/qemu_conf.h | 12 + src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 46 +++ src/qemu/test_libvirtd_qemu.aug.in| 1 + ...cated-features-off-active.s390x-latest.xml | 25 ++ ...ted-features-off-inactive.s390x-latest.xml | 25 ++ ...ecated-features-on-active.s390x-latest.xml | 25 ++ ...ated-features-on-inactive.s390x-latest.xml | 25 ++ tests/qemuxmlactivetest.c | 10 +++- ...deprecated-features-none.s390x-latest.args | 32 + ...-deprecated-features-none.s390x-latest.xml | 25 ++ .../cpu-model-deprecated-features-none.xml| 15 ++ ...l-deprecated-features-on.s390x-latest.args | 32 + ...el-deprecated-features-on.s390x-latest.xml | 25 ++ .../cpu-model-deprecated-features-on.xml | 15 ++ ...default-video-type-s390x.s390x-latest.args | 2 +- ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- .../s390-panic.s390x-latest.args | 2 +- tests/qemuxmlconftest.c | 2 + 28 files changed, 375 insertions(+), 22 deletions(-) create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.xml create mode 100644 tests/qe
[PATCH v5 1/5] docs: domain: document deprecated_features attribute
Provide documentation for the deprecated_features XML attribute. Available since 11.0.0, and supported for S390. Signed-off-by: Collin Walling --- docs/formatdomain.rst | 8 1 file changed, 8 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 9a2f065590..cd316ac272 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1674,6 +1674,14 @@ In case no restrictions need to be put on CPU model and its features, a simpler ... +``deprecated_features`` + :since:`Since 11.0.0`, S390 guests may utilize the ``deprecated_features`` + attribute to specify toggling of CPU model features that are flagged as + deprecated by the hypervisor. When this attribute is set to ``off``, the + active guest XML will reflect the respective features with the disable + policy. When this attribute is set to ``on``, the respective features will + be enabled. + ``cache`` :since:`Since 3.3.0` the ``cache`` element describes the virtual CPU cache. If the element is missing, the hypervisor will use a sensible default. -- 2.49.0
[PATCH v5 3/5] qemu: process: refactor deprecated features code
Group up the deprecated features code into a single block to keep things clean; only check if the deprecated_features attribute is present once and then do relevent work. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_process.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e6124b670a..7155742d13 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6448,18 +6448,17 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; -if (def->cpu->deprecated_feats && -!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("toggling deprecated features for CPU model is unsupported")); -return -1; -} - if (def->cpu->deprecated_feats) { virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) policy = VIR_CPU_FEATURE_DISABLE; +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("toggling deprecated features for CPU model is unsupported")); +return -1; +} + virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu, policy); } -- 2.49.0
[PATCH v5 2/5] qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures
Currently, virQEMUCapsUpdateCPUDeprecatedFeatures only allows for disabling deprecated features. This locks the deprecated_features attribute to only do something if set to 'off'. Let's add a virCPUFeaturePolicy to the function's parameters which will allow the caller to decide what happens to these features. Add a test with guest XML using deprecated_features='on' to ensure the API is working properly. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_capabilities.c | 6 ++-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 9 -- ...l-deprecated-features-on.s390x-latest.args | 32 +++ ...el-deprecated-features-on.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-on.xml | 15 + tests/qemuxmlconftest.c | 1 + 8 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.xml diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b02f8e7a01..52ad80a9ca 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3366,7 +3366,8 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, - virCPUDef *cpu) + virCPUDef *cpu, + virCPUFeaturePolicy policy) { qemuMonitorCPUModelInfo *modelInfo; size_t i; @@ -3377,8 +3378,7 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, return; for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { -virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], - VIR_CPU_FEATURE_DISABLE); +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], policy); } } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 966e30fa11..a044bda918 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -787,7 +787,8 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, char ***features); void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, -virCPUDef *cpu); +virCPUDef *cpu, +virCPUFeaturePolicy policy); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9b583ad7aa..c6139d02a1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16720,7 +16720,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) { virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, - domCaps->cpu.hostModel); + domCaps->cpu.hostModel, + VIR_CPU_FEATURE_DISABLE); } return virDomainCapsFormat(domCaps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 82cab3f76e..e6124b670a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6455,8 +6455,13 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, return -1; } -if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { -virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu); +if (def->cpu->deprecated_feats) { +virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) +policy = VIR_CPU_FEATURE_DISABLE; + +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, + def->cpu, policy); } return 0; diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args new file mode 100644 index 00..8cdb2a2ac2 --- /dev/null +++ b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-guest \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/do
[PATCH v5 5/5] qemu: add default_cpu_deprecated_features configuration option
From: Boris Fiuczynski Allow to define the default for deprecated_features when the attribute is not set in the cpu defintion of a domain XML. If these features are still desired, they may be reenabled via the deprecated_features='on' attribute. Some existing tests utilize this updated behavior, so update the CPU features on the corresponding args files. Signed-off-by: Boris Fiuczynski Signed-off-by: Collin Walling --- src/qemu/libvirtd_qemu.aug| 3 ++ src/qemu/qemu.conf.in | 14 src/qemu/qemu_conf.c | 33 +++ src/qemu/qemu_conf.h | 12 +++ src/qemu/qemu_process.c | 26 ++- src/qemu/test_libvirtd_qemu.aug.in| 1 + ...deprecated-features-none.s390x-latest.args | 2 +- ...default-video-type-s390x.s390x-latest.args | 2 +- ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- .../s390-panic.s390x-latest.args | 2 +- 13 files changed, 95 insertions(+), 8 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index e1e479d72c..2b674d258d 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -160,6 +160,8 @@ module Libvirtd_qemu = let filesystem_entry = str_array_entry "shared_filesystems" + let default_cpu_deprecated_features = str_entry "default_cpu_deprecated_features" + (* Entries that used to exist in the config which are now * deleted. We keep on parsing them so we don't break * ability to parse old configs after upgrade @@ -192,6 +194,7 @@ module Libvirtd_qemu = | capability_filters_entry | storage_entry | filesystem_entry + | default_cpu_deprecated_features | obsolete_entry let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 221bfa8095..368d929f78 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -1100,3 +1100,17 @@ # "/path/to/nvram", # "/path/to/swtpm" #] + +# If QEMU provides a list of deprecated CPU features it is possible to use +# this list for removal of deprecated CPU features during CPU model expansion. +# The deprecated_features XML attribute on the XML CPU element in the domain +# XML can be used to turn deprecated CPU features 'off' or 'on'. Using the +# option default_cpu_deprecated_features allows to define the default behavior +# when the attribute deprecated_features is not provided in the domain XML. +# +# Possible options are: +# "off" - (default) deprecated features are removed during CPU model expansion +# "on" - deprecated features remain required in the expanded CPU model +# "none" - no deprecated_features attribute is added to expanded CPU model +# +#default_cpu_deprecated_features = "off" diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 9bf12fc179..a9089ed0b9 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -81,6 +81,11 @@ VIR_ENUM_IMPL(virQEMUSchedCore, "emulator", "full"); +VIR_ENUM_IMPL(virQEMUDeprecatedFeatures, + QEMU_DEPRECATED_FEATURES_LAST, + "off", + "on", + "none"); static virClass *virQEMUDriverConfigClass; static void virQEMUDriverConfigDispose(void *obj); @@ -1258,6 +1263,31 @@ virQEMUDriverConfigLoadFilesystemEntry(virQEMUDriverConfig *cfg, } +static int +virQEMUDriverConfigLoadDeprecatedFeaturesEntry(virQEMUDriverConfig *cfg, + virConf *conf) +{ +g_autofree char *depFeats = NULL; + +if (virConfGetValueString(conf, "default_cpu_deprecated_features", &depFeats) < 0) +return -1; +if (depFeats) { +int val = virQEMUDeprecatedFeaturesTypeFromString(depFeats); + +if (val < 0) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown default_cpu_deprecated_features value %1$s"), + depFeats); +return -1; +} + +cfg->defaultDeprecatedFeatures = val; +} + +return 0; +} + + int virQEMUDriverConfigLoadFile(virQEMUDriverConfig *cfg, const char *filename, bool privileged) @@ -1338,6 +1368,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfig *cfg, if (virQEMUDriverConfigLoadFilesystemEntry(cfg, conf) < 0) return -1; +if (vir
[PATCH v5 4/5] tests: new qemuxmlactive tests for s390x
From: Boris Fiuczynski Add tests for active/inactive XML with deprecated_features attribute. Note that for the qemuxmlactivetest, it is not possible to test an inactive guest XML with the absence of "deprecated_features" attribute and expect the active XML to have the attribute present. This is due to the fact that the tests never touch the code path in qemu_process that trigger this change in the domain definition. Signed-off-by: Boris Fiuczynski Reviewed-by: Collin Walling --- ...cated-features-off-active.s390x-latest.xml | 25 +++ ...ted-features-off-inactive.s390x-latest.xml | 25 +++ ...ecated-features-on-active.s390x-latest.xml | 25 +++ ...ated-features-on-inactive.s390x-latest.xml | 25 +++ tests/qemuxmlactivetest.c | 10 -- ...deprecated-features-none.s390x-latest.args | 32 +++ ...-deprecated-features-none.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-none.xml| 15 + tests/qemuxmlconftest.c | 1 + 9 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.xml diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml new file mode 100644 index 00..c5761b1f89 --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destroy + +/usr/bin/qemu-system-s390x + + + + + + + + diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml new file mode 100644 index 00..fdd87acb1d --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destroy + +/usr/bin/qemu-system-s390x + + + + + + + + diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-active.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-active.s390x-latest.xml new file mode 100644 index 00..789b7ba018 --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-active.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destroy + +/usr/bin/qemu-system-s390x + + + + + + + + diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-inactive.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-inactive.s390x-latest.xml new file mode 100644 index 00..3bea664f40 --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-inactive.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destroy + +/usr/bin/qemu-system-s390x + + + + + + + + diff --git a/tests/qemuxmlactivetest.c b/tests/qemuxmlactivetest.c index de2b1e48eb..44e66a4a29 100644 --- a/tests/qemuxmlactivetest.c +++ b/tests/qemuxmlactivetest.c @@ -232,9 +232,12 @@ mymain(void) virSetConnectSecret(conn); virSetConnectStorage(conn); +#define DO_TEST_ACTIVE_CAPS_ARCH_LATEST(_name, arch) \ +testRunActive(_name, "." arch "-latest", &testConf, &ret, \ + ARG_CAPS_ARCH, arch, ARG_CAPS_VER, "latest", ARG_END); + #define DO_TEST_ACTIVE_CAPS_LATEST(_name) \ -testRunActive(_name, ".x86_64-latest", &testConf, &ret, \ - ARG_CAPS_ARCH, "x86_64", ARG_CAPS_VER, "latest", ARG_END); +DO_TEST_ACTIVE_CAPS_ARCH_LATEST(_name, "x86_64"); DO_TEST_ACTIV
Re: [PATCH v5 0/5] Disable Deprecated Features by Default on s390 CPU Models
On 6/29/25 23:19, Collin Walling wrote: Pinging again, since it's been about three weeks since the last bump. Unless these patches are satisfactory, please inform on what needs to change. -- Regards, Collin
Re: [PATCH v1 0/2] Disable Deprecated Features by Default on s390 CPU Models
On 5/1/25 4:17 PM, Collin Walling wrote: Ping. > The intention of reporting deprecated features and modifying the guest > CPU model was to alleviate the user from the burden of preparing a guest > with the necessary amendments to assure migration to newer hardware. > While that goal was met by way of the "deprecated_features='on|off'" > attribute, it still adds an extra step that the user must be aware to > prepare a guest for migration and the errors that stem from an > unsuccessful migration (due to feature incompatibility) is not always > clear how to resolve. > > These patches make s390 CPU host models migration ready from the get-go > by disabling deprecated features by default. They may still be disabled > for other model types via the respective attribute, or reenabled if > desired. > > Collin Walling (2): > qemu: caps: add virCPUFeaturePolicy param to > virQEMUCapsUpdateCPUDeprecatedFeatures > qemu: caps: disable deprecated features for s390 models by default > > src/qemu/qemu_capabilities.c | 10 +++--- > src/qemu/qemu_capabilities.h | 3 ++- > src/qemu/qemu_driver.c| 3 ++- > src/qemu/qemu_process.c | 19 --- > tests/domaincapsdata/qemu_10.0.0.s390x.xml| 8 > tests/domaincapsdata/qemu_9.1.0.s390x.xml | 8 > tests/domaincapsdata/qemu_9.2.0.s390x.xml | 8 > ...default-video-type-s390x.s390x-latest.args | 2 +- > ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- > .../launch-security-s390-pv.s390x-latest.args | 2 +- > ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- > .../s390-defaultconsole.s390x-latest.args | 2 +- > .../s390-panic.s390x-latest.args | 2 +- > 13 files changed, 41 insertions(+), 30 deletions(-) > -- Regards, Collin
[PATCH v2 1/3] qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures
Currently, virQEMUCapsUpdateCPUDeprecatedFeatures only allows for disabling deprecated features. This locks the deprecated_features attribute to only do something if set to 'off'. Let's add a virCPUFeaturePolicy to the function's parameters which will allow the caller to decide what happens to these features. Add a test with guest XML using deprecated_features='on' to ensure the API is working properly. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 6 ++-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 10 -- ...l-deprecated-features-on.s390x-latest.args | 32 +++ ...el-deprecated-features-on.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-on.xml | 15 + tests/qemuxmlconftest.c | 1 + 8 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.xml diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b600dd38b8..275f2f1e0b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3347,7 +3347,8 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, - virCPUDef *cpu) + virCPUDef *cpu, + virCPUFeaturePolicy policy) { qemuMonitorCPUModelInfo *modelInfo; size_t i; @@ -3358,8 +3359,7 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, return; for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { -virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], - VIR_CPU_FEATURE_DISABLE); +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], policy); } } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index df33212a34..50d3f7226c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -779,7 +779,8 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, char ***features); void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, -virCPUDef *cpu); +virCPUDef *cpu, +virCPUFeaturePolicy policy); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 893fa0c66c..0638fea59c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16716,7 +16716,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) { virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, - domCaps->cpu.hostModel); + domCaps->cpu.hostModel, + VIR_CPU_FEATURE_DISABLE); } return virDomainCapsFormat(domCaps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 04e5c005a0..e4f8cb8c01 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6595,8 +6595,14 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, return -1; } -if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { -virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu); +if (def->cpu->deprecated_feats) { + +virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) +policy = VIR_CPU_FEATURE_DISABLE; + +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, + def->cpu, policy); } return 0; diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args new file mode 100644 index 00..8cdb2a2ac2 --- /dev/null +++ b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-guest \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-guest/.local/share
[PATCH v2 0/3] Disable Deprecated Features by Default on s390 CPU Models
Changelog v2 - changed behavior from disabling features on the host model to instead flagging the guest CPU to disable deprecated features - removed disabling deprecated features on host model in virQEMUCapsInitCPUModelS390 - added flagging deprecated_feats in qemuProcessUpdateGuestCPU - added tests for deprecated_features='on' - split virQEMUCapsUpdateCPUDeprecatedFeatures update and qemuProcessUpdateGuestCPU changes The intention of reporting deprecated features and modifying the guest CPU model was to alleviate the user from the burden of preparing a guest with the necessary amendments to assure migration to newer hardware. While that goal was met by way of the "deprecated_features='on|off'" attribute, it still adds an extra step that the user must be aware to prepare a guest for migration and the errors that stem from an unsuccessful migration (due to feature incompatibility) is not always clear how to resolve. These patches make s390 CPU host models migration ready from the get-go by disabling deprecated features by default. They may still be disabled for other model types via the respective attribute, or reenabled if desired. Collin Walling (3): qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures qemu: process: refactor deprecated features code qemu: process: disable deprecated features for s390 models by default src/qemu/qemu_capabilities.c | 6 ++-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 30 - ...l-deprecated-features-on.s390x-latest.args | 32 +++ ...el-deprecated-features-on.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-on.xml | 15 + ...default-video-type-s390x.s390x-latest.args | 2 +- ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- .../s390-panic.s390x-latest.args | 2 +- tests/qemuxmlconftest.c | 1 + 14 files changed, 108 insertions(+), 19 deletions(-) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.xml -- 2.47.1
[PATCH v2 3/3] qemu: process: disable deprecated features for s390 host-model by default
To ease the user with defining a guest with a migratable CPU model, let's disable the deprecated features from the get-go if using mode host-model. If these features are still desired, they may be reenabled via the deprecated_features='on' attribute. Some existing tests utilize this updated behavior, so update the CPU features on the corresponding args files. Signed-off-by: Collin Walling --- src/qemu/qemu_process.c | 9 + .../default-video-type-s390x.s390x-latest.args | 2 +- .../hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args| 2 +- ...s390-default-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args| 2 +- tests/qemuxmlconfdata/s390-panic.s390x-latest.args | 2 +- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b4989f7ab8..53ba90f03b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6547,6 +6547,15 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, return -1; } +/* s390 CPU models should disable deprecated features off by default. + * Set the flag now so the appropriate features are updated later. + */ +if (ARCH_IS_S390(def->os.arch) && +def->cpu->mode == VIR_CPU_MODE_HOST_MODEL && +!def->cpu->deprecated_feats) { +def->cpu->deprecated_feats = VIR_TRISTATE_SWITCH_OFF; +} + /* nothing to update for host-passthrough / maximum */ if (def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH && def->cpu->mode != VIR_CPU_MODE_MAXIMUM) { diff --git a/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args b/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args index 1c1a1066e4..ff71f5b872 100644 --- a/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args +++ b/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-default-video-type-s/.config \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-default-video-type-s/master-key.aes"}' \ -machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \ -accel kvm \ --cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=on,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=on,ais=on,bpb=on,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=on,cmm=on,vxpdeh2=on \ +-cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=off,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=off,ais=on,bpb=off,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=off,cmm=on,vxpdeh2=on \ -m size=1048576k \ -object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":1073741824}' \ -overcommit mem-lock=off \ diff --git a/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args b/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args index d69ebfc8fd..25c0ed2c9c 100644 --- a/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args +++ b/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-KVMGuest1/.config \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-KVMGuest1/master-key.aes"}' \ -machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \ -accel kvm \ --cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=on,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=on,ais=on,bpb=on,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=on,cmm=on,vxpdeh2=on \ +-cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxp
[PATCH v2 2/3] qemu: process: refactor deprecated features code
Group up the deprecated features code into a single block to keep things clean; only check if the deprecated_features attribute is present once and then do relevent work. Signed-off-by: Collin Walling --- src/qemu/qemu_process.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e4f8cb8c01..b4989f7ab8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6588,19 +6588,18 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; -if (def->cpu->deprecated_feats && -!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("toggling deprecated features for CPU model is unsupported")); -return -1; -} - if (def->cpu->deprecated_feats) { virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) policy = VIR_CPU_FEATURE_DISABLE; +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("toggling deprecated features for CPU model is unsupported")); +return -1; +} + virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu, policy); } -- 2.47.1
Re: [PATCH v2 2/3] qemu: process: refactor deprecated features code
On 5/22/25 1:33 AM, Collin Walling wrote: > Group up the deprecated features code into a single block to keep things > clean; only check if the deprecated_features attribute is present > once and then do relevent work. > > Signed-off-by: Collin Walling > --- > src/qemu/qemu_process.c | 13 ++--- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c > index e4f8cb8c01..b4989f7ab8 100644 > --- a/src/qemu/qemu_process.c > +++ b/src/qemu/qemu_process.c > @@ -6588,19 +6588,18 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, > &def->os.arch) < 0) > return -1; > > -if (def->cpu->deprecated_feats && > -!virQEMUCapsGet(qemuCaps, > QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { > -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > - _("toggling deprecated features for CPU model is > unsupported")); > -return -1; > -} > - > if (def->cpu->deprecated_feats) { > > virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; > if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) > policy = VIR_CPU_FEATURE_DISABLE; > > +if (!virQEMUCapsGet(qemuCaps, > QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { > +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > + _("toggling deprecated features for CPU model is > unsupported")); > +return -1; > +} > + > virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, > def->cpu, policy); > } Of course it's not until after I send out the patches that I realize setting this means it will break s390 guests running on a QEMU without deprecated features support (due to next patch setting the flag by default). When I first put in that caps check, it was to make setting the deprecated_features flag reactive if no change could possibly happen e.g. if x86 sets the attribute, user will get an error letting them know no changes can occur. I'll amend this with a quick fix in order to not hold things up. -- Regards, Collin
[PATCH v3 0/3] Disable Deprecated Features by Default on s390 CPU Models
Changelog v3 - added qemu caps check to avoid breaking s390 guests trying to default deprecated_features='off' on QEMU versions that do not support reporting these features v2 - changed behavior from disabling features on the host model to instead flagging the guest CPU to disable deprecated features - removed disabling deprecated features on host model in virQEMUCapsInitCPUModelS390 - added flagging deprecated_feats in qemuProcessUpdateGuestCPU - added tests for deprecated_features='on' - split virQEMUCapsUpdateCPUDeprecatedFeatures update and qemuProcessUpdateGuestCPU changes The intention of reporting deprecated features and modifying the guest CPU model was to alleviate the user from the burden of preparing a guest with the necessary amendments to assure migration to newer hardware. While that goal was met by way of the "deprecated_features='on|off'" attribute, it still adds an extra step that the user must be aware to prepare a guest for migration and the errors that stem from an unsuccessful migration (due to feature incompatibility) is not always clear how to resolve. These patches make s390 CPU host models migration ready from the get-go by disabling deprecated features by default. They may still be disabled for other model types via the respective attribute, or reenabled if desired. Collin Walling (3): qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures qemu: process: refactor deprecated features code qemu: process: disable deprecated features for s390 models by default src/qemu/qemu_capabilities.c | 6 ++-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 32 ++- ...l-deprecated-features-on.s390x-latest.args | 32 +++ ...el-deprecated-features-on.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-on.xml | 15 + ...default-video-type-s390x.s390x-latest.args | 2 +- ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- .../s390-panic.s390x-latest.args | 2 +- tests/qemuxmlconftest.c | 1 + 14 files changed, 110 insertions(+), 19 deletions(-) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.xml -- 2.47.1
[PATCH v3 3/3] qemu: process: disable deprecated features for s390 models by default
To ease the user with defining a guest with a migratable CPU model, let's disable the deprecated features from the get-go. If these features are still desired, they may be reenabled via the deprecated_features='on' attribute. Some existing tests utilize this updated behavior, so update the CPU features on the corresponding args files. Signed-off-by: Collin Walling --- src/qemu/qemu_process.c | 11 +++ .../default-video-type-s390x.s390x-latest.args| 2 +- ...hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...0-default-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- tests/qemuxmlconfdata/s390-panic.s390x-latest.args| 2 +- 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b4989f7ab8..637ec2f1d2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6547,6 +6547,17 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, return -1; } +/* s390 CPU models should disable deprecated features off by default if + * supported by QEMU. Set the flag now so the appropriate features are + * updated later. + */ +if (ARCH_IS_S390(def->os.arch) && +virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS) && +def->cpu->mode == VIR_CPU_MODE_HOST_MODEL && +!def->cpu->deprecated_feats) { +def->cpu->deprecated_feats = VIR_TRISTATE_SWITCH_OFF; +} + /* nothing to update for host-passthrough / maximum */ if (def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH && def->cpu->mode != VIR_CPU_MODE_MAXIMUM) { diff --git a/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args b/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args index 1c1a1066e4..ff71f5b872 100644 --- a/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args +++ b/tests/qemuxmlconfdata/default-video-type-s390x.s390x-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-default-video-type-s/.config \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-default-video-type-s/master-key.aes"}' \ -machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \ -accel kvm \ --cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=on,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=on,ais=on,bpb=on,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=on,cmm=on,vxpdeh2=on \ +-cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=off,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=off,ais=on,bpb=off,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,sea_esop2=on,beareh=on,te=off,cmm=on,vxpdeh2=on \ -m size=1048576k \ -object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":1073741824}' \ -overcommit mem-lock=off \ diff --git a/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args b/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args index d69ebfc8fd..25c0ed2c9c 100644 --- a/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args +++ b/tests/qemuxmlconfdata/hostdev-vfio-zpci-ccw-memballoon.s390x-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-KVMGuest1/.config \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-KVMGuest1/master-key.aes"}' \ -machine s390-ccw-virtio,usb=off,dump-guest-core=off,memory-backend=s390.ram \ -accel kvm \ --cpu gen16a-base,nnpa=on,aen=on,cmmnt=on,vxpdeh=on,aefsi=on,diag318=on,csske=on,mepoch=on,msa9=on,msa8=on,msa7=on,msa6=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,sthyi=on,edat=on,ri=on,deflate=on,edat2=on,etoken=on,vx=on,ipter=on,pai=on,paie=on,mepochptff=on,ap=on,vxeh=on,vxpd=on,esop=on,msa9_pckmo=on,vxeh2=on,esort=on,appv=on,apqi=on,apft=on,els=on,iep=on,appvi=on,apqci=on,cte=on,ais=on,bpb=on,ctop=on,gs=on,ppa15=on,zpci=on,rdp=on,se
[PATCH v3 1/3] qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures
Currently, virQEMUCapsUpdateCPUDeprecatedFeatures only allows for disabling deprecated features. This locks the deprecated_features attribute to only do something if set to 'off'. Let's add a virCPUFeaturePolicy to the function's parameters which will allow the caller to decide what happens to these features. Add a test with guest XML using deprecated_features='on' to ensure the API is working properly. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 6 ++-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 10 -- ...l-deprecated-features-on.s390x-latest.args | 32 +++ ...el-deprecated-features-on.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-on.xml | 15 + tests/qemuxmlconftest.c | 1 + 8 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.xml diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b600dd38b8..275f2f1e0b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3347,7 +3347,8 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, - virCPUDef *cpu) + virCPUDef *cpu, + virCPUFeaturePolicy policy) { qemuMonitorCPUModelInfo *modelInfo; size_t i; @@ -3358,8 +3359,7 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, return; for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { -virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], - VIR_CPU_FEATURE_DISABLE); +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], policy); } } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index df33212a34..50d3f7226c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -779,7 +779,8 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, char ***features); void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, -virCPUDef *cpu); +virCPUDef *cpu, +virCPUFeaturePolicy policy); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 893fa0c66c..0638fea59c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16716,7 +16716,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) { virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, - domCaps->cpu.hostModel); + domCaps->cpu.hostModel, + VIR_CPU_FEATURE_DISABLE); } return virDomainCapsFormat(domCaps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 04e5c005a0..e4f8cb8c01 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6595,8 +6595,14 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, return -1; } -if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { -virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu); +if (def->cpu->deprecated_feats) { + +virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) +policy = VIR_CPU_FEATURE_DISABLE; + +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, + def->cpu, policy); } return 0; diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args new file mode 100644 index 00..8cdb2a2ac2 --- /dev/null +++ b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-guest \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-guest/.local/share
[PATCH v3 2/3] qemu: process: refactor deprecated features code
Group up the deprecated features code into a single block to keep things clean; only check if the deprecated_features attribute is present once and then do relevent work. Signed-off-by: Collin Walling --- src/qemu/qemu_process.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e4f8cb8c01..b4989f7ab8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6588,19 +6588,18 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; -if (def->cpu->deprecated_feats && -!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("toggling deprecated features for CPU model is unsupported")); -return -1; -} - if (def->cpu->deprecated_feats) { virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) policy = VIR_CPU_FEATURE_DISABLE; +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("toggling deprecated features for CPU model is unsupported")); +return -1; +} + virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu, policy); } -- 2.47.1
Re: [PATCH v2 0/3] Disable Deprecated Features by Default on s390 CPU Models
On 5/22/25 1:33 AM, Collin Walling wrote: Please refer to v3 and ignore this version. I found an issue after posting. It is fixed in v3. -- Regards, Collin
[PATCH v4 0/5] Disable Deprecated Features by Default on s390 CPU Models
Changelog v4 - added qemu.conf option to dictate the default behavior for the deprecated_features attribute (Boris) - added qemuxmlactivetests (Boris) - snuck in missing documentation for deprecated_features in formatdomain.rst v3 - added qemu caps check to avoid breaking s390 guests trying to default deprecated_features='off' on QEMU versions that do not support reporting these features v2 - changed behavior from disabling features on the host model to instead flagging the guest CPU to disable deprecated features - removed disabling deprecated features on host model in virQEMUCapsInitCPUModelS390 - added flagging deprecated_feats in qemuProcessUpdateGuestCPU - added tests for deprecated_features='on' - split virQEMUCapsUpdateCPUDeprecatedFeatures update and qemuProcessUpdateGuestCPU changes The intention of reporting deprecated features and modifying the guest CPU model was to alleviate the user from the burden of preparing a guest with the necessary amendments to assure migration to newer hardware. While that goal was met by way of the "deprecated_features='on|off'" attribute, it still adds an extra step that the user must be aware to prepare a guest for migration and the errors that stem from an unsuccessful migration (due to feature incompatibility) is not always clear how to resolve. These patches make s390 CPU *host models* migration ready from the get-go by introducing a qemu.conf option for disabling deprecated features by default. They may still be disabled for other model types via the respective attribute, or reenabled if desired. The configured behavior may be overridden by explicitly providing the attribute within the guest XML. Boris Fiuczynski (1): tests: new qemuxmlactive tests for s390x Collin Walling (4): docs: domain: document deprecated_features attribute qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures qemu: process: refactor deprecated features code qemu: add default_cpu_deprecated_features configuration option docs/formatdomain.rst | 8 src/qemu/libvirtd_qemu.aug| 3 ++ src/qemu/qemu.conf.in | 14 ++ src/qemu/qemu_capabilities.c | 6 +-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_conf.c | 33 + src/qemu/qemu_conf.h | 12 + src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 46 +++ src/qemu/test_libvirtd_qemu.aug.in| 1 + ...ated-features-none-active.s390x-latest.xml | 25 ++ ...ed-features-none-inactive.s390x-latest.xml | 25 ++ ...cated-features-off-active.s390x-latest.xml | 25 ++ ...ted-features-off-inactive.s390x-latest.xml | 25 ++ ...ecated-features-on-active.s390x-latest.xml | 25 ++ ...ated-features-on-inactive.s390x-latest.xml | 25 ++ tests/qemuxmlactivetest.c | 11 - ...deprecated-features-none.s390x-latest.args | 32 + ...-deprecated-features-none.s390x-latest.xml | 25 ++ .../cpu-model-deprecated-features-none.xml| 15 ++ ...l-deprecated-features-on.s390x-latest.args | 32 + ...el-deprecated-features-on.s390x-latest.xml | 25 ++ .../cpu-model-deprecated-features-on.xml | 15 ++ ...default-video-type-s390x.s390x-latest.args | 2 +- ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- .../s390-panic.s390x-latest.args | 2 +- tests/qemuxmlconftest.c | 2 + 30 files changed, 426 insertions(+), 22 deletions(-) create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-fe
[PATCH v4 1/5] docs: domain: document deprecated_features attribute
Provide documentation for the deprecated_features XML attribute. Available since 11.0.0, and supported for S390. Signed-off-by: Collin Walling --- docs/formatdomain.rst | 8 1 file changed, 8 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index c7c75ae219..fbe8da765f 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1674,6 +1674,14 @@ In case no restrictions need to be put on CPU model and its features, a simpler ... +``deprecated_features`` + :since:`Since 11.0.0`, S390 guests may utilize the ``deprecated_features`` + attribute to specify toggling of CPU model features that are flagged as + deprecated by the hypervisor. When this attribute is set to ``off``, the + active guest XML will reflect the respective features with the disable + policy. When this attribute is set to ``on``, the respective features will + be enabled. + ``cache`` :since:`Since 3.3.0` the ``cache`` element describes the virtual CPU cache. If the element is missing, the hypervisor will use a sensible default. -- 2.47.1
[PATCH v4 4/5] qemu: add default_cpu_deprecated_features configuration option
Allow to define the default for deprecated_features when the attribute is not set in the cpu defintion of a domain XML. If these features are still desired, they may be reenabled via the deprecated_features='on' attribute. Some existing tests utilize this updated behavior, so update the CPU features on the corresponding args files. Signed-off-by: Boris Fiuczynski Signed-off-by: Collin Walling --- src/qemu/libvirtd_qemu.aug| 3 ++ src/qemu/qemu.conf.in | 14 src/qemu/qemu_conf.c | 33 +++ src/qemu/qemu_conf.h | 12 +++ src/qemu/qemu_process.c | 26 ++- src/qemu/test_libvirtd_qemu.aug.in| 1 + ...default-video-type-s390x.s390x-latest.args | 2 +- ...vfio-zpci-ccw-memballoon.s390x-latest.args | 2 +- .../launch-security-s390-pv.s390x-latest.args | 2 +- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +- .../s390-defaultconsole.s390x-latest.args | 2 +- .../s390-panic.s390x-latest.args | 2 +- 12 files changed, 94 insertions(+), 7 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index bd744940d2..5727cf605f 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -158,6 +158,8 @@ module Libvirtd_qemu = let filesystem_entry = str_array_entry "shared_filesystems" + let default_cpu_deprecated_features = str_entry "default_cpu_deprecated_features" + (* Entries that used to exist in the config which are now * deleted. We keep on parsing them so we don't break * ability to parse old configs after upgrade @@ -190,6 +192,7 @@ module Libvirtd_qemu = | capability_filters_entry | storage_entry | filesystem_entry + | default_cpu_deprecated_features | obsolete_entry let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 502adbf5c3..3224967aca 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -1126,3 +1126,17 @@ # "/path/to/nvram", # "/path/to/swtpm" #] + +# If QEMU provides a list of deprecated CPU features it is possible to use +# this list for removal of deprecated CPU features during CPU model expansion. +# The deprecated_features XML attribute on the XML CPU element in the domain +# XML can be used to turn deprecated CPU features 'off' or 'on'. Using the +# option default_cpu_deprecated_features allows to define the default behavior +# when the attribute deprecated_features is not provided in the domain XML. +# +# Possible options are: +# "off" - (default) deprecated features are removed during CPU model expansion +# "on" - deprecated features remain required in the expanded CPU model +# "none" - no deprecated_features attribute is added to expanded CPU model +# +#default_cpu_deprecated_features = "off" diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 8ffbcacaf2..a6b43c2209 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -81,6 +81,11 @@ VIR_ENUM_IMPL(virQEMUSchedCore, "emulator", "full"); +VIR_ENUM_IMPL(virQEMUDeprecatedFeatures, + QEMU_DEPRECATED_FEATURES_LAST, + "off", + "on", + "none"); static virClass *virQEMUDriverConfigClass; static void virQEMUDriverConfigDispose(void *obj); @@ -1265,6 +1270,31 @@ virQEMUDriverConfigLoadFilesystemEntry(virQEMUDriverConfig *cfg, } +static int +virQEMUDriverConfigLoadDeprecatedFeaturesEntry(virQEMUDriverConfig *cfg, + virConf *conf) +{ +g_autofree char *depFeats = NULL; + +if (virConfGetValueString(conf, "default_cpu_deprecated_features", &depFeats) < 0) +return -1; +if (depFeats) { +int val = virQEMUDeprecatedFeaturesTypeFromString(depFeats); + +if (val < 0) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown default_cpu_deprecated_features value %1$s"), + depFeats); +return -1; +} + +cfg->defaultDeprecatedFeatures = val; +} + +return 0; +} + + int virQEMUDriverConfigLoadFile(virQEMUDriverConfig *cfg, const char *filename, bool privileged) @@ -1345,6 +1375,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfig *cfg, if (virQEMUDriverConfigLoadFilesystemEntry(cfg, conf) < 0) return -1; +if (virQEMUDriverConfigLoadDeprecatedFeaturesEntry(cfg, conf) < 0) +
[PATCH v4 2/5] qemu: caps: add virCPUFeaturePolicy param to virQEMUCapsUpdateCPUDeprecatedFeatures
Currently, virQEMUCapsUpdateCPUDeprecatedFeatures only allows for disabling deprecated features. This locks the deprecated_features attribute to only do something if set to 'off'. Let's add a virCPUFeaturePolicy to the function's parameters which will allow the caller to decide what happens to these features. Add a test with guest XML using deprecated_features='on' to ensure the API is working properly. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_capabilities.c | 6 ++-- src/qemu/qemu_capabilities.h | 3 +- src/qemu/qemu_driver.c| 3 +- src/qemu/qemu_process.c | 9 -- ...l-deprecated-features-on.s390x-latest.args | 32 +++ ...el-deprecated-features-on.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-on.xml | 15 + tests/qemuxmlconftest.c | 1 + 8 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-on.xml diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b600dd38b8..275f2f1e0b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3347,7 +3347,8 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, - virCPUDef *cpu) + virCPUDef *cpu, + virCPUFeaturePolicy policy) { qemuMonitorCPUModelInfo *modelInfo; size_t i; @@ -3358,8 +3359,7 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, return; for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) { -virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], - VIR_CPU_FEATURE_DISABLE); +virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], policy); } } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index df33212a34..50d3f7226c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -779,7 +779,8 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, char ***features); void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, -virCPUDef *cpu); +virCPUDef *cpu, +virCPUFeaturePolicy policy); virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index aef313ae9c..9ac8bcdffe 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16716,7 +16716,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) { virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, - domCaps->cpu.hostModel); + domCaps->cpu.hostModel, + VIR_CPU_FEATURE_DISABLE); } return virDomainCapsFormat(domCaps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 04e5c005a0..c05aa05a5a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6595,8 +6595,13 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, return -1; } -if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) { -virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu); +if (def->cpu->deprecated_feats) { +virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; +if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) +policy = VIR_CPU_FEATURE_DISABLE; + +virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, + def->cpu, policy); } return 0; diff --git a/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args new file mode 100644 index 00..8cdb2a2ac2 --- /dev/null +++ b/tests/qemuxmlconfdata/cpu-model-deprecated-features-on.s390x-latest.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-guest \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/do
[PATCH v4 3/5] qemu: process: refactor deprecated features code
Group up the deprecated features code into a single block to keep things clean; only check if the deprecated_features attribute is present once and then do relevent work. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_process.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c05aa05a5a..8e3b5cda88 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6588,18 +6588,17 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, &def->os.arch) < 0) return -1; -if (def->cpu->deprecated_feats && -!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("toggling deprecated features for CPU model is unsupported")); -return -1; -} - if (def->cpu->deprecated_feats) { virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE; if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF) policy = VIR_CPU_FEATURE_DISABLE; +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("toggling deprecated features for CPU model is unsupported")); +return -1; +} + virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType, def->cpu, policy); } -- 2.47.1
[PATCH v4 5/5] tests: new qemuxmlactive tests for s390x
From: Boris Fiuczynski Add tests for active/inactive XML with deprecated_features attribute. Note that deprecated_features is not set by default when the attribute is absent while running the active/inactive tests. The active XML should contain the attribute, but it doesn't. This is because the method introduced in the previous patch to check the configured default behavior for the attribute does not get called at all -- just the method virDomainDefCheckABIStability is called. Therefore the test's expected file qemuxmlactive2xmldata/cpu-model-deprecated-features-none-active.s390x-latest.xml should really contain deprecated_features='off'. However, due to the config method not being hit, the attribute has to be omitted to ensure the test passes. Some coverage is handled via the qemuxmlconf test, which will check the expected args to see the respective features disabled when the domain XML does not contain the attribute. Signed-off-by: Boris Fiuczynski Reviewed-by: Collin Walling --- ...ated-features-none-active.s390x-latest.xml | 25 +++ ...ed-features-none-inactive.s390x-latest.xml | 25 +++ ...cated-features-off-active.s390x-latest.xml | 25 +++ ...ted-features-off-inactive.s390x-latest.xml | 25 +++ ...ecated-features-on-active.s390x-latest.xml | 25 +++ ...ated-features-on-inactive.s390x-latest.xml | 25 +++ tests/qemuxmlactivetest.c | 11 +-- ...deprecated-features-none.s390x-latest.args | 32 +++ ...-deprecated-features-none.s390x-latest.xml | 25 +++ .../cpu-model-deprecated-features-none.xml| 15 + tests/qemuxmlconftest.c | 1 + 11 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-active.s390x-latest.xml create mode 100644 tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-on-inactive.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.args create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.s390x-latest.xml create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-none.xml diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-active.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-active.s390x-latest.xml new file mode 100644 index 00..bed2ea8552 --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-active.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destroy + +/usr/bin/qemu-system-s390x + + + + + + + + diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-inactive.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-inactive.s390x-latest.xml new file mode 100644 index 00..e4d688ab44 --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-none-inactive.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destroy + +/usr/bin/qemu-system-s390x + + + + + + + + diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml new file mode 100644 index 00..c5761b1f89 --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-active.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destroy + +/usr/bin/qemu-system-s390x + + + + + + + + diff --git a/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml new file mode 100644 index 00..fdd87acb1d --- /dev/null +++ b/tests/qemuxmlactive2xmldata/cpu-model-deprecated-features-off-inactive.s390x-latest.xml @@ -0,0 +1,25 @@ + + guest + 22782664-6b93-46bf-9595-317220dd2d1c + 219100 + 219100 + 1 + +hvm + + + + + destroy + restart + destr
Re: [PATCH v5 0/5] Disable Deprecated Features by Default on s390 CPU Models
On 7/25/25 09:53, Jiri Denemark via Devel wrote: > On Thu, Jul 24, 2025 at 14:39:02 -0400, Collin Walling wrote: >> On 7/24/25 03:35, Thomas Huth via Devel wrote: >>> On 30/06/2025 05.19, Collin Walling wrote: >>>> Changelog >>>> >>>> v5 >>>> - dropped the "none" test in qemuxmlactivetest (see commit for >>>> details) >>>> - reordered patches to introduce some tests first, then add >>>> qemu.conf changes >>>> >>>> v4 >>>> - added qemu.conf option to dictate the default behavior for the >>>> deprecated_features attribute (Boris) >>>> - added qemuxmlactivetests (Boris) >>>> - snuck in missing documentation for deprecated_features in >>>> formatdomain.rst >>>> >>>> v3 >>>> - added qemu caps check to avoid breaking s390 guests trying to >>>> default deprecated_features='off' on QEMU versions that >>>> do not support reporting these features >>>> >>>> v2 >>>> - changed behavior from disabling features on the host model to >>>> instead flagging the guest CPU to disable deprecated features >>>> - removed disabling deprecated features on host model in >>>> virQEMUCapsInitCPUModelS390 >>>> - added flagging deprecated_feats in qemuProcessUpdateGuestCPU >>>> - added tests for deprecated_features='on' >>>> - split virQEMUCapsUpdateCPUDeprecatedFeatures update and >>>> qemuProcessUpdateGuestCPU changes >>>> >>>> The intention of reporting deprecated features and modifying the guest >>>> CPU model was to alleviate the user from the burden of preparing a guest >>>> with the necessary amendments to assure migration to newer hardware. >>>> While that goal was met by way of the "deprecated_features='on|off'" >>>> attribute, it still adds an extra step that the user must be aware to >>>> prepare a guest for migration and the errors that stem from an >>>> unsuccessful migration (due to feature incompatibility) is not always >>>> clear how to resolve. >>>> >>>> These patches make s390 CPU *host models* migration ready from the get-go >>>> by introducing a qemu.conf option for disabling deprecated features by >>>> default. They may still be disabled for other model types via the >>>> respective attribute, or reenabled if desired. The configured behavior >>>> may be overridden by explicitly providing the attribute within the >>>> guest XML. >>> >>> The patch series sounds reasonable to me, so FWIW: >>> >>> Series >>> Acked-by: Thomas Huth >>> >>> Peter, Michal, could we still get this merged for libvirt 11.6 ? >>> >>> Thomas >> >> Thanks for the Ack and helping to move this along. >> >> I've posted a patch to the list for NEWS mentioning this features in >> case this series is accepted in time for 11.6. > > Both this series and the NEWS patch are pushed now. > > Jirka Thanks! -- Regards, Collin
[PATCH] NEWS: mention disabling deprecated features by default on s390 CPU models
Signed-off-by: Collin Walling --- NEWS.rst | 8 1 file changed, 8 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index e5e8626729..6cc8f23225 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -32,6 +32,14 @@ v11.6.0 (unreleased) that is liable to cause crashes of the source QEMU when performing long running live migration operations with TLS enabled. + * Add support for disabling deprecated CPU model features by default for s390 domains + +Starting an s390 domain with host-model will now default to setting the +``deprecated_features`` attribute to ``off``, ensuring the domain starts +with a migration-compatible CPU model to newer systems. This behavior can +be modified by setting the ``default_cpu_deprecated_features`` option in +the qemu.conf file. + * **Improvements** * qemu: Change default SCSI controller model to ``virtio-scsi`` for ARM and RISC-V -- 2.49.0
Re: [PATCH v5 0/5] Disable Deprecated Features by Default on s390 CPU Models
On 7/24/25 03:35, Thomas Huth via Devel wrote: > On 30/06/2025 05.19, Collin Walling wrote: >> Changelog >> >> v5 >> - dropped the "none" test in qemuxmlactivetest (see commit for >> details) >> - reordered patches to introduce some tests first, then add >> qemu.conf changes >> >> v4 >> - added qemu.conf option to dictate the default behavior for the >> deprecated_features attribute (Boris) >> - added qemuxmlactivetests (Boris) >> - snuck in missing documentation for deprecated_features in >> formatdomain.rst >> >> v3 >> - added qemu caps check to avoid breaking s390 guests trying to >> default deprecated_features='off' on QEMU versions that >> do not support reporting these features >> >> v2 >> - changed behavior from disabling features on the host model to >> instead flagging the guest CPU to disable deprecated features >> - removed disabling deprecated features on host model in >> virQEMUCapsInitCPUModelS390 >> - added flagging deprecated_feats in qemuProcessUpdateGuestCPU >> - added tests for deprecated_features='on' >> - split virQEMUCapsUpdateCPUDeprecatedFeatures update and >> qemuProcessUpdateGuestCPU changes >> >> The intention of reporting deprecated features and modifying the guest >> CPU model was to alleviate the user from the burden of preparing a guest >> with the necessary amendments to assure migration to newer hardware. >> While that goal was met by way of the "deprecated_features='on|off'" >> attribute, it still adds an extra step that the user must be aware to >> prepare a guest for migration and the errors that stem from an >> unsuccessful migration (due to feature incompatibility) is not always >> clear how to resolve. >> >> These patches make s390 CPU *host models* migration ready from the get-go >> by introducing a qemu.conf option for disabling deprecated features by >> default. They may still be disabled for other model types via the >> respective attribute, or reenabled if desired. The configured behavior >> may be overridden by explicitly providing the attribute within the >> guest XML. > > The patch series sounds reasonable to me, so FWIW: > > Series > Acked-by: Thomas Huth > > Peter, Michal, could we still get this merged for libvirt 11.6 ? > > Thomas Thanks for the Ack and helping to move this along. I've posted a patch to the list for NEWS mentioning this features in case this series is accepted in time for 11.6. -- Regards, Collin