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. At this point there is nothing left to do anyways,
the event loop is gone so no API call that qemuStateStop() does
in attempt to save running domains can ever succeed.
But to be fair, if there was a domain running we would have
registered shutdown inhibitor so we would not get killed by
signal. So there is nothing left to do for qemuStateStop()
anyway.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1895359
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/qemu/qemu_driver.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 05f8eb2cb7..9aa0ce4ec8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1046,7 +1046,12 @@ qemuStateStop(void)
int state;
virDomainPtr *domains = NULL;
g_autofree unsigned int *flags = NULL;
- g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(qemu_driver);
+ g_autoptr(virQEMUDriverConfig) cfg = NULL;
+
+ if (!qemu_driver)
+ return -1;
+
+ cfg = virQEMUDriverGetConfig(qemu_driver);
if (!(conn = virConnectOpen(cfg->uri)))
goto cleanup;
--
2.26.2
On 12.11.2020 21:45, Michal Privoznik wrote: > 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. At this point there is nothing left to do anyways, > the event loop is gone so no API call that qemuStateStop() does > in attempt to save running domains can ever succeed. > > But to be fair, if there was a domain running we would have > registered shutdown inhibitor so we would not get killed by > signal. So there is nothing left to do for qemuStateStop() > anyway. > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1895359 > > Signed-off-by: Michal Privoznik <mprivozn@redhat.com> > --- > src/qemu/qemu_driver.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index 05f8eb2cb7..9aa0ce4ec8 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -1046,7 +1046,12 @@ qemuStateStop(void) > int state; > virDomainPtr *domains = NULL; > g_autofree unsigned int *flags = NULL; > - g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(qemu_driver); > + g_autoptr(virQEMUDriverConfig) cfg = NULL; > + > + if (!qemu_driver) > + return -1; > + > + cfg = virQEMUDriverGetConfig(qemu_driver); > > if (!(conn = virConnectOpen(cfg->uri))) > goto cleanup; > Hi, Michal. There is a machinery to handle such issues now in libvirt. https://www.redhat.com/archives/libvir-list/2020-November/msg00667.html Nikolay
© 2016 - 2024 Red Hat, Inc.