static int write_reftable_entry(BlockDriverState *bs, int rt_index)

{

    BDRVQcowState *s = bs->opaque;

    uint64_t buf[RT_ENTRIES_PER_SECTOR];

    int rt_start_index;

    int i, ret;



    rt_start_index = rt_index & ~(RT_ENTRIES_PER_SECTOR - 1);

    for (i = 0; i < RT_ENTRIES_PER_SECTOR; i++) {

        buf[i] = cpu_to_be64(s->refcount_table[rt_start_index + i]);

    }



    ret = qcow2_pre_write_overlap_check(bs,

            QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_TABLE,

            s->refcount_table_offset + rt_start_index * sizeof(uint64_t),

            sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_UPDATE);

    ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset +

            rt_start_index * sizeof(uint64_t), buf, sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    return 0;

}

static int write_reftable_entry(BlockDriverState *bs, int rt_index)

{

    BDRVQcowState *s = bs->opaque;

    uint64_t buf[RT_ENTRIES_PER_SECTOR];

    int rt_start_index;

    int i, ret;



    rt_start_index = rt_index & ~(RT_ENTRIES_PER_SECTOR - 1);

    for (i = 0; i < RT_ENTRIES_PER_SECTOR; i++) {

        buf[i] = cpu_to_be64(s->refcount_table[rt_start_index + i]);

    }



    ret = qcow2_pre_write_overlap_check(bs,

            QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_TABLE,

            s->refcount_table_offset + rt_start_index * sizeof(uint64_t),

            sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_UPDATE);

    ret = bdrv_pwrite_sync(bs->file, s->refcount_table_offset +

            rt_start_index * sizeof(uint64_t), buf, sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    return 0;

}

    ret = qcow2_pre_write_overlap_check(bs,     ret = qcow2_pre_write_overlap_check(bs,             QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_TABLE,     ret = qcow2_pre_write_overlap_check(bs,
static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)

{

    BDRVQcowState *s = VAR_0->opaque;

    uint64_t buf[RT_ENTRIES_PER_SECTOR];

    int VAR_2;

    int VAR_3, VAR_4;



    VAR_2 = VAR_1 & ~(RT_ENTRIES_PER_SECTOR - 1);

    for (VAR_3 = 0; VAR_3 < RT_ENTRIES_PER_SECTOR; VAR_3++) {

        buf[VAR_3] = cpu_to_be64(s->refcount_table[VAR_2 + VAR_3]);

    }



    VAR_4 = qcow2_pre_write_overlap_check(VAR_0,

            QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_TABLE,

            s->refcount_table_offset + VAR_2 * sizeof(uint64_t),

            sizeof(buf));

    if (VAR_4 < 0) {

        return VAR_4;

    }



    BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_UPDATE);

    VAR_4 = bdrv_pwrite_sync(VAR_0->file, s->refcount_table_offset +

            VAR_2 * sizeof(uint64_t), buf, sizeof(buf));

    if (VAR_4 < 0) {

        return VAR_4;

    }



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{ BDRVQcowState *s = VAR_0->opaque; uint64_t buf[RT_ENTRIES_PER_SECTOR]; int VAR_2; int VAR_3, VAR_4; VAR_2 = VAR_1 & ~(RT_ENTRIES_PER_SECTOR - 1); for (VAR_3 = 0; VAR_3 < RT_ENTRIES_PER_SECTOR; VAR_3++) { buf[VAR_3] = cpu_to_be64(s->refcount_table[VAR_2 + VAR_3]); } VAR_4 = qcow2_pre_write_overlap_check(VAR_0,
QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_TABLE,
s->refcount_table_offset + VAR_2 * sizeof(uint64_t),
sizeof(buf)); if (VAR_4 < 0) { return VAR_4; } BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_UPDATE); VAR_4 = bdrv_pwrite_sync(VAR_0->file, s->refcount_table_offset +
VAR_2 * sizeof(uint64_t), buf, sizeof(buf)); if (VAR_4 < 0) { return VAR_4; } return 0; }