Skip to contentSkip to conversation

virtio-rng: ask for more data if queue is not fully drained

PATCH In review Ladi Prosek 2 participants 2 messages Mar 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-rng: ask for more data if queue is not fully drained

This commit effectively reverts:

commit 4621c1768ef5d12171cca2aa1473595ecb9f1c9e
Author: Amit Shah <[email protected]>
Date: Wed Nov 21 11:21:19 2012 +0530

virtio-rng: remove extra request for entropy

but instead of calling virtio_rng_process unconditionally, it first checks to see if the queue is empty as a little bit of optimization.

---
This commit has a logical dependency on

[PATCH v3 0/4] rng-random: implement request queue

which removes a synchronous invocation of the receive_func callback in rng_random_request_entropy, thereby eliminating the risk of infinite recursion.

 hw/virtio/virtio-rng.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/virtio/virtio-rng.c +7 -0
index 17da2f8..d713464 100644
@@ -69,6 +69,13 @@ static void chr_read(void *opaque, const void *buf, size_t size)
         g_free(elem);
     }
     virtio_notify(vdev, vrng->vq);
+
+    if (!virtio_queue_empty(vrng->vq)) {
+        /* If we didn't drain the queue, call virtio_rng_process
+         * to take care of asking for more data as appropriate.
+         */
+        virtio_rng_process(vrng);
+    }
 }
 
 static void virtio_rng_process(VirtIORNG *vrng)
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ladi Prosek

This commit effectively reverts:

commit 4621c1768ef5d12171cca2aa1473595ecb9f1c9e
Author: Amit Shah <[email protected]>
Date: Wed Nov 21 11:21:19 2012 +0530

Quoted 7 lines

virtio-rng: remove extra request for entropy

but instead of calling virtio_rng_process unconditionally, it first checks to see if the queue is empty as a little bit of optimization.

Amit