virDomainDefSetMetadata: Rework memory handling
virDomainDefSetMetadata: Rework memory handling

Switch to use g_autoptr for 'doc' and 'new' local variables.
Additionally report proper error when 'xmlAddChild' fails because OOM is
not the only error it can report.

Signed-off-by: Peter Krempa <2cf5c04c61aa466e4a47bfedc747d17279c72ffc@redhat.com>
Reviewed-by: Laine Stump <c23361c43fbf79fed83e8b76173707b083d6caf5@redhat.com>

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