[libvirt] [PATCH] fix bug libvirt daemon deadlock when another force console break down an existed console client when this deadlock hanppened, libvirtd backtrace as follow, a typical ABBA deadlock circumstance:

LanceLiu liu.lance.89 at gmail.com
Tue Nov 19 11:39:50 UTC 2019

(gdb) thread 23
[Switching to thread 23 (Thread 0x7fbb54810700 (LWP 296966))]
(gdb) bt
    at rpc/virnetserverclient.c:1503
    client=client at entry=0x5641d20e20a0, msg=0x7fbb08003ab0, rerr=rerr at entry=0x7fbb5480f7b0, procedure=201,
    type=type at entry=3, serial=9) at rpc/virnetserverprogram.c:173
    msg=<optimized out>, rerr=rerr at entry=0x7fbb5480f7b0, procedure=<optimized out>, serial=<optimized out>)
    at rpc/virnetserverprogram.c:222
    opaque=opaque at entry=0x5641d20e20a0) at stream.c:246
    force=force at entry=true) at conf/virchrdev.c:386
    at qemu/qemu_driver.c:16188
    st=st at entry=0x7fbb08008fc0, flags=1) at libvirt-domain.c:9363
    rerr=0x7fbb5480fc10, msg=<optimized out>, client=0x5641d20e4e80) at remote_dispatch.h:8540
    rerr=0x7fbb5480fc10, args=0x7fbb08005eb0, ret=<optimized out>) at remote_dispatch.h:8505
    server=0x5641d20be420, prog=0x5641d20da580) at rpc/virnetserverprogram.c:437
    msg=0x5641d20e9a20) at rpc/virnetserverprogram.c:307
    srv=0x5641d20be420) at rpc/virnetserver.c:148
---Type <return> to continue, or q <return> to quit---

(gdb) thread 26
[Switching to thread 26 (Thread 0x7fbb87a378c0 (LWP 295636))]
(gdb) bt
    at stream.c:286
    at rpc/virnetserverclient.c:1247
    at rpc/virnetserverclient.c:1457
    at util/vireventpoll.c:508

Signed-off-by: LanceLiu <liu.lance.89 at gmail.com>
 src/remote/remote_daemon_stream.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 1f6e783..b27348f 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -284,14 +284,16 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
  * -1 on fatal client error
 static int
-daemonStreamFilter(virNetServerClientPtr client ATTRIBUTE_UNUSED,
+daemonStreamFilter(virNetServerClientPtr client,
                    virNetMessagePtr msg,
                    void *opaque)
     daemonClientStream *stream = opaque;
     int ret = 0;
+    virObjectUnlock(client);
+    virObjectLock(client);
     if (msg->header.type != VIR_NET_STREAM &&
         msg->header.type != VIR_NET_STREAM_HOLE)

More information about the libvir-list mailing list