[libvirt] PATCH: Ensure errors are guarenteed reported in virConnectOpen

Jim Meyering jim at meyering.net
Thu Aug 21 07:15:24 UTC 2008


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> The virConnectOpen method is unfortuantely rather special. While there is
> a virConnect object available, the current rule is that drivers must report
> errors against the global error object, because upon failure no virConnect
> object will be returned to the caller. Unforatunately, despite frequent
> cleanups of code getting this wrong, I've just audited the remote driver
> and found another 20 or so places where its wrong. This is clearly not a
> sustainable approach to error reporting.
>
> The guarenteed correct solution is actually rather simple
>
>  - Always report errors against the virConnect object, even in the driver
>    open method
>
>  - In the cleanup patch of do_open() in libvirt.c, if no global error is
>    set, copy the error from the virConnect object's virError, into the
>    global virError.
>
> With this in place we can change all the drivers back to always report
> against the error object, and thus cleanup some disgusting code like
>
>         __virRaiseError (in_open ? NULL : conn, ...
>
> To just
>
>         __virRaiseError (conn, ...

Looks good, indeed.
ACK

> Index: src/libvirt.c
> ===================================================================
...
> +    /* If not global error was set, copy any error set

s/not/no/




More information about the libvir-list mailing list