• Markus Armbruster's avatar
    Revert "qemu-char: Print strerror message on failure" and deps · 1f51470d
    Markus Armbruster authored
    The commit's purpose is laudable:
    
        The only way for chardev drivers to communicate an error was to
        return a NULL pointer, which resulted in an error message that
        said _that_ something went wrong, but not _why_.
    
    It attempts to achieve it by changing the interface to return 0/-errno
    and update qemu_chr_open_opts() to use strerror() to display a more
    helpful error message.  Unfortunately, it has serious flaws:
    
    1. Backends "socket" and "udp" return bogus error codes, because
    qemu_chr_open_socket() and qemu_chr_open_udp() assume that
    unix_listen_opts(), unix_connect_opts(), inet_listen_opts(),
    inet_connect_opts() and inet_dgram_opts() fail with errno set
    appropriately.  That assumption is wrong, and the commit turns
    unspecific error messages into misleading error messages.  For
    instance:
    
        $ qemu-system-x86_64 -nodefaults -vnc :0 -chardev socket,id=bar,host=xxx
        inet_connect: host and/or port not specified
        chardev: opening backend "socket" failed: No such file or directory
    
    ENOENT is what happens to be in my errno when the backend returns
    -errno.  Let's put ERANGE there just for giggles:
    
        $ qemu-system-x86_64 -nodefaults -vnc :0 -chardev socket,id=bar,host=xxx -drive if=none,iops=99999999999999999999
        inet_connect: host and/or port not specified
        chardev: opening backend "socket" failed: Numerical result out of range
    
    Worse: when errno happens to be zero, return -errno erroneously
    signals success, and qemu_chr_new_from_opts() dies dereferencing
    uninitialized chr.  I observe this with "-serial unix:".
    
    2. All qemu_chr_open_opts() knows about the error is an errno error
    code.  That's simply not enough for a decent message.  For instance,
    when inet_dgram() can't resolve the parameter host, which errno code
    should it use?  What if it can't resolve parameter localaddr?
    
    Clue: many backends already report errors in their open methods.
    Let's revert the flawed commit along with its dependencies, and fix up
    the silent error paths instead.
    
    This reverts commit 6e1db57b.
    
    Conflicts:
    
    	console.c
    	hw/baum.c
    	qemu-char.c
    
    This reverts commit aad04cd0.
    
    The parts of commit db418a0a "Add stdio char device on windows" that
    depend on the reverted change fixed up.
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
    1f51470d
