Move libvirtd event loop into background thread

The virStateInitialize() call for starting up stateful drivers
may require that the event loop is running already. This it is
neccessary to start the event loop before this call. At the
same time, network clients must not be processed until afte
virStateInitialize has completed.

The qemudListenUnix() and remoteListenTCP() methods must
therefore not register file handle watches, merely open the
network sockets & listen() on them. This means clients can
connected and are queued, pending completion of initialization

The qemudRunLoop() method is moved into a background thread
that is started early to allow access to the event loop during
driver initialization. The main process thread leader pretty
much does nothing once the daemon is running, merely waits
for the event loop thread to quit

* daemon/libvirtd.c, daemon/libvirtd.h: Move event loop into
  a background thread
* daemon/THREADING.txt: Rewrite docs to better reflect reality
This commit is contained in:
Daniel P. Berrange
2009-10-16 16:34:37 +01:00
parent 9ae8fa5839
commit 075bb5f1aa
3 changed files with 118 additions and 83 deletions

View File

@@ -269,7 +269,9 @@ struct qemud_server {
int sigread;
int sigwrite;
char *logDir;
unsigned int shutdown : 1;
pthread_t eventThread;
unsigned int hasEventThread :1;
unsigned int quitEventThread :1;
#ifdef HAVE_AVAHI
struct libvirtd_mdns *mdns;
#endif