[libvirt] [PATCH] Unify most error reporting (ver 2)

Cole Robinson crobinso at redhat.com
Wed Oct 8 18:17:45 UTC 2008


The attached patch is a more complete cut at unifying
error reporting among the different source files.
Most files have their own custom Error function, each
with varying degrees of functionality, and lots of
code duplication.

The attached patch adds a helper function to virterror.c
that centralizes all this logic, and redefines each
local error function as a macro that calls out to
the helper. The fixed files now offer printf style
reporting, and the macros pass off function name,
file name, and line number of the reported error 
(currently not used, but handy to have).

This change centralizes probably 90% of the error calls.
Some files have pretty custom error functions that
don't map easily to the helper, or call __virRaiseError
directly in a number of places, so I skipped these for
now. Eventually we should move all these edge cases over
so any src/ wide error changes will be pretty easy to
make.

The one thing we lose here is that some some places
were logging info in the err{1,2,3} and int{1,2} fields
of raised error. I don't consider this a loss: even
where it was used, it was used inconsistently and
rarely for anything that would be useful to a user.
In the places where the data had some value, I
included it in the error string.

One side question: is src/xmlrpc.{c,h} even used? And
if not, can it be removed?

Thanks,
Cole

 domain_conf.c    |   27 +-----------
 hash.c           |   26 +-----------
 internal.h       |    6 ++
 lxc_conf.c       |   21 ---------
 lxc_conf.h       |    7 +--
 network_conf.c   |   23 +---------
 openvz_conf.c    |   22 ----------
 openvz_conf.h    |    7 ++-
 proxy_internal.c |   23 +---------
 qemu_conf.c      |   21 ---------
 qemu_conf.h      |    8 +--
 qparams.c        |   10 +---
 sexpr.c          |   25 +----------
 storage_conf.c   |   19 ---------
 storage_conf.h   |    7 +--
 test.c           |   28 ++++---------
 util.c           |   27 +-----------
 virterror.c      |   40 ++++++++++++++++++
 xen_internal.c   |  116 ++++++++++++++++++-------------------------------------
 xen_unified.c    |   24 ++---------
 xend_internal.c  |   59 ++-------------------------
 xm_internal.c    |   28 ++-----------
 xml.c            |   43 +++++---------------
 xs_internal.c    |   23 +---------
 24 files changed, 164 insertions(+), 476 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-2unify-report-error.patch
Type: text/x-patch
Size: 41947 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20081008/fbe9aff1/attachment-0001.bin>


More information about the libvir-list mailing list