int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index)

{

    BDRVQcowState *s = bs->opaque;

    uint64_t buf[L1_ENTRIES_PER_SECTOR];

    int l1_start_index;

    int i, ret;



    l1_start_index = l1_index & ~(L1_ENTRIES_PER_SECTOR - 1);

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

        buf[i] = cpu_to_be64(s->l1_table[l1_start_index + i]);

    }



    ret = qcow2_pre_write_overlap_check(bs,

            QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L1,

            s->l1_table_offset + 8 * l1_start_index, sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE);

    ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset + 8 * l1_start_index,

        buf, sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    return 0;

}

int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index)

{

    BDRVQcowState *s = bs->opaque;

    uint64_t buf[L1_ENTRIES_PER_SECTOR];

    int l1_start_index;

    int i, ret;



    l1_start_index = l1_index & ~(L1_ENTRIES_PER_SECTOR - 1);

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

        buf[i] = cpu_to_be64(s->l1_table[l1_start_index + i]);

    }



    ret = qcow2_pre_write_overlap_check(bs,

            QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L1,

            s->l1_table_offset + 8 * l1_start_index, sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE);

    ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset + 8 * l1_start_index,

        buf, sizeof(buf));

    if (ret < 0) {

        return ret;

    }



    return 0;

}

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

{

    BDRVQcowState *s = VAR_0->opaque;

    uint64_t buf[L1_ENTRIES_PER_SECTOR];

    int VAR_2;

    int VAR_3, VAR_4;



    VAR_2 = VAR_1 & ~(L1_ENTRIES_PER_SECTOR - 1);

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

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

    }



    VAR_4 = qcow2_pre_write_overlap_check(VAR_0,

            QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L1,

            s->l1_table_offset + 8 * VAR_2, sizeof(buf));

    if (VAR_4 < 0) {

        return VAR_4;

    }



    BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_UPDATE);

    VAR_4 = bdrv_pwrite_sync(VAR_0->file, s->l1_table_offset + 8 * VAR_2,

        buf, sizeof(buf));

    if (VAR_4 < 0) {

        return VAR_4;

    }



    return 0;

}

int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{ BDRVQcowState *s = VAR_0->opaque; uint64_t buf[L1_ENTRIES_PER_SECTOR]; int VAR_2; int VAR_3, VAR_4; VAR_2 = VAR_1 & ~(L1_ENTRIES_PER_SECTOR - 1); for (VAR_3 = 0; VAR_3 < L1_ENTRIES_PER_SECTOR; VAR_3++) { buf[VAR_3] = cpu_to_be64(s->l1_table[VAR_2 + VAR_3]); } VAR_4 = qcow2_pre_write_overlap_check(VAR_0,
QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L1,
s->l1_table_offset + 8 * VAR_2, sizeof(buf)); if (VAR_4 < 0) { return VAR_4; } BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_UPDATE); VAR_4 = bdrv_pwrite_sync(VAR_0->file, s->l1_table_offset + 8 * VAR_2,
buf, sizeof(buf)); if (VAR_4 < 0) { return VAR_4; } return 0; }