[PATCH v1 16/19] conf: Set up vhost-scsi hostdev to self-close source tag

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

 



Since the vhost-scsi protocol for hostdev tags has no child
elements within its source tag, we can use a self-closing
source tag to make the resulting XML a little cleaner.

Suggested-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Eric Farman <farman@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx>
---
 src/conf/domain_conf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 79087b2..8d6d208 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20436,6 +20436,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
                                 unsigned int flags,
                                 bool includeTypeInAddr)
 {
+    bool closedSource = false;
     virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb;
     virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci;
     virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
@@ -20481,7 +20482,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
                               protocol, iscsisrc->path);
             break;
         case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_VHOST:
-            virBufferAsprintf(buf, " protocol='%s' wwpn='%s'",
+            closedSource = true;
+            virBufferAsprintf(buf, " protocol='%s' wwpn='%s'/",
                               protocol, vhostsrc->wwpn);
             break;
         default:
@@ -20533,7 +20535,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
             virBufferEscapeString(buf, " port='%s'", iscsisrc->hosts[0].port);
             virBufferAddLit(buf, "/>\n");
         } else if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_VHOST) {
-            /* Nothing to do here */
+            /* Nothing to do here; closedSource already set to true */
         } else {
             virBufferAsprintf(buf, "<adapter name='%s'/>\n",
                               scsihostsrc->adapter);
@@ -20559,7 +20561,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
     }
 
     virBufferAdjustIndent(buf, -2);
-    virBufferAddLit(buf, "</source>\n");
+    if (!closedSource)
+        virBufferAddLit(buf, "</source>\n");
 
     return 0;
 }
-- 
1.9.1

--
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]