[PATCH 1/4] qemu_shim: Don't hang if failed to start domain

Michal Privoznik mprivozn at redhat.com
Mon Mar 1 11:49:55 UTC 2021


The qemu shim spawns a separate thread in which the event loop is
ran. The virEventRunDefaultImpl() call is wrapped in a while()
loop, just like it should. There are few lines of code around
which try to ensure that domain is destroyed (when quitting) and
that the last round of event loop is ran after the
virDomainDestroy() call. Only after that the loop is quit from
and the thread quits. Well, if creating the domain failed then
the thread is stuck inside event loop forever.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1920337
Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_shim.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c
index c10598df4b..21a24abade 100644
--- a/src/qemu/qemu_shim.c
+++ b/src/qemu/qemu_shim.c
@@ -45,9 +45,12 @@ qemuShimEventLoop(void *opaque G_GNUC_UNUSED)
     while (!quit) {
         g_mutex_lock(&eventLock);
         if (eventQuitFlag && !eventPreventQuitFlag) {
+            quit = true;
             if (dom) {
                 virDomainDestroy(dom);
-                quit = true;
+            } else {
+                g_mutex_unlock(&eventLock);
+                break;
             }
         }
         g_mutex_unlock(&eventLock);
-- 
2.26.2




More information about the libvir-list mailing list