static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp)

{

    BDRVQcow2State *s = bs->opaque;

    int flags = s->flags;

    QCryptoCipher *cipher = NULL;

    QDict *options;

    Error *local_err = NULL;

    int ret;



    /*

     * Backing files are read-only which makes all of their metadata immutable,

     * that means we don't have to worry about reopening them here.

     */



    cipher = s->cipher;

    s->cipher = NULL;



    qcow2_close(bs);



    bdrv_invalidate_cache(bs->file->bs, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        bs->drv = NULL;

        return;

    }



    memset(s, 0, sizeof(BDRVQcow2State));

    options = qdict_clone_shallow(bs->options);



    flags &= ~BDRV_O_INACTIVE;

    ret = qcow2_open(bs, options, flags, &local_err);

    QDECREF(options);

    if (local_err) {

        error_propagate(errp, local_err);

        error_prepend(errp, "Could not reopen qcow2 layer: ");

        bs->drv = NULL;

        return;

    } else if (ret < 0) {

        error_setg_errno(errp, -ret, "Could not reopen qcow2 layer");

        bs->drv = NULL;

        return;

    }



    s->cipher = cipher;

}

static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp)

{

    BDRVQcow2State *s = bs->opaque;

    int flags = s->flags;

    QCryptoCipher *cipher = NULL;

    QDict *options;

    Error *local_err = NULL;

    int ret;



    









    cipher = s->cipher;

    s->cipher = NULL;



    qcow2_close(bs);



    bdrv_invalidate_cache(bs->file->bs, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        bs->drv = NULL;

        return;

    }



    memset(s, 0, sizeof(BDRVQcow2State));

    options = qdict_clone_shallow(bs->options);



    flags &= ~BDRV_O_INACTIVE;

    ret = qcow2_open(bs, options, flags, &local_err);

    QDECREF(options);

    if (local_err) {

        error_propagate(errp, local_err);

        error_prepend(errp, "Could not reopen qcow2 layer: ");

        bs->drv = NULL;

        return;

    } else if (ret < 0) {

        error_setg_errno(errp, -ret, "Could not reopen qcow2 layer");

        bs->drv = NULL;

        return;

    }



    s->cipher = cipher;

}

static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)

{

    BDRVQcow2State *s = VAR_0->opaque;

    int VAR_2 = s->VAR_2;

    QCryptoCipher *cipher = NULL;

    QDict *options;

    Error *local_err = NULL;

    int VAR_3;



    









    cipher = s->cipher;

    s->cipher = NULL;



    qcow2_close(VAR_0);



    bdrv_invalidate_cache(VAR_0->file->VAR_0, &local_err);

    if (local_err) {

        error_propagate(VAR_1, local_err);

        VAR_0->drv = NULL;

        return;

    }



    memset(s, 0, sizeof(BDRVQcow2State));

    options = qdict_clone_shallow(VAR_0->options);



    VAR_2 &= ~BDRV_O_INACTIVE;

    VAR_3 = qcow2_open(VAR_0, options, VAR_2, &local_err);

    QDECREF(options);

    if (local_err) {

        error_propagate(VAR_1, local_err);

        error_prepend(VAR_1, "Could not reopen qcow2 layer: ");

        VAR_0->drv = NULL;

        return;

    } else if (VAR_3 < 0) {

        error_setg_errno(VAR_1, -VAR_3, "Could not reopen qcow2 layer");

        VAR_0->drv = NULL;

        return;

    }



    s->cipher = cipher;

}

static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{ BDRVQcow2State *s = VAR_0->opaque; int VAR_2 = s->VAR_2; QCryptoCipher *cipher = NULL; QDict *options; Error *local_err = NULL; int VAR_3; cipher = s->cipher; s->cipher = NULL; qcow2_close(VAR_0); bdrv_invalidate_cache(VAR_0->file->VAR_0, &local_err); if (local_err) { error_propagate(VAR_1, local_err); VAR_0->drv = NULL; return; } memset(s, 0, sizeof(BDRVQcow2State)); options = qdict_clone_shallow(VAR_0->options); VAR_2 &= ~BDRV_O_INACTIVE; VAR_3 = qcow2_open(VAR_0, options, VAR_2, &local_err); QDECREF(options); if (local_err) { error_propagate(VAR_1, local_err); error_prepend(VAR_1, "Could not reopen qcow2 layer: "); VAR_0->drv = NULL; return; } else if (VAR_3 < 0) { error_setg_errno(VAR_1, -VAR_3, "Could not reopen qcow2 layer"); VAR_0->drv = NULL; return; } s->cipher = cipher; }