static int qcow2_set_up_encryption(BlockDriverState *bs, const char *encryptfmt,

                                   QemuOpts *opts, Error **errp)

{

    BDRVQcow2State *s = bs->opaque;

    QCryptoBlockCreateOptions *cryptoopts = NULL;

    QCryptoBlock *crypto = NULL;

    int ret = -EINVAL;

    QDict *options, *encryptopts;



    options = qemu_opts_to_qdict(opts, NULL);

    qdict_extract_subqdict(options, &encryptopts, "encrypt.");

    QDECREF(options);



    if (!g_str_equal(encryptfmt, "aes")) {

        error_setg(errp, "Unknown encryption format '%s', expected 'aes'",

                   encryptfmt);

        ret = -EINVAL;

        goto out;

    }

    cryptoopts = block_crypto_create_opts_init(

        Q_CRYPTO_BLOCK_FORMAT_QCOW, encryptopts, errp);

    if (!cryptoopts) {

        ret = -EINVAL;

        goto out;

    }

    s->crypt_method_header = QCOW_CRYPT_AES;



    crypto = qcrypto_block_create(cryptoopts,

                                  NULL, NULL,

                                  bs, errp);

    if (!crypto) {

        ret = -EINVAL;

        goto out;

    }



    ret = qcow2_update_header(bs);

    if (ret < 0) {

        error_setg_errno(errp, -ret, "Could not write encryption header");

        goto out;

    }



 out:

    QDECREF(encryptopts);

    qcrypto_block_free(crypto);

    qapi_free_QCryptoBlockCreateOptions(cryptoopts);

    return ret;

}

static int qcow2_set_up_encryption(BlockDriverState *bs, const char *encryptfmt,

                                   QemuOpts *opts, Error **errp)

{

    BDRVQcow2State *s = bs->opaque;

    QCryptoBlockCreateOptions *cryptoopts = NULL;

    QCryptoBlock *crypto = NULL;

    int ret = -EINVAL;

    QDict *options, *encryptopts;



    options = qemu_opts_to_qdict(opts, NULL);

    qdict_extract_subqdict(options, &encryptopts, "encrypt.");

    QDECREF(options);



    if (!g_str_equal(encryptfmt, "aes")) {

        error_setg(errp, "Unknown encryption format '%s', expected 'aes'",

                   encryptfmt);

        ret = -EINVAL;

        goto out;

    }

    cryptoopts = block_crypto_create_opts_init(

        Q_CRYPTO_BLOCK_FORMAT_QCOW, encryptopts, errp);

    if (!cryptoopts) {

        ret = -EINVAL;

        goto out;

    }

    s->crypt_method_header = QCOW_CRYPT_AES;



    crypto = qcrypto_block_create(cryptoopts,

                                  NULL, NULL,

                                  bs, errp);

    if (!crypto) {

        ret = -EINVAL;

        goto out;

    }



    ret = qcow2_update_header(bs);

    if (ret < 0) {

        error_setg_errno(errp, -ret, "Could not write encryption header");

        goto out;

    }



 out:

    QDECREF(encryptopts);

    qcrypto_block_free(crypto);

    qapi_free_QCryptoBlockCreateOptions(cryptoopts);

    return ret;

}

        ret = -EINVAL;     if (!g_str_equal(encryptfmt, "aes")) {         error_setg(errp, "Unknown encryption format '%s', expected 'aes'",                    encryptfmt);         ret = -EINVAL;         goto out;     cryptoopts = block_crypto_create_opts_init(         Q_CRYPTO_BLOCK_FORMAT_QCOW, encryptopts, errp);     s->crypt_method_header = QCOW_CRYPT_AES;                                   NULL, NULL,
static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1,

                                   QemuOpts *VAR_2, Error **VAR_3)

{

    BDRVQcow2State *s = VAR_0->opaque;

    QCryptoBlockCreateOptions *cryptoopts = NULL;

    QCryptoBlock *crypto = NULL;

    int VAR_4 = -EINVAL;

    QDict *options, *encryptopts;



    options = qemu_opts_to_qdict(VAR_2, NULL);

    qdict_extract_subqdict(options, &encryptopts, "encrypt.");

    QDECREF(options);



    if (!g_str_equal(VAR_1, "aes")) {

        error_setg(VAR_3, "Unknown encryption format '%s', expected 'aes'",

                   VAR_1);

        VAR_4 = -EINVAL;

        goto out;

    }

    cryptoopts = block_crypto_create_opts_init(

        Q_CRYPTO_BLOCK_FORMAT_QCOW, encryptopts, VAR_3);

    if (!cryptoopts) {

        VAR_4 = -EINVAL;

        goto out;

    }

    s->crypt_method_header = QCOW_CRYPT_AES;



    crypto = qcrypto_block_create(cryptoopts,

                                  NULL, NULL,

                                  VAR_0, VAR_3);

    if (!crypto) {

        VAR_4 = -EINVAL;

        goto out;

    }



    VAR_4 = qcow2_update_header(VAR_0);

    if (VAR_4 < 0) {

        error_setg_errno(VAR_3, -VAR_4, "Could not write encryption header");

        goto out;

    }



 out:

    QDECREF(encryptopts);

    qcrypto_block_free(crypto);

    qapi_free_QCryptoBlockCreateOptions(cryptoopts);

    return VAR_4;

}

static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1,
QemuOpts *VAR_2, Error **VAR_3)
{ BDRVQcow2State *s = VAR_0->opaque; QCryptoBlockCreateOptions *cryptoopts = NULL; QCryptoBlock *crypto = NULL; int VAR_4 = -EINVAL; QDict *options, *encryptopts; options = qemu_opts_to_qdict(VAR_2, NULL); qdict_extract_subqdict(options, &encryptopts, "encrypt."); QDECREF(options); if (!g_str_equal(VAR_1, "aes")) { error_setg(VAR_3, "Unknown encryption format '%s', expected 'aes'",
VAR_1); VAR_4 = -EINVAL; goto out; } cryptoopts = block_crypto_create_opts_init(
Q_CRYPTO_BLOCK_FORMAT_QCOW, encryptopts, VAR_3); if (!cryptoopts) { VAR_4 = -EINVAL; goto out; } s->crypt_method_header = QCOW_CRYPT_AES; crypto = qcrypto_block_create(cryptoopts,
NULL, NULL,
VAR_0, VAR_3); if (!crypto) { VAR_4 = -EINVAL; goto out; } VAR_4 = qcow2_update_header(VAR_0); if (VAR_4 < 0) { error_setg_errno(VAR_3, -VAR_4, "Could not write encryption header"); goto out; } out:
QDECREF(encryptopts); qcrypto_block_free(crypto); qapi_free_QCryptoBlockCreateOptions(cryptoopts); return VAR_4; }