Add yank option which is passed to the socket-channel. Signed-off-by: Lukas Straub <lukasstra...@web.de> --- chardev/char-socket.c | 8 ++++++++ chardev/char.c | 3 +++ qapi/char.json | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 185fe38dda..e476358941 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -65,6 +65,7 @@ typedef struct { int max_size; int do_telnetopt; int do_nodelay; + int do_yank; int *read_msgfds; size_t read_msgfds_num; int *write_msgfds; @@ -877,6 +878,9 @@ static int tcp_chr_new_client(Chardev *chr, QIOChannelSocket *sioc) if (s->do_nodelay) { qio_channel_set_delay(s->ioc, false); } + if (s->do_yank) { + qio_channel_set_yank(s->ioc, true); + } if (s->listener) { qio_net_listener_set_client_func_full(s->listener, NULL, NULL, NULL, chr->gcontext); @@ -1297,6 +1301,7 @@ static void qmp_chardev_open_socket(Chardev *chr, SocketChardev *s = SOCKET_CHARDEV(chr); ChardevSocket *sock = backend->u.socket.data; bool do_nodelay = sock->has_nodelay ? sock->nodelay : false; + bool do_yank = sock->has_yank ? sock->yank : false; bool is_listen = sock->has_server ? sock->server : true; bool is_telnet = sock->has_telnet ? sock->telnet : false; bool is_tn3270 = sock->has_tn3270 ? sock->tn3270 : false; @@ -1310,6 +1315,7 @@ static void qmp_chardev_open_socket(Chardev *chr, s->is_tn3270 = is_tn3270; s->is_websock = is_websock; s->do_nodelay = do_nodelay; + s->do_yank = do_yank; if (sock->tls_creds) { Object *creds; creds = object_resolve_path_component( @@ -1400,6 +1406,8 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, sock->has_nodelay = qemu_opt_get(opts, "delay"); sock->nodelay = !qemu_opt_get_bool(opts, "delay", true); + sock->has_yank = qemu_opt_get(opts, "yank"); + sock->yank = qemu_opt_get_bool(opts, "yank", false); /* * We have different default to QMP for 'server', hence * we can't just check for existence of 'server' diff --git a/chardev/char.c b/chardev/char.c index e77564060d..04075389bf 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -939,6 +939,9 @@ QemuOptsList qemu_chardev_opts = { },{ .name = "logappend", .type = QEMU_OPT_BOOL, + },{ + .name = "yank", + .type = QEMU_OPT_BOOL, }, { /* end of list */ } }, diff --git a/qapi/char.json b/qapi/char.json index daceb20f84..f9c04e720c 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -270,6 +270,8 @@ # then attempt a reconnect after the given number of seconds. # Setting this to zero disables this function. (default: 0) # (Since: 2.2) +# @yank: Shutdown the socket when the 'yank' qmp command is executed. +# (Since: 5.1) # # Since: 1.4 ## @@ -283,7 +285,8 @@ '*telnet': 'bool', '*tn3270': 'bool', '*websocket': 'bool', - '*reconnect': 'int' }, + '*reconnect': 'int', + '*yank': 'bool' }, 'base': 'ChardevCommon' } ## -- 2.20.1
pgpUbUHjeM1AM.pgp
Description: OpenPGP digital signature