]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: storage: Add JSON backing store parser for 'sheepdog' protocol
authorPeter Krempa <pkrempa@redhat.com>
Thu, 14 Jul 2016 11:07:46 +0000 (13:07 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 27 Jul 2016 11:24:20 +0000 (13:24 +0200)
src/util/virstoragefile.c

index 53ff710d3a3c7e1cbddfb2ad8b17504c1efb5a0d..169d70ec8a8cf6d27b84943cce1c1c90703a554a 100644 (file)
@@ -2746,6 +2746,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, "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);
@@ -2764,6 +2788,7 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
     {"gluster", virStorageSourceParseBackingJSONGluster, 0},
     {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0},
     {"nbd", virStorageSourceParseBackingJSONNbd, 0},
+    {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0},
 };