From: Sandesh Patel <sandesh.patel@nutanix.com>
Hi,
This RFC series adds libvirt support for ARM CPU features that are
exposed by QEMU as multi-valued properties, rather than the on/off
booleans we are used to from x86.
Background
==========
On ARM, several CPU properties can take one of a small set of
values (e.g. "0.0", "1.0", "1.1_base", "off"), and the set
of values supported by each property is host-specific. This cannot
be expressed using libvirt's existing boolean feature model.
This series depends on a pending QEMU RFC [1] that introduces
non-boolean feature handling for ARM CPUs. That series also adds a
new QMP command, query-arm-cpu-props-info, which reports the values
the host accelerator supports for each ARM CPU property. Example
reply fragment:
{
"name": "hw_prop_WRPs",
"supported-values": ["0-3"],
"type": "number"
}
On top of that QEMU work, this libvirt RFC wires up the end-to-end
flow: probing the host, caching the probed information, exposing
the values in the guest CPU XML, and passing them through to the
QEMU -cpu command line.
I am posting this as an RFC primarily to get maintainer feedback on
the overall approach before investing in the missing pieces (in
particular, value validation, which is intentionally not yet
implemented). See "Open questions" below.
Overview of the series
======================
1. "Query supported ARM CPU property values from QEMU"
Adds the QMP wrapper for query-arm-cpu-props-info, a new
QEMU_CAPS_QUERY_ARM_CPU_PROPS_INFO capability bit, and the
qemuMonitorCPUPropsInfoList data structure. The command is
issued on ARM + KVM hosts and the reply is stored in the
per-accelerator capabilities.
2. "Cache ARM CPU property information"
Persists the probed list into the on-disk QEMU capabilities
cache as <cpuPropertyInfo>, so that subsequent libvirtd
restarts do not need to re-issue the QMP query.
3. "Support 'value' attribute on CPU features"
Extends the guest CPU XML with an optional 'value' attribute
on <feature>:
<cpu mode='host-passthrough'>
<feature policy='require' name='feat_RAS' value='1.0'/>
<feature policy='require' name='hw_prop_API' value='off'/>
<feature policy='enable' name='hw_prop_WRPs' value='2'/>
</cpu>
When a feature carries a non-NULL 'value', libvirt emits
'<name>=<value>' on the QEMU -cpu command line; in that case
the policy must be 'require' or 'force'. The existing
policy-driven '=on' / '=off' path is used only for features
without an explicit value.
All ARM property names returned by query-arm-cpu-props-info
are registered in src/cpu_map/arm_features.xml so that the
guest XML parser and validator accept them.
With this change, the generated QEMU command line can look
like:
-cpu host-passthrough,hw_prop_API=off,hw_prop_WRPs=2
Open questions
==============
- Value validation: should libvirt validate the requested value
against the host's supported-values list at define time, at
start time, or defer entirely to QEMU?
- Policy vs. value conflicts: is requiring policy='require' /
'force' whenever 'value' is set the right rule?
- Caching location: is the per-accelerator QEMU capabilities
cache the right place to store the probed property list, or
should this live alongside the CPU model data in cpu_map?
[1]
https://lore.kernel.org/qemu-arm/20260605083358.1320563-1-khushit.shah@nutanix.com/
Thanks
Sandesh Patel (3):
Query supported ARM CPU property values from QEMU
Cache ARM CPU property information
Support 'value' attribute on CPU features
src/conf/cpu_conf.c | 21 ++-
src/conf/cpu_conf.h | 1 +
src/conf/schemas/cputypes.rng | 5 +
src/cpu_map/arm_features.xml | 170 ++++++++++++++++++
src/qemu/qemu_capabilities.c | 133 +++++++++++++-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 13 ++
src/qemu/qemu_monitor.c | 51 ++++++
src/qemu/qemu_monitor.h | 26 +++
src/qemu/qemu_monitor_json.c | 66 +++++++
src/qemu/qemu_monitor_json.h | 5 +
.../caps_11.1.0_aarch64.replies | 69 +++++++
.../caps_11.1.0_aarch64.xml | 14 ++
tests/qemumonitorjsontest.c | 91 ++++++++++
...arch64-cpu-passthrough.aarch64-latest.args | 2 +-
...aarch64-cpu-passthrough.aarch64-latest.xml | 6 +-
.../aarch64-cpu-passthrough.xml | 6 +-
tests/testutilshostcpus.h | 74 ++++----
18 files changed, 709 insertions(+), 45 deletions(-)
--
2.43.7