
This patch changes the implementations lots of functions which parse XML documents, so that if the XML document is not well-formed then we get detailed error messages. The general form of the change is: static void catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) { // a callback which calls virDomainReportError } virDomainDefPtr virDomainDefParseString(virConnectPtr conn, virCapsPtr caps, const char *xmlStr) { xmlParserCtxtPtr pctxt; pctxt = xmlNewParserCtxt (); pctxt->sax->error = catchXMLError; xml = xmlCtxtReadDoc (pctxt, //...) etc. There are some unavoidable shortcomings: (1) There is no place to stash user pointers during the callback (the suggestively named pctxt->userData field is already used for something else), so we cannot pass the virConnectPtr to the error function. As a result, virterror will store the error in a global variable, and callers will probably not be able to access it. (2) The XML parser routinely produces multiple error messages, and virterror throws away all but the last one. The errors do, however, get printed to stderr. You can test this by using 'virsh define', 'virsh net-define', 'virsh pool-define', etc. on not-well-formed XML files. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v