summary refs log tree commit diff stats
path: root/hw/virtio/virtio-rng.c
diff options
context:
space:
mode:
authorAmos Kong <akong@redhat.com>2013-11-21 18:53:23 +0800
committerAnthony Liguori <aliguori@amazon.com>2013-11-21 07:55:26 -0800
commitd44bb8604e87ecd3823f12f0c92d5e56d613de0d (patch)
treef387c0a8005e623f2b262f53b2ba8f7d181d3a8a /hw/virtio/virtio-rng.c
parent376827d48922941d16ef9949672e86f820005d0a (diff)
downloadfocaccia-qemu-d44bb8604e87ecd3823f12f0c92d5e56d613de0d.tar.gz
focaccia-qemu-d44bb8604e87ecd3823f12f0c92d5e56d613de0d.zip
virtio-rng: add check of period
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>
Diffstat (limited to 'hw/virtio/virtio-rng.c')
-rw-r--r--hw/virtio/virtio-rng.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 314e393520..b22ccf1008 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));