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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 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
@@ -1708,6 +1708,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *priv)
 
     priv->originalMemlock = 0;
     priv->preMigrationMemlock = 0;
+
+    virHashRemoveAll(priv->statsSchema);
 }
 
 
@@ -1747,6 +1749,9 @@ qemuDomainObjPrivateFree(void *data)
         g_object_unref(priv->eventThread);
     }
 
+    if (priv->statsSchema)
+        g_clear_pointer(&priv->statsSchema, g_hash_table_destroy);
+
     g_free(priv);
 }
 
@@ -1778,6 +1783,8 @@ qemuDomainObjPrivateAlloc(void *opaque)
     priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
     priv->driver = opaque;
 
+    priv->statsSchema = NULL;
+
     return g_steal_pointer(&priv);
 }
 
@@ -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;
+
+    qemuDomainObjEnterMonitor(dom);
+    schema = qemuMonitorQueryStatsSchema(priv->mon, QEMU_MONITOR_QUERY_STATS_PROVIDER_LAST);
+    qemuDomainObjExitMonitor(dom);
+
+    if (!schema)
+        return -1;
+
+    priv->statsSchema = schema;
+
+    return 0;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 592ee9805b..cbc65feafc 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -244,6 +244,8 @@ struct _qemuDomainObjPrivate {
 
     unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no
                                          * restore will be required later */
+
+    GHashTable *statsSchema; /* (name, data) pair for stats */
 };
 
 #define QEMU_DOMAIN_PRIVATE(vm) \
@@ -1098,3 +1100,6 @@ qemuDomainRemoveLogs(virQEMUDriver *driver,
 
 int
 qemuDomainObjWait(virDomainObj *vm);
+
+int
+qemuDomainRefreshStatsSchema(virDomainObj *dom);
-- 
2.37.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux