static int bdrv_inactivate_recurse(BlockDriverState *bs,

                                   bool setting_flag)

{

    BdrvChild *child, *parent;

    int ret;



    if (!setting_flag && bs->drv->bdrv_inactivate) {

        ret = bs->drv->bdrv_inactivate(bs);

        if (ret < 0) {

            return ret;

        }

    }



    if (setting_flag) {

        uint64_t perm, shared_perm;



        bs->open_flags |= BDRV_O_INACTIVE;



        QLIST_FOREACH(parent, &bs->parents, next_parent) {

            if (parent->role->inactivate) {

                ret = parent->role->inactivate(parent);

                if (ret < 0) {

                    bs->open_flags &= ~BDRV_O_INACTIVE;

                    return ret;

                }

            }

        }



        /* Update permissions, they may differ for inactive nodes */

        bdrv_get_cumulative_perm(bs, &perm, &shared_perm);

        bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort);

        bdrv_set_perm(bs, perm, shared_perm);

    }



    QLIST_FOREACH(child, &bs->children, next) {

        ret = bdrv_inactivate_recurse(child->bs, setting_flag);

        if (ret < 0) {

            return ret;

        }

    }



    /* At this point persistent bitmaps should be already stored by the format

     * driver */

    bdrv_release_persistent_dirty_bitmaps(bs);



    return 0;

}

static int bdrv_inactivate_recurse(BlockDriverState *bs,

                                   bool setting_flag)

{

    BdrvChild *child, *parent;

    int ret;



    if (!setting_flag && bs->drv->bdrv_inactivate) {

        ret = bs->drv->bdrv_inactivate(bs);

        if (ret < 0) {

            return ret;

        }

    }



    if (setting_flag) {

        uint64_t perm, shared_perm;



        bs->open_flags |= BDRV_O_INACTIVE;



        QLIST_FOREACH(parent, &bs->parents, next_parent) {

            if (parent->role->inactivate) {

                ret = parent->role->inactivate(parent);

                if (ret < 0) {

                    bs->open_flags &= ~BDRV_O_INACTIVE;

                    return ret;

                }

            }

        }



        

        bdrv_get_cumulative_perm(bs, &perm, &shared_perm);

        bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort);

        bdrv_set_perm(bs, perm, shared_perm);

    }



    QLIST_FOREACH(child, &bs->children, next) {

        ret = bdrv_inactivate_recurse(child->bs, setting_flag);

        if (ret < 0) {

            return ret;

        }

    }



    



    bdrv_release_persistent_dirty_bitmaps(bs);



    return 0;

}

    if (setting_flag) {         bs->open_flags |= BDRV_O_INACTIVE;                     bs->open_flags &= ~BDRV_O_INACTIVE;
static int FUNC_0(BlockDriverState *VAR_0,

                                   bool VAR_1)

{

    BdrvChild *child, *parent;

    int VAR_2;



    if (!VAR_1 && VAR_0->drv->bdrv_inactivate) {

        VAR_2 = VAR_0->drv->bdrv_inactivate(VAR_0);

        if (VAR_2 < 0) {

            return VAR_2;

        }

    }



    if (VAR_1) {

        uint64_t perm, shared_perm;



        VAR_0->open_flags |= BDRV_O_INACTIVE;



        QLIST_FOREACH(parent, &VAR_0->parents, next_parent) {

            if (parent->role->inactivate) {

                VAR_2 = parent->role->inactivate(parent);

                if (VAR_2 < 0) {

                    VAR_0->open_flags &= ~BDRV_O_INACTIVE;

                    return VAR_2;

                }

            }

        }



        

        bdrv_get_cumulative_perm(VAR_0, &perm, &shared_perm);

        bdrv_check_perm(VAR_0, perm, shared_perm, NULL, &error_abort);

        bdrv_set_perm(VAR_0, perm, shared_perm);

    }



    QLIST_FOREACH(child, &VAR_0->children, next) {

        VAR_2 = FUNC_0(child->VAR_0, VAR_1);

        if (VAR_2 < 0) {

            return VAR_2;

        }

    }



    



    bdrv_release_persistent_dirty_bitmaps(VAR_0);



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0,
bool VAR_1)
{ BdrvChild *child, *parent; int VAR_2; if (!VAR_1 && VAR_0->drv->bdrv_inactivate) { VAR_2 = VAR_0->drv->bdrv_inactivate(VAR_0); if (VAR_2 < 0) { return VAR_2; } } if (VAR_1) { uint64_t perm, shared_perm; VAR_0->open_flags |= BDRV_O_INACTIVE; QLIST_FOREACH(parent, &VAR_0->parents, next_parent) { if (parent->role->inactivate) { VAR_2 = parent->role->inactivate(parent); if (VAR_2 < 0) { VAR_0->open_flags &= ~BDRV_O_INACTIVE; return VAR_2; } } } bdrv_get_cumulative_perm(VAR_0, &perm, &shared_perm); bdrv_check_perm(VAR_0, perm, shared_perm, NULL, &error_abort); bdrv_set_perm(VAR_0, perm, shared_perm); } QLIST_FOREACH(child, &VAR_0->children, next) { VAR_2 = FUNC_0(child->VAR_0, VAR_1); if (VAR_2 < 0) { return VAR_2; } } bdrv_release_persistent_dirty_bitmaps(VAR_0); return 0; }