From patchwork Fri Feb 12 14:46:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 8292481 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2D8D49F6E4 for ; Fri, 12 Feb 2016 14:48:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A43CD203AC for ; Fri, 12 Feb 2016 14:48:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75280203EB for ; Fri, 12 Feb 2016 14:48:19 +0000 (UTC) Received: from localhost ([::1]:33272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUF18-0007a2-TN for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Feb 2016 09:48:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUEzu-0005W0-8g for qemu-devel@nongnu.org; Fri, 12 Feb 2016 09:47:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUEzp-0005KG-5r for qemu-devel@nongnu.org; Fri, 12 Feb 2016 09:47:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUEzp-0005KC-1R; Fri, 12 Feb 2016 09:46:57 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A04C28E697; Fri, 12 Feb 2016 14:46:56 +0000 (UTC) Received: from t530wlan.home.berrange.com.com (dhcp-1-180.lcy.redhat.com [10.32.224.180]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1CEktAY023705; Fri, 12 Feb 2016 09:46:55 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Fri, 12 Feb 2016 14:46:50 +0000 Message-Id: <1455288410-27046-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-trivial@nongnu.org, Paolo Bonzini , Igor Mammedov Subject: [Qemu-devel] [PATCH] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- qemu-char.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 1b7d5da..c2e24a5 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; }