Blob Blame History Raw
From 8874ecd393f7098376d9c46c34f43d47a697f932 Mon Sep 17 00:00:00 2001
Message-Id: <8874ecd393f7098376d9c46c34f43d47a697f932@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 9 Jun 2017 12:48:55 +0200
Subject: [PATCH] conf: introduce virDomainControllerDriverFormat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Split out formatting the <driver> subelement of <controller>
to make adding new options easier.

(cherry picked from commit fe262186dccfa5c5cbcfe5ab7eb95195cf3b10f5)
Signed-off-by: Ján Tomko <jtomko@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1283251
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/conf/domain_conf.c | 55 +++++++++++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 23 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e004559f9f..275145b1ec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21323,6 +21323,37 @@ virDomainDiskDefFormat(virBufferPtr buf,
 #undef FORMAT_IOTUNE
 
 
+static void
+virDomainControllerDriverFormat(virBufferPtr buf,
+                                virDomainControllerDefPtr def)
+{
+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
+
+    if (def->queues)
+        virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
+
+    if (def->cmd_per_lun)
+        virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun);
+
+    if (def->max_sectors)
+        virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors);
+
+    if (def->ioeventfd) {
+        virBufferAsprintf(&driverBuf, " ioeventfd='%s'",
+                          virTristateSwitchTypeToString(def->ioeventfd));
+    }
+
+    if (def->iothread)
+        virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
+
+    if (virBufferUse(&driverBuf)) {
+        virBufferAddLit(buf, "<driver");
+        virBufferAddBuffer(buf, &driverBuf);
+        virBufferAddLit(buf, "/>\n");
+    }
+}
+
+
 static int
 virDomainControllerDefFormat(virBufferPtr buf,
                              virDomainControllerDefPtr def,
@@ -21332,7 +21363,6 @@ virDomainControllerDefFormat(virBufferPtr buf,
     const char *model = NULL;
     const char *modelName = NULL;
     bool pcihole64 = false, pciModel = false, pciTarget = false;
-    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
 
     if (!type) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -21437,28 +21467,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
             }
         }
 
-        if (def->queues)
-            virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
-
-        if (def->cmd_per_lun)
-            virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun);
-
-        if (def->max_sectors)
-            virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors);
-
-        if (def->ioeventfd) {
-            virBufferAsprintf(&driverBuf, " ioeventfd='%s'",
-                              virTristateSwitchTypeToString(def->ioeventfd));
-        }
-
-        if (def->iothread)
-            virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
-
-        if (virBufferUse(&driverBuf)) {
-            virBufferAddLit(buf, "<driver");
-            virBufferAddBuffer(buf, &driverBuf);
-            virBufferAddLit(buf, "/>\n");
-        }
+        virDomainControllerDriverFormat(buf, def);
 
         if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
             virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-- 
2.13.1