BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,

        int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,

        BlockDriverCompletionFunc *cb, void *opaque, int type)

{

    struct qemu_laio_state *s = aio_ctx;

    struct qemu_laiocb *laiocb;

    struct iocb *iocbs;

    off_t offset = sector_num * 512;



    laiocb = qemu_aio_get(&laio_pool, bs, cb, opaque);

    if (!laiocb)

        return NULL;

    laiocb->nbytes = nb_sectors * 512;

    laiocb->ctx = s;

    laiocb->ret = -EINPROGRESS;

    laiocb->async_context_id = get_async_context_id();



    iocbs = &laiocb->iocb;



    switch (type) {

    case QEMU_AIO_WRITE:

        io_prep_pwritev(iocbs, fd, qiov->iov, qiov->niov, offset);

	break;

    case QEMU_AIO_READ:

        io_prep_preadv(iocbs, fd, qiov->iov, qiov->niov, offset);

	break;

    default:

        fprintf(stderr, "%s: invalid AIO request type 0x%x.\n",

                        __func__, type);

        goto out_free_aiocb;

    }

    io_set_eventfd(&laiocb->iocb, s->efd);

    s->count++;



    if (io_submit(s->ctx, 1, &iocbs) < 0)

        goto out_dec_count;

    return &laiocb->common;



out_free_aiocb:

    qemu_aio_release(laiocb);

out_dec_count:

    s->count--;

    return NULL;

}

BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,

        int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,

        BlockDriverCompletionFunc *cb, void *opaque, int type)

{

    struct qemu_laio_state *s = aio_ctx;

    struct qemu_laiocb *laiocb;

    struct iocb *iocbs;

    off_t offset = sector_num * 512;



    laiocb = qemu_aio_get(&laio_pool, bs, cb, opaque);

    if (!laiocb)

        return NULL;

    laiocb->nbytes = nb_sectors * 512;

    laiocb->ctx = s;

    laiocb->ret = -EINPROGRESS;

    laiocb->async_context_id = get_async_context_id();



    iocbs = &laiocb->iocb;



    switch (type) {

    case QEMU_AIO_WRITE:

        io_prep_pwritev(iocbs, fd, qiov->iov, qiov->niov, offset);

	break;

    case QEMU_AIO_READ:

        io_prep_preadv(iocbs, fd, qiov->iov, qiov->niov, offset);

	break;

    default:

        fprintf(stderr, "%s: invalid AIO request type 0x%x.\n",

                        __func__, type);

        goto out_free_aiocb;

    }

    io_set_eventfd(&laiocb->iocb, s->efd);

    s->count++;



    if (io_submit(s->ctx, 1, &iocbs) < 0)

        goto out_dec_count;

    return &laiocb->common;



out_free_aiocb:

    qemu_aio_release(laiocb);

out_dec_count:

    s->count--;

    return NULL;

}

BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, void *aio_ctx, int fd,

        int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,

        BlockDriverCompletionFunc *cb, void *opaque, int type)

{

    struct qemu_laio_state *VAR_0 = aio_ctx;

    struct qemu_laiocb *VAR_1;

    struct iocb *VAR_2;

    off_t offset = sector_num * 512;



    VAR_1 = qemu_aio_get(&laio_pool, bs, cb, opaque);

    if (!VAR_1)

        return NULL;

    VAR_1->nbytes = nb_sectors * 512;

    VAR_1->ctx = VAR_0;

    VAR_1->ret = -EINPROGRESS;

    VAR_1->async_context_id = get_async_context_id();



    VAR_2 = &VAR_1->iocb;



    switch (type) {

    case QEMU_AIO_WRITE:

        io_prep_pwritev(VAR_2, fd, qiov->iov, qiov->niov, offset);

	break;

    case QEMU_AIO_READ:

        io_prep_preadv(VAR_2, fd, qiov->iov, qiov->niov, offset);

	break;

    default:

        fprintf(stderr, "%VAR_0: invalid AIO request type 0x%x.\n",

                        __func__, type);

        goto out_free_aiocb;

    }

    io_set_eventfd(&VAR_1->iocb, VAR_0->efd);

    VAR_0->count++;



    if (io_submit(VAR_0->ctx, 1, &VAR_2) < 0)

        goto out_dec_count;

    return &VAR_1->common;



out_free_aiocb:

    qemu_aio_release(VAR_1);

out_dec_count:

    VAR_0->count--;

    return NULL;

}

BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, void *aio_ctx, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{ struct qemu_laio_state *VAR_0 = aio_ctx; struct qemu_laiocb *VAR_1; struct iocb *VAR_2; off_t offset = sector_num * 512; VAR_1 = qemu_aio_get(&laio_pool, bs, cb, opaque); if (!VAR_1)
return NULL; VAR_1->nbytes = nb_sectors * 512; VAR_1->ctx = VAR_0; VAR_1->ret = -EINPROGRESS; VAR_1->async_context_id = get_async_context_id(); VAR_2 = &VAR_1->iocb; switch (type) { case QEMU_AIO_WRITE:
io_prep_pwritev(VAR_2, fd, qiov->iov, qiov->niov, offset); break; case QEMU_AIO_READ:
io_prep_preadv(VAR_2, fd, qiov->iov, qiov->niov, offset); break; default:
fprintf(stderr, "%VAR_0: invalid AIO request type 0x%x.\n",
__func__, type); goto out_free_aiocb; } io_set_eventfd(&VAR_1->iocb, VAR_0->efd); VAR_0->count++; if (io_submit(VAR_0->ctx, 1, &VAR_2) < 0)
goto out_dec_count; return &VAR_1->common; out_free_aiocb:
qemu_aio_release(VAR_1); out_dec_count:
VAR_0->count--; return NULL; }