If QEMU driver fails to initialize for whatever reason (it can be
as trivial as a typo on qemu.conf), the control jumps to error
label in qemuStateInitialize() where qemuStateCleanup() is called
which frees the driver. But the daemon then asks drivers to
prepare for shutdown, which in case of QEMU driver is implemented
in qemuStateShutdownPrepare(). In here, the driver is
dereferenced but since it was freed earlier, the pointer is NULL
which leads to instant crash.
Solution is simple - just check if qemu_driver is not NULL. But
doing so only in qemuStateShutdownPrepare() would push the
problem down to virStateShutdownWait(), well
qemuStateShutdownWait(). Therefore, duplicate the trick there
too.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=
1895359#c14
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
static int
qemuStateShutdownPrepare(void)
{
+ if (!qemu_driver)
+ return 0;
+
virThreadPoolStop(qemu_driver->workerPool);
return 0;
}
static int
qemuStateShutdownWait(void)
{
+ if (!qemu_driver)
+ return 0;
+
virDomainObjListForEach(qemu_driver->domains, false,
qemuDomainObjStopWorkerIter, NULL);
virThreadPoolDrain(qemu_driver->workerPool);