Name
Last commit
Last update
QMP Loading commit data...
audio Loading commit data...
block Loading commit data...
bsd-user Loading commit data...
darwin-user Loading commit data...
default-configs Loading commit data...
docs Loading commit data...
fpu Loading commit data...
fsdev Loading commit data...
gdb-xml Loading commit data...
hw Loading commit data...
include/qemu Loading commit data...
libcacard Loading commit data...
linux-headers Loading commit data...
linux-user Loading commit data...
net Loading commit data...
pc-bios Loading commit data...
qapi Loading commit data...
qga Loading commit data...
qom Loading commit data...
roms Loading commit data...
scripts Loading commit data...
slirp Loading commit data...
sysconfigs/target Loading commit data...
target-alpha Loading commit data...
target-arm Loading commit data...
target-cris Loading commit data...
target-i386 Loading commit data...
target-lm32 Loading commit data...
target-m68k Loading commit data...
target-microblaze Loading commit data...
target-mips Loading commit data...
target-ppc Loading commit data...
target-s390x Loading commit data...
target-sh4 Loading commit data...
target-sparc Loading commit data...
target-unicore32 Loading commit data...
target-xtensa Loading commit data...
tcg Loading commit data...
tests Loading commit data...
trace Loading commit data...
ui Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.mailmap Loading commit data...
CODING_STYLE Loading commit data...
COPYING Loading commit data...
COPYING.LIB Loading commit data...
Changelog Loading commit data...
HACKING Loading commit data...
LICENSE Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
Makefile.dis Loading commit data...
Makefile.hw Loading commit data...
Makefile.objs Loading commit data...
Makefile.target Loading commit data...
Makefile.user Loading commit data...
README Loading commit data...
TODO Loading commit data...
VERSION Loading commit data...
a.out.h Loading commit data...
acl.c Loading commit data...
acl.h Loading commit data...
aes.c Loading commit data...
aes.h Loading commit data...
aio.c Loading commit data...
alpha-dis.c Loading commit data...
alpha.ld Loading commit data...
arch_init.c Loading commit data...
arch_init.h Loading commit data...
arm-dis.c Loading commit data...
arm-semi.c Loading commit data...
arm.ld Loading commit data...
async.c Loading commit data...
balloon.c Loading commit data...
balloon.h Loading commit data...
bitmap.c Loading commit data...
bitmap.h Loading commit data...
bitops.c Loading commit data...
bitops.h Loading commit data...
block-migration.c Loading commit data...
block-migration.h Loading commit data...
block.c Loading commit data...
block.h Loading commit data...
block_int.h Loading commit data...
blockdev.c Loading commit data...
blockdev.h Loading commit data...
bswap.h Loading commit data...
bt-host.c Loading commit data...
bt-host.h Loading commit data...
bt-vhci.c Loading commit data...
buffered_file.c Loading commit data...
buffered_file.h Loading commit data...
cache-utils.c Loading commit data...
cache-utils.h Loading commit data...
check-qdict.c Loading commit data...
check-qfloat.c Loading commit data...
check-qint.c Loading commit data...
check-qjson.c Loading commit data...
check-qlist.c Loading commit data...
check-qstring.c Loading commit data...
cmd.c Loading commit data...
cmd.h Loading commit data...
compatfd.c Loading commit data...
compatfd.h Loading commit data...
compiler.h Loading commit data...
config.h Loading commit data...
configure Loading commit data...
console.c Loading commit data...
console.h Loading commit data...
coroutine-gthread.c Loading commit data...
coroutine-ucontext.c Loading commit data...
coroutine-win32.c Loading commit data...
cpu-all.h Loading commit data...
cpu-common.h Loading commit data...
cpu-defs.h Loading commit data...
cpu-exec.c Loading commit data...
cpus.c Loading commit data...
cpus.h Loading commit data...
cris-dis.c Loading commit data...
cursor.c Loading commit data...
cursor_hidden.xpm Loading commit data...
cursor_left_ptr.xpm Loading commit data...
cutils.c Loading commit data...
def-helper.h Loading commit data...
device_tree.c Loading commit data...
device_tree.h Loading commit data...
dis-asm.h Loading commit data...
disas.c Loading commit data...
disas.h Loading commit data...
dma-helpers.c Loading commit data...
dma.h Loading commit data...
dyngen-exec.h Loading commit data...
elf.h Loading commit data...
envlist.c Loading commit data...
envlist.h Loading commit data...
error.c Loading commit data...
error.h Loading commit data...
error_int.h Loading commit data...
event_notifier.c Loading commit data...
event_notifier.h Loading commit data...
exec-all.h Loading commit data...
exec-memory.h Loading commit data...
exec-obsolete.h Loading commit data...
exec.c Loading commit data...
gdbstub.c Loading commit data...
gdbstub.h Loading commit data...
gen-icount.h Loading commit data...
hmp-commands.hx Loading commit data...
hmp.c Loading commit data...
hmp.h Loading commit data...
host-utils.c Loading commit data...
host-utils.h Loading commit data...
hppa-dis.c Loading commit data...
hppa.ld Loading commit data...
i386-dis.c Loading commit data...
i386.ld Loading commit data...
ia64-dis.c Loading commit data...
ia64.ld Loading commit data...
input.c Loading commit data...
int128.h Loading commit data...
iohandler.c Loading commit data...
ioport-user.c Loading commit data...
ioport.c Loading commit data...
ioport.h Loading commit data...
iorange.h Loading commit data...
iov.c Loading commit data...
iov.h Loading commit data...
json-lexer.c Loading commit data...
json-lexer.h Loading commit data...
json-parser.c Loading commit data...
json-parser.h Loading commit data...
json-streamer.c Loading commit data...
json-streamer.h Loading commit data...
kvm-all.c Loading commit data...
kvm-stub.c Loading commit data...
kvm.h Loading commit data...
libfdt_env.h Loading commit data...
linux-aio.c Loading commit data...
m68k-dis.c Loading commit data...
m68k-semi.c Loading commit data...
m68k.ld Loading commit data...
main-loop.c Loading commit data...
main-loop.h Loading commit data...
memory.c Loading commit data...
memory.h Loading commit data...
microblaze-dis.c Loading commit data...
migration-exec.c Loading commit data...
migration-fd.c Loading commit data...
migration-tcp.c Loading commit data...
migration-unix.c Loading commit data...
migration.c Loading commit data...
migration.h Loading commit data...
mips-dis.c Loading commit data...
mips.ld Loading commit data...
module.c Loading commit data...
module.h Loading commit data...
monitor.c Loading commit data...
monitor.h Loading commit data...
nbd.c Loading commit data...
nbd.h Loading commit data...
net.c Loading commit data...
net.h Loading commit data...
notify.c Loading commit data...
notify.h Loading commit data...
os-posix.c Loading commit data...
os-win32.c Loading commit data...
osdep.c Loading commit data...
osdep.h Loading commit data...
oslib-posix.c Loading commit data...
oslib-win32.c Loading commit data...
path.c Loading commit data...
pci-ids.txt Loading commit data...
pflib.c Loading commit data...
pflib.h Loading commit data...
poison.h Loading commit data...
posix-aio-compat.c Loading commit data...
ppc-dis.c Loading commit data...
ppc.ld Loading commit data...
ppc64.ld Loading commit data...
qapi-schema-guest.json Loading commit data...
qapi-schema-test.json Loading commit data...
qapi-schema.json Loading commit data...
qbool.c Loading commit data...
qbool.h Loading commit data...
qdict-test-data.txt Loading commit data...
qdict.c Loading commit data...
qdict.h Loading commit data...
qemu-aio.h Loading commit data...
qemu-barrier.h Loading commit data...
qemu-bridge-helper.c Loading commit data...
qemu-char.c Loading commit data...
qemu-char.h Loading commit data...
qemu-common.h Loading commit data...
qemu-config.c Loading commit data...
qemu-config.h Loading commit data...
qemu-coroutine-int.h Loading commit data...
qemu-coroutine-io.c Loading commit data...
qemu-coroutine-lock.c Loading commit data...
qemu-coroutine-sleep.c Loading commit data...
qemu-coroutine.c Loading commit data...
qemu-coroutine.h Loading commit data...
qemu-doc.texi Loading commit data...
qemu-error.c Loading commit data...
qemu-error.h Loading commit data...
qemu-file.h Loading commit data...
qemu-ga.c Loading commit data...
qemu-img-cmds.hx Loading commit data...
qemu-img.c Loading commit data...
qemu-img.texi Loading commit data...
qemu-io.c Loading commit data...
qemu-lock.h Loading commit data...
qemu-log.h Loading commit data...
qemu-nbd.c Loading commit data...
qemu-nbd.texi Loading commit data...
qemu-objects.h Loading commit data...
qemu-option.c Loading commit data...
qemu-option.h Loading commit data...
qemu-options-wrapper.h Loading commit data...
qemu-options.h Loading commit data...
qemu-options.hx Loading commit data...
qemu-os-posix.h Loading commit data...
qemu-os-win32.h Loading commit data...
qemu-progress.c Loading commit data...
qemu-queue.h Loading commit data...
qemu-sockets.c Loading commit data...
qemu-tech.texi Loading commit data...
qemu-thread-posix.c Loading commit data...
qemu-thread-posix.h Loading commit data...
qemu-thread-win32.c Loading commit data...
qemu-thread-win32.h Loading commit data...
qemu-thread.h Loading commit data...
qemu-timer-common.c Loading commit data...
qemu-timer.c Loading commit data...
qemu-timer.h Loading commit data...
qemu-tls.h Loading commit data...
qemu-tool.c Loading commit data...
qemu-x509.h Loading commit data...
qemu-xattr.h Loading commit data...
qemu.sasl Loading commit data...
qemu_socket.h Loading commit data...
qerror.c Loading commit data...
qerror.h Loading commit data...
qfloat.c Loading commit data...
qfloat.h Loading commit data...
qint.c Loading commit data...
qint.h Loading commit data...
qjson.c Loading commit data...
qjson.h Loading commit data...
qlist.c Loading commit data...
qlist.h Loading commit data...
qmp-commands.hx Loading commit data...
qmp.c Loading commit data...
qobject.h Loading commit data...
qstring.c Loading commit data...
qstring.h Loading commit data...
range.h Loading commit data...
readline.c Loading commit data...
readline.h Loading commit data...
rules.mak Loading commit data...
s390-dis.c Loading commit data...
s390.ld Loading commit data...
savevm.c Loading commit data...
sh4-dis.c Loading commit data...
softmmu-semi.h Loading commit data...
softmmu_defs.h Loading commit data...
softmmu_exec.h Loading commit data...
softmmu_header.h Loading commit data...
softmmu_template.h Loading commit data...
sparc-dis.c Loading commit data...
sparc.ld Loading commit data...
sparc64.ld Loading commit data...
spice-qemu-char.c Loading commit data...
sysemu.h Loading commit data...
targphys.h Loading commit data...
tcg-runtime.c Loading commit data...
tci-dis.c Loading commit data...
tci.c Loading commit data...
test-coroutine.c Loading commit data...
test-qmp-commands.c Loading commit data...
test-qmp-input-visitor.c Loading commit data...
test-qmp-output-visitor.c Loading commit data...
test-string-input-visitor.c Loading commit data...
test-string-output-visitor.c Loading commit data...
thunk.c Loading commit data...
thunk.h Loading commit data...
trace-events Loading commit data...
translate-all.c Loading commit data...
uboot_image.h Loading commit data...
usb-bsd.c Loading commit data...
usb-linux.c Loading commit data...
usb-redir.c Loading commit data...
usb-stub.c Loading commit data...
user-exec.c Loading commit data...
version.rc Loading commit data...
vgafont.h Loading commit data...
vl.c Loading commit data...
vmstate.h Loading commit data...
x86_64.ld Loading commit data...
xen-all.c Loading commit data...
xen-mapcache.c Loading commit data...
xen-mapcache.h Loading commit data...
xen-stub.c Loading commit data...
xtensa-semi.c Loading commit data...