[libvirt] [PATCH v2 06/10] util: Add more getters to threadpool parameters

Erik Skultety eskultet at redhat.com
Tue Mar 29 07:51:31 UTC 2016


In order for the client to see all thread counts and limits, current total
and free worker count getters need to be introduced. Client might also be
interested in the job queue length, so provide a getter for that too.
---
 src/libvirt_private.syms |  3 +++
 src/util/virthreadpool.c | 15 +++++++++++++++
 src/util/virthreadpool.h |  3 +++
 3 files changed, 21 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index af133c5..c2bff17 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2333,6 +2333,9 @@ virThreadJobSetWorker;
 
 # util/virthreadpool.h
 virThreadPoolFree;
+virThreadPoolGetCurrentWorkers;
+virThreadPoolGetFreeWorkers;
+virThreadPoolGetJobQueueDepth;
 virThreadPoolGetMaxWorkers;
 virThreadPoolGetMinWorkers;
 virThreadPoolGetPriorityWorkers;
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index e2e9fe4..518b880 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -299,6 +299,21 @@ size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool)
     return pool->nPrioWorkers;
 }
 
+size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool)
+{
+    return pool->nWorkers;
+}
+
+size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool)
+{
+    return pool->freeWorkers;
+}
+
+size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool)
+{
+    return pool->jobQueueDepth;
+}
+
 /*
  * @priority - job priority
  * Return: 0 on success, -1 otherwise
diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h
index 538b62f..bc0c907 100644
--- a/src/util/virthreadpool.h
+++ b/src/util/virthreadpool.h
@@ -46,6 +46,9 @@ virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers,
 size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool);
 size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool);
 size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool);
 
 void virThreadPoolFree(virThreadPoolPtr pool);
 
-- 
2.4.3




More information about the libvir-list mailing list