summaryrefslogtreecommitdiff
path: root/qemu-char.c
AgeCommit message (Collapse)AuthorFilesLines
2013-01-28Merge remote-tracking branch 'luiz/queue/qmp' into stagingAnthony Liguori1-0/+203
# By Lei Li (3) and others # Via Luiz Capitulino * luiz/queue/qmp: QAPI: Introduce memchar-read QMP command QAPI: Introduce memchar-write QMP command qemu-char: Add new char backend CirMemCharDriver docs: document virtio-balloon stats balloon: re-enable balloon stats balloon: drop old stats code & API block: Monitor command commit neglects to report some errors
2013-01-26qemu-char: Avoid unused variable warning in some configsPeter Maydell1-2/+6
Avoid unused variable warnings: qemu-char.c: In function 'qmp_chardev_open_port': qemu-char.c:3132: warning: unused variable 'fd' qemu-char.c:3132: warning: unused variable 'flags' in configurations with neither HAVE_CHARDEV_TTY nor HAVE_CHARDEV_PARPORT set. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-25QAPI: Introduce memchar-read QMP commandLei Li1-0/+47
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-25QAPI: Introduce memchar-write QMP commandLei Li1-0/+42
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-25qemu-char: Add new char backend CirMemCharDriverLei Li1-0/+114
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-16chardev: add pty chardev support to chardev-add (qmp)Gerd Hoffmann1-0/+13
The ptsname is returned directly, so there is no need to use query-chardev to figure the pty device path. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add socket chardev support to chardev-add (qmp)Gerd Hoffmann1-53/+113
qemu_chr_open_socket is split into two functions. All initialization after creating the socket file handler is split away into the new qemu_chr_open_socket_fd function. chr->filename doesn't get filled from QemuOpts any more. Qemu gathers the information using getsockname and getnameinfo instead. This way it will also work correctly for file handles passed via file descriptor passing. Finally qmp_chardev_open_socket() is the actual qmp hotplug implementation which basically just calls socket_listen or socket_connect and the new qemu_chr_open_socket_fd function. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add parallel chardev support to chardev-add (qmp)Gerd Hoffmann1-16/+28
Also alias the old parport name to parallel for -chardev. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add serial chardev support to chardev-add (qmp)Gerd Hoffmann1-8/+54
Similar to file, except that no separate in/out files are supported because it's pointless for direct device access. Also the special tty ioctl hooks (pass through linespeed settings etc) are activated on Unix. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add file chardev support to chardev-add (qmp)Gerd Hoffmann1-0/+61
Add support for file chardevs. Output file is mandatory, input file is optional. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add qmp hotplug commands, with null chardev supportGerd Hoffmann1-0/+53
Add chardev-add and chardev-remove qmp commands. Hotplugging a null chardev is supported for now, more will be added later. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: reduce chardev ifdef mess a bitGerd Hoffmann1-11/+11
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: fix QemuOpts lifecycleGerd Hoffmann1-6/+14
qemu_chr_new_from_opts handles QemuOpts release now, so callers don't have to worry. It will either be saved in CharDriverState, then released in qemu_chr_delete, or in the error case released instantly. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-16chardev: add error reporting for qemu_chr_new_from_optsGerd Hoffmann1-9/+15
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-12qemu-option: move standard option definitions out of qemu-config.cPaolo Bonzini1-0/+72
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-01-03pty: unbreak libvirtGerd Hoffmann1-4/+5
Commit 586502189edf9fd0f89a83de96717a2ea826fdb0 breaks libvirt pty support because it tried to figure the pts name from stderr output. Fix this by moving the label to the end of the line, this way the libvirt parser does still recognise the message. libvirt looks for "char device redirected to ${ptsname}<whitespace>". Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-02disallow -daemonize usage of stdio (curses display, -nographic, -serial ↵Michael Tokarev1-0/+4
stdio etc) Curses display requires stdin/out to stay on the terminal, so -daemonize makes no sense in this case. Instead of leaving display uninitialized like is done since 995ee2bf469de6bb, explicitly detect this case earlier and error out. -nographic can actually be used with -daemonize, by redirecting everything to a null device, but the problem is that according to documentation and historical behavour, -nographic redirects guest ports to stdin/out, which, again, makes no sense in case of -daemonize. Since -nographic is a legacy option, don't bother fixing this case (to allow -nographic and -daemonize by redirecting guest ports to null instead of stdin/out in this case), but disallow it completely instead, to stop garbling host terminal. If no display display needed and user wants to use -nographic, the right way to go is to use -serial null -parallel null -monitor none -display none -vga none instead of -nographic. Also prevent the same issue -- it was possible to get garbled host tty after -nographic -daemonize and it is still possible to have it by using -serial stdio -daemonize Fix this by disallowing opening stdio chardev when -daemonize is specified. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-23qemu-char: Inherit ptys and improve output from -serial ptyLei Li1-1/+7
Changes since V1: - Avoid crashing since qemu_opts_id() may return null on some systems according to Markus's suggestion. When controlling a qemu instance from another program, it's hard to know which serial port or monitor device is redirected to which pty. With more than one device using "pty" a lot of guesswork is involved. $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device redirected to /dev/pts/5 char device redirected to /dev/pts/6 char device redirected to /dev/pts/7 Although we can find out what everything else is connected to by the "info chardev" with "-monitor stdio" in the command line, It'd be very useful to be able to have qemu inherit pseudo-tty file descriptors so they could just be specified on the command line like: $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device compat_monitor0 redirected to /dev/pts/5 char device serial0 redirected to /dev/pts/6 char device serial1 redirected to /dev/pts/7 Referred link: https://bugs.launchpad.net/qemu/+bug/938552 Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-19Merge remote-tracking branch 'bonzini/header-dirs' into stagingAnthony Liguori1-7/+6
* bonzini/header-dirs: (45 commits) janitor: move remaining public headers to include/ hw: move executable format header files to hw/ fpu: move public header file to include/fpu softmmu: move remaining include files to include/ subdirectories softmmu: move include files to include/sysemu/ misc: move include files to include/qemu/ qom: move include files to include/qom/ migration: move include files to include/migration/ monitor: move include files to include/monitor/ exec: move include files to include/exec/ block: move include files to include/block/ qapi: move include files to include/qobject/ janitor: add guards to headers qapi: make struct Visitor opaque qapi: remove qapi/qapi-types-core.h qapi: move inclusions of qemu-common.h from headers to .c files ui: move files to ui/ and include/ui/ qemu-ga: move qemu-ga files to qga/ net: reorganize headers net: move net.c to net/ ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-19softmmu: move remaining include files to include/ subdirectoriesPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19monitor: move include files to include/monitor/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19ui: move files to ui/ and include/ui/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19net: do not include net.h everywherePaolo Bonzini1-1/+0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-17spice-qemu-char: add spiceport chardevMarc-André Lureau1-0/+3
Add a new spice chardev to allow arbitrary communication between the host and the Spice client via the spice server. Examples: This allows the Spice client to have a special port for the qemu monitor: ... -chardev spiceport,name=org.qemu.monitor,id=monitorport -mon chardev=monitorport v2: - remove support for chardev to chardev linking - conditionnaly compile with SPICE_SERVER_VERSION Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-24chardev: Use real-time clock for open timerJan Kiszka1-2/+2
The vm clock may be stopped, and then we won't get open events anymore. Seen with QMP sessions. Reported-by: Dietmar Maurer <dietmar@proxmox.com> Tested-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-10-31chardev: Use timer instead of bottom-half to postpone open eventJan Kiszka1-6/+7
As the block layer may decide to flush bottom-halfs while the machine is still initializing (e.g. to read geometry data from the disk), our postponed open event may be processed before the last frontend registered with a muxed chardev. Until the semantics of BHs have been clarified, use an expired timer to achieve the same effect (suggested by Paolo Bonzini). This requires to perform the alarm timer initialization earlier as otherwise timer subsystem can be used before being ready. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-10-23qemu-sockets: add error propagation to inet_dgram_optsPaolo Bonzini1-1/+0
Before: $ qemu-system-x86_64 -monitor udp:localhost:631@localhost:631 inet_dgram_opts: bind(ipv4,127.0.0.1,631): OK inet_dgram_opts failed chardev: opening backend "udp" failed After: $ x86_64-softmmu/qemu-system-x86_64 -monitor udp:localhost:631@localhost:631 qemu-system-x86_64: -monitor udp:localhost:631@localhost:631: Failed to bind socket: Address already in use chardev: opening backend "udp" failed Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-23qemu-char: ask and print error information from qemu-socketsPaolo Bonzini1-6/+17
Before: $ qemu-system-x86_64 -monitor tcp:localhost:6000 (starts despite error) $ qemu-system-x86_64 -monitor tcp:foo.bar:12345 getaddrinfo(foo.bar,12345): Name or service not known chardev: opening backend "socket" failed $ qemu-system-x86_64 -monitor tcp:localhost:443,server=on inet_listen_opts: bind(ipv4,127.0.0.1,443): Permission denied inet_listen_opts: FAILED chardev: opening backend "socket" failed After: $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:localhost:6000 x86_64-softmmu/qemu-system-x86_64: -monitor tcp:localhost:6000: Failed to connect to socket: Connection refused chardev: opening backend "socket" failed $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:foo.bar:12345 qemu-system-x86_64: -monitor tcp:foo.bar:12345: address resolution failed for foo.bar:12345: Name or service not known chardev: opening backend "socket" failed $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:localhost:443,server=on qemu-system-x86_64: -monitor tcp:localhost:443,server=on: Failed to bind socket: Permission denied chardev: opening backend "socket" failed Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-23qemu-sockets: add nonblocking connect for Unix socketsPaolo Bonzini1-1/+1
This patch mostly mimics what was done to TCP sockets, but simpler because there is only one address to try. It also includes a free EINTR bug fix. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-23qemu-sockets: add Error ** to all functionsPaolo Bonzini1-3/+3
This lets me adjust the clients to do proper error propagation first, thus avoiding temporary regressions in the quality of the error messages. Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-09-25Fix address handling in inet_nonblocking_connectOrit Wasserman1-1/+1
getaddrinfo can give us a list of addresses, but we only try to connect to the first one. If that fails we never proceed to the next one. This is common on desktop setups that often have ipv6 configured but not actually working. To fix this make inet_connect_nonblocking retry connection with a different address. callers on inet_nonblocking_connect register a callback function that will be called when connect opertion completes, in case of failure the fd will have a negative value Signed-off-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-25Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connectOrit Wasserman1-1/+1
No need to add non blocking parameters to the blocking inet_connect add block parameter for inet_connect_opts instead of using QemuOpt "block". Signed-off-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-17qemu-char: BUGFIX, don't call FD_ISSET with negative fdDavid Gibson1-2/+4
tcp_chr_connect(), unlike for example udp_chr_update_read_handler() does not check if the fd it is using is valid (>= 0) before passing it to qemu_set_fd_handler2(). If using e.g. a TCP serial port, which is not initially connected, this can result in -1 being passed to FD_ISSET, which has undefined behaviour. On x86 it seems to harmlessly return 0, but on PowerPC, it causes a fortify buffer overflow error to be thrown. This patch fixes this by putting an extra test in tcp_chr_connect(), and also adds an assert qemu_set_fd_handler2() to catch other such errors on all platforms, rather than just some. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-17Revert 455aa1e08 and c3767ed0ebAnthony Liguori1-6/+1
commit c3767ed0eb5d0bb25fe409ae5dec06e3411ff1b6 qemu-char: (Re-)connect for tcp_chr_write() unconnected writing Has no hope of working because tcp_chr_connect() does not actually connect. 455aa1e08 just fixes the SEGV with server() but the attempt to connect a client socket is still completely broken. This patch reverts both. Reported-by: Richard W.M. Jones <rjones@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10socket: don't attempt to reconnect a TCP socket in server modeAnthony Liguori1-1/+3
Commit c3767ed0eb5d0bb25fe409ae5dec06e3411ff1b6 introduced a possible SEGV when using a socket chardev with server=on because it assumes that all TCP sockets are in client mode. This patch adds a check to only reconnect when in client mode. Cc: Lei Li <lilei@linux.vnet.ibm.com> Reported-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-16qemu-char: (Re-)connect for tcp_chr_write() unconnected writingLei Li1-2/+5
tcp_chr_write() did not deal with writing to an unconnected connection and return the original length of the data, it's not right and would cause false writing. So (re-)connect it and return 0 for this situation. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-15qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsgCorey Bryant1-2/+10
Set the close-on-exec flag for the file descriptor received via SCM_RIGHTS. Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-08-13net: inet_connect(), inet_connect_opts(): add in_progress argumentLuiz Capitulino1-1/+1
It's used to indicate the special case where a valid file-descriptor is returned (ie. success) but the connection can't be completed w/o blocking. This is needed because QERR_SOCKET_CONNECT_IN_PROGRESS is not treated like an error and a future commit will drop it. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-06-09do not include <libutil.h> needlessly or if it doesn't existMichael Tokarev1-7/+7
<libutil.h> and <util.h> on *BSD (some have one, some another) were #included just for openpty() declaration. The only file where this function is actually used is qemu-char.c. In vl.c and net/tap-bsd.c, none of functions declared in libutil.h (login logout logwtmp timdomain openpty forkpty uu_lock realhostname fparseln and a few others depending on version) are used. Initially the code which is currently in qemu-char.c was in vl.c, it has been removed into separate file in commit 0e82f34d077dc2542 Fri Oct 31 18:44:40 2008, but the #includes were left in vl.c. So with vl.c, we just remove includes - libutil.h, util.h and pty.h (which declares only openpty() and forkpty()) from there. The code in net/tap-bsd.c, which come from net/tap.c, had this commit 5281d757efa6e40d74ce124be048b08d43887555 Author: Mark McLoughlin <markmc@redhat.com> Date: Thu Oct 22 17:49:07 2009 +0100 net: split all the tap code out into net/tap.c Note this commit not only moved stuff out of net.c to net/tap.c, but also rewrote large portions of the tap code, and added these completely unnecessary #includes -- as usual, I question why such a misleading commit messages are allowed. Again, no functions defined in libutil.h or util.h on *BSD are used by neither net/tap.c nor net/tap-bsd.c. Removing them. And finally, the only real user for these #includes, qemu-char.c, which actually uses openpty(). There, the #ifdef logic is wrong. A GLIBC-based system has <pty.h>, even if it is a variant of *BSD. So __GLIBC__ should be checked first, and instead of trying to include <libutil.h> or <util.h>, we include <pty.h>. If it is not GLIBC-based, we check for variations between <*util.h> as before. This patch fixes build of qemu 1.1 on Debian/kFreebsd (well, one of the two problems): it is a distribution with a FreeBSD kernel, so it #defines at least __FreeBSD_kernel__, but since it is based on GLIBC, it has <pty.h>, but current version does not have neither <util.h> nor <libutil.h>, which the code tries to include 3 times but uses only once. Signed-off-By: Michael Tokarev <mjt@tls.msk.ru> Cc: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-06-04qemu-option: qemu_opts_create(): use error_set()Luiz Capitulino1-2/+6
This commit converts qemu_opts_create() from qerror_report() to error_set(). Currently, most calls to qemu_opts_create() can't fail, so most callers don't need any changes. The two cases where code checks for qemu_opts_create() erros are: 1. Initialization code in vl.c. All of them print their own error messages directly to stderr, no need to pass the Error object 2. The functions opts_parse(), qemu_opts_from_qdict() and qemu_chr_parse_compat() make use of the error information and they can be called from HMP or QMP. In this case, to allow for incremental conversion, we propagate the error up using qerror_report_err(), which keeps the QError semantics Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-By: Laszlo Ersek <lersek@redhat.com>
2012-05-10sockets: use error class to pass listen errorAmos Kong1-1/+1
Add a new argument in inet_listen()/inet_listen_opts() to pass back listen error. Change nbd, qemu-char, vnc to use new interface. Signed-off-by: Amos Kong <akong@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-05-10sockets: change inet_connect() to support nonblock socketAmos Kong1-1/+1
Add a bool argument to inet_connect() to assign if set socket to block/nonblock, and delete original argument 'socktype' that is unused. Add a new argument to inet_connect()/inet_connect_opts(), to pass back connect error by error class. Retry to connect when -EINTR is got. Connect's successful for nonblock socket when following errors are got, user should wait for connecting by select(): -EINPROGRESS -EWOULDBLOCK (win32) -WSAEALREADY (win32) Change nbd, vnc to use new interface. Signed-off-by: Amos Kong <akong@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-04-24qemu-char: Fix crash when switching consolesStefan Weil1-1/+3
qemu-system-arm (and other system emulations) crashes with SDL when the user switches consoles (Alt-Ctrl-F4). We already check for NULL pointers in qemu_chr_fe_ioctl, qemu_chr_be_can_write and other functions, so do this also for s->chr_read in qemu_chr_be_write. This fixes the crash. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-04-16Kick io-thread on qemu_chr_accept_inputJan Kiszka1-0/+1
Once a chr frontend is able to receive input again, we need to inform the io-thread about this fact. Otherwise, main_loop_wait may continue to select without the related backend file descriptor in its set. This can cause high input latencies if only low-rate events arrive otherwise. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-02-24qemu-char: qemu_chr_open_fd() can't fail, don't checkMarkus Armbruster1-4/+0
Cleaned up silently in commit aad04cd0, but that just got reverted. Re-apply this part. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-24qemu-char: Re-apply style fixes from just reverted aad04cd0Markus Armbruster1-7/+14
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-24qemu-char: Use qemu_open() to avoid leaking fds to childrenMarkus Armbruster1-4/+4
Fixed silently in commit aad04cd0, but that just got reverted. Re-apply the fixes, plus one missed instance: parport on Linux. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-24Revert "qemu-char: Print strerror message on failure" and depsMarkus Armbruster1-101/+68
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 6e1db57b2ac9025c2443c665a0d9e78748637b26. Conflicts: console.c hw/baum.c qemu-char.c This reverts commit aad04cd024f0c59f0b96f032cde2e24eb3abba6d. The parts of commit db418a0a "Add stdio char device on windows" that depend on the reverted change fixed up. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>