conf: Rework <tpm/> formatting
conf: Rework <tpm/> formatting

The <tpm/> element formatting is handled in
virDomainTPMDefFormat() which uses the "old style" - appending
strings directly into the output buffer. With this, it's easy to
get conditions that tell when an element has ended wrong. In this
particular case, if both <encryption/> and <active_pcr_banks/>
are to be formatted the current code puts a stray '>' into the
output buffer, resulting in invalid XML.

Rewrite the function to use virXMLFormatElement() which is more
clever.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2016599#c15
Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Peter Krempa <2cf5c04c61aa466e4a47bfedc747d17279c72ffc@redhat.com>

olafhering/libvirt,zippy2/libvirt,jfehlig/libvirt,libvirt/libvirt,jfehlig/libvirt,crobinso/libvirt,jfehlig/libvirt,olafhering/libvirt,jfehlig/libvirt,crobinso/libvirt,libvirt/libvirt,zippy2/libvirt,libvirt/libvirt,zippy2/libvirt,zippy2/libvirt,crobinso/libvirt,libvirt/libvirt,olafhering/libvirt,crobinso/libvirt,olafhering/libvirt