[PATCH 07/11] virDomainHostdevDefFormatSubsys: Split out formatting of mdev subsystem

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

 



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

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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index facfddeea7..e9fee10e31 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -26163,6 +26163,19 @@ virDomainHostdevDefFormatSubsysSCSIHost(virBufferPtr buf,
 }


+static void
+virDomainHostdevDefFormatSubsysMDEV(virBufferPtr buf,
+                                    virDomainHostdevDefPtr def)
+{
+    g_auto(virBuffer) sourceChildBuf = VIR_BUFFER_INIT_CHILD(buf);
+    virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev;
+
+    virBufferAsprintf(&sourceChildBuf, "<address uuid='%s'/>\n", mdevsrc->uuidstr);
+
+    virXMLFormatElement(buf, "source", NULL, &sourceChildBuf);
+}
+
+
 static int
 virDomainHostdevDefFormatSubsys(virBufferPtr buf,
                                 virDomainHostdevDefPtr def,
@@ -26170,9 +26183,6 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
                                 bool includeTypeInAddr,
                                 virDomainXMLOptionPtr xmlopt)
 {
-    g_auto(virBuffer) sourceChildBuf = VIR_BUFFER_INIT_CHILD(buf);
-    virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev;
-
     switch ((virDomainHostdevSubsysType) def->source.subsys.type) {
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
         virDomainHostdevDefFormatSubsysUSB(buf, def, flags, includeTypeInAddr);
@@ -26189,7 +26199,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
         return 0;

     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
-        break;
+        virDomainHostdevDefFormatSubsysMDEV(buf, def);
+        return 0;

     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
     default:
@@ -26197,29 +26208,6 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
         return -1;
     }

-
-    switch (def->source.subsys.type) {
-    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
-        break;
-    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
-        break;
-    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
-        break;
-    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
-        break;
-    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
-        virBufferAsprintf(&sourceChildBuf, "<address uuid='%s'/>\n",
-                          mdevsrc->uuidstr);
-        break;
-    default:
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("unexpected hostdev type %d"),
-                       def->source.subsys.type);
-        return -1;
-    }
-
-    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