[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Make error reporting in libvirtd thread safe



On 03/23/2011 09:52 AM, Jiri Denemark wrote:
> 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().
> 

> 
> diff --git a/daemon/dispatch.c b/daemon/dispatch.c
> index dc3b48a..4814017 100644
> --- a/daemon/dispatch.c
> +++ b/daemon/dispatch.c
> @@ -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

I agree this avoids the problem...

> diff --git a/daemon/remote.c b/daemon/remote.c
> index a8fef4d..4b42ed2 100644
> --- a/daemon/remote.c
> +++ b/daemon/remote.c
> @@ -757,8 +757,8 @@ remoteDispatchDomainGetSchedulerType (struct qemud_server *server ATTRIBUTE_UNUS
>  
>      type = virDomainGetSchedulerType (dom, &nparams);
>      if (type == NULL) {
> -        virDomainFree(dom);
>          remoteDispatchConnError(rerr, conn);
> +        virDomainFree(dom);
>          return -1;
>      }

...and that this rearrangement is required to avoid clobbering the last
error.

I spent time browsing remote.c for any instances you might of missed,
and found one.

ACK with this squashed in:

diff --git i/daemon/remote.c w/daemon/remote.c
index 4b42ed2..7520df3 100644
--- i/daemon/remote.c
+++ w/daemon/remote.c
@@ -6590,8 +6590,8 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct
qemud_server *server ATTRIBUTE_UNU
     }

     if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags)
== -1) {
-        virDomainFree(dom);
         remoteDispatchConnError(rerr, conn);
+        virDomainFree(dom);
         return -1;
     }


-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]