
On Mon, Sep 15, 2008 at 04:12:58PM +0100, Daniel P. Berrange wrote:
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.
+1, no problem, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/