qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-rng: ask for more data if queue is not fully drained
@ 2016-03-03  9:48 Ladi Prosek
  2016-03-03 12:08 ` Amit Shah
  0 siblings, 1 reply; 2+ messages in thread
From: Ladi Prosek @ 2016-03-03  9:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: amit.shah, pbonzini, mst, Ladi Prosek, pagupta

This commit effectively reverts:

  commit 4621c1768ef5d12171cca2aa1473595ecb9f1c9e
  Author: Amit Shah <amit.shah@redhat.com>
  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.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
---
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(+)

diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 17da2f8..d713464 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -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)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] virtio-rng: ask for more data if queue is not fully drained
  2016-03-03  9:48 [Qemu-devel] [PATCH] virtio-rng: ask for more data if queue is not fully drained Ladi Prosek
@ 2016-03-03 12:08 ` Amit Shah
  0 siblings, 0 replies; 2+ messages in thread
From: Amit Shah @ 2016-03-03 12:08 UTC (permalink / raw)
  To: Ladi Prosek; +Cc: pbonzini, mst, qemu-devel, pagupta

On (Thu) 03 Mar 2016 [10:48:34], Ladi Prosek wrote:
> This commit effectively reverts:
> 
>   commit 4621c1768ef5d12171cca2aa1473595ecb9f1c9e
>   Author: Amit Shah <amit.shah@redhat.com>
>   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.
> 
> Signed-off-by: Ladi Prosek <lprosek@redhat.com>

Reviewed-by: Amit Shah <amit.shah@redhat.com>

		Amit

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-03 12:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-03  9:48 [Qemu-devel] [PATCH] virtio-rng: ask for more data if queue is not fully drained Ladi Prosek
2016-03-03 12:08 ` Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).