diff options
author | Ladi Prosek <lprosek@redhat.com> | 2016-03-03 14:16:11 +0100 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2016-03-08 12:54:14 +0530 |
commit | 443590c2044968a97f5e7cddd35100c6075856a4 (patch) | |
tree | 55fffa1528d3d3e52f9d2f64afb750d380927910 /backends/rng-egd.c | |
parent | 97556fe80e4f7252300b3498b3477fb4295153a3 (diff) | |
download | qemu-443590c2044968a97f5e7cddd35100c6075856a4.zip qemu-443590c2044968a97f5e7cddd35100c6075856a4.tar.gz qemu-443590c2044968a97f5e7cddd35100c6075856a4.tar.bz2 |
rng: switch request queue to QSIMPLEQ
QSIMPLEQ supports appending to tail in O(1) and is intrusive so
it doesn't require extra memory allocations for the bookkeeping
data.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Message-Id: <1457010971-24771-1-git-send-email-lprosek@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'backends/rng-egd.c')
-rw-r--r-- | backends/rng-egd.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/backends/rng-egd.c b/backends/rng-egd.c index 30332ed..6e0ba22 100644 --- a/backends/rng-egd.c +++ b/backends/rng-egd.c @@ -49,11 +49,10 @@ static void rng_egd_request_entropy(RngBackend *b, RngRequest *req) static int rng_egd_chr_can_read(void *opaque) { RngEgd *s = RNG_EGD(opaque); - GSList *i; + RngRequest *req; int size = 0; - for (i = s->parent.requests; i; i = i->next) { - RngRequest *req = i->data; + QSIMPLEQ_FOREACH(req, &s->parent.requests, next) { size += req->size - req->offset; } @@ -65,8 +64,8 @@ static void rng_egd_chr_read(void *opaque, const uint8_t *buf, int size) RngEgd *s = RNG_EGD(opaque); size_t buf_offset = 0; - while (size > 0 && s->parent.requests) { - RngRequest *req = s->parent.requests->data; + while (size > 0 && !QSIMPLEQ_EMPTY(&s->parent.requests)) { + RngRequest *req = QSIMPLEQ_FIRST(&s->parent.requests); int len = MIN(size, req->size - req->offset); memcpy(req->data + req->offset, buf + buf_offset, len); |