提交 f44bfb7f 编写于 作者: J Jiri Denemark

Make error reporting in libvirtd thread safe

Bug https://bugzilla.redhat.com/show_bug.cgi?id=689374 reported libvirtd
crash during error dispatch.

The reason is that libvirtd uses remoteDispatchConnError() with non-NULL
conn parameter which means that virConnGetLastError() is used instead of
its thread safe replacement virGetLastError().

So when several libvirtd threads are reporting errors at the same time,
the errors can get mixed or corrupted or in case of bad luck libvirtd
itself crashes.

Since Daniel B. is going to rewrite this code from scratch on top of his
RPC infrastructure, I tried to come up with a minimal fix. Thus,
remoteDispatchConnError() now just ignores its conn argument and always
calls virGetLastError(). However, several callers had to be touched as
well, since no libvirt API is allowed to be called before dispatching
the error. Doing so would reset the error and we would have nothing to
dispatch. As a result of that, the code is not very nice but that
doesn't really make daemon/remote.c worse than it is now :-) And it will
all die soon, which is good.

The bug report also contains a reproducer in C which detects both mixed
up error messages and libvirtd crash. Before this patch, I was able to
crash libvirtd in about 20 seconds up to 3 minutes depending on number
of CPU cores (more is better) and luck.
上级 9450a7cb
......@@ -113,14 +113,10 @@ void remoteDispatchOOMError (remote_error *rerr)
void remoteDispatchConnError (remote_error *rerr,
virConnectPtr conn)
virConnectPtr conn ATTRIBUTE_UNUSED)
{
virErrorPtr verr;
virErrorPtr verr = virGetLastError();
if (conn)
verr = virConnGetLastError(conn);
else
verr = virGetLastError();
if (verr)
remoteDispatchCopyError(rerr, verr);
else
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册