render / rpms / libvirt

Forked from rpms/libvirt 11 months ago
Clone
6ae9ed
From c121eeae663ec36a5b6d2269e843b22df58b68ed Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <c121eeae663ec36a5b6d2269e843b22df58b68ed@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Tue, 2 Aug 2016 13:41:52 +0200
6ae9ed
Subject: [PATCH] util: storage: Add json pseudo protocol support for iSCSI
6ae9ed
 volumes
6ae9ed
6ae9ed
iSCSI is a bit odd in this aspect since it only supports URIs but using
6ae9ed
the 'filename' property and does not have any alternative syntax.
6ae9ed
6ae9ed
(cherry picked from commit 3236bb23707f918a7abf00bd3e3f47f9b0bb3a18)
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1134878 [JSON backing]
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1247521 [gluster multi-host]
6ae9ed
---
6ae9ed
 src/util/virstoragefile.c | 21 +++++++++++++++++++++
6ae9ed
 1 file changed, 21 insertions(+)
6ae9ed
6ae9ed
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
6ae9ed
index 23cdf4b..7fd1593 100644
6ae9ed
--- a/src/util/virstoragefile.c
6ae9ed
+++ b/src/util/virstoragefile.c
6ae9ed
@@ -2691,6 +2691,26 @@ virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
+static int
6ae9ed
+virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
6ae9ed
+                                      virJSONValuePtr json,
6ae9ed
+                                      int opaque ATTRIBUTE_UNUSED)
6ae9ed
+{
6ae9ed
+    const char *uri;
6ae9ed
+
6ae9ed
+    /* legacy URI based syntax passed via 'filename' option */
6ae9ed
+    if ((uri = virJSONValueObjectGetString(json, "filename")))
6ae9ed
+        return virStorageSourceParseBackingJSONUriStr(src, uri,
6ae9ed
+                                                      VIR_STORAGE_NET_PROTOCOL_ISCSI);
6ae9ed
+
6ae9ed
+    /* iSCSI currently supports only URI syntax passed in as filename */
6ae9ed
+    virReportError(VIR_ERR_INVALID_ARG, "%s",
6ae9ed
+                   _("missing iSCSI URI in JSON backing volume definition"));
6ae9ed
+
6ae9ed
+    return -1;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
 struct virStorageSourceJSONDriverParser {
6ae9ed
     const char *drvname;
6ae9ed
     int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque);
6ae9ed
@@ -2707,6 +2727,7 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
6ae9ed
     {"ftps", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_FTPS},
6ae9ed
     {"tftp", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_TFTP},
6ae9ed
     {"gluster", virStorageSourceParseBackingJSONGluster, 0},
6ae9ed
+    {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0},
6ae9ed
 };
6ae9ed
 
6ae9ed
 
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed