提交 caf71b64 编写于 作者: P Peter Krempa

qemu: block: Add JSON props generator for ssh storage backing

上级 8da68d87
......@@ -900,6 +900,38 @@ qemuBlockStorageSourceGetSheepdogProps(virStorageSourcePtr src)
return ret;
}
static virJSONValuePtr
qemuBlockStorageSourceGetSshProps(virStorageSourcePtr src)
{
virJSONValuePtr serverprops;
virJSONValuePtr ret = NULL;
const char *username = NULL;
if (src->nhosts != 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("sheepdog protocol accepts only one host"));
return NULL;
}
serverprops = qemuBlockStorageSourceBuildJSONInetSocketAddress(&src->hosts[0]);
if (!serverprops)
return NULL;
if (src->auth)
username = src->auth->username;
ignore_value(virJSONValueObjectCreate(&ret,
"s:driver", "ssh",
"s:path", src->path,
"a:server", serverprops,
"S:user", username,
NULL));
return ret;
}
/**
* qemuBlockStorageSourceGetBackendProps:
* @src: disk source
......@@ -970,6 +1002,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
break;
case VIR_STORAGE_NET_PROTOCOL_SSH:
if (!(fileprops = qemuBlockStorageSourceGetSshProps(src)))
return NULL;
break;
case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_LAST:
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册