qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()
qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()

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 <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Jiri Denemark <62bdf77dc47919a4d59a91822129d14633cfca81@redhat.com>

crobinso/libvirt,libvirt/libvirt,olafhering/libvirt,libvirt/libvirt,jfehlig/libvirt,olafhering/libvirt,nertpinx/libvirt,nertpinx/libvirt,crobinso/libvirt,crobinso/libvirt,nertpinx/libvirt,zippy2/libvirt,jfehlig/libvirt,zippy2/libvirt,libvirt/libvirt,olafhering/libvirt,zippy2/libvirt,nertpinx/libvirt,libvirt/libvirt,zippy2/libvirt,jfehlig/libvirt,nertpinx/libvirt,crobinso/libvirt,olafhering/libvirt,jfehlig/libvirt