]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virnetdaemon: Wait for "daemon-stop" thread to finish before quitting
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 13 Nov 2020 09:56:59 +0000 (10:56 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 24 Nov 2020 16:52:54 +0000 (17:52 +0100)
commita42b46dd7db2cafe77010bfae55f2e4631a26844
tree9c719eddddf836307dd5a5a6bf6082b1b11e0a77
parentb67080b3451fced61fa92f2e445d325a4286fa5f
virnetdaemon: Wait for "daemon-stop" thread to finish before quitting

When the host is shutting down then we get PrepareForShutdown
signal on DBus to which we react by creating a thread which
runs virStateStop() and thus qemuStateStop(). But if scheduling
the thread is delayed just a but it may happen that we receive
SIGTERM (sent by systemd) to which we respond by quitting our
event loop and cleaning up everything (including drivers). And
only after that the thread gets to run only to find qemu_driver
being NULL.

What we can do is to delay exiting event loop and join the thread
that's executing virStateStop(). If the join doesn't happen in
given timeout (currently 30 seconds) then libvirtd shuts down
forcefully anyways (see virNetDaemonRun()).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1895359
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1739564

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_remote.syms
src/remote/remote_daemon.c
src/rpc/virnetdaemon.c
src/rpc/virnetdaemon.h