When virNetDaemonQuit is called, we need to let the NetServers
know a quit is pending and a subsequent Close will tear down
the environment.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/libvirt_remote.syms | 1 +
src/rpc/virnetdaemon.c | 13 +++++++++++++
src/rpc/virnetserver.c | 23 +++++++++++++++++++++++
src/rpc/virnetserver.h | 2 ++
4 files changed, 39 insertions(+)
diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index a181c4cf7..3170fbd7c 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -116,6 +116,7 @@ virNetServerNewPostExecRestart;
virNetServerNextClientID;
virNetServerPreExecRestart;
virNetServerProcessClients;
+virNetServerQuitRequested;
virNetServerSetClientAuthenticated;
virNetServerStart;
virNetServerUpdateServices;
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 8c2141489..e5b376ced 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -850,6 +850,18 @@ virNetDaemonRun(virNetDaemonPtr dmn)
}
+static int
+daemonServerQuitRequested(void *payload,
+ const void *key ATTRIBUTE_UNUSED,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ virNetServerPtr srv = payload;
+
+ virNetServerQuitRequested(srv);
+ return 0;
+}
+
+
void
virNetDaemonQuit(virNetDaemonPtr dmn)
{
@@ -857,6 +869,7 @@ virNetDaemonQuit(virNetDaemonPtr dmn)
VIR_DEBUG("Quit requested %p", dmn);
dmn->quit = true;
+ virHashForEach(dmn->servers, daemonServerQuitRequested, NULL);
virObjectUnlock(dmn);
}
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 7bab11efb..7114749ab 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -823,6 +823,29 @@ void virNetServerDispose(void *obj)
virNetServerMDNSFree(srv->mdns);
}
+
+/* virNetServerQuitRequested:
+ * @srv: Netserver pointer
+ *
+ * Disable new connections and drain anything waiting to run.
+ */
+void
+virNetServerQuitRequested(virNetServerPtr srv)
+{
+ size_t i;
+
+ if (!srv)
+ return;
+
+ VIR_DEBUG("Quit server requested '%s'", srv->name);
+
+ for (i = 0; i < srv->nservices; i++)
+ virNetServerServiceToggle(srv->services[i], false);
+
+ virThreadPoolDrain(srv->workers);
+}
+
+
void virNetServerClose(virNetServerPtr srv)
{
size_t i;
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 7728a67f5..a9bd3480b 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -57,6 +57,8 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
virFreeCallback clientPrivFree,
void *clientPrivOpaque);
+void virNetServerQuitRequested(virNetServerPtr srv);
+
void virNetServerClose(virNetServerPtr srv);
virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv);
--
2.13.6