From: "Daniel P. Berrange" <berrange(a)redhat.com>
If the virStateInitialize call fails we must shutdown libvirtd
since drivers will not be available. Just free'ing the virNetServer
is not sufficient, we must send a SIGTERM to ourselves so that
we interrupt the event loop and trigger a orderly shutdown
* daemon/libvirtd.c: Kill ourselves if state init fails
* src/rpc/virnetserver.c: Add some debugging to event loop
---
daemon/libvirtd.c | 2 ++
src/rpc/virnetserver.c | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 8f8b8b1..4a5f671 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1160,6 +1160,8 @@ static void daemonRunStateInit(void *opaque)
* seriously delay OS bootup process */
if (virStateInitialize(virNetServerIsPrivileged(srv)) < 0) {
VIR_ERROR(_("Driver state initialization failed"));
+ /* Ensure the main event loop quits */
+ kill(getpid(), SIGTERM);
virNetServerFree(srv);
return;
}
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 35f18b9..8f3ac4b 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -671,6 +671,7 @@ void virNetServerRun(virNetServerPtr srv)
goto cleanup;
}
+ VIR_DEBUG("srv=%p quit=%d", srv, srv->quit);
while (!srv->quit) {
/* A shutdown timeout is specified, so check
* if any drivers have active state, if not
@@ -731,6 +732,7 @@ void virNetServerQuit(virNetServerPtr srv)
{
virNetServerLock(srv);
+ VIR_DEBUG("Quit requested %p", srv);
srv->quit = 1;
virNetServerUnlock(srv);
--
1.7.6