Use the virXMLFormatElement helper to format the driver element to simplify adding further sub-elements. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/conf/domain_conf.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 707d58e1a4..6deb8e5434 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24996,7 +24996,7 @@ virDomainFSDefFormat(virBufferPtr buf, const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver); const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy); const char *src = def->src->path; - g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER; if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -25021,25 +25021,21 @@ virDomainFSDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, 2); if (def->fsdriver) { - virBufferAsprintf(&driverBuf, " type='%s'", fsdriver); + virBufferAsprintf(&driverAttrBuf, " type='%s'", fsdriver); if (def->format) - virBufferAsprintf(&driverBuf, " format='%s'", + virBufferAsprintf(&driverAttrBuf, " format='%s'", virStorageFileFormatTypeToString(def->format)); /* Don't generate anything if wrpolicy is set to default */ if (def->wrpolicy) - virBufferAsprintf(&driverBuf, " wrpolicy='%s'", wrpolicy); + virBufferAsprintf(&driverAttrBuf, " wrpolicy='%s'", wrpolicy); } - virDomainVirtioOptionsFormat(&driverBuf, def->virtio); + virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio); - if (virBufferUse(&driverBuf)) { - virBufferAddLit(buf, "<driver"); - virBufferAddBuffer(buf, &driverBuf); - virBufferAddLit(buf, "/>\n"); - } + virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); switch (def->type) { case VIR_DOMAIN_FS_TYPE_MOUNT: -- 2.21.0