static int block_crypto_create_generic(QCryptoBlockFormat format,

                                       const char *filename,

                                       QemuOpts *opts,

                                       Error **errp)

{

    int ret = -EINVAL;

    QCryptoBlockCreateOptions *create_opts = NULL;

    QCryptoBlock *crypto = NULL;

    struct BlockCryptoCreateData data = {

        .size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),

                         BDRV_SECTOR_SIZE),

        .opts = opts,

        .filename = filename,

    };



    create_opts = block_crypto_create_opts_init(format, opts, errp);

    if (!create_opts) {

        return -1;

    }



    crypto = qcrypto_block_create(create_opts,

                                  block_crypto_init_func,

                                  block_crypto_write_func,

                                  &data,

                                  errp);



    if (!crypto) {

        ret = -EIO;

        goto cleanup;

    }



    ret = 0;

 cleanup:

    qcrypto_block_free(crypto);

    blk_unref(data.blk);

    qapi_free_QCryptoBlockCreateOptions(create_opts);

    return ret;

}

static int block_crypto_create_generic(QCryptoBlockFormat format,

                                       const char *filename,

                                       QemuOpts *opts,

                                       Error **errp)

{

    int ret = -EINVAL;

    QCryptoBlockCreateOptions *create_opts = NULL;

    QCryptoBlock *crypto = NULL;

    struct BlockCryptoCreateData data = {

        .size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),

                         BDRV_SECTOR_SIZE),

        .opts = opts,

        .filename = filename,

    };



    create_opts = block_crypto_create_opts_init(format, opts, errp);

    if (!create_opts) {

        return -1;

    }



    crypto = qcrypto_block_create(create_opts,

                                  block_crypto_init_func,

                                  block_crypto_write_func,

                                  &data,

                                  errp);



    if (!crypto) {

        ret = -EIO;

        goto cleanup;

    }



    ret = 0;

 cleanup:

    qcrypto_block_free(crypto);

    blk_unref(data.blk);

    qapi_free_QCryptoBlockCreateOptions(create_opts);

    return ret;

}

static int FUNC_0(QCryptoBlockFormat VAR_0,

                                       const char *VAR_1,

                                       QemuOpts *VAR_2,

                                       Error **VAR_3)

{

    int VAR_4 = -EINVAL;

    QCryptoBlockCreateOptions *create_opts = NULL;

    QCryptoBlock *crypto = NULL;

    struct BlockCryptoCreateData VAR_5 = {

        .size = ROUND_UP(qemu_opt_get_size_del(VAR_2, BLOCK_OPT_SIZE, 0),

                         BDRV_SECTOR_SIZE),

        .VAR_2 = VAR_2,

        .VAR_1 = VAR_1,

    };



    create_opts = block_crypto_create_opts_init(VAR_0, VAR_2, VAR_3);

    if (!create_opts) {

        return -1;

    }



    crypto = qcrypto_block_create(create_opts,

                                  block_crypto_init_func,

                                  block_crypto_write_func,

                                  &VAR_5,

                                  VAR_3);



    if (!crypto) {

        VAR_4 = -EIO;

        goto cleanup;

    }



    VAR_4 = 0;

 cleanup:

    qcrypto_block_free(crypto);

    blk_unref(VAR_5.blk);

    qapi_free_QCryptoBlockCreateOptions(create_opts);

    return VAR_4;

}

static int FUNC_0(QCryptoBlockFormat VAR_0,
const char *VAR_1,
QemuOpts *VAR_2,
Error **VAR_3)
{ int VAR_4 = -EINVAL; QCryptoBlockCreateOptions *create_opts = NULL; QCryptoBlock *crypto = NULL; struct BlockCryptoCreateData VAR_5 = { .size = ROUND_UP(qemu_opt_get_size_del(VAR_2, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE),
.VAR_2 = VAR_2,
.VAR_1 = VAR_1,
}; create_opts = block_crypto_create_opts_init(VAR_0, VAR_2, VAR_3); if (!create_opts) { return -1; } crypto = qcrypto_block_create(create_opts,
block_crypto_init_func,
block_crypto_write_func,
&VAR_5,
VAR_3); if (!crypto) { VAR_4 = -EIO; goto cleanup; } VAR_4 = 0; cleanup:
qcrypto_block_free(crypto); blk_unref(VAR_5.blk); qapi_free_QCryptoBlockCreateOptions(create_opts); return VAR_4; }