提交 2a48252b 编写于 作者: A Ashish Mittal 提交者: John Ferlan

util: storage: Add JSON backing volume parse for VxHS

Add the backing parse and a test case to verify parsing of VxHS
backing storage.
Signed-off-by: NAshish Mittal <Ashish.Mittal@veritas.com>
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 e6a7fa26
......@@ -3212,6 +3212,40 @@ virStorageSourceParseBackingJSONRaw(virStorageSourcePtr src,
return virStorageSourceParseBackingJSONInternal(src, json);
}
static int
virStorageSourceParseBackingJSONVxHS(virStorageSourcePtr src,
virJSONValuePtr json,
int opaque ATTRIBUTE_UNUSED)
{
const char *vdisk_id = virJSONValueObjectGetString(json, "vdisk-id");
virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
if (!vdisk_id || !server) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("missing 'vdisk-id' or 'server' attribute in "
"JSON backing definition for VxHS volume"));
return -1;
}
src->type = VIR_STORAGE_TYPE_NETWORK;
src->protocol = VIR_STORAGE_NET_PROTOCOL_VXHS;
if (VIR_STRDUP(src->path, vdisk_id) < 0)
return -1;
if (VIR_ALLOC_N(src->hosts, 1) < 0)
return -1;
src->nhosts = 1;
if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts,
server) < 0)
return -1;
return 0;
}
struct virStorageSourceJSONDriverParser {
const char *drvname;
int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque);
......@@ -3234,6 +3268,7 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
{"ssh", virStorageSourceParseBackingJSONSSH, 0},
{"rbd", virStorageSourceParseBackingJSONRBD, 0},
{"raw", virStorageSourceParseBackingJSONRaw, 0},
{"vxhs", virStorageSourceParseBackingJSONVxHS, 0},
};
......@@ -3995,6 +4030,8 @@ virStorageSourceNetworkDefaultPort(virStorageNetProtocol protocol)
return 0;
case VIR_STORAGE_NET_PROTOCOL_VXHS:
return 9999;
case VIR_STORAGE_NET_PROTOCOL_LAST:
case VIR_STORAGE_NET_PROTOCOL_NONE:
return 0;
......
......@@ -1592,6 +1592,17 @@ mymain(void)
"<source protocol='sheepdog' name='Alice'>\n"
" <host name='10.10.10.10' port='7000'/>\n"
"</source>\n");
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"vxhs\","
"\"vdisk-id\":\"c6718f6b-0401-441d-a8c3-1f0064d75ee0\","
"\"server\": { \"type\":\"tcp\","
"\"host\":\"example.com\","
"\"port\":\"9999\""
"}"
"}"
"}",
"<source protocol='vxhs' name='c6718f6b-0401-441d-a8c3-1f0064d75ee0'>\n"
" <host name='example.com' port='9999'/>\n"
"</source>\n");
#endif /* WITH_YAJL */
cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册