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

Michal Privoznik mprivozn at redhat.com
Fri Mar 12 14:24:34 UTC 2021


On 3/12/21 11:42 AM, Andrea Bolognani wrote:
> On Mon, 2021-03-01 at 12:49 +0100, Michal Privoznik wrote:
>> +++ 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);
> 
> I'm probably missing something obvious, but I thought this could be
> simply
> 
>    while (!quit) {
>        g_mutex_lock(&eventLock);
>        if (eventQuitFlag && !eventPreventQuitFlag) {
>            quit = true;
>            if (dom) {
>                virDomainDestroy(dom);
>            }
>        }
>        g_mutex_unlock(&eventLock);
>        virEventRunDefaultImpl();
>    }
> 
> Do we specifically want to avoid call virEventRunDefaultImpl() one
> last time if the domain has failed to start?
> 

Huh, riddle me this - how come now this is sufficient, but back then 
when I was writing this it wasn't?

diff --git i/src/qemu/qemu_shim.c w/src/qemu/qemu_shim.c
index c10598df4b..5a9ffdd416 100644
--- i/src/qemu/qemu_shim.c
+++ w/src/qemu/qemu_shim.c
@@ -45,9 +45,9 @@ qemuShimEventLoop(void *opaque G_GNUC_UNUSED)
      while (!quit) {
          g_mutex_lock(&eventLock);
          if (eventQuitFlag && !eventPreventQuitFlag) {
+            quit = true;
              if (dom) {
                  virDomainDestroy(dom);
-                quit = true;
              }
          }
          g_mutex_unlock(&eventLock);

Will post it as v2, soon.

Michal




More information about the libvir-list mailing list