mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
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>
This commit is contained in:
parent
6e6a11bc0a
commit
05e518f47a
@ -626,6 +626,10 @@ static void daemonRunStateInit(void *opaque)
|
|||||||
|
|
||||||
driversInitialized = true;
|
driversInitialized = true;
|
||||||
|
|
||||||
|
virNetDaemonSetShutdownCallbacks(dmn,
|
||||||
|
virStateShutdownPrepare,
|
||||||
|
virStateShutdownWait);
|
||||||
|
|
||||||
/* Tie the non-privileged daemons to the session/shutdown lifecycle */
|
/* Tie the non-privileged daemons to the session/shutdown lifecycle */
|
||||||
if (!virNetDaemonIsPrivileged(dmn)) {
|
if (!virNetDaemonIsPrivileged(dmn)) {
|
||||||
|
|
||||||
@ -1214,9 +1218,6 @@ int main(int argc, char **argv) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Run event loop. */
|
/* Run event loop. */
|
||||||
virNetDaemonSetShutdownCallbacks(dmn,
|
|
||||||
virStateShutdownPrepare,
|
|
||||||
virStateShutdownWait);
|
|
||||||
virNetDaemonRun(dmn);
|
virNetDaemonRun(dmn);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user