On 11/6/25 17:26, Praveen K Paladugu wrote: > From: Praveen K Paladugu <[email protected]> > > Use the `query-accelerators` command to generically query the enabled > acclerator. Below is an example invocation in Qemu: > > { "execute": "query-accelerators"} > "return": {"enabled": "kvm", "present": ["kvm", "mshv", "qtest", "tcg", > "xen"]}} > > "enabled" here indicates "kvm" is the enabled accelertor. > > If query-accelerators command is not available, fallback to existing > mechnisms for querying kvm and hvf capabilities. > > Signed-off-by: Praveen K Paladugu <[email protected]> > --- > src/qemu/qemu_capabilities.c | 38 ++++++++++++++++--- > src/qemu/qemu_monitor.c | 9 +++++ > src/qemu/qemu_monitor.h | 4 ++ > src/qemu/qemu_monitor_json.c | 23 +++++++++++ > src/qemu/qemu_monitor_json.h | 5 +++ > .../caps_10.2.0_x86_64.replies | 11 ++++-- > 6 files changed, 82 insertions(+), 8 deletions(-) > > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c > index b0d4e76572..38e1913d49 100644 > --- a/src/qemu/qemu_capabilities.c > +++ b/src/qemu/qemu_capabilities.c > @@ -3466,6 +3466,29 @@ virQEMUCapsProbeQMPKVMState(virQEMUCaps *qemuCaps, > return 0; > } > > +static int > +virQEMUCapsProbeAccels(virQEMUCaps *qemuCaps, > + qemuMonitor *mon) > +{ > + g_autofree char *enabled = NULL; > + > + if (qemuMonitorGetAccelerators(mon, &enabled) < 0) > + return -1; > + > + if (!enabled) { > + return 0; > + } > + > + if (STREQ(enabled, "tcg")) > + virQEMUCapsSet(qemuCaps, QEMU_CAPS_TCG); > + else if (STREQ(enabled, "hvf")) > + virQEMUCapsSet(qemuCaps, QEMU_CAPS_HVF); > + else if (STREQ(enabled, "kvm")) > + virQEMUCapsSet(qemuCaps, QEMU_CAPS_KVM);
Ignoring an unknown accelerator is fine, but failing to extract one from QEMU reply (of QEMU failing to set 'enabled' attribute should be a failure. > + > + return 0; > +} > + Michal
