]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test_driver: Introduce testDomainGetStatsIOThread
authorLuke Yue <lukedyue@gmail.com>
Wed, 15 Sep 2021 15:30:31 +0000 (23:30 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 23 Sep 2021 11:41:36 +0000 (13:41 +0200)
Introduce testDomainGetStatsIOThread to add support for
testConnectGetAllDomainStats to get IOThread infos.

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/test/test_driver.c

index baaf650980163bca8b21cc64ef1bc9252c9fcf47..b5413cc03d047425d432298270c476970d2738a7 100644 (file)
@@ -9905,6 +9905,46 @@ testDomainGetStatsState(virDomainObj *dom,
     return 0;
 }
 
+static int
+testDomainGetStatsIOThread(virDomainObj *dom,
+                           virTypedParamList *params)
+{
+    testDomainObjPrivate *priv = dom->privateData;
+    size_t i;
+    int niothreads = 0;
+
+    if (!virDomainObjIsActive(dom))
+        return 0;
+
+    niothreads = priv->iothreads->len;
+
+    if (niothreads == 0) {
+        return 0;
+    }
+
+    if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0)
+        return -1;
+
+    for (i = 0; i < niothreads; i++) {
+        testIOThreadInfo iothread = g_array_index(priv->iothreads,
+                                                  testIOThreadInfo, i);
+        if (virTypedParamListAddULLong(params, iothread.poll_max_ns,
+                                       "iothread.%u.poll-max-ns",
+                                       iothread.iothread_id) < 0)
+            return -1;
+        if (virTypedParamListAddUInt(params, iothread.poll_grow,
+                                     "iothread.%u.poll-grow",
+                                     iothread.iothread_id) < 0)
+            return -1;
+        if (virTypedParamListAddUInt(params, iothread.poll_shrink,
+                                     "iothread.%u.poll-shrink",
+                                     iothread.iothread_id) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
 typedef int
 (*testDomainGetStatsFunc)(virDomainObj *dom,
                           virTypedParamList *list);
@@ -9916,6 +9956,7 @@ struct testDomainGetStatsWorker {
 
 static struct testDomainGetStatsWorker testDomainGetStatsWorkers[] = {
     { testDomainGetStatsState, VIR_DOMAIN_STATS_STATE },
+    { testDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD },
     { NULL, 0 }
 };
 
@@ -9962,7 +10003,8 @@ testConnectGetAllDomainStats(virConnectPtr conn,
                                    VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT |
                                    VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE);
 
-    unsigned int supported = VIR_DOMAIN_STATS_STATE;
+    unsigned int supported = VIR_DOMAIN_STATS_STATE |
+                             VIR_DOMAIN_STATS_IOTHREAD;
     virDomainObj **vms = NULL;
     size_t nvms;
     virDomainStatsRecordPtr *tmpstats = NULL;