]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
rng random backend: check for -EAGAIN errors on read
authorAmit Shah <amit.shah@redhat.com>
Tue, 16 Apr 2013 10:28:16 +0000 (15:58 +0530)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 16 Apr 2013 21:10:21 +0000 (16:10 -0500)
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.

Reported-by: yunpingzheng <yunzheng@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Message-id: eacda84dfaf2d99cf6d250b678be4e4d6c2088fb.1366108096.git.amit.shah@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
backends/rng-random.c

index d5761f2ccea7a436b6b6b8dea864d66d0a644ad6..830360c7808ee29dc46a03423b5bca3599e0efe1 100644 (file)
@@ -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);