From 46d258d1fda80b2fe6c518c0dfa9794f38e307de Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Tue, 3 Jul 2018 13:37:35 +0200 Subject: [PATCH] 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 Reviewed-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: John Ferlan --- src/util/virthreadpool.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 10f2bd2c3a..4635170141 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -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, -- GitLab