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>
This commit is contained in:
KONRAD Frederic 2013-04-24 10:07:55 +02:00 committed by Anthony Liguori
parent af1a8ad646
commit 6eac8aec02
4 changed files with 117 additions and 16 deletions

View file

@ -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