int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)

{

    char backing_filename[PATH_MAX];

    int back_flags, ret;

    BlockDriver *back_drv = NULL;

    Error *local_err = NULL;



    if (bs->backing_hd != NULL) {

        QDECREF(options);

        return 0;

    }



    /* NULL means an empty set of options */

    if (options == NULL) {

        options = qdict_new();

    }



    bs->open_flags &= ~BDRV_O_NO_BACKING;

    if (qdict_haskey(options, "file.filename")) {

        backing_filename[0] = '\0';

    } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) {

        QDECREF(options);

        return 0;

    }



    bs->backing_hd = bdrv_new("");

    bdrv_get_full_backing_filename(bs, backing_filename,

                                   sizeof(backing_filename));



    if (bs->backing_format[0] != '\0') {

        back_drv = bdrv_find_format(bs->backing_format);

    }



    /* backing files always opened read-only */

    back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);



    ret = bdrv_open(bs->backing_hd,

                    *backing_filename ? backing_filename : NULL, options,

                    back_flags, back_drv, &local_err);

    if (ret < 0) {

        bdrv_unref(bs->backing_hd);

        bs->backing_hd = NULL;

        bs->open_flags |= BDRV_O_NO_BACKING;

        error_propagate(errp, local_err);

        return ret;

    }

    return 0;

}

int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)

{

    char backing_filename[PATH_MAX];

    int back_flags, ret;

    BlockDriver *back_drv = NULL;

    Error *local_err = NULL;



    if (bs->backing_hd != NULL) {

        QDECREF(options);

        return 0;

    }



    

    if (options == NULL) {

        options = qdict_new();

    }



    bs->open_flags &= ~BDRV_O_NO_BACKING;

    if (qdict_haskey(options, "file.filename")) {

        backing_filename[0] = '\0';

    } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) {

        QDECREF(options);

        return 0;

    }



    bs->backing_hd = bdrv_new("");

    bdrv_get_full_backing_filename(bs, backing_filename,

                                   sizeof(backing_filename));



    if (bs->backing_format[0] != '\0') {

        back_drv = bdrv_find_format(bs->backing_format);

    }



    

    back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);



    ret = bdrv_open(bs->backing_hd,

                    *backing_filename ? backing_filename : NULL, options,

                    back_flags, back_drv, &local_err);

    if (ret < 0) {

        bdrv_unref(bs->backing_hd);

        bs->backing_hd = NULL;

        bs->open_flags |= BDRV_O_NO_BACKING;

        error_propagate(errp, local_err);

        return ret;

    }

    return 0;

}

int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, Error **VAR_2)

{

    char VAR_3[PATH_MAX];

    int VAR_4, VAR_5;

    BlockDriver *back_drv = NULL;

    Error *local_err = NULL;



    if (VAR_0->backing_hd != NULL) {

        QDECREF(VAR_1);

        return 0;

    }



    

    if (VAR_1 == NULL) {

        VAR_1 = qdict_new();

    }



    VAR_0->open_flags &= ~BDRV_O_NO_BACKING;

    if (qdict_haskey(VAR_1, "file.filename")) {

        VAR_3[0] = '\0';

    } else if (VAR_0->backing_file[0] == '\0' && qdict_size(VAR_1) == 0) {

        QDECREF(VAR_1);

        return 0;

    }



    VAR_0->backing_hd = bdrv_new("");

    bdrv_get_full_backing_filename(VAR_0, VAR_3,

                                   sizeof(VAR_3));



    if (VAR_0->backing_format[0] != '\0') {

        back_drv = bdrv_find_format(VAR_0->backing_format);

    }



    

    VAR_4 = VAR_0->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);



    VAR_5 = bdrv_open(VAR_0->backing_hd,

                    *VAR_3 ? VAR_3 : NULL, VAR_1,

                    VAR_4, back_drv, &local_err);

    if (VAR_5 < 0) {

        bdrv_unref(VAR_0->backing_hd);

        VAR_0->backing_hd = NULL;

        VAR_0->open_flags |= BDRV_O_NO_BACKING;

        error_propagate(VAR_2, local_err);

        return VAR_5;

    }

    return 0;

}

int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, Error **VAR_2)
{ char VAR_3[PATH_MAX]; int VAR_4, VAR_5; BlockDriver *back_drv = NULL; Error *local_err = NULL; if (VAR_0->backing_hd != NULL) { QDECREF(VAR_1); return 0; } if (VAR_1 == NULL) { VAR_1 = qdict_new(); } VAR_0->open_flags &= ~BDRV_O_NO_BACKING; if (qdict_haskey(VAR_1, "file.filename")) { VAR_3[0] = '\0'; } else if (VAR_0->backing_file[0] == '\0' && qdict_size(VAR_1) == 0) { QDECREF(VAR_1); return 0; } VAR_0->backing_hd = bdrv_new(""); bdrv_get_full_backing_filename(VAR_0, VAR_3,
sizeof(VAR_3)); if (VAR_0->backing_format[0] != '\0') { back_drv = bdrv_find_format(VAR_0->backing_format); } VAR_4 = VAR_0->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT); VAR_5 = bdrv_open(VAR_0->backing_hd,
*VAR_3 ? VAR_3 : NULL, VAR_1,
VAR_4, back_drv, &local_err); if (VAR_5 < 0) { bdrv_unref(VAR_0->backing_hd); VAR_0->backing_hd = NULL; VAR_0->open_flags |= BDRV_O_NO_BACKING; error_propagate(VAR_2, local_err); return VAR_5; } return 0; }