Received: from eggs.gnu.org ([2001:4830:134:3::10]:33790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjRtD-00069O-Sz for qemu-devel@nongnu.org; Thu, 21 Nov 2013 05:53:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjRt7-0006e2-TE for qemu-devel@nongnu.org; Thu, 21 Nov 2013 05:53:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjRt7-0006ds-LS for qemu-devel@nongnu.org; Thu, 21 Nov 2013 05:53:33 -0500 From: Amos Kong Date: Thu, 21 Nov 2013 18:53:23 +0800 Message-Id: <1385031203-23790-1-git-send-email-akong@redhat.com> Subject: [Qemu-devel] [PATCH resend] virtio-rng: add check of period List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: anthony@codemonkey.ws If period is assigned to 0, limit timer will expire immediately. It causes a qemu warning: "main-loop: WARNING: I/O thread spun for 1000 iterations" This limit is meaningless. This patch forbids to assign 0 to period. Reviewed-by: Amit Shah Signed-off-by: Amos Kong --- hw/virtio/virtio-rng.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 314e393..b22ccf1 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -139,6 +139,12 @@ static int virtio_rng_device_init(VirtIODevice *vdev) VirtIORNG *vrng = VIRTIO_RNG(vdev); Error *local_err = NULL; + if (!vrng->conf.period_ms > 0) { + qerror_report(QERR_INVALID_PARAMETER_VALUE, "period", + "a positive number"); + return -1; + } + if (vrng->conf.rng == NULL) { vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM)); -- 1.8.3.1