From patchwork Tue Apr 16 10:28:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 236920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0013E2C0114 for ; Tue, 16 Apr 2013 20:28:47 +1000 (EST) Received: from localhost ([::1]:35528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US382-0000Q4-7i for incoming@patchwork.ozlabs.org; Tue, 16 Apr 2013 06:28:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US37n-0000PS-5q for qemu-devel@nongnu.org; Tue, 16 Apr 2013 06:28:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1US37i-0000am-GU for qemu-devel@nongnu.org; Tue, 16 Apr 2013 06:28:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US37i-0000ac-9S for qemu-devel@nongnu.org; Tue, 16 Apr 2013 06:28:26 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3GASObX017625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 16 Apr 2013 06:28:24 -0400 Received: from localhost (dhcp193-82.pnq.redhat.com [10.65.193.82]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3GASMWC007432; Tue, 16 Apr 2013 06:28:23 -0400 From: Amit Shah To: Anthony Liguori Date: Tue, 16 Apr 2013 15:58:16 +0530 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , qemu list Subject: [Qemu-devel] [PATCH 1/1] rng random backend: check for -EAGAIN errors on read 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 Not handling EAGAIN triggers the assert qemu/backends/rng-random.c:44:entropy_available: assertion failed: (len != -1) Aborted (core dumped) This happens when starting a guest with '-device virtio-rng-pci', issuing a 'cat /dev/hwrng' in the guest, while also doing 'cat /dev/random' on the host. Reported-by: yunpingzheng Signed-off-by: Amit Shah --- backends/rng-random.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backends/rng-random.c b/backends/rng-random.c index d5761f2..830360c 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -41,6 +41,9 @@ static void entropy_available(void *opaque) ssize_t len; len = read(s->fd, buffer, s->size); + if (len < 0 && errno == EAGAIN) { + return; + } g_assert(len != -1); s->receive_func(s->opaque, buffer, len);