static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos,

                                  QEMUIOVector *qiov,

                                  BlockDriverCompletionFunc *cb, void *opaque)

{

    uint64_t backing_length = 0;

    size_t size;



    /* If there is a backing file, get its length.  Treat the absence of a

     * backing file like a zero length backing file.

     */

    if (s->bs->backing_hd) {

        int64_t l = bdrv_getlength(s->bs->backing_hd);

        if (l < 0) {

            cb(opaque, l);

            return;

        }

        backing_length = l;

    }



    /* Zero all sectors if reading beyond the end of the backing file */

    if (pos >= backing_length ||

        pos + qiov->size > backing_length) {

        qemu_iovec_memset(qiov, 0, 0, qiov->size);

    }



    /* Complete now if there are no backing file sectors to read */

    if (pos >= backing_length) {

        cb(opaque, 0);

        return;

    }



    /* If the read straddles the end of the backing file, shorten it */

    size = MIN((uint64_t)backing_length - pos, qiov->size);



    BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO);

    bdrv_aio_readv(s->bs->backing_hd, pos / BDRV_SECTOR_SIZE,

                   qiov, size / BDRV_SECTOR_SIZE, cb, opaque);

}

static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos,

                                  QEMUIOVector *qiov,

                                  BlockDriverCompletionFunc *cb, void *opaque)

{

    uint64_t backing_length = 0;

    size_t size;



    





    if (s->bs->backing_hd) {

        int64_t l = bdrv_getlength(s->bs->backing_hd);

        if (l < 0) {

            cb(opaque, l);

            return;

        }

        backing_length = l;

    }



    

    if (pos >= backing_length ||

        pos + qiov->size > backing_length) {

        qemu_iovec_memset(qiov, 0, 0, qiov->size);

    }



    

    if (pos >= backing_length) {

        cb(opaque, 0);

        return;

    }



    

    size = MIN((uint64_t)backing_length - pos, qiov->size);



    BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO);

    bdrv_aio_readv(s->bs->backing_hd, pos / BDRV_SECTOR_SIZE,

                   qiov, size / BDRV_SECTOR_SIZE, cb, opaque);

}

                   qiov, size / BDRV_SECTOR_SIZE, cb, opaque);
static void FUNC_0(BDRVQEDState *VAR_0, uint64_t VAR_1,

                                  QEMUIOVector *VAR_2,

                                  BlockDriverCompletionFunc *VAR_3, void *VAR_4)

{

    uint64_t backing_length = 0;

    size_t size;



    





    if (VAR_0->bs->backing_hd) {

        int64_t l = bdrv_getlength(VAR_0->bs->backing_hd);

        if (l < 0) {

            VAR_3(VAR_4, l);

            return;

        }

        backing_length = l;

    }



    

    if (VAR_1 >= backing_length ||

        VAR_1 + VAR_2->size > backing_length) {

        qemu_iovec_memset(VAR_2, 0, 0, VAR_2->size);

    }



    

    if (VAR_1 >= backing_length) {

        VAR_3(VAR_4, 0);

        return;

    }



    

    size = MIN((uint64_t)backing_length - VAR_1, VAR_2->size);



    BLKDBG_EVENT(VAR_0->bs->file, BLKDBG_READ_BACKING_AIO);

    bdrv_aio_readv(VAR_0->bs->backing_hd, VAR_1 / BDRV_SECTOR_SIZE,

                   VAR_2, size / BDRV_SECTOR_SIZE, VAR_3, VAR_4);

}

static void FUNC_0(BDRVQEDState *VAR_0, uint64_t VAR_1,
QEMUIOVector *VAR_2,
BlockDriverCompletionFunc *VAR_3, void *VAR_4)
{ uint64_t backing_length = 0; size_t size; if (VAR_0->bs->backing_hd) { int64_t l = bdrv_getlength(VAR_0->bs->backing_hd); if (l < 0) { VAR_3(VAR_4, l); return; } backing_length = l; } if (VAR_1 >= backing_length ||
VAR_1 + VAR_2->size > backing_length) { qemu_iovec_memset(VAR_2, 0, 0, VAR_2->size); } if (VAR_1 >= backing_length) { VAR_3(VAR_4, 0); return; } size = MIN((uint64_t)backing_length - VAR_1, VAR_2->size); BLKDBG_EVENT(VAR_0->bs->file, BLKDBG_READ_BACKING_AIO); bdrv_aio_readv(VAR_0->bs->backing_hd, VAR_1 / BDRV_SECTOR_SIZE,
VAR_2, size / BDRV_SECTOR_SIZE, VAR_3, VAR_4); }