[libvirt] PATCH: Ensure errors are guarenteed reported in virConnectOpen
Daniel Veillard
veillard at redhat.com
Tue Aug 19 13:42:21 UTC 2008
On Tue, Aug 19, 2008 at 11:35:18AM +0100, Daniel P. Berrange 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, ...
Okay, make sense, it's better to be more flexible in one location
and simplify code everywhere else.
+1
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list