[PATCH 06/11] virDomainHostdevDefFormatSubsys: Split out formatting of vHBA subsystem

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

 



Similarly to previous commit split out formatting of the vHBA subsystem
related stuff.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7b181e0587..facfddeea7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -26148,6 +26148,21 @@ virDomainHostdevDefFormatSubsysSCSI(virBufferPtr buf,
 }


+static void
+virDomainHostdevDefFormatSubsysSCSIHost(virBufferPtr buf,
+                                        virDomainHostdevDefPtr def)
+{
+    g_auto(virBuffer) sourceAttrBuf = VIR_BUFFER_INITIALIZER;
+    virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
+
+    virBufferAsprintf(&sourceAttrBuf, " protocol='%s' wwpn='%s'",
+                      virDomainHostdevSubsysSCSIHostProtocolTypeToString(hostsrc->protocol),
+                      hostsrc->wwpn);
+
+    virXMLFormatElement(buf, "source", &sourceAttrBuf, NULL);
+}
+
+
 static int
 virDomainHostdevDefFormatSubsys(virBufferPtr buf,
                                 virDomainHostdevDefPtr def,
@@ -26155,9 +26170,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
                                 bool includeTypeInAddr,
                                 virDomainXMLOptionPtr xmlopt)
 {
-    g_auto(virBuffer) sourceAttrBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) sourceChildBuf = VIR_BUFFER_INIT_CHILD(buf);
-    virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
     virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev;

     switch ((virDomainHostdevSubsysType) def->source.subsys.type) {
@@ -26172,6 +26185,9 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
         return virDomainHostdevDefFormatSubsysSCSI(buf, def, flags, includeTypeInAddr, xmlopt);

     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
+        virDomainHostdevDefFormatSubsysSCSIHost(buf, def);
+        return 0;
+
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
         break;

@@ -26182,14 +26198,6 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
     }


-    if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) {
-        const char *protocol =
-            virDomainHostdevSubsysSCSIHostProtocolTypeToString(hostsrc->protocol);
-
-        virBufferAsprintf(&sourceAttrBuf, " protocol='%s' wwpn='%s'",
-                          protocol, hostsrc->wwpn);
-    }
-
     switch (def->source.subsys.type) {
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
         break;
@@ -26210,7 +26218,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
         return -1;
     }

-    virXMLFormatElement(buf, "source", &sourceAttrBuf, &sourceChildBuf);
+    virXMLFormatElement(buf, "source", NULL, &sourceChildBuf);

     return 0;
 }
-- 
2.26.2




[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