]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add APIs for virThreadPoolPtr to query some config params
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 9 Aug 2012 10:48:17 +0000 (11:48 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 15 Aug 2012 09:55:51 +0000 (10:55 +0100)
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@redhat.com>
src/libvirt_private.syms
src/util/threadpool.c
src/util/threadpool.h

index 4c4a9bd08b24153ef7deba954d33e0fb854275a8..649f2c308cf891d9636fff6fca91b4420e7fd61f 100644 (file)
@@ -1086,6 +1086,9 @@ virSysinfoRead;
 virThreadPoolFree;
 virThreadPoolNew;
 virThreadPoolSendJob;
+virThreadPoolGetMinWorkers;
+virThreadPoolGetMaxWorkers;
+virThreadPoolGetPriorityWorkers;
 
 
 # threads.h
index 63c5ea0c1529200938c49dd6bfe9a2f6af24929c..2ae11b8b8aede261a58810f7676d4f1bb1e8e90a 100644 (file)
@@ -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
index 894b2783e2589ca56c851c5be3009862c1c1a384..798fd0b7f78eac35965c0dc85e854135c914f3d0 100644 (file)
@@ -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,