[PATCH 01/18] conf: introduce virDomainControllerDriverFormat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Split out formatting the <driver> subelement of <controller>
to make adding new options easier.
---
 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 c7e20b8..318e254 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21357,6 +21357,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,
@@ -21366,7 +21397,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,
@@ -21471,28 +21501,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.10.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux