Re: [PATCH 2/2] xml: Surpress printing "domain.xml" for parse errors on XML strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/16/2011 06:49 AM, Peter Krempa wrote:
Patch a53ab1094e93f1b6d93ad9be63d8ccc5fd19a2a9 introduces printing
file name on XML errors. This corrects the URL string to be NULL and
therefrore to print an error message not containing bogus filename

s/therefrore/therefore/

"domain.xml".
---
  src/conf/domain_conf.c        |    2 +-
  src/security/virt-aa-helper.c |    2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

+++ b/src/conf/domain_conf.c
@@ -7048,7 +7048,7 @@ virDomainDefParse(const char *xmlStr,
      xmlDocPtr xml;
      virDomainDefPtr def = NULL;

-    if ((xml = virXMLParse(filename, xmlStr, "domain.xml"))) {
+    if ((xml = virXMLParse(filename, xmlStr, NULL))) {

I'm not sure I follow the difference between filename and url arguments. In virXMLParseHelper, this is resulting in the difference between xmlCtxtReadFile(pctxt, filename, NULL, flags) and xmlCtxtReadDoc(pctxt, string, url, NULL, flags). If I'm understanding correctly, that means that 'url' is treated as the filename owning the string being parsed (that is, if you had manually read the file contents yourself and pass the contents as a string, instead of caling xmlCtxtReadFile directly, then you would use the filename of xmlCtxtReadFile as the url of xmlCtxtReadDoc).

I guess passing NULL as the url is okay - it just means that any errors reported by the parser are no longer tied to a specific filename (which is okay, because we are intercepting the error reporting, and reporting it on behalf of just the string line number anyway).

I wonder if this patch is complete, or if there are more instances where we are passing a url to xml parse functions even though the string was generated rather than being tied to a real file. tools/virsh.c in particular may need some cleanups related to this, although I don't see it using virXMLParse.

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]