Ensure that libvirtd shuts down if initialization fails

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
This commit is contained in:
Daniel P. Berrange 2011-07-21 18:23:21 +01:00
parent d489b04628
commit 92509413e2
2 changed files with 4 additions and 0 deletions

View File

@ -1156,6 +1156,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;
}

View File

@ -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);