Skip to contentSkip to conversation

rng random backend: check for -EAGAIN errors on read

PATCH Applied Amit Shah 3 participants 4 messages Apr 16, 2013 – Apr 22, 2013

lore
Share & tools
lore

Amit Shah

author
#0 lore raw

PATCH 1/1 rng random backend: check for -EAGAIN errors on read

Not handling EAGAIN triggers the assert

qemu/backends/rng-random.c:44:entropy_available: assertion failed: (len != -1) Aborted (core dumped)

This happens when starting a guest with '-device virtio-rng-pci', issuing a 'cat /dev/hwrng' in the guest, while also doing 'cat /dev/random' on the host.

---
 backends/rng-random.c | 3 +++
 1 file changed, 3 insertions(+)
backends/rng-random.c +3 -0
index d5761f2..830360c 100644
@@ -41,6 +41,9 @@ static void entropy_available(void *opaque)
     ssize_t len;
 
     len = read(s->fd, buffer, s->size);
+    if (len < 0 && errno == EAGAIN) {
+        return;
+    }
     g_assert(len != -1);
 
     s->receive_func(s->opaque, buffer, len);
Signature · 1 line
1.8.1.4
#1 lore raw

Am 16.04.2013 12:28, schrieb Amit Shah:

Quoted 11 lines

Not handling EAGAIN triggers the assert

qemu/backends/rng-random.c:44:entropy_available: assertion failed: (len != -1) Aborted (core dumped)

This happens when starting a guest with '-device virtio-rng-pci', issuing a 'cat /dev/hwrng' in the guest, while also doing 'cat /dev/random' on the host.

Doesn't this apply to stable, too, then?

Regards,
Andreas

Quoted 18 lines
---
 backends/rng-random.c | 3 +++
 1 file changed, 3 insertions(+)
backends/rng-random.c +3 -0
index d5761f2..830360c 100644
@@ -41,6 +41,9 @@ static void entropy_available(void *opaque)
     ssize_t len;
 
     len = read(s->fd, buffer, s->size);
+    if (len < 0 && errno == EAGAIN) {
+        return;
+    }
     g_assert(len != -1);
 
     s->receive_func(s->opaque, buffer, len);
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
author
#2 lore raw
Quoted 6 lines · Andreas Färber

Am 16.04.2013 12:28, schrieb Amit Shah:

Quoted 5 lines

Not handling EAGAIN triggers the assert

qemu/backends/rng-random.c:44:entropy_available: assertion failed: (len != -1) Aborted (core dumped)

Quoted 8 lines
Quoted 6 lines

This happens when starting a guest with '-device virtio-rng-pci', issuing a 'cat /dev/hwrng' in the guest, while also doing 'cat /dev/random' on the host.

Doesn't this apply to stable, too, then?

Ah, good point, it does.

Thanks for CC'ing stable.

Amit