diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-09 15:49:08 -0400 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-09 15:49:14 -0400 |
commit | 76d20ea0f1b26ebd5da2f5fb2fdf3250cde887bb (patch) | |
tree | bcb0e4a8f29bdcfa0f5785a09608bff57a82107c /chardev | |
parent | 7ed57b66221b5a3e23b3519824637b297dc92090 (diff) | |
parent | dcd3b25d656d346205dc0f2254723fccf0264e45 (diff) |
Merge remote-tracking branch 'armbru/tags/pull-qapi-2017-05-04-v3' into staging
QAPI patches for 2017-05-04
# gpg: Signature made Tue 09 May 2017 03:16:12 AM EDT
# gpg: using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* armbru/tags/pull-qapi-2017-05-04-v3: (28 commits)
qmp-shell: improve help
qmp-shell: don't show version greeting if unavailable
qmp-shell: Cope with query-commands error
qmp-shell: add -N option to skip negotiate
qmp-shell: add persistent command history
qobject-input-visitor: Catch misuse of end_struct vs. end_list
qapi: Document intended use of @name within alternate visits
qobject-input-visitor: Document full_name_nth()
qmp: Improve QMP dispatch error messages
sockets: Delete unused helper socket_address_crumple()
sockets: Limit SocketAddressLegacy to external interfaces
sockets: Rename SocketAddressFlat to SocketAddress
sockets: Rename SocketAddress to SocketAddressLegacy
qapi: New QAPI_CLONE_MEMBERS()
sockets: Prepare inet_parse() for flattened SocketAddress
sockets: Prepare vsock_parse() for flattened SocketAddress
test-qga: Actually test 0xff sync bytes
fdc-test: Avoid deprecated 'change' command
QemuOpts: Simplify qemu_opts_to_qdict()
block: Simplify bdrv_append_temp_snapshot() logic
...
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'chardev')
-rw-r--r-- | chardev/char-socket.c | 36 | ||||
-rw-r--r-- | chardev/char-udp.c | 20 |
2 files changed, 30 insertions, 26 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 3bda89a1fa..e2fb7f7cd5 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -360,26 +360,26 @@ static char *SocketAddress_to_str(const char *prefix, SocketAddress *addr, bool is_listen, bool is_telnet) { switch (addr->type) { - case SOCKET_ADDRESS_KIND_INET: + case SOCKET_ADDRESS_TYPE_INET: return g_strdup_printf("%s%s:%s:%s%s", prefix, is_telnet ? "telnet" : "tcp", - addr->u.inet.data->host, - addr->u.inet.data->port, + addr->u.inet.host, + addr->u.inet.port, is_listen ? ",server" : ""); break; - case SOCKET_ADDRESS_KIND_UNIX: + case SOCKET_ADDRESS_TYPE_UNIX: return g_strdup_printf("%sunix:%s%s", prefix, - addr->u.q_unix.data->path, + addr->u.q_unix.path, is_listen ? ",server" : ""); break; - case SOCKET_ADDRESS_KIND_FD: - return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd.data->str, + case SOCKET_ADDRESS_TYPE_FD: + return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd.str, is_listen ? ",server" : ""); break; - case SOCKET_ADDRESS_KIND_VSOCK: + case SOCKET_ADDRESS_TYPE_VSOCK: return g_strdup_printf("%svsock:%s:%s", prefix, - addr->u.vsock.data->cid, - addr->u.vsock.data->port); + addr->u.vsock.cid, + addr->u.vsock.port); default: abort(); } @@ -648,7 +648,7 @@ static void tcp_chr_tls_init(Chardev *chr) } else { tioc = qio_channel_tls_new_client( s->ioc, s->tls_creds, - s->addr->u.inet.data->host, + s->addr->u.inet.host, &err); } if (tioc == NULL) { @@ -859,7 +859,6 @@ static void qmp_chardev_open_socket(Chardev *chr, { SocketChardev *s = SOCKET_CHARDEV(chr); ChardevSocket *sock = backend->u.socket.data; - SocketAddress *addr = sock->addr; bool do_nodelay = sock->has_nodelay ? sock->nodelay : false; bool is_listen = sock->has_server ? sock->server : true; bool is_telnet = sock->has_telnet ? sock->telnet : false; @@ -867,6 +866,7 @@ static void qmp_chardev_open_socket(Chardev *chr, bool is_waitconnect = sock->has_wait ? sock->wait : false; int64_t reconnect = sock->has_reconnect ? sock->reconnect : 0; QIOChannelSocket *sioc = NULL; + SocketAddress *addr; s->is_listen = is_listen; s->is_telnet = is_telnet; @@ -905,11 +905,11 @@ static void qmp_chardev_open_socket(Chardev *chr, } } - s->addr = QAPI_CLONE(SocketAddress, sock->addr); + s->addr = addr = socket_address_flatten(sock->addr); qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE); /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */ - if (addr->type == SOCKET_ADDRESS_KIND_UNIX) { + if (addr->type == SOCKET_ADDRESS_TYPE_UNIX) { qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); } @@ -985,7 +985,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, const char *host = qemu_opt_get(opts, "host"); const char *port = qemu_opt_get(opts, "port"); const char *tls_creds = qemu_opt_get(opts, "tls-creds"); - SocketAddress *addr; + SocketAddressLegacy *addr; ChardevSocket *sock; backend->type = CHARDEV_BACKEND_KIND_SOCKET; @@ -1022,14 +1022,14 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, sock->reconnect = reconnect; sock->tls_creds = g_strdup(tls_creds); - addr = g_new0(SocketAddress, 1); + addr = g_new0(SocketAddressLegacy, 1); if (path) { UnixSocketAddress *q_unix; - addr->type = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX; q_unix = addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); q_unix->path = g_strdup(path); } else { - addr->type = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; addr->u.inet.data = g_new(InetSocketAddress, 1); *addr->u.inet.data = (InetSocketAddress) { .host = g_strdup(host), diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 76ef83f930..607647642a 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -134,7 +134,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, const char *localaddr = qemu_opt_get(opts, "localaddr"); const char *localport = qemu_opt_get(opts, "localport"); bool has_local = false; - SocketAddress *addr; + SocketAddressLegacy *addr; ChardevUdp *udp; backend->type = CHARDEV_BACKEND_KIND_UDP; @@ -159,8 +159,8 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, udp = backend->u.udp.data = g_new0(ChardevUdp, 1); qemu_chr_parse_common(opts, qapi_ChardevUdp_base(udp)); - addr = g_new0(SocketAddress, 1); - addr->type = SOCKET_ADDRESS_KIND_INET; + addr = g_new0(SocketAddressLegacy, 1); + addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; addr->u.inet.data = g_new(InetSocketAddress, 1); *addr->u.inet.data = (InetSocketAddress) { .host = g_strdup(host), @@ -174,8 +174,8 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, if (has_local) { udp->has_local = true; - addr = g_new0(SocketAddress, 1); - addr->type = SOCKET_ADDRESS_KIND_INET; + addr = g_new0(SocketAddressLegacy, 1); + addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; addr->u.inet.data = g_new(InetSocketAddress, 1); *addr->u.inet.data = (InetSocketAddress) { .host = g_strdup(localaddr), @@ -191,13 +191,17 @@ static void qmp_chardev_open_udp(Chardev *chr, Error **errp) { ChardevUdp *udp = backend->u.udp.data; + SocketAddress *local_addr = socket_address_flatten(udp->local); + SocketAddress *remote_addr = socket_address_flatten(udp->remote); QIOChannelSocket *sioc = qio_channel_socket_new(); char *name; UdpChardev *s = UDP_CHARDEV(chr); + int ret; - if (qio_channel_socket_dgram_sync(sioc, - udp->local, udp->remote, - errp) < 0) { + ret = qio_channel_socket_dgram_sync(sioc, local_addr, remote_addr, errp); + qapi_free_SocketAddress(local_addr); + qapi_free_SocketAddress(remote_addr); + if (ret < 0) { object_unref(OBJECT(sioc)); return; } |