[PATCH for 7.4.0] conf: Avoid double indentation of <metadata/> element

Bjoern Walk bwalk at linux.ibm.com
Tue May 25 09:21:32 UTC 2021


Bjoern Walk <bwalk at linux.ibm.com> [2021-05-25, 11:01AM +0200]:
> Michal Privoznik <mprivozn at redhat.com> [2021-05-25, 09:32AM +0200]:
> > There was a recent change in libxml2 that caused a trouble for
> > us. To us, <metadata/> in domain or network XMLs are just opaque
> > value where management application can store whatever data it
> > finds fit. At XML parser/formatter level, we just make a copy of
> > the element during parsing and then format it back. For
> > formatting we use xmlNodeDump() which allows caller to specify
> > level of indentation. Previously, the indentation was not
> > applied onto the very first line, but as of v2.9.12-2-g85b1792e
> > libxml2 is applying indentation also on the first line.
> > 
> > This does not work well with out virBuffer because as soon as we
> > call virBufferAsprintf() to append <metadata/> element,
> > virBufferAsprintf() will apply another level of indentation.
> > 
> > Instead of version checking, let's skip any indentation added by
> > libxml2 before virBufferAsprintf() is called.
> > 
> > Note, the problem is only when telling xmlNodeDump() to use
> > indentation, i.e. level argument is not zero. Therefore,
> > virXMLNodeToString() which also calls xmlNodeDump() is safe as it
> > passes zero.
> > 
> > Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> 
> Tested-by: Bjoern Walk <bwalk at linux.ibm.com>
> 
> But like Daniel said, this now breaks for older libxml2 versions.

Ah, I also misread this. All is fine with both libxml2 v2.9.12 and
earlier.

-- 
IBM Systems
Linux on Z & KVM Development
--------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
--------------------------------------------------
Vorsitzende des Aufsichtsrats: Gregor Pillen
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 902 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210525/704cbc05/attachment-0001.sig>


More information about the libvir-list mailing list