提交 1f915d40 编写于 作者: P Peter Krempa

util: storage: Add support for type 'inet' in virStorageSourceParseBackingJSONSocketAddress

'SocketAddress' structure was changed to contain 'inet' instead of
'tcp' since qemu commit c5f1ae3ae7b. Existing entries have a backward
compatibility layer.

Libvirt will parse 'inet' and 'tcp' as equivalents.
上级 8829142b
......@@ -2802,18 +2802,17 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
const char *hostname = virJSONValueObjectGetString(json, "host");
const char *port = virJSONValueObjectGetString(json, "port");
const char *socket = virJSONValueObjectGetString(json, "socket");
int transport;
if ((transport = virStorageNetHostTransportTypeFromString(type)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown backing store transport protocol '%s'"), type);
if (!type) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("missing socket address type in "
"JSON backing volume definition"));
return -1;
}
host->transport = transport;
if (STREQ(type, "tcp") || STREQ(type, "inet")) {
host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
switch ((virStorageNetHostTransport) transport) {
case VIR_STORAGE_NET_HOST_TRANS_TCP:
if (!hostname) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("missing hostname for tcp backing server in "
......@@ -2824,9 +2823,9 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
if (VIR_STRDUP(host->name, hostname) < 0 ||
VIR_STRDUP(host->port, port) < 0)
return -1;
break;
} else if (STREQ(type, "unix")) {
host->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
case VIR_STORAGE_NET_HOST_TRANS_UNIX:
if (!socket) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("missing socket path for udp backing server in "
......@@ -2834,13 +2833,9 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
return -1;
}
if (VIR_STRDUP(host->socket, socket) < 0)
return -1;
break;
case VIR_STORAGE_NET_HOST_TRANS_RDMA:
case VIR_STORAGE_NET_HOST_TRANS_LAST:
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("backing store protocol '%s' is not yet supported"),
type);
......
......@@ -1431,7 +1431,7 @@ mymain(void)
"{ \"type\":\"unix\","
"\"socket\":\"/path/socket\""
"},"
"{ \"type\":\"tcp\","
"{ \"type\":\"inet\","
"\"host\":\"example.com\""
"}"
"]"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册