aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMathieu Poirier <mathieu.poirier@linaro.org>2021-10-12 14:59:02 -0600
committerMichael S. Tsirkin <mst@redhat.com>2021-10-20 04:37:55 -0400
commit821d28b88f850e5fbc66ee62bdd155eb2d474a29 (patch)
tree05d9a58b5475b64acfc20c5d2cda7452660c99d3 /include
parent6889eb2d431ae962e3e083b57bff47cd573cb1c4 (diff)
downloadqemu-821d28b88f850e5fbc66ee62bdd155eb2d474a29.zip
qemu-821d28b88f850e5fbc66ee62bdd155eb2d474a29.tar.gz
qemu-821d28b88f850e5fbc66ee62bdd155eb2d474a29.tar.bz2
vhost-user-rng: Add vhost-user-rng implementation
Introduce a random number generator (RNG) backend that communicates with a vhost-user server to retrieve entropy. That way other VMM that comply with the vhost user protocl can use the same vhost-user daemon without having to write yet another RNG driver. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Message-Id: <20211012205904.4106769-2-mathieu.poirier@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/hw/virtio/vhost-user-rng.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/hw/virtio/vhost-user-rng.h b/include/hw/virtio/vhost-user-rng.h
new file mode 100644
index 0000000..0715399
--- /dev/null
+++ b/include/hw/virtio/vhost-user-rng.h
@@ -0,0 +1,33 @@
+/*
+ * Vhost-user RNG virtio device
+ *
+ * Copyright (c) 2021 Mathieu Poirier <mathieu.poirier@linaro.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef _QEMU_VHOST_USER_RNG_H
+#define _QEMU_VHOST_USER_RNG_H
+
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-user.h"
+#include "chardev/char-fe.h"
+
+#define TYPE_VHOST_USER_RNG "vhost-user-rng"
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG)
+
+struct VHostUserRNG {
+ /*< private >*/
+ VirtIODevice parent;
+ CharBackend chardev;
+ struct vhost_virtqueue *vhost_vq;
+ struct vhost_dev vhost_dev;
+ VhostUserState vhost_user;
+ VirtQueue *req_vq;
+ bool connected;
+
+ /*< public >*/
+};
+
+#endif /* _QEMU_VHOST_USER_RNG_H */