From patchwork Tue Feb 16 16:34:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 583538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3B5E41401DE for ; Wed, 17 Feb 2016 03:43:01 +1100 (AEDT) Received: from localhost ([::1]:47917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aViiJ-0000N7-9o for incoming@patchwork.ozlabs.org; Tue, 16 Feb 2016 11:42:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aViaW-00038H-A3 for qemu-devel@nongnu.org; Tue, 16 Feb 2016 11:34:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aViaV-00076t-Fy for qemu-devel@nongnu.org; Tue, 16 Feb 2016 11:34:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aViaV-00076h-3c for qemu-devel@nongnu.org; Tue, 16 Feb 2016 11:34:55 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id BFC628F269 for ; Tue, 16 Feb 2016 16:34:54 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1GGYlLZ023440; Tue, 16 Feb 2016 11:34:53 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 16 Feb 2016 17:34:22 +0100 Message-Id: <1455640486-6101-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1455640486-6101-1-git-send-email-pbonzini@redhat.com> References: <1455640486-6101-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/28] char: fix handling of QIO_CHANNEL_ERR_BLOCK X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Daniel P. Berrange" If io_channel_send_full gets QIO_CHANNEL_ERR_BLOCK it and has already sent some of the data, it should return that amount of data, not EAGAIN, as that would cause the caller to re-try already sent data. Unfortunately due to a previous rebase conflict resolution error, the code for dealing with this was in the wrong part of the conditional, and so mistakenly ran on other I/O errors. This be seen running qemu-system-x86_64 -monitor stdio and entering 'info mtree', when running on a slow console (eg a slow remote ssh session). The monitor would get into an indefinite loop writing the same data until it managed to send it all without getting EAGAIN. Reported-by: Igor Mammedov Signed-off-by: Daniel P. Berrange Message-Id: <1455288410-27046-1-git-send-email-berrange@redhat.com> Signed-off-by: Paolo Bonzini --- qemu-char.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 00caf65..ad11b75 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -896,13 +896,13 @@ static int io_channel_send_full(QIOChannel *ioc, ioc, &iov, 1, fds, nfds, NULL); if (ret == QIO_CHANNEL_ERR_BLOCK) { - errno = EAGAIN; - return -1; - } else if (ret < 0) { if (offset) { return offset; } + errno = EAGAIN; + return -1; + } else if (ret < 0) { errno = EINVAL; return -1; }