static int read_config(BDRVBlkdebugState *s, const char *filename, Error **errp)

{

    FILE *f;

    int ret;

    struct add_rule_data d;



    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;

    }



    d.s = s;

    d.action = ACTION_INJECT_ERROR;

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



    d.action = ACTION_SET_STATE;

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



    ret = 0;

fail:

    qemu_opts_reset(&inject_error_opts);

    qemu_opts_reset(&set_state_opts);

    fclose(f);

    return ret;

}

static int read_config(BDRVBlkdebugState *s, const char *filename, Error **errp)

{

    FILE *f;

    int ret;

    struct add_rule_data d;



    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;

    }



    d.s = s;

    d.action = ACTION_INJECT_ERROR;

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



    d.action = ACTION_SET_STATE;

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



    ret = 0;

fail:

    qemu_opts_reset(&inject_error_opts);

    qemu_opts_reset(&set_state_opts);

    fclose(f);

    return ret;

}

static int FUNC_0(BDRVBlkdebugState *VAR_0, const char *VAR_1, Error **VAR_2)

{

    FILE *f;

    int VAR_3;

    struct add_rule_data VAR_4;



    f = fopen(VAR_1, "r");

    if (f == NULL) {

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

        return -errno;

    }



    VAR_3 = qemu_config_parse(f, config_groups, VAR_1);

    if (VAR_3 < 0) {

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

        VAR_3 = -EINVAL;

        goto fail;

    }



    VAR_4.VAR_0 = VAR_0;

    VAR_4.action = ACTION_INJECT_ERROR;

    qemu_opts_foreach(&inject_error_opts, add_rule, &VAR_4, 0);



    VAR_4.action = ACTION_SET_STATE;

    qemu_opts_foreach(&set_state_opts, add_rule, &VAR_4, 0);



    VAR_3 = 0;

fail:

    qemu_opts_reset(&inject_error_opts);

    qemu_opts_reset(&set_state_opts);

    fclose(f);

    return VAR_3;

}

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