[PATCH 0/3] qemu: add an API for "query-stats" QMP command

Amneesh Singh natto at weirdnatto.in
Thu Jul 14 05:48:53 UTC 2022


QEMU is gaining introspectable statistics which can be queried via the
"query-stats" QMP command. This patchset aims to add an API for the
same.

The returned JSON for "query-stats" is an array of objects containing
their own respective array of statistics.

Patch 1 adds the API which returns the deserialized JSON in the form of
a GPtrArray of GHashTables.

Patch 2 adds the "query-stats" to QEMU capabilities.

Patch 3 uses the API to query the halt poll success time and the halt
poll failure time.

v2 -> v3
========
Sorry for the late patchset, I was under the impression I had sent it on
Monday but apparently, I did not.

[1/3]:
  - use a single enum for all the statistics.
  - use QEMU_MONITOR_QUERY_STATS_NAME_LAST as the sentinel value for the
    provider constructor.
  - relevant changes to enum values.

[2/3]:
  - fix comment spacing

[3/3]
  - better checks


v1 -> v2
========
I have been tinkering with the v1 patchset and have rewrote the v2
patches a couple of times. I believe the current patchset is still not
perfect and would appreciate some reviews.

I have another patch or two written but they do not make any significant
changes to the current patchset.

[1/3]:
  - use virBitmap instead of an array of strings for statistics.
  - add enums for the stat names and add
    qemuMonitorQueryStatsNameTypeToString to switch between the
    "ToString" functions based on the target type.
  - change qemuMonitorQueryStatsProviderNew to a variadic function that
    takes stat enum values with the sentinel value being -1.

[2/3]:
  - No changes

[3/3]:
  - Add relevant monitor related checks to check if the domain is
    active.
  - Acquire and release qemuMonitorObj lock before and after calling
    qemuMonitorQueryStats respectively.
  - Add the check for privileged access.

Relevant QEMU patches can be found here:
https://lore.kernel.org/all/20220530150714.756954-1-pbonzini@redhat.com/

This patchset is part of the 2022 GSOC contributor project.

Amneesh Singh (3):
  qemu_monitor: add qemuMonitorQueryStats
  qemu_capabilities: add "query-stats" QMP command to the QEMU
    capabilities
  qemu_driver: use qemuMonitorQueryStats to extract halt poll time

 src/qemu/qemu_capabilities.c |   2 +
 src/qemu/qemu_capabilities.h |   1 +
 src/qemu/qemu_driver.c       |  69 ++++++++++++++++---
 src/qemu/qemu_monitor.c      |  70 +++++++++++++++++++
 src/qemu/qemu_monitor.h      |  45 ++++++++++++
 src/qemu/qemu_monitor_json.c | 130 +++++++++++++++++++++++++++++++++++
 src/qemu/qemu_monitor_json.h |   6 ++
 7 files changed, 315 insertions(+), 8 deletions(-)

-- 
2.36.1



More information about the libvir-list mailing list