static int block_crypto_open_generic(QCryptoBlockFormat format,

                                     QemuOptsList *opts_spec,

                                     BlockDriverState *bs,

                                     QDict *options,

                                     int flags,

                                     Error **errp)

{

    BlockCrypto *crypto = bs->opaque;

    QemuOpts *opts = NULL;

    Error *local_err = NULL;

    int ret = -EINVAL;

    QCryptoBlockOpenOptions *open_opts = NULL;

    unsigned int cflags = 0;



    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,

                               false, errp);

    if (!bs->file) {

        return -EINVAL;

    }



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

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        goto cleanup;

    }



    open_opts = block_crypto_open_opts_init(format, opts, errp);

    if (!open_opts) {

        goto cleanup;

    }



    if (flags & BDRV_O_NO_IO) {

        cflags |= QCRYPTO_BLOCK_OPEN_NO_IO;

    }

    crypto->block = qcrypto_block_open(open_opts,

                                       block_crypto_read_func,

                                       bs,

                                       cflags,

                                       errp);



    if (!crypto->block) {

        ret = -EIO;

        goto cleanup;

    }



    bs->encrypted = true;

    bs->valid_key = true;



    ret = 0;

 cleanup:

    qapi_free_QCryptoBlockOpenOptions(open_opts);

    return ret;

}

static int block_crypto_open_generic(QCryptoBlockFormat format,

                                     QemuOptsList *opts_spec,

                                     BlockDriverState *bs,

                                     QDict *options,

                                     int flags,

                                     Error **errp)

{

    BlockCrypto *crypto = bs->opaque;

    QemuOpts *opts = NULL;

    Error *local_err = NULL;

    int ret = -EINVAL;

    QCryptoBlockOpenOptions *open_opts = NULL;

    unsigned int cflags = 0;



    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,

                               false, errp);

    if (!bs->file) {

        return -EINVAL;

    }



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

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        goto cleanup;

    }



    open_opts = block_crypto_open_opts_init(format, opts, errp);

    if (!open_opts) {

        goto cleanup;

    }



    if (flags & BDRV_O_NO_IO) {

        cflags |= QCRYPTO_BLOCK_OPEN_NO_IO;

    }

    crypto->block = qcrypto_block_open(open_opts,

                                       block_crypto_read_func,

                                       bs,

                                       cflags,

                                       errp);



    if (!crypto->block) {

        ret = -EIO;

        goto cleanup;

    }



    bs->encrypted = true;

    bs->valid_key = true;



    ret = 0;

 cleanup:

    qapi_free_QCryptoBlockOpenOptions(open_opts);

    return ret;

}

static int FUNC_0(QCryptoBlockFormat VAR_0,

                                     QemuOptsList *VAR_1,

                                     BlockDriverState *VAR_2,

                                     QDict *VAR_3,

                                     int VAR_4,

                                     Error **VAR_5)

{

    BlockCrypto *crypto = VAR_2->opaque;

    QemuOpts *opts = NULL;

    Error *local_err = NULL;

    int VAR_6 = -EINVAL;

    QCryptoBlockOpenOptions *open_opts = NULL;

    unsigned int VAR_7 = 0;



    VAR_2->file = bdrv_open_child(NULL, VAR_3, "file", VAR_2, &child_file,

                               false, VAR_5);

    if (!VAR_2->file) {

        return -EINVAL;

    }



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

    qemu_opts_absorb_qdict(opts, VAR_3, &local_err);

    if (local_err) {

        error_propagate(VAR_5, local_err);

        goto cleanup;

    }



    open_opts = block_crypto_open_opts_init(VAR_0, opts, VAR_5);

    if (!open_opts) {

        goto cleanup;

    }



    if (VAR_4 & BDRV_O_NO_IO) {

        VAR_7 |= QCRYPTO_BLOCK_OPEN_NO_IO;

    }

    crypto->block = qcrypto_block_open(open_opts,

                                       block_crypto_read_func,

                                       VAR_2,

                                       VAR_7,

                                       VAR_5);



    if (!crypto->block) {

        VAR_6 = -EIO;

        goto cleanup;

    }



    VAR_2->encrypted = true;

    VAR_2->valid_key = true;



    VAR_6 = 0;

 cleanup:

    qapi_free_QCryptoBlockOpenOptions(open_opts);

    return VAR_6;

}

static int FUNC_0(QCryptoBlockFormat VAR_0,
QemuOptsList *VAR_1,
BlockDriverState *VAR_2,
QDict *VAR_3,
int VAR_4,
Error **VAR_5)
{ BlockCrypto *crypto = VAR_2->opaque; QemuOpts *opts = NULL; Error *local_err = NULL; int VAR_6 = -EINVAL; QCryptoBlockOpenOptions *open_opts = NULL; unsigned int VAR_7 = 0; VAR_2->file = bdrv_open_child(NULL, VAR_3, "file", VAR_2, &child_file,
false, VAR_5); if (!VAR_2->file) { return -EINVAL; } opts = qemu_opts_create(VAR_1, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, VAR_3, &local_err); if (local_err) { error_propagate(VAR_5, local_err); goto cleanup; } open_opts = block_crypto_open_opts_init(VAR_0, opts, VAR_5); if (!open_opts) { goto cleanup; } if (VAR_4 & BDRV_O_NO_IO) { VAR_7 |= QCRYPTO_BLOCK_OPEN_NO_IO; } crypto->block = qcrypto_block_open(open_opts,
block_crypto_read_func,
VAR_2,
VAR_7,
VAR_5); if (!crypto->block) { VAR_6 = -EIO; goto cleanup; } VAR_2->encrypted = true; VAR_2->valid_key = true; VAR_6 = 0; cleanup:
qapi_free_QCryptoBlockOpenOptions(open_opts); return VAR_6; }