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

[libvirt] [PATCH 4/9] util: introduce virStorageSourceInitiator functions



The same code would be used for storage pools and domain disks.

Signed-off-by: Pavel Hrdina <phrdina redhat com>
---
 src/util/virstoragefile.c | 34 ++++++++++++++++++++++++++++++++++
 src/util/virstoragefile.h | 15 +++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 56082f34e9..fb79ceddd0 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -4314,6 +4314,40 @@ virStorageSourcePrivateDataFormatRelPath(virStorageSourcePtr src,
     return 0;
 }
 
+void
+virStorageSourceInitiatorParseXML(xmlXPathContextPtr ctxt,
+                                  virStorageSourceInitiatorDefPtr initiator)
+{
+    initiator->iqn = virXPathString("string(./initiator/iqn/@name)", ctxt);
+}
+
+void
+virStorageSourceInitiatorFormatXML(virStorageSourceInitiatorDefPtr initiator,
+                                   virBufferPtr buf)
+{
+    if (!initiator->iqn)
+        return;
+
+    virBufferAddLit(buf, "<initiator>\n");
+    virBufferAdjustIndent(buf, 2);
+    virBufferEscapeString(buf, "<iqn name='%s'/>\n", initiator->iqn);
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "</initiator>\n");
+}
+
+int
+virStorageSourceInitiatorCopy(virStorageSourceInitiatorDefPtr dest,
+                              const virStorageSourceInitiatorDef *src)
+{
+    return VIR_STRDUP(dest->iqn, src->iqn);
+}
+
+void
+virStorageSourceInitiatorClear(virStorageSourceInitiatorDefPtr initiator)
+{
+    VIR_FREE(initiator->iqn);
+}
+
 static bool
 virStorageFileIsInitialized(const virStorageSource *src)
 {
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index d9e27a4a5f..b6013431cc 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -492,6 +492,21 @@ int
 virStorageSourcePrivateDataFormatRelPath(virStorageSourcePtr src,
                                          virBufferPtr buf);
 
+void
+virStorageSourceInitiatorParseXML(xmlXPathContextPtr ctxt,
+                                  virStorageSourceInitiatorDefPtr initiator);
+
+void
+virStorageSourceInitiatorFormatXML(virStorageSourceInitiatorDefPtr initiator,
+                                   virBufferPtr buf);
+
+int
+virStorageSourceInitiatorCopy(virStorageSourceInitiatorDefPtr dest,
+                              const virStorageSourceInitiatorDef *src);
+
+void
+virStorageSourceInitiatorClear(virStorageSourceInitiatorDefPtr initiator);
+
 int virStorageFileInit(virStorageSourcePtr src);
 int virStorageFileInitAs(virStorageSourcePtr src,
                          uid_t uid, gid_t gid);
-- 
2.17.1


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