]> git.proxmox.com Git - qemu.git/commitdiff
virtio-rng: add check of period
authorAmos Kong <akong@redhat.com>
Thu, 21 Nov 2013 10:53:23 +0000 (18:53 +0800)
committerAnthony Liguori <aliguori@amazon.com>
Thu, 21 Nov 2013 15:55:26 +0000 (07:55 -0800)
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 <amit.shah@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Message-id: 1385031203-23790-1-git-send-email-akong@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
hw/virtio/virtio-rng.c

index 314e39352022077e7243e9f1d44e8a2d3fdaa81f..b22ccf1008516001067876da68560a089ab714d0 100644 (file)
@@ -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));