[libvirt] [PATCH] Improved error messages in XM conf module

Daniel P. Berrange berrange at redhat.com
Mon Sep 15 15:12:58 UTC 2008

On Mon, Sep 15, 2008 at 04:06:46PM +0100, Richard W.M. Jones wrote:
> The attached patch improves error handling in the XM config file
> parser (src/conf.c).
> Currently it has a custom error function called virConfError which has
> three problems.  Firstly the conf argument is ignored and therefore
> pointless to even pass.  Secondly the function takes a line number
> parameter (for reporting the line number where parsing failed), but
> this is swallowed and not printed in error messages.  Thirdly, and
> most importantly, the name of the file where the error occurs is not
> printed by default unless the caller happens to print it.
> If there is an _empty_ file in /etc/xen we get this error:
>   # virsh list --all
>   libvir: error : failed to read configuration file /etc/xen/foobar
> but if the spurious file under /etc/xen is non-empty, like a script,
> you get completely anonymous errors such as:
>   libvir: error : configuration file syntax error: expecting an assignment
> or:
>   libvir: error : configuration file syntax error: expecting a value
> The patch fixes this by printing out the filename and line number if
> these are available from the parser context (and the parser context is
> passed to virConfError instead of the unused virConfPtr).  With this
> patch you'll get errors for the second case like this:
>   # virsh list --inactive
>   libvir: error : /etc/xen/foobar:1: expecting a value

ACK, this has annoyed the hell out of me for ages.

|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

More information about the libvir-list mailing list