Received: from eggs.gnu.org ([2001:4830:134:3::10]:38036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnNA2-0001HL-Qa for qemu-devel@nongnu.org; Sun, 09 Nov 2014 02:43:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XnN9w-00014u-Oq for qemu-devel@nongnu.org; Sun, 09 Nov 2014 02:43:46 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:54941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnN9w-00014q-Jb for qemu-devel@nongnu.org; Sun, 09 Nov 2014 02:43:40 -0500 Received: by mail-pa0-f50.google.com with SMTP id eu11so6147682pac.23 for ; Sat, 08 Nov 2014 23:43:40 -0800 (PST) From: Ming Lei Date: Sun, 9 Nov 2014 15:42:53 +0800 Message-Id: <1415518978-2837-9-git-send-email-ming.lei@canonical.com> In-Reply-To: <1415518978-2837-1-git-send-email-ming.lei@canonical.com> References: <1415518978-2837-1-git-send-email-ming.lei@canonical.com> Subject: [Qemu-devel] [PATCH 08/13] block/linux-aio.c: allocate events dynamically List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini , Stefan Hajnoczi , Kevin Wolf Cc: Ming Lei , Fam Zheng 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 --- block/linux-aio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/linux-aio.c b/block/linux-aio.c index c5c7944..5be8036 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -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", -- 1.7.9.5