chardev: add nodelay option

The "delay" option was introduced as a way to enable Nagle's algorithm
with ",nodelay".  Since the short form for boolean options has now been
deprecated, introduce a more properly named "nodelay" option.  The "delay"
option remains as an undocumented option.

"delay" and "nodelay" are mutually exclusive.  Because the check is
done at consumption time, the code also rejects them if one of the
two is specified via -set.

Based-on: <20210226080526.651705-1-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2021-02-25 11:47:52 +01:00
parent 9f34101db0
commit a9b1315f86
4 changed files with 22 additions and 10 deletions

View File

@ -1472,8 +1472,17 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
sock = backend->u.socket.data = g_new0(ChardevSocket, 1); sock = backend->u.socket.data = g_new0(ChardevSocket, 1);
qemu_chr_parse_common(opts, qapi_ChardevSocket_base(sock)); qemu_chr_parse_common(opts, qapi_ChardevSocket_base(sock));
sock->has_nodelay = qemu_opt_get(opts, "delay"); if (qemu_opt_get(opts, "delay") && qemu_opt_get(opts, "nodelay")) {
sock->nodelay = !qemu_opt_get_bool(opts, "delay", true); error_setg(errp, "'delay' and 'nodelay' are mutually exclusive");
return;
}
sock->has_nodelay =
qemu_opt_get(opts, "delay") ||
qemu_opt_get(opts, "nodelay");
sock->nodelay =
!qemu_opt_get_bool(opts, "delay", true) ||
qemu_opt_get_bool(opts, "nodelay", false);
/* /*
* We have different default to QMP for 'server', hence * We have different default to QMP for 'server', hence
* we can't just check for existence of 'server' * we can't just check for existence of 'server'

View File

@ -867,6 +867,9 @@ QemuOptsList qemu_chardev_opts = {
},{ },{
.name = "delay", .name = "delay",
.type = QEMU_OPT_BOOL, .type = QEMU_OPT_BOOL,
},{
.name = "nodelay",
.type = QEMU_OPT_BOOL,
},{ },{
.name = "reconnect", .name = "reconnect",
.type = QEMU_OPT_NUMBER, .type = QEMU_OPT_NUMBER,

View File

@ -3505,7 +3505,7 @@ int gdbserver_start(const char *device)
if (strstart(device, "tcp:", NULL)) { if (strstart(device, "tcp:", NULL)) {
/* enforce required TCP attributes */ /* enforce required TCP attributes */
snprintf(gdbstub_device_name, sizeof(gdbstub_device_name), snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
"%s,wait=off,delay=off,server=on", device); "%s,wait=off,nodelay=on,server=on", device);
device = gdbstub_device_name; device = gdbstub_device_name;
} }
#ifndef _WIN32 #ifndef _WIN32

View File

@ -3033,7 +3033,7 @@ DEFHEADING(Character device options:)
DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
"-chardev help\n" "-chardev help\n"
"-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
"-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4=on|off][,ipv6=on|off][,delay=on|off][,reconnect=seconds]\n" "-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4=on|off][,ipv6=on|off][,nodelay=on|off][,reconnect=seconds]\n"
" [,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds][,mux=on|off]\n" " [,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds][,mux=on|off]\n"
" [,logfile=PATH][,logappend=on|off][,tls-creds=ID][,tls-authz=ID] (tcp)\n" " [,logfile=PATH][,logappend=on|off][,tls-creds=ID][,tls-authz=ID] (tcp)\n"
"-chardev socket,id=id,path=path[,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds]\n" "-chardev socket,id=id,path=path[,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds]\n"
@ -3184,7 +3184,7 @@ The available backends are:
TCP and unix socket options are given below: TCP and unix socket options are given below:
``TCP options: port=port[,host=host][,to=to][,ipv4=on|off][,ipv6=on|off][,delay=on|off]`` ``TCP options: port=port[,host=host][,to=to][,ipv4=on|off][,ipv6=on|off][,nodelay=on|off]``
``host`` for a listening socket specifies the local address to ``host`` for a listening socket specifies the local address to
be bound. For a connecting socket species the remote host to be bound. For a connecting socket species the remote host to
connect to. ``host`` is optional for listening sockets. If not connect to. ``host`` is optional for listening sockets. If not
@ -3204,7 +3204,7 @@ The available backends are:
or IPv6 must be used. If neither is specified the socket may or IPv6 must be used. If neither is specified the socket may
use either protocol. use either protocol.
``delay=on|off`` disables the Nagle algorithm. ``nodelay=on|off`` disables the Nagle algorithm.
``unix options: path=path[,abstract=on|off][,tight=on|off]`` ``unix options: path=path[,abstract=on|off][,tight=on|off]``
``path`` specifies the local path of the unix socket. ``path`` ``path`` specifies the local path of the unix socket. ``path``
@ -3593,13 +3593,13 @@ SRST
``telnet options:`` ``telnet options:``
localhost 5555 localhost 5555
``tcp:[host]:port[,server=on|off][,wait=on|off][,delay=on|off][,reconnect=seconds]`` ``tcp:[host]:port[,server=on|off][,wait=on|off][,nodelay=on|off][,reconnect=seconds]``
The TCP Net Console has two modes of operation. It can send the The TCP Net Console has two modes of operation. It can send the
serial I/O to a location or wait for a connection from a serial I/O to a location or wait for a connection from a
location. By default the TCP Net Console is sent to host at the location. By default the TCP Net Console is sent to host at the
port. If you use the ``server=on`` option QEMU will wait for a client port. If you use the ``server=on`` option QEMU will wait for a client
socket application to connect to the port before continuing, socket application to connect to the port before continuing,
unless the ``wait=on|off`` option was specified. The ``delay=on|off`` unless the ``wait=on|off`` option was specified. The ``nodelay=on|off``
option disables the Nagle buffering algorithm. The ``reconnect=on`` option disables the Nagle buffering algorithm. The ``reconnect=on``
option only applies if ``server=no`` is set, if the connection goes option only applies if ``server=no`` is set, if the connection goes
down it will attempt to reconnect at the given interval. If host down it will attempt to reconnect at the given interval. If host
@ -3616,7 +3616,7 @@ SRST
``Example to not wait and listen on ip 192.168.0.100 port 4444`` ``Example to not wait and listen on ip 192.168.0.100 port 4444``
-serial tcp:192.168.0.100:4444,server=on,wait=off -serial tcp:192.168.0.100:4444,server=on,wait=off
``telnet:host:port[,server=on|off][,wait=on|off][,delay=on|off]`` ``telnet:host:port[,server=on|off][,wait=on|off][,nodelay=on|off]``
The telnet protocol is used instead of raw tcp sockets. The The telnet protocol is used instead of raw tcp sockets. The
options work the same as if you had specified ``-serial tcp``. options work the same as if you had specified ``-serial tcp``.
The difference is that the port acts like a telnet server or The difference is that the port acts like a telnet server or
@ -3626,7 +3626,7 @@ SRST
you do it with Control-] and then type "send break" followed by you do it with Control-] and then type "send break" followed by
pressing the enter key. pressing the enter key.
``websocket:host:port,server=on[,wait=on|off][,delay=on|off]`` ``websocket:host:port,server=on[,wait=on|off][,nodelay=on|off]``
The WebSocket protocol is used instead of raw tcp socket. The The WebSocket protocol is used instead of raw tcp socket. The
port acts as a WebSocket server. Client mode is not supported. port acts as a WebSocket server. Client mode is not supported.