From patchwork Mon Apr 1 09:25:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 232689 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 167492C00E1 for ; Mon, 1 Apr 2013 20:25:50 +1100 (EST) Received: from localhost ([::1]:50177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMazr-0007mi-Ob for incoming@patchwork.ozlabs.org; Mon, 01 Apr 2013 05:25:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMazZ-0007mc-3R for qemu-devel@nongnu.org; Mon, 01 Apr 2013 05:25:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMazX-0006Uh-EL for qemu-devel@nongnu.org; Mon, 01 Apr 2013 05:25:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMazX-0006Ub-6F for qemu-devel@nongnu.org; Mon, 01 Apr 2013 05:25:27 -0400 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 (8.14.4/8.14.4) with ESMTP id r319PPKk030820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 1 Apr 2013 05:25:25 -0400 Received: from localhost (dhcp193-82.pnq.redhat.com [10.65.193.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r319PM6s003064; Mon, 1 Apr 2013 05:25:23 -0400 From: Amit Shah To: Anthony Liguori Date: Mon, 1 Apr 2013 14:55:12 +0530 Message-Id: <74d06e1f94cc2337aa1bb6784a7ad2210ec55364.1364808312.git.amit.shah@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: Amit Shah , qemu list Subject: [Qemu-devel] [PATCH 1/1] rng backend: open backend in blocking mode 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 Opening backends in non-blocking mode isn't necessary, we don't do anything while waiting for data. This also excuses us from checking for EAGAIN, which for the default random backend, is a very common return error type. Starting the guest with '-device virtio-rng-pci', issuing a 'cat /dev/hwrng' in the guest while also doing 'cat /dev/random' on the host causes backends/rng-random.c:44:entropy_available: assertion failed: (len != -1) without this fix. Reported-by: yunpingzheng Signed-off-by: Amit Shah --- backends/rng-random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/rng-random.c b/backends/rng-random.c index acd20af..252139b 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -74,7 +74,7 @@ static void rng_random_opened(RngBackend *b, Error **errp) error_set(errp, QERR_INVALID_PARAMETER_VALUE, "filename", "a valid filename"); } else { - s->fd = qemu_open(s->filename, O_RDONLY | O_NONBLOCK); + s->fd = qemu_open(s->filename, O_RDONLY); if (s->fd == -1) { error_set(errp, QERR_OPEN_FILE_FAILED, s->filename);