summaryrefslogtreecommitdiffstats
path: root/qemu/include/sysemu/rng.h
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/include/sysemu/rng.h')
-rw-r--r--qemu/include/sysemu/rng.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/qemu/include/sysemu/rng.h b/qemu/include/sysemu/rng.h
index 0a27c9b88..45629c4c5 100644
--- a/qemu/include/sysemu/rng.h
+++ b/qemu/include/sysemu/rng.h
@@ -15,7 +15,6 @@
#include "qom/object.h"
#include "qemu-common.h"
-#include "qapi/error.h"
#define TYPE_RNG_BACKEND "rng-backend"
#define RNG_BACKEND(obj) \
@@ -25,6 +24,7 @@
#define RNG_BACKEND_CLASS(klass) \
OBJECT_CLASS_CHECK(RngBackendClass, (klass), TYPE_RNG_BACKEND)
+typedef struct RngRequest RngRequest;
typedef struct RngBackendClass RngBackendClass;
typedef struct RngBackend RngBackend;
@@ -32,13 +32,21 @@ typedef void (EntropyReceiveFunc)(void *opaque,
const void *data,
size_t size);
+struct RngRequest
+{
+ EntropyReceiveFunc *receive_entropy;
+ uint8_t *data;
+ void *opaque;
+ size_t offset;
+ size_t size;
+ QSIMPLEQ_ENTRY(RngRequest) next;
+};
+
struct RngBackendClass
{
ObjectClass parent_class;
- void (*request_entropy)(RngBackend *s, size_t size,
- EntropyReceiveFunc *receive_entropy, void *opaque);
- void (*cancel_requests)(RngBackend *s);
+ void (*request_entropy)(RngBackend *s, RngRequest *req);
void (*opened)(RngBackend *s, Error **errp);
};
@@ -49,8 +57,10 @@ struct RngBackend
/*< protected >*/
bool opened;
+ QSIMPLEQ_HEAD(requests, RngRequest) requests;
};
+
/**
* rng_backend_request_entropy:
* @s: the backend to request entropy from
@@ -71,12 +81,13 @@ void rng_backend_request_entropy(RngBackend *s, size_t size,
void *opaque);
/**
- * rng_backend_cancel_requests:
- * @s: the backend to cancel all pending requests in
+ * rng_backend_free_request:
+ * @s: the backend that created the request
+ * @req: the request to finalize
*
- * Cancels all pending requests submitted by @rng_backend_request_entropy. This
- * should be used by a device during reset or in preparation for live migration
- * to stop tracking any request.
+ * Used by child rng backend classes to finalize requests once they've been
+ * processed. The request is removed from the list of active requests and
+ * deleted.
*/
-void rng_backend_cancel_requests(RngBackend *s);
+void rng_backend_finalize_request(RngBackend *s, RngRequest *req);
#endif