Description of problem: virt-qemu-run hang if starting qemu process failed Version-Release number of selected component (if applicable): libvirt-daemon-7.0.0-2.module+el8.4.0+9520+ef609c5f.x86_64 How reproducible: 100% Steps to Reproduce: 1.Start a qemu process with enforcing mode selinux policy(see https://bugzilla.redhat.com/show_bug.cgi?id=1772943#c7): # virt-qemu-run -v -d /root/vm2.xml virt-qemu-run: 32: initializing libvirt 4348 virt-qemu-run: 1790: initializing signal handlers virt-qemu-run: 1888: preparing event loop thread virt-qemu-run: 1973: opening qemu:///embed?root=/tmp/virt-qemu-run-2MRIX0 virt-qemu-run: 32725: fetching guest config /root/vm2.xml virt-qemu-run: 32761: starting guest /root/vm2.xml virt-qemu-run: cannot start VM: can't connect to virtlogd: Cannot recv data: Connection reset by peer 2.After step1, virt-qemu-run did not exit and also can not terminate by 'ctrl-c'; 3.After step2, check the virt-qemu-run process: # ps aux | grep -i virt-qemu-run root 4348 0.0 0.0 550184 25580 pts/0 Tl 00:51 0:00 virt-qemu-run -v -d /root/vm2.xml 4.The backtrace of virt-qemu-run: (gdb) t a a bt Thread 2 (Thread 0x7f1738dd7700 (LWP 4349)): #0 0x00007f174dd35a31 in __GI___poll (fds=0x563311e9a3a0, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x00007f174e26eab6 in g_main_context_poll (priority=<optimized out>, n_fds=2, fds=0x563311e9a3a0, timeout=<optimized out>, context=0x563311e9a2e0) at gmain.c:4203 #2 0x00007f174e26eab6 in g_main_context_iterate (context=context@entry=0x563311e9a2e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3897 #3 0x00007f174e26ebe0 in g_main_context_iteration (context=0x563311e9a2e0, may_block=1) at gmain.c:3963 #4 0x00007f174e60d134 in virEventGLibRunOnce () at /lib64/libvirt.so.0 #5 0x0000563310d67cbd in qemuShimEventLoop () #6 0x00007f174e296e1a in g_thread_proxy (data=0x563311e96400) at gthread.c:784 #7 0x00007f174ad6214a in start_thread (arg=<optimized out>) at pthread_create.c:479 #8 0x00007f174dd40db3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 1 (Thread 0x7f174eda2fc0 (LWP 4348)): #0 0x00007f174ad6363d in __GI___pthread_timedjoin_ex (threadid=139737715013376, thread_return=thread_return@entry=0x0, abstime=abstime@entry=0x0, block=block@entry=true) at pthread_join_common.c:89 #1 0x00007f174ad63450 in __pthread_join (threadid=<optimized out>, thread_return=thread_return@entry=0x0) at pthread_join.c:24 #2 0x00007f174e2b59bb in g_system_thread_wait (thread=0x563311e96400) at gthread-posix.c:1219 #3 0x00007f174e2972ae in g_thread_join (thread=0x563311e96400) at gthread.c:952 #4 0x0000563310d67319 in main () Actual results: virt-qemu-run hang if starting qemu process failed Expected results: virt-qemu-run should exit if starting qemu process failed Additional info:
Patches posted upstream: https://listman.redhat.com/archives/libvir-list/2021-March/msg00010.html
v2: https://listman.redhat.com/archives/libvir-list/2021-March/msg00607.html
Merged upstream: 52a937d8a2 qemu_shim: Don't hang if failed to start domain v7.1.0-202-g52a937d8a2
Verifeid with libvirt-daemon-7.3.0-1.module+el8.5.0+11004+f4810536.x86_64. Test steps: 1.Start a qemu process with enforcing mode selinux policy(see https://bugzilla.redhat.com/show_bug.cgi?id=1772943#c7), process exited successfully after failed to start: # virt-qemu-run -d -v /root/vm1.xml virt-qemu-run: 31: initializing libvirt 104942 virt-qemu-run: 2603: initializing signal handlers virt-qemu-run: 2891: preparing event loop thread virt-qemu-run: 2989: opening qemu:///embed?root=%2Ftmp%2Fvirt-qemu-run-JRNW30 virt-qemu-run: 36677: fetching guest config /root/vm1.xml virt-qemu-run: 36820: starting guest /root/vm1.xml virt-qemu-run: cannot start VM: can't connect to virtlogd: Cannot recv data: Connection reset by peer virt-qemu-run: 618467: cleaned up, exiting
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2021:4684