From 6eac8aec02b1e9c5a626820bcca7654cb7d006a7 Mon Sep 17 00:00:00 2001 From: KONRAD Frederic Date: Wed, 24 Apr 2013 10:07:55 +0200 Subject: 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 Tested-by: Cornelia Huck Acked-by: Amit Shah Message-id: 1366790881-3026-3-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori --- include/hw/virtio/virtio-rng.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h index c578c00..973d809 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 -- cgit v1.1