[libvirt] [PATCH v5 3/3] libvirtd: fix crash on termination

Martin Kletzander mkletzan at redhat.com
Mon Oct 30 16:21:30 UTC 2017

On Mon, Oct 30, 2017 at 07:14:39AM -0400, John Ferlan wrote:
>From: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
>The problem is incorrect order of qemu driver shutdown and shutdown
>of netserver threads that serve client requests (thru qemu driver
>Net server threads are shutdown upon dispose which is triggered
>by last daemon object unref at the end of main function. At the same
>time qemu driver is shutdown earlier in virStateCleanup. As a result
>netserver threads see invalid driver object in the middle of request
>Let's move shutting down netserver threads earlier to virNetDaemonClose.
>Note: order of last daemon unref and virStateCleanup
>is introduced in 85c3a182 for a valid reason.

I must say I don't believe that's true.  Reading it back, that patch is
wrong IMHO.  I haven't gone through all the details of it and I don't
remember them from when I rewrote part of it, but the way this should
be handled is different.

The way you can clearly identify such issues is when you see that one
thread determines the validity of data (pointer in this case).  This
must never happen.  That means that the pointer is used from more places
than how many references that object has.  However each of the pointers
for such object should have their own reference.

So the problem is probably somewhere else.

>Signed-off-by: John Ferlan <jferlan at redhat.com>
> src/rpc/virnetdaemon.c | 1 +
> 1 file changed, 1 insertion(+)
>diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
>index 8c21414897..33bd8e3b06 100644
>--- a/src/rpc/virnetdaemon.c
>+++ b/src/rpc/virnetdaemon.c
>@@ -881,6 +881,7 @@ virNetDaemonClose(virNetDaemonPtr dmn)
>     virObjectLock(dmn);
>     virHashForEach(dmn->servers, daemonServerClose, NULL);
>+    virHashRemoveAll(dmn->servers);

If I get this correctly, you are removing the servers so that their workers get
cleaned up, but that should be done in a separate step.  Most probably what
daemonServerClose should be doing.  This is a workaround, but not a proper fix.
If that's not true than the previous commit mentioned here should also be fixed

So this is a clear NACK from my POV.

>     virObjectUnlock(dmn);
> }
>libvir-list mailing list
>libvir-list at redhat.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20171030/bf7f14b4/attachment-0001.sig>

More information about the libvir-list mailing list