[libvirt] [PATCH 03/23] Add APIs for virThreadPoolPtr to query some config params

Daniel P. Berrange berrange at redhat.com
Thu Aug 9 15:20:08 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

It is desirable to be able to query the config params of
the thread pool, in order to save the server state. Add
virThreadPoolGetMinWorkers, virThreadPoolGetMaxWorkers
and virThreadPoolGetPriorityWorkers APIs.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 src/libvirt_private.syms |  3 +++
 src/util/threadpool.c    | 19 +++++++++++++++++++
 src/util/threadpool.h    |  4 ++++
 3 files changed, 26 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 79b4a18..3a23fe6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1085,6 +1085,9 @@ virSysinfoRead;
 virThreadPoolFree;
 virThreadPoolNew;
 virThreadPoolSendJob;
+virThreadPoolGetMinWorkers;
+virThreadPoolGetMaxWorkers;
+virThreadPoolGetPriorityWorkers;
 
 
 # threads.h
diff --git a/src/util/threadpool.c b/src/util/threadpool.c
index 63c5ea0..2ae11b8 100644
--- a/src/util/threadpool.c
+++ b/src/util/threadpool.c
@@ -66,6 +66,7 @@ struct _virThreadPool {
     virCond quit_cond;
 
     size_t maxWorkers;
+    size_t minWorkers;
     size_t freeWorkers;
     size_t nWorkers;
     virThreadPtr workers;
@@ -188,7 +189,9 @@ virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
     if (VIR_ALLOC_N(pool->workers, minWorkers) < 0)
         goto error;
 
+    pool->minWorkers = minWorkers;
     pool->maxWorkers = maxWorkers;
+
     for (i = 0; i < minWorkers; i++) {
         if (VIR_ALLOC(data) < 0) {
             virReportOOMError();
@@ -277,6 +280,22 @@ void virThreadPoolFree(virThreadPoolPtr pool)
     VIR_FREE(pool);
 }
 
+
+size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool)
+{
+    return pool->minWorkers;
+}
+
+size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool)
+{
+    return pool->maxWorkers;
+}
+
+size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool)
+{
+    return pool->nPrioWorkers;
+}
+
 /*
  * @priority - job priority
  * Return: 0 on success, -1 otherwise
diff --git a/src/util/threadpool.h b/src/util/threadpool.h
index 894b278..798fd0b 100644
--- a/src/util/threadpool.h
+++ b/src/util/threadpool.h
@@ -39,6 +39,10 @@ virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
                                   virThreadPoolJobFunc func,
                                   void *opaque) ATTRIBUTE_NONNULL(4);
 
+size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool);
+
 void virThreadPoolFree(virThreadPoolPtr pool);
 
 int virThreadPoolSendJob(virThreadPoolPtr pool,
-- 
1.7.11.2




More information about the libvir-list mailing list