[RFC PATCH 3/6] qemu_domain: add statsSchema to qemuDomainObjPrivate

Martin Kletzander mkletzan at redhat.com
Wed Oct 19 14:01:56 UTC 2022


On Wed, Sep 07, 2022 at 04:04:20PM +0530, Amneesh Singh wrote:
>This patch adds a hashtable for storing the stats schema and a function
>to refresh it by querying "query-stats-schemas" using
>qemuMonitorQueryStatsSchema
>
>Signed-off-by: Amneesh Singh <natto at weirdnatto.in>
>---
> src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++
> src/qemu/qemu_domain.h |  5 +++++
> 2 files changed, 46 insertions(+)
>
>diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>index fe3ce023a4..e621e8b25e 100644
>--- a/src/qemu/qemu_domain.c
>+++ b/src/qemu/qemu_domain.c

[...]

>@@ -11744,3 +11751,37 @@ qemuDomainObjWait(virDomainObj *vm)
>
>     return 0;
> }
>+
>+
>+/**
>+ * virDomainRefreshStatsSchema:
>+ * @driver: qemu driver data
>+ * @vm: Pointer to the vm object
>+ *
>+ * Load data into dom->privateData->statsSchema if not stored
>+ *
>+ * Returns -1 on failure, 0 otherwise.
>+ */
>+int
>+qemuDomainRefreshStatsSchema(virDomainObj *dom)
>+{
>+    qemuDomainObjPrivate *priv = dom->privateData;
>+    GHashTable *schema = priv->statsSchema;
>+
>+    if (schema && g_hash_table_size(schema) > 0)
>+        return 0;
>+
>+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_STATS_SCHEMAS))
>+        return 0;

So this return value indicates the data were successfully loaded
according to the docs, but it looks like it just reports there was no
error.  Even though this cannot technically happen (for now, or rather
in a future patch since there is a restriction on the stats type) it
would be nicer to use in the future.

>+
>+    qemuDomainObjEnterMonitor(dom);
>+    schema = qemuMonitorQueryStatsSchema(priv->mon, QEMU_MONITOR_QUERY_STATS_PROVIDER_LAST);
>+    qemuDomainObjExitMonitor(dom);
>+
>+    if (!schema)
>+        return -1;
>+
>+    priv->statsSchema = schema;
>+

This could override an empty hash table in statsSchema, it should be
free'd first.

[...]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20221019/65daa473/attachment-0001.sig>


More information about the libvir-list mailing list