static void dma_bdrv_cb(void *opaque, int ret)

{

    DMAAIOCB *dbs = (DMAAIOCB *)opaque;

    target_phys_addr_t cur_addr, cur_len;

    void *mem;



    dbs->acb = NULL;

    dbs->sector_num += dbs->iov.size / 512;

    dma_bdrv_unmap(dbs);

    qemu_iovec_reset(&dbs->iov);



    if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {

        dbs->common.cb(dbs->common.opaque, ret);

        qemu_iovec_destroy(&dbs->iov);

        qemu_aio_release(dbs);

        return;

    }



    while (dbs->sg_cur_index < dbs->sg->nsg) {

        cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;

        cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte;

        mem = cpu_physical_memory_map(cur_addr, &cur_len, !dbs->to_dev);

        if (!mem)

            break;

        qemu_iovec_add(&dbs->iov, mem, cur_len);

        dbs->sg_cur_byte += cur_len;

        if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) {

            dbs->sg_cur_byte = 0;

            ++dbs->sg_cur_index;

        }

    }



    if (dbs->iov.size == 0) {

        cpu_register_map_client(dbs, continue_after_map_failure);

        return;

    }



    dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov,

                            dbs->iov.size / 512, dma_bdrv_cb, dbs);

    if (!dbs->acb) {

        dma_bdrv_unmap(dbs);

        qemu_iovec_destroy(&dbs->iov);

        return;

    }

}

static void dma_bdrv_cb(void *opaque, int ret)

{

    DMAAIOCB *dbs = (DMAAIOCB *)opaque;

    target_phys_addr_t cur_addr, cur_len;

    void *mem;



    dbs->acb = NULL;

    dbs->sector_num += dbs->iov.size / 512;

    dma_bdrv_unmap(dbs);

    qemu_iovec_reset(&dbs->iov);



    if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {

        dbs->common.cb(dbs->common.opaque, ret);

        qemu_iovec_destroy(&dbs->iov);

        qemu_aio_release(dbs);

        return;

    }



    while (dbs->sg_cur_index < dbs->sg->nsg) {

        cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;

        cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte;

        mem = cpu_physical_memory_map(cur_addr, &cur_len, !dbs->to_dev);

        if (!mem)

            break;

        qemu_iovec_add(&dbs->iov, mem, cur_len);

        dbs->sg_cur_byte += cur_len;

        if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) {

            dbs->sg_cur_byte = 0;

            ++dbs->sg_cur_index;

        }

    }



    if (dbs->iov.size == 0) {

        cpu_register_map_client(dbs, continue_after_map_failure);

        return;

    }



    dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov,

                            dbs->iov.size / 512, dma_bdrv_cb, dbs);

    if (!dbs->acb) {

        dma_bdrv_unmap(dbs);

        qemu_iovec_destroy(&dbs->iov);

        return;

    }

}

    qemu_iovec_reset(&dbs->iov);         dbs->common.cb(dbs->common.opaque, ret);         qemu_iovec_destroy(&dbs->iov);         qemu_aio_release(dbs);         dma_bdrv_unmap(dbs);         qemu_iovec_destroy(&dbs->iov);     if (!dbs->acb) {         qemu_aio_release(dbs);
static void FUNC_0(void *VAR_0, int VAR_1)

{

    DMAAIOCB *dbs = (DMAAIOCB *)VAR_0;

    target_phys_addr_t cur_addr, cur_len;

    void *VAR_2;



    dbs->acb = NULL;

    dbs->sector_num += dbs->iov.size / 512;

    dma_bdrv_unmap(dbs);

    qemu_iovec_reset(&dbs->iov);



    if (dbs->sg_cur_index == dbs->sg->nsg || VAR_1 < 0) {

        dbs->common.cb(dbs->common.VAR_0, VAR_1);

        qemu_iovec_destroy(&dbs->iov);

        qemu_aio_release(dbs);

        return;

    }



    while (dbs->sg_cur_index < dbs->sg->nsg) {

        cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;

        cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte;

        VAR_2 = cpu_physical_memory_map(cur_addr, &cur_len, !dbs->to_dev);

        if (!VAR_2)

            break;

        qemu_iovec_add(&dbs->iov, VAR_2, cur_len);

        dbs->sg_cur_byte += cur_len;

        if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) {

            dbs->sg_cur_byte = 0;

            ++dbs->sg_cur_index;

        }

    }



    if (dbs->iov.size == 0) {

        cpu_register_map_client(dbs, continue_after_map_failure);

        return;

    }



    dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov,

                            dbs->iov.size / 512, FUNC_0, dbs);

    if (!dbs->acb) {

        dma_bdrv_unmap(dbs);

        qemu_iovec_destroy(&dbs->iov);

        return;

    }

}

static void FUNC_0(void *VAR_0, int VAR_1)
{ DMAAIOCB *dbs = (DMAAIOCB *)VAR_0; target_phys_addr_t cur_addr, cur_len; void *VAR_2; dbs->acb = NULL; dbs->sector_num += dbs->iov.size / 512; dma_bdrv_unmap(dbs); qemu_iovec_reset(&dbs->iov); if (dbs->sg_cur_index == dbs->sg->nsg || VAR_1 < 0) { dbs->common.cb(dbs->common.VAR_0, VAR_1); qemu_iovec_destroy(&dbs->iov); qemu_aio_release(dbs); return; } while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte; cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; VAR_2 = cpu_physical_memory_map(cur_addr, &cur_len, !dbs->to_dev); if (!VAR_2)
break; qemu_iovec_add(&dbs->iov, VAR_2, cur_len); dbs->sg_cur_byte += cur_len; if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) { dbs->sg_cur_byte = 0; ++dbs->sg_cur_index; } } if (dbs->iov.size == 0) { cpu_register_map_client(dbs, continue_after_map_failure); return; } dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov,
dbs->iov.size / 512, FUNC_0, dbs); if (!dbs->acb) { dma_bdrv_unmap(dbs); qemu_iovec_destroy(&dbs->iov); return; } }