render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 4e32b3e8ab394aaf1f94b1166d7c5e38cec8ede4 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <4e32b3e8ab394aaf1f94b1166d7c5e38cec8ede4@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Fri, 9 Jun 2017 12:48:53 +0200
3e5111
Subject: [PATCH] Use a separate buffer for <controller><driver>
3e5111
MIME-Version: 1.0
3e5111
Content-Type: text/plain; charset=UTF-8
3e5111
Content-Transfer-Encoding: 8bit
3e5111
3e5111
Make adding new attributes easier.
3e5111
3e5111
(cherry picked from commit 5e5fc766257b05979c37593434d28cc9eb7e0cf0)
3e5111
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1283251
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/conf/domain_conf.c | 39 ++++++++++++++++++++-------------------
3e5111
 1 file changed, 20 insertions(+), 19 deletions(-)
3e5111
3e5111
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
3e5111
index d5c5a7030b..242a79a7e7 100644
3e5111
--- a/src/conf/domain_conf.c
3e5111
+++ b/src/conf/domain_conf.c
3e5111
@@ -21332,6 +21332,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
3e5111
     const char *model = NULL;
3e5111
     const char *modelName = NULL;
3e5111
     bool pcihole64 = false, pciModel = false, pciTarget = false;
3e5111
+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
3e5111
 
3e5111
     if (!type) {
3e5111
         virReportError(VIR_ERR_INTERNAL_ERROR,
3e5111
@@ -21436,26 +21437,26 @@ virDomainControllerDefFormat(virBufferPtr buf,
3e5111
             }
3e5111
         }
3e5111
 
3e5111
-        if (def->queues || def->cmd_per_lun ||
3e5111
-            def->max_sectors || def->ioeventfd || def->iothread) {
3e5111
+        if (def->queues)
3e5111
+            virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
3e5111
+
3e5111
+        if (def->cmd_per_lun)
3e5111
+            virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun);
3e5111
+
3e5111
+        if (def->max_sectors)
3e5111
+            virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors);
3e5111
+
3e5111
+        if (def->ioeventfd) {
3e5111
+            virBufferAsprintf(&driverBuf, " ioeventfd='%s'",
3e5111
+                              virTristateSwitchTypeToString(def->ioeventfd));
3e5111
+        }
3e5111
+
3e5111
+        if (def->iothread)
3e5111
+            virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
3e5111
+
3e5111
+        if (virBufferUse(&driverBuf)) {
3e5111
             virBufferAddLit(buf, "
3e5111
-            if (def->queues)
3e5111
-                virBufferAsprintf(buf, " queues='%u'", def->queues);
3e5111
-
3e5111
-            if (def->cmd_per_lun)
3e5111
-                virBufferAsprintf(buf, " cmd_per_lun='%u'", def->cmd_per_lun);
3e5111
-
3e5111
-            if (def->max_sectors)
3e5111
-                virBufferAsprintf(buf, " max_sectors='%u'", def->max_sectors);
3e5111
-
3e5111
-            if (def->ioeventfd) {
3e5111
-                virBufferAsprintf(buf, " ioeventfd='%s'",
3e5111
-                                  virTristateSwitchTypeToString(def->ioeventfd));
3e5111
-            }
3e5111
-
3e5111
-            if (def->iothread)
3e5111
-                virBufferAsprintf(buf, " iothread='%u'", def->iothread);
3e5111
-
3e5111
+            virBufferAddBuffer(buf, &driverBuf);
3e5111
             virBufferAddLit(buf, "/>\n");
3e5111
         }
3e5111
 
3e5111
-- 
3e5111
2.13.1
3e5111