static int read_config(BDRVBlkdebugState *s, const char *filename,

                       QDict *options, Error **errp)

{

    FILE *f = NULL;

    int ret;

    struct add_rule_data d;

    Error *local_err = NULL;



    if (filename) {

        f = fopen(filename, "r");

        if (f == NULL) {

            error_setg_errno(errp, errno, "Could not read blkdebug config file");

            return -errno;

        }



        ret = qemu_config_parse(f, config_groups, filename);

        if (ret < 0) {

            error_setg(errp, "Could not parse blkdebug config file");

            ret = -EINVAL;

            goto fail;

        }

    }



    qemu_config_parse_qdict(options, config_groups, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    d.s = s;

    d.action = ACTION_INJECT_ERROR;

    qemu_opts_foreach(&inject_error_opts, add_rule, &d, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    d.action = ACTION_SET_STATE;

    qemu_opts_foreach(&set_state_opts, add_rule, &d, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    ret = 0;

fail:

    qemu_opts_reset(&inject_error_opts);

    qemu_opts_reset(&set_state_opts);

    if (f) {

        fclose(f);

    }

    return ret;

}

static int read_config(BDRVBlkdebugState *s, const char *filename,

                       QDict *options, Error **errp)

{

    FILE *f = NULL;

    int ret;

    struct add_rule_data d;

    Error *local_err = NULL;



    if (filename) {

        f = fopen(filename, "r");

        if (f == NULL) {

            error_setg_errno(errp, errno, "Could not read blkdebug config file");

            return -errno;

        }



        ret = qemu_config_parse(f, config_groups, filename);

        if (ret < 0) {

            error_setg(errp, "Could not parse blkdebug config file");

            ret = -EINVAL;

            goto fail;

        }

    }



    qemu_config_parse_qdict(options, config_groups, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    d.s = s;

    d.action = ACTION_INJECT_ERROR;

    qemu_opts_foreach(&inject_error_opts, add_rule, &d, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    d.action = ACTION_SET_STATE;

    qemu_opts_foreach(&set_state_opts, add_rule, &d, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    ret = 0;

fail:

    qemu_opts_reset(&inject_error_opts);

    qemu_opts_reset(&set_state_opts);

    if (f) {

        fclose(f);

    }

    return ret;

}

static int FUNC_0(BDRVBlkdebugState *VAR_0, const char *VAR_1,

                       QDict *VAR_2, Error **VAR_3)

{

    FILE *f = NULL;

    int VAR_4;

    struct add_rule_data VAR_5;

    Error *local_err = NULL;



    if (VAR_1) {

        f = fopen(VAR_1, "r");

        if (f == NULL) {

            error_setg_errno(VAR_3, errno, "Could not read blkdebug config file");

            return -errno;

        }



        VAR_4 = qemu_config_parse(f, config_groups, VAR_1);

        if (VAR_4 < 0) {

            error_setg(VAR_3, "Could not parse blkdebug config file");

            VAR_4 = -EINVAL;

            goto fail;

        }

    }



    qemu_config_parse_qdict(VAR_2, config_groups, &local_err);

    if (local_err) {

        error_propagate(VAR_3, local_err);

        VAR_4 = -EINVAL;

        goto fail;

    }



    VAR_5.VAR_0 = VAR_0;

    VAR_5.action = ACTION_INJECT_ERROR;

    qemu_opts_foreach(&inject_error_opts, add_rule, &VAR_5, &local_err);

    if (local_err) {

        error_propagate(VAR_3, local_err);

        VAR_4 = -EINVAL;

        goto fail;

    }



    VAR_5.action = ACTION_SET_STATE;

    qemu_opts_foreach(&set_state_opts, add_rule, &VAR_5, &local_err);

    if (local_err) {

        error_propagate(VAR_3, local_err);

        VAR_4 = -EINVAL;

        goto fail;

    }



    VAR_4 = 0;

fail:

    qemu_opts_reset(&inject_error_opts);

    qemu_opts_reset(&set_state_opts);

    if (f) {

        fclose(f);

    }

    return VAR_4;

}

static int FUNC_0(BDRVBlkdebugState *VAR_0, const char *VAR_1,
QDict *VAR_2, Error **VAR_3)
{ FILE *f = NULL; int VAR_4; struct add_rule_data VAR_5; Error *local_err = NULL; if (VAR_1) { f = fopen(VAR_1, "r"); if (f == NULL) { error_setg_errno(VAR_3, errno, "Could not read blkdebug config file"); return -errno; } VAR_4 = qemu_config_parse(f, config_groups, VAR_1); if (VAR_4 < 0) { error_setg(VAR_3, "Could not parse blkdebug config file"); VAR_4 = -EINVAL; goto fail; } } qemu_config_parse_qdict(VAR_2, config_groups, &local_err); if (local_err) { error_propagate(VAR_3, local_err); VAR_4 = -EINVAL; goto fail; } VAR_5.VAR_0 = VAR_0; VAR_5.action = ACTION_INJECT_ERROR; qemu_opts_foreach(&inject_error_opts, add_rule, &VAR_5, &local_err); if (local_err) { error_propagate(VAR_3, local_err); VAR_4 = -EINVAL; goto fail; } VAR_5.action = ACTION_SET_STATE; qemu_opts_foreach(&set_state_opts, add_rule, &VAR_5, &local_err); if (local_err) { error_propagate(VAR_3, local_err); VAR_4 = -EINVAL; goto fail; } VAR_4 = 0; fail:
qemu_opts_reset(&inject_error_opts); qemu_opts_reset(&set_state_opts); if (f) { fclose(f); } return VAR_4; }