From 263cc0f803c4c0e2e7ac1a9bce3fc2ee20539ff9 Mon Sep 17 00:00:00 2001 Message-Id: <263cc0f803c4c0e2e7ac1a9bce3fc2ee20539ff9@dist-git> From: Peter Krempa Date: Tue, 2 Aug 2016 13:41:54 +0200 Subject: [PATCH] util: storage: Add JSON backing store parser for 'sheepdog' protocol (cherry picked from commit ba8806c8cc62161ea55d0ef68bcaab73a2c70bf8) 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 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7f598fa..48c0956 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2755,6 +2755,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); @@ -2773,6 +2797,7 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = { {"gluster", virStorageSourceParseBackingJSONGluster, 0}, {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0}, {"nbd", virStorageSourceParseBackingJSONNbd, 0}, + {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0}, }; -- 2.9.2