]> xenbits.xensource.com Git - libvirt.git/commitdiff
virThreadPool: Prevent switching between zero and non-zero maxWorkers
authorMarc Hartmayer <mhartmay@linux.ibm.com>
Tue, 3 Jul 2018 11:37:35 +0000 (13:37 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 21 Jul 2018 11:46:45 +0000 (07:46 -0400)
...since maxWorkers=0 is only intended for virtlockd or virlogd which
must not be multithreaded.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/util/virthreadpool.c

index 10f2bd2c3a03ac1186d393258b643bcea2cadf96..463517014194a507d2a258756339cf879984320d 100644 (file)
@@ -442,6 +442,14 @@ virThreadPoolSetParameters(virThreadPoolPtr pool,
         goto error;
     }
 
+    if ((maxWorkers == 0 && pool->maxWorkers > 0) ||
+        (maxWorkers > 0 && pool->maxWorkers == 0)) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("maxWorkers must not be switched from zero to non-zero"
+                         " and vice versa"));
+        goto error;
+    }
+
     if (minWorkers >= 0) {
         if ((size_t) minWorkers > pool->nWorkers &&
             virThreadPoolExpand(pool, minWorkers - pool->nWorkers,