qemu: domain: Refactor formatting of node names into status XML

Use virXMLFormatElement to simplify the logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-02-10 14:23:30 +01:00
parent b18328256b
commit 9fb7ccb3cf

View File

@ -2370,15 +2370,12 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
{
g_auto(virBuffer) tmp = VIR_BUFFER_INIT_CHILD(buf);
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
g_auto(virBuffer) nodenamesChildBuf = VIR_BUFFER_INIT_CHILD(buf);
if (src->nodestorage || src->nodeformat) {
virBufferAddLit(buf, "<nodenames>\n");
virBufferAdjustIndent(buf, 2);
virBufferEscapeString(buf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
virBufferEscapeString(buf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</nodenames>\n");
}
virBufferEscapeString(&nodenamesChildBuf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
virBufferEscapeString(&nodenamesChildBuf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
virXMLFormatElement(buf, "nodenames", NULL, &nodenamesChildBuf);
if (src->pr)
virBufferAsprintf(buf, "<reservations mgralias='%s'/>\n", src->pr->mgralias);