From 33d02dfca67bd8fd65a50631f7aaae07215ed7cd Mon Sep 17 00:00:00 2001
From: Laine Stump <laine@redhat.com>
Date: Tue, 20 Aug 2019 22:53:11 -0400
Subject: [PATCH] conf: use virXMLFormatElement for interface <target>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This will simplify addition of another attribute to the <target> element

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/conf/domain_conf.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e051d4b67a..ddc72d3cf9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25339,6 +25339,7 @@ virDomainNetDefFormat(virBufferPtr buf,
     const char *typeStr;
     virDomainHostdevDefPtr hostdef = NULL;
     char macstr[VIR_MAC_STRING_BUFLEN];
+    VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
 
     /* publicActual is true if we should report the current state in
      * def->data.network.actual *instead of* the config (*not* in
@@ -25553,9 +25554,12 @@ virDomainNetDefFormat(virBufferPtr buf,
           (STRPREFIX(def->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
            (prefix && STRPREFIX(def->ifname, prefix))))) {
         /* Skip auto-generated target names for inactive config. */
-        virBufferEscapeString(buf, "<target dev='%s'/>\n", def->ifname);
+        virBufferEscapeString(&attrBuf, " dev='%s'", def->ifname);
     }
 
+    if (virXMLFormatElement(buf, "target", &attrBuf, NULL) < 0)
+        return -1;
+
     if (def->ifname_guest || def->ifname_guest_actual) {
         virBufferAddLit(buf, "<guest");
         /* Skip auto-generated target names for inactive config. */
-- 
GitLab