[PATCH v3 0/7] Allow Guest CPU Model with Deprecated Features Disabled

Collin Walling posted 7 patches 4 days, 17 hours ago
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-deprecated-features-off.s390x-latest.xml
create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.xml
[PATCH v3 0/7] Allow Guest CPU Model with Deprecated Features Disabled
Posted by Collin Walling 4 days, 17 hours ago
# 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):

    <mode name='host-model' supported='yes'>
      <model fallback='forbid'>z14.2-base</model>
      <feature policy='require' name='aen'/>
      <feature policy='require' name='cmmnt'/>
      <feature policy='require' name='aefsi'/>
      <feature policy='require' name='diag318'/>
      <feature policy='require' name='mepoch'/>
      <feature policy='require' name='msa8'/>
      <feature policy='require' name='msa7'/>
      <feature policy='require' name='msa6'/>
      <feature policy='require' name='msa5'/>
      <feature policy='require' name='msa4'/>
      <feature policy='require' name='msa3'/>
      <feature policy='require' name='msa2'/>
      <feature policy='require' name='msa1'/>
      <feature policy='require' name='sthyi'/>
      <feature policy='require' name='edat'/>
      <feature policy='require' name='ri'/>
      <feature policy='require' name='edat2'/>
      <feature policy='require' name='etoken'/>
      <feature policy='require' name='vx'/>
      <feature policy='require' name='ipter'/>
      <feature policy='require' name='mepochptff'/>
      <feature policy='require' name='ap'/>
      <feature policy='require' name='vxeh'/>
      <feature policy='require' name='vxpd'/>
      <feature policy='require' name='esop'/>
      <feature policy='require' name='apqi'/>
      <feature policy='require' name='apft'/>
      <feature policy='require' name='els'/>
      <feature policy='require' name='iep'/>
      <feature policy='require' name='apqci'/>
      <feature policy='disable' name='cte'/>
      <feature policy='require' name='ais'/>
      <feature policy='disable' name='bpb'/>
      <feature policy='require' name='ctop'/>
      <feature policy='require' name='gs'/>
      <feature policy='require' name='ppa15'/>
      <feature policy='require' name='zpci'/>
      <feature policy='require' name='sea_esop2'/>
      <feature policy='disable' name='te'/>
      <feature policy='require' name='cmm'/>
      <feature policy='disable' name='csske'/>
    </mode>

A domain may be defined with a new <cpu> XML attribute, deprecated_features='on|off':

  <cpu mode='host-model' check='partial' deprecated_features='off'/>

e.g. after guest has started (trimmed):

  <cpu mode='custom' match='exact' check='partial' deprecated_features='off'>
    <model fallback='forbid'>z14.2-base</model>
    <feature policy='require' name='aen'/>
    <feature policy='require' name='cmmnt'/>
    <feature policy='require' name='aefsi'/>
    <feature policy='require' name='diag318'/>
    <feature policy='require' name='mepoch'/>
    <feature policy='require' name='msa8'/>
    <feature policy='require' name='msa7'/>
    <feature policy='require' name='msa6'/>
    <feature policy='require' name='msa5'/>
    <feature policy='require' name='msa4'/>
    <feature policy='require' name='msa3'/>
    <feature policy='require' name='msa2'/>
    <feature policy='require' name='msa1'/>
    <feature policy='require' name='sthyi'/>
    <feature policy='require' name='edat'/>
    <feature policy='require' name='ri'/>
    <feature policy='require' name='edat2'/>
    <feature policy='require' name='etoken'/>
    <feature policy='require' name='vx'/>
    <feature policy='require' name='ipter'/>
    <feature policy='require' name='mepochptff'/>
    <feature policy='require' name='ap'/>
    <feature policy='require' name='vxeh'/>
    <feature policy='require' name='vxpd'/>
    <feature policy='require' name='esop'/>
    <feature policy='require' name='apqi'/>
    <feature policy='require' name='apft'/>
    <feature policy='require' name='els'/>
    <feature policy='require' name='iep'/>
    <feature policy='require' name='apqci'/>
    <feature policy='disable' name='cte'/>
    <feature policy='require' name='ais'/>
    <feature policy='disable' name='bpb'/>
    <feature policy='require' name='ctop'/>
    <feature policy='require' name='gs'/>
    <feature policy='require' name='ppa15'/>
    <feature policy='require' name='zpci'/>
    <feature policy='require' name='sea_esop2'/>
    <feature policy='disable' name='te'/>
    <feature policy='require' name='cmm'/>
    <feature policy='disable' name='csske'/>
  </cpu>

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-deprecated-features-off.s390x-latest.xml
 create mode 100644 tests/qemuxmlconfdata/cpu-model-deprecated-features-off.xml

-- 
2.47.1
Re: [PATCH v3 0/7] Allow Guest CPU Model with Deprecated Features Disabled
Posted by Jiri Denemark 4 days, 5 hours ago
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 <jdenemar@redhat.com>

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;
 }
Re: [PATCH v3 0/7] Allow Guest CPU Model with Deprecated Features Disabled
Posted by Collin Walling 4 days, 2 hours ago
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 <jdenemar@redhat.com>
> 
> 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