summaryrefslogtreecommitdiff
path: root/include/hw/virtio/virtio-rng.h
diff options
context:
space:
mode:
authorKONRAD Frederic <fred.konrad@greensocs.com>2013-04-24 10:07:55 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-04-24 11:50:19 -0500
commit6eac8aec02b1e9c5a626820bcca7654cb7d006a7 (patch)
tree77f3e6457170731433fcbe483f7c1f73e7206510 /include/hw/virtio/virtio-rng.h
parentaf1a8ad6467eb7056573bc3580d3d1824a05224a (diff)
downloadqemu-6eac8aec02b1e9c5a626820bcca7654cb7d006a7.tar.gz
qemu-6eac8aec02b1e9c5a626820bcca7654cb7d006a7.tar.bz2
qemu-6eac8aec02b1e9c5a626820bcca7654cb7d006a7.zip
virtio-rng: add virtio-rng device.
Create virtio-rng-device which extends virtio-device, so it can be connected on virtio-bus. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Amit Shah <amit.shah@redhat.com> Message-id: 1366790881-3026-3-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'include/hw/virtio/virtio-rng.h')
-rw-r--r--include/hw/virtio/virtio-rng.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h
index c578c00c1b..973d8095d3 100644
--- a/include/hw/virtio/virtio-rng.h
+++ b/include/hw/virtio/virtio-rng.h
@@ -15,6 +15,10 @@
#include "sysemu/rng.h"
#include "sysemu/rng-random.h"
+#define TYPE_VIRTIO_RNG "virtio-rng-device"
+#define VIRTIO_RNG(obj) \
+ OBJECT_CHECK(VirtIORNG, (obj), TYPE_VIRTIO_RNG)
+
/* The Virtio ID for the virtio rng device */
#define VIRTIO_ID_RNG 4
@@ -44,4 +48,14 @@ typedef struct VirtIORNG {
int64_t quota_remaining;
} VirtIORNG;
+/* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s. If
+ you have an entropy source capable of generating more entropy than this
+ and you can pass it through via virtio-rng, then hats off to you. Until
+ then, this is unlimited for all practical purposes.
+*/
+#define DEFINE_VIRTIO_RNG_PROPERTIES(_state, _conf_field) \
+ DEFINE_PROP_UINT64("max-bytes", _state, _conf_field.max_bytes, \
+ INT64_MAX), \
+ DEFINE_PROP_UINT32("period", _state, _conf_field.period_ms, 1 << 16)
+
#endif