[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v7 09/20] qcow: convert QCow to use QCryptoBlock
From: |
Alberto Garcia |
Subject: |
Re: [Qemu-block] [PATCH v7 09/20] qcow: convert QCow to use QCryptoBlock for encryption |
Date: |
Fri, 26 May 2017 14:03:40 +0200 |
User-agent: |
Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) |
On Thu 25 May 2017 06:38:40 PM CEST, Daniel P. Berrange wrote:
> @@ -105,6 +116,13 @@ static int qcow_open(BlockDriverState *bs, QDict
> *options, int flags,
> int ret;
> QCowHeader header;
> Error *local_err = NULL;
> + QCryptoBlockOpenOptions *crypto_opts = NULL;
> + unsigned int cflags = 0;
> + QDict *encryptopts = NULL;
> + const char *encryptfmt;
> +
> + qdict_extract_subqdict(options, &encryptopts, "encrypt.");
> + encryptfmt = qdict_get_try_str(encryptopts, "format");
>
> bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
> false, errp);
> if (!bs->file) {
> return -EINVAL;
> }
You're leaking encryptopts if the function returns here.
> @@ -873,6 +850,20 @@ static int qcow_create(const char *filename, QemuOpts
> *opts, Error **errp)
> goto exit;
> }
> header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
> +
> + crypto_opts = block_crypto_create_opts_init(
> + Q_CRYPTO_BLOCK_FORMAT_QCOW, encryptopts, &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> + ret = -EINVAL;
> + goto exit;
> + }
Not very important, and my fault for not having pointed it out in my
previous review, but you can spare the error_propagate() call if you
pass errp directly to block_crypto_create_opts_init() and then check if
crypto_opts is NULL.
Actually none of the error_propagate() calls in qcow_create() is really
necessary, but that could be fixed in a separate patch, if at all (it's
not so important).
The leak however needs to be fixed. With that,
Reviewed-by: Alberto Garcia <address@hidden>
Berto
- [Qemu-block] [PATCH v7 01/20] block: expose crypto option names / defs to other drivers, (continued)
- [Qemu-block] [PATCH v7 01/20] block: expose crypto option names / defs to other drivers, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 02/20] block: add ability to set a prefix for opt names, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 03/20] qcow: document another weakness of qcow AES encryption, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 04/20] qcow: require image size to be > 1 for new images, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 05/20] iotests: skip 042 with qcow which dosn't support zero sized images, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 06/20] iotests: skip 048 with qcow which doesn't support resize, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 08/20] qcow: make encrypt_sectors encrypt in place, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 07/20] block: deprecate "encryption=on" in favor of "encrypt.format=aes", Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 09/20] qcow: convert QCow to use QCryptoBlock for encryption, Daniel P. Berrange, 2017/05/25
- Re: [Qemu-block] [PATCH v7 09/20] qcow: convert QCow to use QCryptoBlock for encryption,
Alberto Garcia <=
- [Qemu-block] [PATCH v7 10/20] qcow2: make qcow2_encrypt_sectors encrypt in place, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 12/20] qcow2: extend specification to cover LUKS encryption, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 11/20] qcow2: convert QCow2 to use QCryptoBlock for encryption, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 14/20] qcow2: add iotests to cover LUKS encryption support, Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 15/20] iotests: enable tests 134 and 158 to work with qcow (v1), Daniel P. Berrange, 2017/05/25
- [Qemu-block] [PATCH v7 13/20] qcow2: add support for LUKS encryption format, Daniel P. Berrange, 2017/05/25