@@ -67,7 +67,7 @@ struct qemu_laio_state {
/* I/O completion processing */
QEMUBH *completion_bh;
- struct io_event events[MAX_EVENTS];
+ struct io_event *events;
int event_idx;
int event_max;
@@ -409,6 +409,7 @@ static struct qemu_laio_state *laio_state_alloc(AioContext *context)
goto out_close_efd;
}
+ s->events = g_malloc(sizeof(*s->events) * MAX_EVENTS);
s->io_q = laio_alloc_ioq(context, s);
s->completion_bh = aio_bh_new(context, qemu_laio_completion_bh, s);
aio_set_event_notifier(context, &s->e, qemu_laio_completion_cb);
@@ -429,6 +430,7 @@ static void laio_state_free(struct qemu_laio_state *s, AioContext *context)
laio_free_ioq(s, s->io_q);
event_notifier_cleanup(&s->e);
+ g_free(s->events);
if (io_destroy(s->ctx) != 0) {
fprintf(stderr, "%s: destroy AIO context %p failed\n",
This patch allocates events array of 'struct qemu_laio_state' dynamically so that in the following patch we can allocate resource elasticly in case of AioContext wide IO submission as batch. Signed-off-by: Ming Lei <ming.lei@canonical.com> --- block/linux-aio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)