[libvirt] [PATCH 5/9] conf: use virStorageSourceInitiator functions

Pavel Hrdina phrdina at redhat.com
Tue Aug 7 13:55:24 UTC 2018


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/conf/storage_conf.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index a0c92af820..50dbc937e7 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -380,7 +380,7 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr source)
     VIR_FREE(source->dir);
     VIR_FREE(source->name);
     virStorageAdapterClear(&source->adapter);
-    VIR_FREE(source->initiator.iqn);
+    virStorageSourceInitiatorClear(&source->initiator);
     virStorageAuthDefFree(source->auth);
     VIR_FREE(source->vendor);
     VIR_FREE(source->product);
@@ -488,7 +488,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
     }
 
     VIR_FREE(nodeset);
-    source->initiator.iqn = virXPathString("string(./initiator/iqn/@name)", ctxt);
+
+    virStorageSourceInitiatorParseXML(ctxt, &source->initiator);
 
     nsource = virXPathNodeSet("./device", ctxt, &nodeset);
     if (nsource < 0)
@@ -950,15 +951,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
     if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME)
         virBufferEscapeString(buf, "<name>%s</name>\n", src->name);
 
-    if ((options->flags & VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN) &&
-        src->initiator.iqn) {
-        virBufferAddLit(buf, "<initiator>\n");
-        virBufferAdjustIndent(buf, 2);
-        virBufferEscapeString(buf, "<iqn name='%s'/>\n",
-                              src->initiator.iqn);
-        virBufferAdjustIndent(buf, -2);
-        virBufferAddLit(buf, "</initiator>\n");
-    }
+    if (options->flags & VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN)
+        virStorageSourceInitiatorFormatXML(&src->initiator, buf);
 
     if (options->formatToString) {
         const char *format = (options->formatToString)(src->format);
-- 
2.17.1




More information about the libvir-list mailing list