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 for "query-stats" and a function to deserialize the returned objects into respective hashtables. 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. v3 -> v4 ======== Some changes based on past reviews by Mr. Martin and me [1/3]: - - clean up qemuMonitorQueryStatsProviderNew. - make relevant checks/changes to support the change above. - do NOT return the GPtrArray, instead just return the json object. (this helps retain the non-stat info returned which will be useful in the future patches). - add a function which deserializes value associated with the "stats" key in the JSON object (one of the objects returned in the JSON array above) into a GHashTable. [2/3]: - add a flag to for the capability in tests. [3/3]: - use a helper function to make things cleaner. 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@xxxxxxxxxx/ 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 | 4 + src/qemu/qemu_capabilities.h | 3 + src/qemu/qemu_driver.c | 81 +++++++++++- src/qemu/qemu_monitor.c | 117 ++++++++++++++++++ src/qemu/qemu_monitor.h | 48 +++++++ src/qemu/qemu_monitor_json.c | 91 ++++++++++++++ src/qemu/qemu_monitor_json.h | 6 + .../caps_7.1.0.x86_64.xml | 1 + 8 files changed, 345 insertions(+), 6 deletions(-) -- 2.37.1