From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkaND-0004v6-10 for qemu-devel@nongnu.org; Mon, 17 Dec 2012 08:04:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkaN8-0004EA-EJ for qemu-devel@nongnu.org; Mon, 17 Dec 2012 08:04:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkaN8-0004Dk-6Q for qemu-devel@nongnu.org; Mon, 17 Dec 2012 08:04:42 -0500 From: Gerd Hoffmann Date: Mon, 17 Dec 2012 14:04:34 +0100 Message-Id: <1355749479-25470-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1355749479-25470-1-git-send-email-kraxel@redhat.com> References: <1355749479-25470-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 3/8] spice-qemu-char: write to chardev whatever amount it can read List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann From: Marc-Andr=C3=A9 Lureau The current code waits until the chardev can read MIN(len, VMC_MAX) But some chardev may never reach than amount, in fact some of them will only ever accept write of 1. Fix the min computation and remove the VMC_MAX constant. Signed-off-by: Gerd Hoffmann --- spice-qemu-char.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 09aa22d..665efd3 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -14,8 +14,6 @@ } = \ } while (0) =20 -#define VMC_MAX_HOST_WRITE 2048 - typedef struct SpiceCharDriver { CharDriverState* chr; SpiceCharDeviceInstance sin; @@ -35,8 +33,8 @@ static int vmc_write(SpiceCharDeviceInstance *sin, cons= t uint8_t *buf, int len) uint8_t* p =3D (uint8_t*)buf; =20 while (len > 0) { - last_out =3D MIN(len, VMC_MAX_HOST_WRITE); - if (qemu_chr_be_can_write(scd->chr) < last_out) { + last_out =3D MIN(len, qemu_chr_be_can_write(scd->chr)); + if (last_out <=3D 0) { break; } qemu_chr_be_write(scd->chr, p, last_out); --=20 1.7.1