Blame SOURCES/libvirt-util-storage-Add-JSON-backing-store-parser-for-sheepdog-protocol.patch

6ae9ed
From 263cc0f803c4c0e2e7ac1a9bce3fc2ee20539ff9 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <263cc0f803c4c0e2e7ac1a9bce3fc2ee20539ff9@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Tue, 2 Aug 2016 13:41:54 +0200
6ae9ed
Subject: [PATCH] util: storage: Add JSON backing store parser for 'sheepdog'
6ae9ed
 protocol
6ae9ed
6ae9ed
(cherry picked from commit ba8806c8cc62161ea55d0ef68bcaab73a2c70bf8)
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 | 25 +++++++++++++++++++++++++
6ae9ed
 1 file changed, 25 insertions(+)
6ae9ed
6ae9ed
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
6ae9ed
index 7f598fa..48c0956 100644
6ae9ed
--- a/src/util/virstoragefile.c
6ae9ed
+++ b/src/util/virstoragefile.c
6ae9ed
@@ -2755,6 +2755,30 @@ virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src,
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
+static int
6ae9ed
+virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src,
6ae9ed
+                                         virJSONValuePtr json,
6ae9ed
+                                         int opaque ATTRIBUTE_UNUSED)
6ae9ed
+{
6ae9ed
+    const char *filename;
6ae9ed
+
6ae9ed
+    /* legacy URI based syntax passed via 'filename' option */
6ae9ed
+    if ((filename = virJSONValueObjectGetString(json, "filename"))) {
6ae9ed
+        if (strstr(filename, "://"))
6ae9ed
+            return virStorageSourceParseBackingJSONUriStr(src, filename,
6ae9ed
+                                                          VIR_STORAGE_NET_PROTOCOL_SHEEPDOG);
6ae9ed
+
6ae9ed
+        /* libvirt doesn't implement a parser for the legacy non-URI syntax */
6ae9ed
+    }
6ae9ed
+
6ae9ed
+    /* Sheepdog currently supports only URI and legacy syntax passed in as filename */
6ae9ed
+    virReportError(VIR_ERR_INVALID_ARG, "%s",
6ae9ed
+                   _("missing sheepdog 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
@@ -2773,6 +2797,7 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
6ae9ed
     {"gluster", virStorageSourceParseBackingJSONGluster, 0},
6ae9ed
     {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0},
6ae9ed
     {"nbd", virStorageSourceParseBackingJSONNbd, 0},
6ae9ed
+    {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0},
6ae9ed
 };
6ae9ed
 
6ae9ed
 
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed