iSCSI is a bit odd in this aspect since it only supports URIs but using
the 'filename' property and does not have any alternative syntax.
---
 src/util/virstoragefile.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 6aaf3ff..0679824 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2595,6 +2595,26 @@ 
virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
 }


+static int
+virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
+                                      virJSONValuePtr json,
+                                      int opaque ATTRIBUTE_UNUSED)
+{
+    const char *uri;
+
+    /* legacy URI based syntax passed via 'filename' option */
+    if ((uri = virJSONValueObjectGetString(json, "file.filename")))
+        return virStorageSourceParseBackingJSONUriStr(src, uri,
+                                                      
VIR_STORAGE_NET_PROTOCOL_ISCSI);
+
+    /* iSCSI currently supports only URI syntax passed in as filename */
+    virReportError(VIR_ERR_INVALID_ARG, "%s",
+                   _("missing iSCSI URI in JSON backing volume definition"));
+
+    return -1;
+}
+
+
 struct virStorageSourceJSONDriverParser {
     const char *drvname;
     int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque);
@@ -2611,6 +2631,7 @@ static const struct virStorageSourceJSONDriverParser 
jsonParsers[] = {
     {"ftps", virStorageSourceParseBackingJSONUri, 
VIR_STORAGE_NET_PROTOCOL_FTPS},
     {"tftp", virStorageSourceParseBackingJSONUri, 
VIR_STORAGE_NET_PROTOCOL_TFTP},
     {"gluster", virStorageSourceParseBackingJSONGluster, 0},
+    {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0},
 };


-- 
2.8.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to