qemu-e2k/chardev
Markus Armbruster b08cc97d6b sockets: Fix default of UnixSocketAddress member @tight
An optional bool member of a QAPI struct can be false, true, or absent.
The previous commit demonstrated that socket_listen() and
socket_connect() are broken for absent @tight, and indeed QMP chardev-
add also defaults absent member @tight to false instead of true.

In C, QAPI members are represented by two fields, has_MEMBER and MEMBER.
We have:

            has_MEMBER    MEMBER
    false         true     false
    true          true      true
    absent       false  false/ignore

When has_MEMBER is false, MEMBER should be set to false on write, and
ignored on read.

For QMP, the QAPI visitors handle absent @tight by setting both
@has_tight and @tight to false.  unix_listen_saddr() and
unix_connect_saddr() however use @tight only, disregarding @has_tight.
This is wrong and means that absent @tight defaults to false whereas it
should default to true.

The same is true for @has_abstract, though @abstract defaults to
false and therefore has the same behavior for all of QMP, HMP and CLI.
Fix unix_listen_saddr() and unix_connect_saddr() to check
@has_abstract/@has_tight, and to default absent @tight to true.

However, this is only half of the story.  HMP chardev-add and CLI
-chardev so far correctly defaulted @tight to true, but defaults to
false again with the above fix for HMP and CLI.  In fact, the "tight"
and "abstract" options now break completely.

Digging deeper, we find that qemu_chr_parse_socket() also ignores
@has_tight, leaving it false when it sets @tight.  That is also wrong,
but the two wrongs cancelled out.  Fix qemu_chr_parse_socket() to set
@has_tight and @has_abstract; writing testcases for HMP and CLI is left
for another day.

Fixes: 776b97d360
Reported-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-03 13:09:28 +00:00
..
baum.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
char-console.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
char-fd.c util: rename qemu_open() to qemu_open_old() 2020-09-16 10:33:48 +01:00
char-fe.c chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h" 2020-07-13 11:59:47 +04:00
char-file.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
char-io.c chardev: use a child source for qio input source 2018-10-03 14:45:05 +04:00
char-mux.c chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h" 2020-07-13 11:59:47 +04:00
char-null.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
char-parallel.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
char-pipe.c util: rename qemu_open() to qemu_open_old() 2020-09-16 10:33:48 +01:00
char-pty.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
char-ringbuf.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
char-serial.c chardev: Add macOS to list of OSes that support -chardev serial 2020-05-04 14:35:23 +02:00
char-socket.c sockets: Fix default of UnixSocketAddress member @tight 2020-11-03 13:09:28 +00:00
char-stdio.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
char-udp.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
char-win-stdio.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
char-win.c chardev: Improve error report by calling error_setg_win32() 2020-03-09 13:36:15 +01:00
char.c char: fix logging when chardev write fails 2020-09-30 19:11:36 +02:00
chardev-internal.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
chardev-sysemu.c chardev: Extract system emulation specific code 2020-07-13 11:59:47 +04:00
meson.build chardev/spice: build spice chardevs as module 2020-10-15 11:14:40 +02:00
msmouse.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
spice.c spice: move add_interface() to QemuSpiceOps. 2020-10-21 15:46:14 +02:00
testdev.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
wctablet.c Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00