From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGrL-0004Gp-7w for qemu-devel@nongnu.org; Tue, 06 Sep 2016 09:56:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhGrF-0006AV-I6 for qemu-devel@nongnu.org; Tue, 06 Sep 2016 09:56:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGrF-0006AO-CD for qemu-devel@nongnu.org; Tue, 06 Sep 2016 09:56:13 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5679C0567A0 for ; Tue, 6 Sep 2016 13:56:12 +0000 (UTC) From: "Daniel P. Berrange" Date: Tue, 6 Sep 2016 14:56:01 +0100 Message-Id: <1473170165-540-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH v2 0/4] Global fix / workaround usage of qemu_chr_fe_write List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Daniel P. Berrange" This series does a global fix and/or workaround for bad usage of qemu_chr_fe_write(). Essentially only about 4/5 places in the code got the usage correct, by handling errors. Everything else would silently loose data if used with a chardev backend that can return EAGAIN. One specific instance of that bug was highlighted when I fixed the socket backend, such that in connect mode, it would be non-blocking. https://bugs.launchpad.net/qemu/+bug/1586756 The "correct" fix is to check for short writes, or EAGAIN and then schedule an event callback to re-try the write later. A couple of places do that correctly (for example hw/char/serial.c and hw/char/virtioconsole.c). Changing existing serial port impls todo this though is a fair amount of amount, so as a temporary fix, this series changes all the broken code to simply use qemu_chr_fe_write_all() instead. Thus we at least stop silently loosing data, albeit at the cost of blocking the guest execution while we wait. So we still need to do a proper fix in all these devices models at some point, hence I've left comments in the code as a reminder. Changed in v2: - Dropped virtio-console patch which already merged in 2.7 Daniel P. Berrange (4): impi: check return of qemu_chr_fe_write() for errors sclpconsolelm: remove bogus check for -EAGAIN hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all char: convert qemu_chr_fe_write to qemu_chr_fe_write_all backends/rng-egd.c | 4 +++- gdbstub.c | 4 +++- hw/arm/omap2.c | 8 +++++--- hw/arm/pxa2xx.c | 4 +++- hw/arm/strongarm.c | 4 +++- hw/char/bcm2835_aux.c | 4 +++- hw/char/debugcon.c | 4 +++- hw/char/digic-uart.c | 2 ++ hw/char/escc.c | 4 +++- hw/char/etraxfs_ser.c | 4 +++- hw/char/exynos4210_uart.c | 4 +++- hw/char/grlib_apbuart.c | 4 +++- hw/char/imx_serial.c | 4 +++- hw/char/ipoctal232.c | 4 +++- hw/char/lm32_juart.c | 2 ++ hw/char/lm32_uart.c | 2 ++ hw/char/mcf_uart.c | 4 +++- hw/char/parallel.c | 4 +++- hw/char/pl011.c | 4 +++- hw/char/sclpconsole-lm.c | 22 ++++++---------------- hw/char/sclpconsole.c | 2 ++ hw/char/sh_serial.c | 4 +++- hw/char/spapr_vty.c | 5 +++-- hw/char/stm32f2xx_usart.c | 2 ++ hw/char/virtio-console.c | 21 +++++++++++++++++++++ hw/char/xilinx_uartlite.c | 4 +++- hw/ipmi/ipmi_bmc_extern.c | 8 ++++++-- hw/usb/ccid-card-passthru.c | 7 +++++-- hw/usb/dev-serial.c | 4 +++- qemu-char.c | 18 ++++++++++++------ slirp/slirp.c | 4 +++- 31 files changed, 125 insertions(+), 50 deletions(-) -- 2.7.4