static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,

                         Error **errp)

{

    BDRVBlkdebugState *s = bs->opaque;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *config;

    uint64_t align;

    int ret;



    opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (error_is_set(&local_err)) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    /* Read rules from config file or command line options */

    config = qemu_opt_get(opts, "config");

    ret = read_config(s, config, options, errp);

    if (ret) {

        goto fail;

    }



    /* Set initial state */

    s->state = 1;



    /* Open the backing file */

    ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-image"), options, "image",

                          flags, true, false, &local_err);

    if (ret < 0) {

        error_propagate(errp, local_err);

        goto fail;

    }



    /* Set request alignment */

    align = qemu_opt_get_size(opts, "align", bs->request_alignment);

    if (align > 0 && align < INT_MAX && !(align & (align - 1))) {

        bs->request_alignment = align;

    } else {

        error_setg(errp, "Invalid alignment");

        ret = -EINVAL;

        goto fail;

    }



    ret = 0;

fail:

    qemu_opts_del(opts);

    return ret;

}

static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,

                         Error **errp)

{

    BDRVBlkdebugState *s = bs->opaque;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *config;

    uint64_t align;

    int ret;



    opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (error_is_set(&local_err)) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    

    config = qemu_opt_get(opts, "config");

    ret = read_config(s, config, options, errp);

    if (ret) {

        goto fail;

    }



    

    s->state = 1;



    

    ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-image"), options, "image",

                          flags, true, false, &local_err);

    if (ret < 0) {

        error_propagate(errp, local_err);

        goto fail;

    }



    

    align = qemu_opt_get_size(opts, "align", bs->request_alignment);

    if (align > 0 && align < INT_MAX && !(align & (align - 1))) {

        bs->request_alignment = align;

    } else {

        error_setg(errp, "Invalid alignment");

        ret = -EINVAL;

        goto fail;

    }



    ret = 0;

fail:

    qemu_opts_del(opts);

    return ret;

}

        goto fail;         goto fail;         goto fail;         goto fail; fail:
static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,

                         Error **VAR_3)

{

    BDRVBlkdebugState *s = VAR_0->opaque;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *VAR_4;

    uint64_t align;

    int VAR_5;



    opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);

    qemu_opts_absorb_qdict(opts, VAR_1, &local_err);

    if (error_is_set(&local_err)) {

        error_propagate(VAR_3, local_err);

        VAR_5 = -EINVAL;

        goto fail;

    }



    

    VAR_4 = qemu_opt_get(opts, "VAR_4");

    VAR_5 = read_config(s, VAR_4, VAR_1, VAR_3);

    if (VAR_5) {

        goto fail;

    }



    

    s->state = 1;



    

    VAR_5 = bdrv_open_image(&VAR_0->file, qemu_opt_get(opts, "x-image"), VAR_1, "image",

                          VAR_2, true, false, &local_err);

    if (VAR_5 < 0) {

        error_propagate(VAR_3, local_err);

        goto fail;

    }



    

    align = qemu_opt_get_size(opts, "align", VAR_0->request_alignment);

    if (align > 0 && align < INT_MAX && !(align & (align - 1))) {

        VAR_0->request_alignment = align;

    } else {

        error_setg(VAR_3, "Invalid alignment");

        VAR_5 = -EINVAL;

        goto fail;

    }



    VAR_5 = 0;

fail:

    qemu_opts_del(opts);

    return VAR_5;

}

static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{ BDRVBlkdebugState *s = VAR_0->opaque; QemuOpts *opts; Error *local_err = NULL; const char *VAR_4; uint64_t align; int VAR_5; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, VAR_1, &local_err); if (error_is_set(&local_err)) { error_propagate(VAR_3, local_err); VAR_5 = -EINVAL; goto fail; } VAR_4 = qemu_opt_get(opts, "VAR_4"); VAR_5 = read_config(s, VAR_4, VAR_1, VAR_3); if (VAR_5) { goto fail; } s->state = 1; VAR_5 = bdrv_open_image(&VAR_0->file, qemu_opt_get(opts, "x-image"), VAR_1, "image",
VAR_2, true, false, &local_err); if (VAR_5 < 0) { error_propagate(VAR_3, local_err); goto fail; } align = qemu_opt_get_size(opts, "align", VAR_0->request_alignment); if (align > 0 && align < INT_MAX && !(align & (align - 1))) { VAR_0->request_alignment = align; } else { error_setg(VAR_3, "Invalid alignment"); VAR_5 = -EINVAL; goto fail; } VAR_5 = 0; fail:
qemu_opts_del(opts); return VAR_5; }