render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From c121eeae663ec36a5b6d2269e843b22df58b68ed Mon Sep 17 00:00:00 2001
Message-Id: <c121eeae663ec36a5b6d2269e843b22df58b68ed@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 2 Aug 2016 13:41:52 +0200
Subject: [PATCH] util: storage: Add json pseudo protocol support for iSCSI
 volumes

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.

(cherry picked from commit 3236bb23707f918a7abf00bd3e3f47f9b0bb3a18)
https://bugzilla.redhat.com/show_bug.cgi?id=1134878 [JSON backing]
https://bugzilla.redhat.com/show_bug.cgi?id=1247521 [gluster multi-host]
---
 src/util/virstoragefile.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 23cdf4b..7fd1593 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2691,6 +2691,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, "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);
@@ -2707,6 +2727,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.9.2