virThreadPool: Prevent switching between zero and non-zero maxWorkers

...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>
This commit is contained in:
Marc Hartmayer 2018-07-03 13:37:35 +02:00 committed by John Ferlan
parent 45e00c7f2d
commit 46d258d1fd

View 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,