qapi-schema: Rename SocketAddressFlat's variant tcp to inet

QAPI type SocketAddressFlat differs from SocketAddress pointlessly:
the discriminator value for variant InetSocketAddress is 'tcp' instead
of 'inet'.  Rename.

The type is so far only used by the Gluster block drivers.  Take care
to keep 'tcp' working in things like -drive's file.server.0.type=tcp.
The "gluster+tcp" URI scheme in pseudo-filenames stays the same.
blockdev-add changes, but it has changed incompatibly since 2.8
already.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2017-03-06 20:00:48 +01:00 committed by Kevin Wolf
parent 2b733709d7
commit c5f1ae3ae7
2 changed files with 35 additions and 32 deletions

View File

@ -152,7 +152,7 @@ static QemuOptsList runtime_type_opts = {
{ {
.name = GLUSTER_OPT_TYPE, .name = GLUSTER_OPT_TYPE,
.type = QEMU_OPT_STRING, .type = QEMU_OPT_STRING,
.help = "tcp|unix", .help = "inet|unix",
}, },
{ /* end of list */ } { /* end of list */ }
}, },
@ -171,14 +171,14 @@ static QemuOptsList runtime_unix_opts = {
}, },
}; };
static QemuOptsList runtime_tcp_opts = { static QemuOptsList runtime_inet_opts = {
.name = "gluster_tcp", .name = "gluster_inet",
.head = QTAILQ_HEAD_INITIALIZER(runtime_tcp_opts.head), .head = QTAILQ_HEAD_INITIALIZER(runtime_inet_opts.head),
.desc = { .desc = {
{ {
.name = GLUSTER_OPT_TYPE, .name = GLUSTER_OPT_TYPE,
.type = QEMU_OPT_STRING, .type = QEMU_OPT_STRING,
.help = "tcp|unix", .help = "inet|unix",
}, },
{ {
.name = GLUSTER_OPT_HOST, .name = GLUSTER_OPT_HOST,
@ -337,14 +337,14 @@ static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf,
/* transport */ /* transport */
if (!uri->scheme || !strcmp(uri->scheme, "gluster")) { if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {
gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_TCP; gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_INET;
} else if (!strcmp(uri->scheme, "gluster+tcp")) { } else if (!strcmp(uri->scheme, "gluster+tcp")) {
gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_TCP; gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_INET;
} else if (!strcmp(uri->scheme, "gluster+unix")) { } else if (!strcmp(uri->scheme, "gluster+unix")) {
gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_UNIX; gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_UNIX;
is_unix = true; is_unix = true;
} else if (!strcmp(uri->scheme, "gluster+rdma")) { } else if (!strcmp(uri->scheme, "gluster+rdma")) {
gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_TCP; gsconf->type = SOCKET_ADDRESS_FLAT_TYPE_INET;
error_report("Warning: rdma feature is not supported, falling " error_report("Warning: rdma feature is not supported, falling "
"back to tcp"); "back to tcp");
} else { } else {
@ -374,11 +374,11 @@ static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf,
} }
gsconf->u.q_unix.path = g_strdup(qp->p[0].value); gsconf->u.q_unix.path = g_strdup(qp->p[0].value);
} else { } else {
gsconf->u.tcp.host = g_strdup(uri->server ? uri->server : "localhost"); gsconf->u.inet.host = g_strdup(uri->server ? uri->server : "localhost");
if (uri->port) { if (uri->port) {
gsconf->u.tcp.port = g_strdup_printf("%d", uri->port); gsconf->u.inet.port = g_strdup_printf("%d", uri->port);
} else { } else {
gsconf->u.tcp.port = g_strdup_printf("%d", GLUSTER_DEFAULT_PORT); gsconf->u.inet.port = g_strdup_printf("%d", GLUSTER_DEFAULT_PORT);
} }
} }
@ -416,15 +416,15 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
ret = glfs_set_volfile_server(glfs, "unix", ret = glfs_set_volfile_server(glfs, "unix",
server->value->u.q_unix.path, 0); server->value->u.q_unix.path, 0);
} else { } else {
if (parse_uint_full(server->value->u.tcp.port, &port, 10) < 0 || if (parse_uint_full(server->value->u.inet.port, &port, 10) < 0 ||
port > 65535) { port > 65535) {
error_setg(errp, "'%s' is not a valid port number", error_setg(errp, "'%s' is not a valid port number",
server->value->u.tcp.port); server->value->u.inet.port);
errno = EINVAL; errno = EINVAL;
goto out; goto out;
} }
ret = glfs_set_volfile_server(glfs, "tcp", ret = glfs_set_volfile_server(glfs, "tcp",
server->value->u.tcp.host, server->value->u.inet.host,
(int)port); (int)port);
} }
@ -448,8 +448,8 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
server->value->u.q_unix.path); server->value->u.q_unix.path);
} else { } else {
error_append_hint(errp, "hint: failed on host %s and port %s ", error_append_hint(errp, "hint: failed on host %s and port %s ",
server->value->u.tcp.host, server->value->u.inet.host,
server->value->u.tcp.port); server->value->u.inet.port);
} }
} }
@ -536,21 +536,24 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
} }
gsconf = g_new0(SocketAddressFlat, 1); gsconf = g_new0(SocketAddressFlat, 1);
if (!strcmp(ptr, "tcp")) {
ptr = "inet"; /* accept legacy "tcp" */
}
gsconf->type = qapi_enum_parse(SocketAddressFlatType_lookup, ptr, gsconf->type = qapi_enum_parse(SocketAddressFlatType_lookup, ptr,
SOCKET_ADDRESS_FLAT_TYPE__MAX, -1, SOCKET_ADDRESS_FLAT_TYPE__MAX, -1,
&local_err); &local_err);
if (local_err) { if (local_err) {
error_append_hint(&local_err, error_append_hint(&local_err,
"Parameter '%s' may be 'tcp' or 'unix'\n", "Parameter '%s' may be 'inet' or 'unix'\n",
GLUSTER_OPT_TYPE); GLUSTER_OPT_TYPE);
error_append_hint(&local_err, GERR_INDEX_HINT, i); error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out; goto out;
} }
qemu_opts_del(opts); qemu_opts_del(opts);
if (gsconf->type == SOCKET_ADDRESS_FLAT_TYPE_TCP) { if (gsconf->type == SOCKET_ADDRESS_FLAT_TYPE_INET) {
/* create opts info from runtime_tcp_opts list */ /* create opts info from runtime_inet_opts list */
opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort); opts = qemu_opts_create(&runtime_inet_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, backing_options, &local_err); qemu_opts_absorb_qdict(opts, backing_options, &local_err);
if (local_err) { if (local_err) {
goto out; goto out;
@ -563,7 +566,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
error_append_hint(&local_err, GERR_INDEX_HINT, i); error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out; goto out;
} }
gsconf->u.tcp.host = g_strdup(ptr); gsconf->u.inet.host = g_strdup(ptr);
ptr = qemu_opt_get(opts, GLUSTER_OPT_PORT); ptr = qemu_opt_get(opts, GLUSTER_OPT_PORT);
if (!ptr) { if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER, error_setg(&local_err, QERR_MISSING_PARAMETER,
@ -571,28 +574,28 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
error_append_hint(&local_err, GERR_INDEX_HINT, i); error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out; goto out;
} }
gsconf->u.tcp.port = g_strdup(ptr); gsconf->u.inet.port = g_strdup(ptr);
/* defend for unsupported fields in InetSocketAddress, /* defend for unsupported fields in InetSocketAddress,
* i.e. @ipv4, @ipv6 and @to * i.e. @ipv4, @ipv6 and @to
*/ */
ptr = qemu_opt_get(opts, GLUSTER_OPT_TO); ptr = qemu_opt_get(opts, GLUSTER_OPT_TO);
if (ptr) { if (ptr) {
gsconf->u.tcp.has_to = true; gsconf->u.inet.has_to = true;
} }
ptr = qemu_opt_get(opts, GLUSTER_OPT_IPV4); ptr = qemu_opt_get(opts, GLUSTER_OPT_IPV4);
if (ptr) { if (ptr) {
gsconf->u.tcp.has_ipv4 = true; gsconf->u.inet.has_ipv4 = true;
} }
ptr = qemu_opt_get(opts, GLUSTER_OPT_IPV6); ptr = qemu_opt_get(opts, GLUSTER_OPT_IPV6);
if (ptr) { if (ptr) {
gsconf->u.tcp.has_ipv6 = true; gsconf->u.inet.has_ipv6 = true;
} }
if (gsconf->u.tcp.has_to) { if (gsconf->u.inet.has_to) {
error_setg(&local_err, "Parameter 'to' not supported"); error_setg(&local_err, "Parameter 'to' not supported");
goto out; goto out;
} }
if (gsconf->u.tcp.has_ipv4 || gsconf->u.tcp.has_ipv6) { if (gsconf->u.inet.has_ipv4 || gsconf->u.inet.has_ipv6) {
error_setg(&local_err, "Parameters 'ipv4/ipv6' not supported"); error_setg(&local_err, "Parameters 'ipv4/ipv6' not supported");
goto out; goto out;
} }
@ -669,7 +672,7 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf,
"file.volume=testvol,file.path=/path/a.qcow2" "file.volume=testvol,file.path=/path/a.qcow2"
"[,file.debug=9]" "[,file.debug=9]"
"[,file.logfile=/path/filename.log]," "[,file.logfile=/path/filename.log],"
"file.server.0.type=tcp," "file.server.0.type=inet,"
"file.server.0.host=1.2.3.4," "file.server.0.host=1.2.3.4,"
"file.server.0.port=24007," "file.server.0.port=24007,"
"file.server.1.transport=unix," "file.server.1.transport=unix,"

View File

@ -4105,14 +4105,14 @@
# #
# Available SocketAddressFlat types # Available SocketAddressFlat types
# #
# @tcp: Internet address # @inet: Internet address
# #
# @unix: Unix domain socket # @unix: Unix domain socket
# #
# Since: 2.9 # Since: 2.9
## ##
{ 'enum': 'SocketAddressFlatType', { 'enum': 'SocketAddressFlatType',
'data': [ 'unix', 'tcp' ] } 'data': [ 'unix', 'inet' ] }
## ##
# @SocketAddressFlat: # @SocketAddressFlat:
@ -4127,7 +4127,7 @@
# A flat union is nicer than simple because it avoids nesting # A flat union is nicer than simple because it avoids nesting
# (i.e. more {}) on the wire. # (i.e. more {}) on the wire.
# #
# 2. SocketAddressFlat supports only types 'unix' and 'tcp', because # 2. SocketAddressFlat supports only types 'unix' and 'inet', because
# that's what its current users need. # that's what its current users need.
# #
# Since: 2.9 # Since: 2.9
@ -4136,7 +4136,7 @@
'base': { 'type': 'SocketAddressFlatType' }, 'base': { 'type': 'SocketAddressFlatType' },
'discriminator': 'type', 'discriminator': 'type',
'data': { 'unix': 'UnixSocketAddress', 'data': { 'unix': 'UnixSocketAddress',
'tcp': 'InetSocketAddress' } } 'inet': 'InetSocketAddress' } }
## ##
# @getfd: # @getfd: