From: Ján Tomko Date: Wed, 15 Jan 2020 14:16:45 +0000 (+0100) Subject: conf: use virXMLFormatElement in virDomainFSDefFormat X-Git-Tag: v6.1.0-rc1~383 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3efdbae5bf054d1a2bdc98fdccff0273abe54c88;p=thirdparty%2Flibvirt.git conf: use virXMLFormatElement in virDomainFSDefFormat Use the virXMLFormatElement helper to format the driver element to simplify adding further sub-elements. Signed-off-by: Ján Tomko Reviewed-by: Peter Krempa --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 839ad8331f..853cfddf1b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24999,7 +24999,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, @@ -25024,25 +25024,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, "\n"); - } + virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); switch (def->type) { case VIR_DOMAIN_FS_TYPE_MOUNT: