]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: use virXMLFormatElement for interface <target>
authorLaine Stump <laine@redhat.com>
Wed, 21 Aug 2019 02:53:11 +0000 (22:53 -0400)
committerLaine Stump <laine@redhat.com>
Mon, 9 Sep 2019 18:34:23 +0000 (14:34 -0400)
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

index e051d4b67a81ec38a580281d61f6aa2d5921aac4..ddc72d3cf992aaf7bd86ea5fbe77673f4950c07c 100644 (file)
@@ -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. */