[libvirt] [libvirt RFC PATCH 08/10] util: storage: Add JSON backing store parser for 'sheepdog' protocol

Peter Krempa pkrempa at redhat.com
Fri Jul 15 13:46:41 UTC 2016


---
 src/util/virstoragefile.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 06f9737..7c6d507 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2659,6 +2659,30 @@ virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src,
 }


+static int
+virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src,
+                                         virJSONValuePtr json,
+                                         int opaque ATTRIBUTE_UNUSED)
+{
+    const char *filename;
+
+    /* legacy URI based syntax passed via 'filename' option */
+    if ((filename = virJSONValueObjectGetString(json, "file.filename"))) {
+        if (strstr(filename, "://"))
+            return virStorageSourceParseBackingJSONUriStr(src, filename,
+                                                          VIR_STORAGE_NET_PROTOCOL_SHEEPDOG);
+
+        /* libvirt doesn't implement a parser for the legacy non-URI syntax */
+    }
+
+    /* Sheepdog currently supports only URI and legacy syntax passed in as filename */
+    virReportError(VIR_ERR_INVALID_ARG, "%s",
+                   _("missing sheepdog URI in JSON backing volume definition"));
+
+    return -1;
+}
+
+
 struct virStorageSourceJSONDriverParser {
     const char *drvname;
     int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque);
@@ -2677,6 +2701,7 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
     {"gluster", virStorageSourceParseBackingJSONGluster, 0},
     {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0},
     {"nbd", virStorageSourceParseBackingJSONNbd, 0},
+    {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0},
 };


-- 
2.8.2




More information about the libvir-list mailing list