[RFC PATCH 4/6] qemu_monitor: add qemuMonitorGetStatsByQOMPath

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

 



This function returns the virJSONValue object which has the
same qom_path as specified.

Signed-off-by: Amneesh Singh <natto@xxxxxxxxxxxxx>
---
 src/qemu/qemu_monitor.c | 38 ++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_monitor.h |  4 ++++
 2 files changed, 42 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 9581e90796..3d4302a6ed 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1537,6 +1537,7 @@ qemuMonitorGetCPUInfoLegacy(struct qemuMonitorQueryCpusEntry *cpuentries,
             vcpus[i].tid = cpuentries[i].tid;
             vcpus[i].halted = cpuentries[i].halted;
             vcpus[i].qemu_id = cpuentries[i].qemu_id;
+            vcpus[i].qom_path = g_strdup(cpuentries[i].qom_path);
         }
 
         /* for legacy hotplug to work we need to fake the vcpu count added by
@@ -4446,3 +4447,40 @@ qemuMonitorExtractQueryStats(virJSONValue *info)
 
     return g_steal_pointer(&hash_table);
 }
+
+
+/**
+ * qemuMonitorStatsSchemaByQOMPath:
+ * @arr: Array of objects returned by qemuMonitorQueryStats
+ *
+ * Returns the object which matches the QOM path of the vCPU
+ *
+ * Returns NULL on failure.
+ */
+virJSONValue *
+qemuMonitorGetStatsByQOMPath(virJSONValue *arr,
+                             char *qom_path)
+{
+    size_t i;
+
+    if (!virJSONValueIsArray(arr) || !qom_path)
+        return NULL;
+
+    for (i = 0; i < virJSONValueArraySize(arr); i++) {
+        virJSONValue *obj = virJSONValueArrayGet(arr, i);
+        const char *test_qom_path = NULL;
+
+        if (!obj)
+            return NULL;
+
+        test_qom_path = virJSONValueObjectGetString(obj, "qom-path");
+
+        if (!test_qom_path)
+            return NULL;
+
+        if (STRCASEEQ(qom_path, test_qom_path))
+            return obj;
+    }
+
+    return NULL;
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 4c817dea20..6b0440fdf0 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1564,3 +1564,7 @@ qemuMonitorQueryStats(qemuMonitor *mon,
 
 GHashTable *
 qemuMonitorExtractQueryStats(virJSONValue *info);
+
+virJSONValue *
+qemuMonitorGetStatsByQOMPath(virJSONValue *arr,
+                             char *qom_path);
-- 
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