static void qcow2_close(BlockDriverState *bs)

{

    BDRVQcow2State *s = bs->opaque;

    qemu_vfree(s->l1_table);

    /* else pre-write overlap checks in cache_destroy may crash */

    s->l1_table = NULL;



    if (!(s->flags & BDRV_O_INACTIVE)) {

        qcow2_inactivate(bs);

    }



    cache_clean_timer_del(bs);

    qcow2_cache_destroy(bs, s->l2_table_cache);

    qcow2_cache_destroy(bs, s->refcount_block_cache);



    qcrypto_cipher_free(s->cipher);

    s->cipher = NULL;



    g_free(s->unknown_header_fields);

    cleanup_unknown_header_ext(bs);



    g_free(s->image_backing_file);

    g_free(s->image_backing_format);



    g_free(s->cluster_cache);

    qemu_vfree(s->cluster_data);

    qcow2_refcount_close(bs);

    qcow2_free_snapshots(bs);

}

static void qcow2_close(BlockDriverState *bs)

{

    BDRVQcow2State *s = bs->opaque;

    qemu_vfree(s->l1_table);

    

    s->l1_table = NULL;



    if (!(s->flags & BDRV_O_INACTIVE)) {

        qcow2_inactivate(bs);

    }



    cache_clean_timer_del(bs);

    qcow2_cache_destroy(bs, s->l2_table_cache);

    qcow2_cache_destroy(bs, s->refcount_block_cache);



    qcrypto_cipher_free(s->cipher);

    s->cipher = NULL;



    g_free(s->unknown_header_fields);

    cleanup_unknown_header_ext(bs);



    g_free(s->image_backing_file);

    g_free(s->image_backing_format);



    g_free(s->cluster_cache);

    qemu_vfree(s->cluster_data);

    qcow2_refcount_close(bs);

    qcow2_free_snapshots(bs);

}

static void FUNC_0(BlockDriverState *VAR_0)

{

    BDRVQcow2State *s = VAR_0->opaque;

    qemu_vfree(s->l1_table);

    

    s->l1_table = NULL;



    if (!(s->flags & BDRV_O_INACTIVE)) {

        qcow2_inactivate(VAR_0);

    }



    cache_clean_timer_del(VAR_0);

    qcow2_cache_destroy(VAR_0, s->l2_table_cache);

    qcow2_cache_destroy(VAR_0, s->refcount_block_cache);



    qcrypto_cipher_free(s->cipher);

    s->cipher = NULL;



    g_free(s->unknown_header_fields);

    cleanup_unknown_header_ext(VAR_0);



    g_free(s->image_backing_file);

    g_free(s->image_backing_format);



    g_free(s->cluster_cache);

    qemu_vfree(s->cluster_data);

    qcow2_refcount_close(VAR_0);

    qcow2_free_snapshots(VAR_0);

}

static void FUNC_0(BlockDriverState *VAR_0)
{ BDRVQcow2State *s = VAR_0->opaque; qemu_vfree(s->l1_table); s->l1_table = NULL; if (!(s->flags & BDRV_O_INACTIVE)) { qcow2_inactivate(VAR_0); } cache_clean_timer_del(VAR_0); qcow2_cache_destroy(VAR_0, s->l2_table_cache); qcow2_cache_destroy(VAR_0, s->refcount_block_cache); qcrypto_cipher_free(s->cipher); s->cipher = NULL; g_free(s->unknown_header_fields); cleanup_unknown_header_ext(VAR_0); g_free(s->image_backing_file); g_free(s->image_backing_format); g_free(s->cluster_cache); qemu_vfree(s->cluster_data); qcow2_refcount_close(VAR_0); qcow2_free_snapshots(VAR_0); }