vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,

              QEMUIOVector *qiov, int flags)

{

    BDRVVPCState *s = bs->opaque;

    int ret;

    int64_t image_offset;

    int64_t n_bytes;

    int64_t bytes_done = 0;

    VHDFooter *footer = (VHDFooter *) s->footer_buf;

    QEMUIOVector local_qiov;



    if (be32_to_cpu(footer->type) == VHD_FIXED) {

        return bdrv_co_preadv(bs->file, offset, bytes, qiov, 0);

    }



    qemu_co_mutex_lock(&s->lock);

    qemu_iovec_init(&local_qiov, qiov->niov);



    while (bytes > 0) {

        image_offset = get_image_offset(bs, offset, false);

        n_bytes = MIN(bytes, s->block_size - (offset % s->block_size));



        if (image_offset == -1) {

            qemu_iovec_memset(qiov, bytes_done, 0, n_bytes);

        } else {

            qemu_iovec_reset(&local_qiov);

            qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);



            ret = bdrv_co_preadv(bs->file, image_offset, n_bytes,

                                 &local_qiov, 0);

            if (ret < 0) {

                goto fail;

            }

        }



        bytes -= n_bytes;

        offset += n_bytes;

        bytes_done += n_bytes;

    }



    ret = 0;

fail:

    qemu_iovec_destroy(&local_qiov);

    qemu_co_mutex_unlock(&s->lock);



    return ret;

}

vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,

              QEMUIOVector *qiov, int flags)

{

    BDRVVPCState *s = bs->opaque;

    int ret;

    int64_t image_offset;

    int64_t n_bytes;

    int64_t bytes_done = 0;

    VHDFooter *footer = (VHDFooter *) s->footer_buf;

    QEMUIOVector local_qiov;



    if (be32_to_cpu(footer->type) == VHD_FIXED) {

        return bdrv_co_preadv(bs->file, offset, bytes, qiov, 0);

    }



    qemu_co_mutex_lock(&s->lock);

    qemu_iovec_init(&local_qiov, qiov->niov);



    while (bytes > 0) {

        image_offset = get_image_offset(bs, offset, false);

        n_bytes = MIN(bytes, s->block_size - (offset % s->block_size));



        if (image_offset == -1) {

            qemu_iovec_memset(qiov, bytes_done, 0, n_bytes);

        } else {

            qemu_iovec_reset(&local_qiov);

            qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);



            ret = bdrv_co_preadv(bs->file, image_offset, n_bytes,

                                 &local_qiov, 0);

            if (ret < 0) {

                goto fail;

            }

        }



        bytes -= n_bytes;

        offset += n_bytes;

        bytes_done += n_bytes;

    }



    ret = 0;

fail:

    qemu_iovec_destroy(&local_qiov);

    qemu_co_mutex_unlock(&s->lock);



    return ret;

}

        image_offset = get_image_offset(bs, offset, false);
FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,

              QEMUIOVector *VAR_3, int VAR_4)

{

    BDRVVPCState *s = VAR_0->opaque;

    int VAR_5;

    int64_t image_offset;

    int64_t n_bytes;

    int64_t bytes_done = 0;

    VHDFooter *footer = (VHDFooter *) s->footer_buf;

    QEMUIOVector local_qiov;



    if (be32_to_cpu(footer->type) == VHD_FIXED) {

        return bdrv_co_preadv(VAR_0->file, VAR_1, VAR_2, VAR_3, 0);

    }



    qemu_co_mutex_lock(&s->lock);

    qemu_iovec_init(&local_qiov, VAR_3->niov);



    while (VAR_2 > 0) {

        image_offset = get_image_offset(VAR_0, VAR_1, false);

        n_bytes = MIN(VAR_2, s->block_size - (VAR_1 % s->block_size));



        if (image_offset == -1) {

            qemu_iovec_memset(VAR_3, bytes_done, 0, n_bytes);

        } else {

            qemu_iovec_reset(&local_qiov);

            qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes);



            VAR_5 = bdrv_co_preadv(VAR_0->file, image_offset, n_bytes,

                                 &local_qiov, 0);

            if (VAR_5 < 0) {

                goto fail;

            }

        }



        VAR_2 -= n_bytes;

        VAR_1 += n_bytes;

        bytes_done += n_bytes;

    }



    VAR_5 = 0;

fail:

    qemu_iovec_destroy(&local_qiov);

    qemu_co_mutex_unlock(&s->lock);



    return VAR_5;

}

FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,
QEMUIOVector *VAR_3, int VAR_4)
{ BDRVVPCState *s = VAR_0->opaque; int VAR_5; int64_t image_offset; int64_t n_bytes; int64_t bytes_done = 0; VHDFooter *footer = (VHDFooter *) s->footer_buf; QEMUIOVector local_qiov; if (be32_to_cpu(footer->type) == VHD_FIXED) { return bdrv_co_preadv(VAR_0->file, VAR_1, VAR_2, VAR_3, 0); } qemu_co_mutex_lock(&s->lock); qemu_iovec_init(&local_qiov, VAR_3->niov); while (VAR_2 > 0) { image_offset = get_image_offset(VAR_0, VAR_1, false); n_bytes = MIN(VAR_2, s->block_size - (VAR_1 % s->block_size)); if (image_offset == -1) { qemu_iovec_memset(VAR_3, bytes_done, 0, n_bytes); } else { qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes); VAR_5 = bdrv_co_preadv(VAR_0->file, image_offset, n_bytes,
&local_qiov, 0); if (VAR_5 < 0) { goto fail; } } VAR_2 -= n_bytes; VAR_1 += n_bytes; bytes_done += n_bytes; } VAR_5 = 0; fail:
qemu_iovec_destroy(&local_qiov); qemu_co_mutex_unlock(&s->lock); return VAR_5; }