From 86cae503a4404e068a11285564a0ee3862d1570c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Tue, 6 Mar 2018 17:56:57 +0000 Subject: [PATCH] rpc: avoid crashing in pre-exec if no workers are present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If max_workers is set to zero, then the worker thread pool won't be created, so when serializing state for pre-exec we must set various parameters to zero. Reviewed-by: John Ferlan Reviewed-by: Jim Fehlig Signed-off-by: Daniel P. Berrangé --- src/rpc/virnetserver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 7a1376bf49..3ce21a8f53 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -580,18 +580,21 @@ virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv) goto error; if (virJSONValueObjectAppendNumberUint(object, "min_workers", + srv->workers == NULL ? 0 : virThreadPoolGetMinWorkers(srv->workers)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot set min_workers data in JSON document")); goto error; } if (virJSONValueObjectAppendNumberUint(object, "max_workers", + srv->workers == NULL ? 0 : virThreadPoolGetMaxWorkers(srv->workers)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot set max_workers data in JSON document")); goto error; } if (virJSONValueObjectAppendNumberUint(object, "priority_workers", + srv->workers == NULL ? 0 : virThreadPoolGetPriorityWorkers(srv->workers)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot set priority_workers data in JSON document"));