[PATCH 4/9] util: introduce virStorageSourceInitiator functions

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

 



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

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 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

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

  Powered by Linux