int bdrv_snapshot_goto(BlockDriverState *bs,

                       const char *snapshot_id)

{

    BlockDriver *drv = bs->drv;

    int ret, open_ret;



    if (!drv)

        return -ENOMEDIUM;

    if (drv->bdrv_snapshot_goto)

        return drv->bdrv_snapshot_goto(bs, snapshot_id);



    if (bs->file) {

        drv->bdrv_close(bs);

        ret = bdrv_snapshot_goto(bs->file, snapshot_id);

        open_ret = drv->bdrv_open(bs, NULL, bs->open_flags);

        if (open_ret < 0) {

            bdrv_delete(bs->file);

            bs->drv = NULL;

            return open_ret;

        }

        return ret;

    }



    return -ENOTSUP;

}

int bdrv_snapshot_goto(BlockDriverState *bs,

                       const char *snapshot_id)

{

    BlockDriver *drv = bs->drv;

    int ret, open_ret;



    if (!drv)

        return -ENOMEDIUM;

    if (drv->bdrv_snapshot_goto)

        return drv->bdrv_snapshot_goto(bs, snapshot_id);



    if (bs->file) {

        drv->bdrv_close(bs);

        ret = bdrv_snapshot_goto(bs->file, snapshot_id);

        open_ret = drv->bdrv_open(bs, NULL, bs->open_flags);

        if (open_ret < 0) {

            bdrv_delete(bs->file);

            bs->drv = NULL;

            return open_ret;

        }

        return ret;

    }



    return -ENOTSUP;

}

int FUNC_0(BlockDriverState *VAR_0,

                       const char *VAR_1)

{

    BlockDriver *drv = VAR_0->drv;

    int VAR_2, VAR_3;



    if (!drv)

        return -ENOMEDIUM;

    if (drv->FUNC_0)

        return drv->FUNC_0(VAR_0, VAR_1);



    if (VAR_0->file) {

        drv->bdrv_close(VAR_0);

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

        VAR_3 = drv->bdrv_open(VAR_0, NULL, VAR_0->open_flags);

        if (VAR_3 < 0) {

            bdrv_delete(VAR_0->file);

            VAR_0->drv = NULL;

            return VAR_3;

        }

        return VAR_2;

    }



    return -ENOTSUP;

}

int FUNC_0(BlockDriverState *VAR_0,
const char *VAR_1)
{ BlockDriver *drv = VAR_0->drv; int VAR_2, VAR_3; if (!drv)
return -ENOMEDIUM; if (drv->FUNC_0)
return drv->FUNC_0(VAR_0, VAR_1); if (VAR_0->file) { drv->bdrv_close(VAR_0); VAR_2 = FUNC_0(VAR_0->file, VAR_1); VAR_3 = drv->bdrv_open(VAR_0, NULL, VAR_0->open_flags); if (VAR_3 < 0) { bdrv_delete(VAR_0->file); VAR_0->drv = NULL; return VAR_3; } return VAR_2; } return -ENOTSUP; }