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

Eric Farman farman at linux.vnet.ibm.com
Mon Jul 25 20:48:17 UTC 2016


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 at linux.vnet.ibm.com>
Signed-off-by: Eric Farman <farman at linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk at linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
---
 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




More information about the libvir-list mailing list