/* posix-aio-compat.c - thread pool based implementation */
-void *paio_init(void);
-BlockDriverAIOCB *paio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
+int paio_init(void);
+BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type);
BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
int type;
unsigned int lseek_err_cnt;
int open_flags;
- void *aio_ctx;
#if defined(__linux__)
/* linux floppy specific */
int64_t fd_open_time;
#endif
#ifdef CONFIG_LINUX_AIO
int use_aio;
+ void *aio_ctx;
#endif
uint8_t* aligned_buf;
} BDRVRawState;
} else
#endif
{
- s->aio_ctx = paio_init();
- if (!s->aio_ctx) {
+ if (paio_init() < 0) {
goto out_free_buf;
}
#ifdef CONFIG_LINUX_AIO
}
}
- return paio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, nb_sectors,
+ return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors,
cb, opaque, type);
}
if (fd_open(bs) < 0)
return NULL;
- return paio_submit(bs, s->aio_ctx, s->fd, 0, NULL, 0,
- cb, opaque, QEMU_AIO_FLUSH);
+ return paio_submit(bs, s->fd, 0, NULL, 0, cb, opaque, QEMU_AIO_FLUSH);
}
static void raw_close(BlockDriverState *bs)
.cancel = paio_cancel,
};
-BlockDriverAIOCB *paio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
+BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
return &acb->common;
}
-void *paio_init(void)
+int paio_init(void)
{
struct sigaction act;
PosixAioState *s;
int ret;
if (posix_aio_state)
- return posix_aio_state;
+ return 0;
s = qemu_malloc(sizeof(PosixAioState));
s->first_aio = NULL;
if (pipe(fds) == -1) {
fprintf(stderr, "failed to create pipe\n");
- return NULL;
+ return -1;
}
s->rfd = fds[0];
QTAILQ_INIT(&request_list);
posix_aio_state = s;
-
- return posix_aio_state;
+ return 0;
}