blob: 31d791fe67bac31f58cec7f101820a5518035183 [file] [log] [blame]
Christoph Hellwig9ef91a62009-08-20 16:58:19 +02001/*
Paolo Bonzini9f8540e2012-06-09 10:57:37 +02002 * Declarations for AIO in the raw protocol
Christoph Hellwig9ef91a62009-08-20 16:58:19 +02003 *
4 * Copyright IBM, Corp. 2008
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
Paolo Bonzini6b620ca2012-01-13 17:44:23 +010012 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
Christoph Hellwig9ef91a62009-08-20 16:58:19 +020014 */
Paolo Bonzini9f8540e2012-06-09 10:57:37 +020015#ifndef QEMU_RAW_AIO_H
16#define QEMU_RAW_AIO_H
Christoph Hellwig9ef91a62009-08-20 16:58:19 +020017
18/* AIO request types */
19#define QEMU_AIO_READ 0x0001
20#define QEMU_AIO_WRITE 0x0002
21#define QEMU_AIO_IOCTL 0x0004
Christoph Hellwigb2e12bc2009-09-04 19:01:49 +020022#define QEMU_AIO_FLUSH 0x0008
Paolo Bonzini82380102013-01-14 16:26:55 +010023#define QEMU_AIO_DISCARD 0x0010
Paolo Bonzini97a2ae32013-11-22 13:39:57 +010024#define QEMU_AIO_WRITE_ZEROES 0x0020
Christoph Hellwig9ef91a62009-08-20 16:58:19 +020025#define QEMU_AIO_TYPE_MASK \
Paolo Bonzini82380102013-01-14 16:26:55 +010026 (QEMU_AIO_READ|QEMU_AIO_WRITE|QEMU_AIO_IOCTL|QEMU_AIO_FLUSH| \
Paolo Bonzini97a2ae32013-11-22 13:39:57 +010027 QEMU_AIO_DISCARD|QEMU_AIO_WRITE_ZEROES)
Christoph Hellwig9ef91a62009-08-20 16:58:19 +020028
29/* AIO flags */
30#define QEMU_AIO_MISALIGNED 0x1000
Paolo Bonzini82380102013-01-14 16:26:55 +010031#define QEMU_AIO_BLKDEV 0x2000
Christoph Hellwig9ef91a62009-08-20 16:58:19 +020032
33
Christoph Hellwig5c6c3a62009-08-20 16:58:35 +020034/* linux-aio.c - Linux native implementation */
Paolo Bonzini9f8540e2012-06-09 10:57:37 +020035#ifdef CONFIG_LINUX_AIO
Christoph Hellwig5c6c3a62009-08-20 16:58:35 +020036void *laio_init(void);
Stefan Hajnocziabd269b2014-05-08 16:34:48 +020037void laio_cleanup(void *s);
Markus Armbruster7c84b1b2014-10-07 13:59:14 +020038BlockAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
Christoph Hellwig5c6c3a62009-08-20 16:58:35 +020039 int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
Markus Armbruster097310b2014-10-07 13:59:15 +020040 BlockCompletionFunc *cb, void *opaque, int type);
Stefan Hajnoczic2f34262014-05-08 16:34:47 +020041void laio_detach_aio_context(void *s, AioContext *old_context);
42void laio_attach_aio_context(void *s, AioContext *new_context);
Ming Lei1b3abdc2014-07-04 18:04:34 +080043void laio_io_plug(BlockDriverState *bs, void *aio_ctx);
Paolo Bonzinide354642014-12-11 14:52:29 +010044void laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug);
Paolo Bonzini9f8540e2012-06-09 10:57:37 +020045#endif
Christoph Hellwig5c6c3a62009-08-20 16:58:35 +020046
Paolo Bonzinia2736522012-10-26 11:43:58 +020047#ifdef _WIN32
48typedef struct QEMUWin32AIOState QEMUWin32AIOState;
49QEMUWin32AIOState *win32_aio_init(void);
Stefan Hajnoczi99cc5982014-05-08 16:34:49 +020050void win32_aio_cleanup(QEMUWin32AIOState *aio);
Paolo Bonzinia2736522012-10-26 11:43:58 +020051int win32_aio_attach(QEMUWin32AIOState *aio, HANDLE hfile);
Markus Armbruster7c84b1b2014-10-07 13:59:14 +020052BlockAIOCB *win32_aio_submit(BlockDriverState *bs,
Paolo Bonzinia2736522012-10-26 11:43:58 +020053 QEMUWin32AIOState *aio, HANDLE hfile,
54 int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
Markus Armbruster097310b2014-10-07 13:59:15 +020055 BlockCompletionFunc *cb, void *opaque, int type);
Stefan Hajnoczi85ebd382014-05-08 16:34:50 +020056void win32_aio_detach_aio_context(QEMUWin32AIOState *aio,
57 AioContext *old_context);
58void win32_aio_attach_aio_context(QEMUWin32AIOState *aio,
59 AioContext *new_context);
Paolo Bonzinia2736522012-10-26 11:43:58 +020060#endif
61
Paolo Bonzini9f8540e2012-06-09 10:57:37 +020062#endif /* QEMU_RAW_AIO_H */