Skip to content

Commit a9b1315

Browse files
committed
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: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9f34101 commit a9b1315

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

chardev/char-socket.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,8 +1472,17 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
14721472
sock = backend->u.socket.data = g_new0(ChardevSocket, 1);
14731473
qemu_chr_parse_common(opts, qapi_ChardevSocket_base(sock));
14741474

1475-
sock->has_nodelay = qemu_opt_get(opts, "delay");
1476-
sock->nodelay = !qemu_opt_get_bool(opts, "delay", true);
1475+
if (qemu_opt_get(opts, "delay") && qemu_opt_get(opts, "nodelay")) {
1476+
error_setg(errp, "'delay' and 'nodelay' are mutually exclusive");
1477+
return;
1478+
}
1479+
sock->has_nodelay =
1480+
qemu_opt_get(opts, "delay") ||
1481+
qemu_opt_get(opts, "nodelay");
1482+
sock->nodelay =
1483+
!qemu_opt_get_bool(opts, "delay", true) ||
1484+
qemu_opt_get_bool(opts, "nodelay", false);
1485+
14771486
/*
14781487
* We have different default to QMP for 'server', hence
14791488
* we can't just check for existence of 'server'

chardev/char.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,9 @@ QemuOptsList qemu_chardev_opts = {
867867
},{
868868
.name = "delay",
869869
.type = QEMU_OPT_BOOL,
870+
},{
871+
.name = "nodelay",
872+
.type = QEMU_OPT_BOOL,
870873
},{
871874
.name = "reconnect",
872875
.type = QEMU_OPT_NUMBER,

gdbstub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3505,7 +3505,7 @@ int gdbserver_start(const char *device)
35053505
if (strstart(device, "tcp:", NULL)) {
35063506
/* enforce required TCP attributes */
35073507
snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
3508-
"%s,wait=off,delay=off,server=on", device);
3508+
"%s,wait=off,nodelay=on,server=on", device);
35093509
device = gdbstub_device_name;
35103510
}
35113511
#ifndef _WIN32

qemu-options.hx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,7 @@ DEFHEADING(Character device options:)
30333033
DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
30343034
"-chardev help\n"
30353035
"-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
3036-
"-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4=on|off][,ipv6=on|off][,delay=on|off][,reconnect=seconds]\n"
3036+
"-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4=on|off][,ipv6=on|off][,nodelay=on|off][,reconnect=seconds]\n"
30373037
" [,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds][,mux=on|off]\n"
30383038
" [,logfile=PATH][,logappend=on|off][,tls-creds=ID][,tls-authz=ID] (tcp)\n"
30393039
"-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:
31843184
31853185
TCP and unix socket options are given below:
31863186
3187-
``TCP options: port=port[,host=host][,to=to][,ipv4=on|off][,ipv6=on|off][,delay=on|off]``
3187+
``TCP options: port=port[,host=host][,to=to][,ipv4=on|off][,ipv6=on|off][,nodelay=on|off]``
31883188
``host`` for a listening socket specifies the local address to
31893189
be bound. For a connecting socket species the remote host to
31903190
connect to. ``host`` is optional for listening sockets. If not
@@ -3204,7 +3204,7 @@ The available backends are:
32043204
or IPv6 must be used. If neither is specified the socket may
32053205
use either protocol.
32063206
3207-
``delay=on|off`` disables the Nagle algorithm.
3207+
``nodelay=on|off`` disables the Nagle algorithm.
32083208
32093209
``unix options: path=path[,abstract=on|off][,tight=on|off]``
32103210
``path`` specifies the local path of the unix socket. ``path``
@@ -3593,13 +3593,13 @@ SRST
35933593
``telnet options:``
35943594
localhost 5555
35953595

3596-
``tcp:[host]:port[,server=on|off][,wait=on|off][,delay=on|off][,reconnect=seconds]``
3596+
``tcp:[host]:port[,server=on|off][,wait=on|off][,nodelay=on|off][,reconnect=seconds]``
35973597
The TCP Net Console has two modes of operation. It can send the
35983598
serial I/O to a location or wait for a connection from a
35993599
location. By default the TCP Net Console is sent to host at the
36003600
port. If you use the ``server=on`` option QEMU will wait for a client
36013601
socket application to connect to the port before continuing,
3602-
unless the ``wait=on|off`` option was specified. The ``delay=on|off``
3602+
unless the ``wait=on|off`` option was specified. The ``nodelay=on|off``
36033603
option disables the Nagle buffering algorithm. The ``reconnect=on``
36043604
option only applies if ``server=no`` is set, if the connection goes
36053605
down it will attempt to reconnect at the given interval. If host
@@ -3616,7 +3616,7 @@ SRST
36163616
``Example to not wait and listen on ip 192.168.0.100 port 4444``
36173617
-serial tcp:192.168.0.100:4444,server=on,wait=off
36183618

3619-
``telnet:host:port[,server=on|off][,wait=on|off][,delay=on|off]``
3619+
``telnet:host:port[,server=on|off][,wait=on|off][,nodelay=on|off]``
36203620
The telnet protocol is used instead of raw tcp sockets. The
36213621
options work the same as if you had specified ``-serial tcp``.
36223622
The difference is that the port acts like a telnet server or
@@ -3626,7 +3626,7 @@ SRST
36263626
you do it with Control-] and then type "send break" followed by
36273627
pressing the enter key.
36283628

3629-
``websocket:host:port,server=on[,wait=on|off][,delay=on|off]``
3629+
``websocket:host:port,server=on[,wait=on|off][,nodelay=on|off]``
36303630
The WebSocket protocol is used instead of raw tcp socket. The
36313631
port acts as a WebSocket server. Client mode is not supported.
36323632

0 commit comments

Comments
 (0)