summaryrefslogtreecommitdiff
path: root/src/remote
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2021-12-09 15:29:43 +0100
committerMichal Privoznik <mprivozn@redhat.com>2021-12-10 13:51:01 +0100
commit05e518f47a78d4d54ac030c5c9e3e8e5877776c9 (patch)
tree01160ef41f19d00fbd851278c99fd6686fff69c1 /src/remote
parent6e6a11bc0ace26f41bbb81656268bf8a5d042bb0 (diff)
downloadlibvirt-05e518f47a78d4d54ac030c5c9e3e8e5877776c9.tar.gz
remote_daemon: Set shutdown callbacks only after init is done
The initialization of drivers happens in a separate thread. However, the main thread continues initialization and sets shutdown callbacks (virStateShutdownPrepare() and virStateShutdownWait()) even though the driver init thread is still running. This is dangerous because if the daemon decides to quit early (e.g. because SIGINT was delivered) the shutdownPrepare and shutdownWait callback are called over partially init drivers. Set callbacks only after all drivers were initialized. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/218 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2027400 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Diffstat (limited to 'src/remote')
-rw-r--r--src/remote/remote_daemon.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index de43a54c2e..4e10f3ad23 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -626,6 +626,10 @@ static void daemonRunStateInit(void *opaque)
driversInitialized = true;
+ virNetDaemonSetShutdownCallbacks(dmn,
+ virStateShutdownPrepare,
+ virStateShutdownWait);
+
/* Tie the non-privileged daemons to the session/shutdown lifecycle */
if (!virNetDaemonIsPrivileged(dmn)) {
@@ -1214,9 +1218,6 @@ int main(int argc, char **argv) {
#endif
/* Run event loop. */
- virNetDaemonSetShutdownCallbacks(dmn,
- virStateShutdownPrepare,
- virStateShutdownWait);
virNetDaemonRun(dmn);
ret = 0;