From nobody Mon Feb 9 04:44:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486746739467158.77794015458642; Fri, 10 Feb 2017 09:12:19 -0800 (PST) Received: from localhost ([::1]:45025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccEk3-0004X7-TD for importer@patchew.org; Fri, 10 Feb 2017 12:12:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccEhv-0003C0-VM for qemu-devel@nongnu.org; Fri, 10 Feb 2017 12:10:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccEhr-0003SJ-Ao for qemu-devel@nongnu.org; Fri, 10 Feb 2017 12:10:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35156) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ccEhh-0003L1-Gz; Fri, 10 Feb 2017 12:09:49 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B73748047A; Fri, 10 Feb 2017 17:09:49 +0000 (UTC) Received: from t460.redhat.com (ovpn-117-251.ams2.redhat.com [10.36.117.251]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1AH9FKX031036; Fri, 10 Feb 2017 12:09:47 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Fri, 10 Feb 2017 17:09:03 +0000 Message-Id: <20170210170910.8867-12-berrange@redhat.com> In-Reply-To: <20170210170910.8867-1-berrange@redhat.com> References: <20170210170910.8867-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 10 Feb 2017 17:09:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 11/18] qcow2: convert QCow2 to use QCryptoBlock for encryption X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This converts the qcow2 driver to make use of the QCryptoBlock APIs for encrypting image content, using the legacyy QCow2 AES scheme. With this change it is now required to use the QCryptoSecret object for providing passwords, instead of the current block password APIs / interactive prompting. $QEMU \ -object secret,id=3Dsec0,filename=3D/home/berrange/encrypted.pw \ -drive file=3D/home/berrange/encrypted.qcow2,aes-key-secret=3Dsec0 The test 087 could be simplified since there is no longer a difference in behaviour when using blockdev_add with encrypted images for the running vs stopped CPU state. Signed-off-by: Daniel P. Berrange Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 47 +---------- block/qcow2.c | 192 +++++++++++++++++++++++++++++------------= ---- block/qcow2.h | 5 +- qapi/block-core.json | 8 +- tests/qemu-iotests/049 | 2 +- tests/qemu-iotests/049.out | 4 +- tests/qemu-iotests/082.out | 27 +++++++ tests/qemu-iotests/087 | 27 +++---- tests/qemu-iotests/087.out | 12 +-- tests/qemu-iotests/134 | 18 +++-- tests/qemu-iotests/134.out | 10 +-- tests/qemu-iotests/158 | 19 +++-- tests/qemu-iotests/158.out | 14 +--- tests/qemu-iotests/common | 10 ++- 14 files changed, 214 insertions(+), 181 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 907e869..a2103dc 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -345,47 +345,6 @@ static int count_contiguous_clusters_by_type(int nb_cl= usters, return i; } =20 -/* The crypt function is compatible with the linux cryptoloop - algorithm for < 4 GB images. */ -int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num, - uint8_t *buf, int nb_sectors, bool enc, - Error **errp) -{ - union { - uint64_t ll[2]; - uint8_t b[16]; - } ivec; - int i; - int ret; - - for(i =3D 0; i < nb_sectors; i++) { - ivec.ll[0] =3D cpu_to_le64(sector_num); - ivec.ll[1] =3D 0; - if (qcrypto_cipher_setiv(s->cipher, - ivec.b, G_N_ELEMENTS(ivec.b), - errp) < 0) { - return -1; - } - if (enc) { - ret =3D qcrypto_cipher_encrypt(s->cipher, - buf, buf, - 512, - errp); - } else { - ret =3D qcrypto_cipher_decrypt(s->cipher, - buf, buf, - 512, - errp); - } - if (ret < 0) { - return -1; - } - sector_num++; - buf +=3D 512; - } - return 0; -} - static int coroutine_fn do_perform_cow(BlockDriverState *bs, uint64_t src_cluster_offset, uint64_t cluster_offset, @@ -426,11 +385,11 @@ static int coroutine_fn do_perform_cow(BlockDriverSta= te *bs, Error *err =3D NULL; int64_t sector =3D (src_cluster_offset + offset_in_cluster) >> BDRV_SECTOR_BITS; - assert(s->cipher); assert((offset_in_cluster & ~BDRV_SECTOR_MASK) =3D=3D 0); assert((bytes & ~BDRV_SECTOR_MASK) =3D=3D 0); - if (qcow2_encrypt_sectors(s, sector, iov.iov_base, - bytes >> BDRV_SECTOR_BITS, true, &err) <= 0) { + assert(s->crypto); + if (qcrypto_block_encrypt(s->crypto, sector, iov.iov_base, + bytes, &err) < 0) { ret =3D -EIO; error_free(err); goto out; diff --git a/block/qcow2.c b/block/qcow2.c index 3c14c86..0859d04 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -37,6 +37,9 @@ #include "qemu/option_int.h" #include "qemu/cutils.h" #include "qemu/bswap.h" +#include "qapi/opts-visitor.h" +#include "qapi-visit.h" +#include "block/crypto.h" =20 /* Differences with QCOW: @@ -461,6 +464,7 @@ static QemuOptsList qcow2_runtime_opts =3D { .type =3D QEMU_OPT_NUMBER, .help =3D "Clean unused cache entries after this time (in seco= nds)", }, + BLOCK_CRYPTO_OPT_DEF_QCOW_KEY_SECRET("aes-"), { /* end of list */ } }, }; @@ -578,6 +582,7 @@ static void read_cache_sizes(BlockDriverState *bs, Qemu= Opts *opts, } } =20 + typedef struct Qcow2ReopenState { Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; @@ -585,6 +590,7 @@ typedef struct Qcow2ReopenState { int overlap_check; bool discard_passthrough[QCOW2_DISCARD_MAX]; uint64_t cache_clean_interval; + QCryptoBlockOpenOptions *crypto_opts; /* Disk encryption runtime optio= ns */ } Qcow2ReopenState; =20 static int qcow2_update_options_prepare(BlockDriverState *bs, @@ -751,6 +757,25 @@ static int qcow2_update_options_prepare(BlockDriverSta= te *bs, r->discard_passthrough[QCOW2_DISCARD_OTHER] =3D qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); =20 + switch (s->crypt_method_header) { + case QCOW_CRYPT_NONE: + break; + + case QCOW_CRYPT_AES: + r->crypto_opts =3D block_crypto_open_opts_init( + Q_CRYPTO_BLOCK_FORMAT_QCOW, opts, "aes-", errp); + break; + + default: + break; + } + if (s->crypt_method_header && !r->crypto_opts) { + error_setg(errp, "Unsupported encryption method %d", + s->crypt_method_header); + ret =3D -EINVAL; + goto fail; + } + ret =3D 0; fail: qemu_opts_del(opts); @@ -785,6 +810,9 @@ static void qcow2_update_options_commit(BlockDriverStat= e *bs, s->cache_clean_interval =3D r->cache_clean_interval; cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); } + + qapi_free_QCryptoBlockOpenOptions(s->crypto_opts); + s->crypto_opts =3D r->crypto_opts; } =20 static void qcow2_update_options_abort(BlockDriverState *bs, @@ -796,6 +824,7 @@ static void qcow2_update_options_abort(BlockDriverState= *bs, if (r->refcount_block_cache) { qcow2_cache_destroy(bs, r->refcount_block_cache); } + qapi_free_QCryptoBlockOpenOptions(r->crypto_opts); } =20 static int qcow2_update_options(BlockDriverState *bs, QDict *options, @@ -967,12 +996,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *opt= ions, int flags, ret =3D -EINVAL; goto fail; } - if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128, - QCRYPTO_CIPHER_MODE_CBC)) { - error_setg(errp, "AES cipher not available"); - ret =3D -EINVAL; - goto fail; - } s->crypt_method_header =3D header.crypt_method; if (s->crypt_method_header) { if (bdrv_uses_whitelist() && @@ -990,6 +1013,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *opt= ions, int flags, } =20 bs->encrypted =3D true; + bs->valid_key =3D true; } =20 s->l2_bits =3D s->cluster_bits - 3; /* L2 is always one cluster */ @@ -1122,6 +1146,24 @@ static int qcow2_open(BlockDriverState *bs, QDict *o= ptions, int flags, goto fail; } =20 + if (s->crypt_method_header =3D=3D QCOW_CRYPT_AES) { + unsigned int cflags =3D 0; + if (flags & BDRV_O_NO_IO) { + cflags |=3D QCRYPTO_BLOCK_OPEN_NO_IO; + } + /* TODO how do we pass the same crypto opts down to the + * backing file by default, so we don't have to manually + * provide the same key-secret property against the full + * backing chain + */ + s->crypto =3D qcrypto_block_open(s->crypto_opts, NULL, NULL, + cflags, errp); + if (!s->crypto) { + ret =3D -EINVAL; + goto fail; + } + } + /* read the backing file name */ if (header.backing_file_offset !=3D 0) { len =3D header.backing_file_size; @@ -1217,41 +1259,6 @@ static void qcow2_refresh_limits(BlockDriverState *b= s, Error **errp) bs->bl.pdiscard_alignment =3D s->cluster_size; } =20 -static int qcow2_set_key(BlockDriverState *bs, const char *key) -{ - BDRVQcow2State *s =3D bs->opaque; - uint8_t keybuf[16]; - int len, i; - Error *err =3D NULL; - - memset(keybuf, 0, 16); - len =3D strlen(key); - if (len > 16) - len =3D 16; - /* XXX: we could compress the chars to 7 bits to increase - entropy */ - for(i =3D 0;i < len;i++) { - keybuf[i] =3D key[i]; - } - assert(bs->encrypted); - - qcrypto_cipher_free(s->cipher); - s->cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_AES_128, - QCRYPTO_CIPHER_MODE_CBC, - keybuf, G_N_ELEMENTS(keybuf), - &err); - - if (!s->cipher) { - /* XXX would be nice if errors in this method could - * be properly propagate to the caller. Would need - * the bdrv_set_key() API signature to be fixed. */ - error_free(err); - return -1; - } - return 0; -} - static int qcow2_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { @@ -1367,7 +1374,7 @@ static int64_t coroutine_fn qcow2_co_get_block_status= (BlockDriverState *bs, *pnum =3D bytes >> BDRV_SECTOR_BITS; =20 if (cluster_offset !=3D 0 && ret !=3D QCOW2_CLUSTER_COMPRESSED && - !s->cipher) { + !s->crypto) { index_in_cluster =3D sector_num & (s->cluster_sectors - 1); cluster_offset |=3D (index_in_cluster << BDRV_SECTOR_BITS); *file =3D bs->file->bs; @@ -1424,7 +1431,7 @@ static coroutine_fn int qcow2_co_preadv(BlockDriverSt= ate *bs, uint64_t offset, =20 /* prepare next request */ cur_bytes =3D MIN(bytes, INT_MAX); - if (s->cipher) { + if (s->crypto) { cur_bytes =3D MIN(cur_bytes, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); } @@ -1493,7 +1500,7 @@ static coroutine_fn int qcow2_co_preadv(BlockDriverSt= ate *bs, uint64_t offset, } =20 if (bs->encrypted) { - assert(s->cipher); + assert(s->crypto); =20 /* * For encrypted images, read everything into a temporary @@ -1525,14 +1532,15 @@ static coroutine_fn int qcow2_co_preadv(BlockDriver= State *bs, uint64_t offset, goto fail; } if (bs->encrypted) { - assert(s->cipher); + assert(s->crypto); assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); Error *err =3D NULL; - if (qcow2_encrypt_sectors(s, offset >> BDRV_SECTOR_BITS, + if (qcrypto_block_decrypt(s->crypto, + offset >> BDRV_SECTOR_BITS, cluster_data, - cur_bytes >> BDRV_SECTOR_BITS, - false, &err) < 0) { + cur_bytes, + &err) < 0) { error_free(err); ret =3D -EIO; goto fail; @@ -1610,7 +1618,7 @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverS= tate *bs, uint64_t offset, =20 if (bs->encrypted) { Error *err =3D NULL; - assert(s->cipher); + assert(s->crypto); if (!cluster_data) { cluster_data =3D qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS @@ -1625,10 +1633,9 @@ static coroutine_fn int qcow2_co_pwritev(BlockDriver= State *bs, uint64_t offset, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); qemu_iovec_to_buf(&hd_qiov, 0, cluster_data, hd_qiov.size); =20 - if (qcow2_encrypt_sectors(s, offset >> BDRV_SECTOR_BITS, + if (qcrypto_block_encrypt(s->crypto, offset >> BDRV_SECTOR_BIT= S, cluster_data, - cur_bytes >>BDRV_SECTOR_BITS, - true, &err) < 0) { + cur_bytes, &err) < 0) { error_free(err); ret =3D -EIO; goto fail; @@ -1747,8 +1754,8 @@ static void qcow2_close(BlockDriverState *bs) qcow2_cache_destroy(bs, s->l2_table_cache); qcow2_cache_destroy(bs, s->refcount_block_cache); =20 - qcrypto_cipher_free(s->cipher); - s->cipher =3D NULL; + qcrypto_block_free(s->crypto); + s->crypto =3D NULL; =20 g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); @@ -1766,7 +1773,7 @@ static void qcow2_invalidate_cache(BlockDriverState *= bs, Error **errp) { BDRVQcow2State *s =3D bs->opaque; int flags =3D s->flags; - QCryptoCipher *cipher =3D NULL; + QCryptoBlock *crypto =3D NULL; QDict *options; Error *local_err =3D NULL; int ret; @@ -1776,8 +1783,8 @@ static void qcow2_invalidate_cache(BlockDriverState *= bs, Error **errp) * that means we don't have to worry about reopening them here. */ =20 - cipher =3D s->cipher; - s->cipher =3D NULL; + crypto =3D s->crypto; + s->crypto =3D NULL; =20 qcow2_close(bs); =20 @@ -1798,7 +1805,7 @@ static void qcow2_invalidate_cache(BlockDriverState *= bs, Error **errp) return; } =20 - s->cipher =3D cipher; + s->crypto =3D crypto; } =20 static size_t header_ext_add(char *buf, uint32_t magic, const void *s, @@ -2022,6 +2029,44 @@ static int qcow2_change_backing_file(BlockDriverStat= e *bs, return qcow2_update_header(bs); } =20 + +static int qcow2_set_up_encryption(BlockDriverState *bs, QemuOpts *opts, + Error **errp) +{ + BDRVQcow2State *s =3D bs->opaque; + QCryptoBlockCreateOptions *cryptoopts =3D NULL; + QCryptoBlock *crypto =3D NULL; + int ret =3D -EINVAL; + + cryptoopts =3D block_crypto_create_opts_init( + Q_CRYPTO_BLOCK_FORMAT_QCOW, opts, "aes-", errp); + if (!cryptoopts) { + ret =3D -EINVAL; + goto out; + } + s->crypt_method_header =3D QCOW_CRYPT_AES; + + crypto =3D qcrypto_block_create(cryptoopts, + NULL, NULL, + bs, errp); + if (!crypto) { + ret =3D -EINVAL; + goto out; + } + + ret =3D qcow2_update_header(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Could not write encryption header"); + goto out; + } + + out: + qcrypto_block_free(crypto); + qapi_free_QCryptoBlockCreateOptions(cryptoopts); + return ret; +} + + static int preallocate(BlockDriverState *bs) { uint64_t bytes; @@ -2214,11 +2259,8 @@ static int qcow2_create2(const char *filename, int64= _t total_size, .header_length =3D cpu_to_be32(sizeof(*header)), }; =20 - if (flags & BLOCK_FLAG_ENCRYPT) { - header->crypt_method =3D cpu_to_be32(QCOW_CRYPT_AES); - } else { - header->crypt_method =3D cpu_to_be32(QCOW_CRYPT_NONE); - } + /* We'll update this to correct value later */ + header->crypt_method =3D cpu_to_be32(QCOW_CRYPT_NONE); =20 if (flags & BLOCK_FLAG_LAZY_REFCOUNTS) { header->compatible_features |=3D @@ -2296,6 +2338,14 @@ static int qcow2_create2(const char *filename, int64= _t total_size, } } =20 + /* Want encryption? There you go. */ + if (flags & BLOCK_FLAG_ENCRYPT) { + ret =3D qcow2_set_up_encryption(blk_bs(blk), opts, errp); + if (ret < 0) { + goto out; + } + } + /* And if we're supposed to preallocate metadata, do that now */ if (prealloc !=3D PREALLOC_MODE_OFF) { BDRVQcow2State *s =3D blk_bs(blk)->opaque; @@ -2311,11 +2361,17 @@ static int qcow2_create2(const char *filename, int6= 4_t total_size, blk_unref(blk); blk =3D NULL; =20 - /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returni= ng */ + /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returni= ng. + * Using BDRV_O_NO_IO, since encryption is now setup we don't want to + * have to setup decryption context. We're not doing any I/O on the top + * level BlockDriverState, only lower layers, where BDRV_O_NO_IO does + * not have effect. + */ options =3D qdict_new(); qdict_put(options, "driver", qstring_from_str("qcow2")); blk =3D blk_new_open(filename, NULL, options, - BDRV_O_RDWR | BDRV_O_NO_BACKING, &local_err); + BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO, + &local_err); if (blk =3D=3D NULL) { error_propagate(errp, local_err); ret =3D -EIO; @@ -3134,9 +3190,9 @@ static int qcow2_amend_options(BlockDriverState *bs, = QemuOpts *opts, backing_format =3D qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { encrypt =3D qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, - !!s->cipher); + !!s->crypto); =20 - if (encrypt !=3D !!s->cipher) { + if (encrypt !=3D !!s->crypto) { error_report("Changing the encryption flag is not supporte= d"); return -ENOTSUP; } @@ -3372,6 +3428,7 @@ static QemuOptsList qcow2_create_opts =3D { .help =3D "Width of a reference count entry in bits", .def_value_str =3D "16" }, + BLOCK_CRYPTO_OPT_DEF_QCOW_KEY_SECRET("aes-"), { /* end of list */ } } }; @@ -3389,7 +3446,6 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_create =3D qcow2_create, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, .bdrv_co_get_block_status =3D qcow2_co_get_block_status, - .bdrv_set_key =3D qcow2_set_key, =20 .bdrv_co_preadv =3D qcow2_co_preadv, .bdrv_co_pwritev =3D qcow2_co_pwritev, diff --git a/block/qcow2.h b/block/qcow2.h index 033d8c0..f4cb171 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -25,7 +25,7 @@ #ifndef BLOCK_QCOW2_H #define BLOCK_QCOW2_H =20 -#include "crypto/cipher.h" +#include "crypto/block.h" #include "qemu/coroutine.h" =20 //#define DEBUG_ALLOC @@ -256,7 +256,8 @@ typedef struct BDRVQcow2State { =20 CoMutex lock; =20 - QCryptoCipher *cipher; /* current cipher, NULL if no key yet */ + QCryptoBlockOpenOptions *crypto_opts; /* Disk encryption runtime optio= ns */ + QCryptoBlock *crypto; /* Disk encryption format driver */ uint32_t crypt_method_header; uint64_t snapshots_offset; int snapshots_size; diff --git a/qapi/block-core.json b/qapi/block-core.json index 0bb61ea..6866a0d 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2326,6 +2326,10 @@ # @cache-clean-interval: #optional clean unused entries in the L2 and ref= count # caches. The interval is in seconds. The default = value # is 0 and it disables this feature (since 2.5) +# @aes-key-secret: #optional the ID of a QCryptoSecret object provi= ding +# the AES decryption key (since 2.9). Mandatory for +# encrypted images, except when doing a metadata-o= nly +# probe of the image. # # Since: 1.7 ## @@ -2339,8 +2343,8 @@ '*cache-size': 'int', '*l2-cache-size': 'int', '*refcount-cache-size': 'int', - '*cache-clean-interval': 'int' } } - + '*cache-clean-interval': 'int', + '*aes-key-secret': 'str' } } =20 ## # @BlockdevOptionsArchipelago: diff --git a/tests/qemu-iotests/049 b/tests/qemu-iotests/049 index fff0760..a16430d 100755 --- a/tests/qemu-iotests/049 +++ b/tests/qemu-iotests/049 @@ -106,7 +106,7 @@ test_qemu_img create -f $IMGFMT -o preallocation=3D1234= "$TEST_IMG" 64M echo "=3D=3D Check encryption option =3D=3D" echo test_qemu_img create -f $IMGFMT -o encryption=3Doff "$TEST_IMG" 64M -test_qemu_img create -f $IMGFMT -o encryption=3Don "$TEST_IMG" 64M +test_qemu_img create -f $IMGFMT --object secret,id=3Dsec0,data=3D123456 -o= encryption=3Don,aes-key-secret=3Dsec0 "$TEST_IMG" 64M =20 echo "=3D=3D Check lazy_refcounts option (only with v3) =3D=3D" echo diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index 4673b67..2615200 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -186,8 +186,8 @@ Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108= 864 encryption=3Doff cluster_si qemu-img create -f qcow2 -o encryption=3Doff TEST_DIR/t.qcow2 64M Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Dof= f cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 =20 -qemu-img create -f qcow2 -o encryption=3Don TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Don= cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +qemu-img create -f qcow2 --object secret,id=3Dsec0,data=3D123456 -o encryp= tion=3Don,aes-key-secret=3Dsec0 TEST_DIR/t.qcow2 64M +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Don= cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 aes-key-secre= t=3Dsec0 =20 =3D=3D Check lazy_refcounts option (only with v3) =3D=3D =20 diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index a952330..f8dee34 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -53,6 +53,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M @@ -66,6 +67,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o cluster_size=3D4k,help TEST_DIR/t.qcow2 128M @@ -79,6 +81,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o cluster_size=3D4k,? TEST_DIR/t.qcow2 128M @@ -92,6 +95,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o help,cluster_size=3D4k TEST_DIR/t.qcow2 128M @@ -105,6 +109,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o ?,cluster_size=3D4k TEST_DIR/t.qcow2 128M @@ -118,6 +123,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o cluster_size=3D4k -o help TEST_DIR/t.qcow2 128M @@ -131,6 +137,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o cluster_size=3D4k -o ? TEST_DIR/t.qcow2 128M @@ -144,6 +151,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: create -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_DIR= /t.qcow2 128M @@ -172,6 +180,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key =20 Testing: create -o help Supported options: @@ -234,6 +243,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base @@ -247,6 +257,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o cluster_size=3D4k,help TEST_DIR/t.qcow2 TEST_= DIR/t.qcow2.base @@ -260,6 +271,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o cluster_size=3D4k,? TEST_DIR/t.qcow2 TEST_DIR= /t.qcow2.base @@ -273,6 +285,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o help,cluster_size=3D4k TEST_DIR/t.qcow2 TEST_= DIR/t.qcow2.base @@ -286,6 +299,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o ?,cluster_size=3D4k TEST_DIR/t.qcow2 TEST_DIR= /t.qcow2.base @@ -299,6 +313,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o cluster_size=3D4k -o help TEST_DIR/t.qcow2 TE= ST_DIR/t.qcow2.base @@ -312,6 +327,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o cluster_size=3D4k -o ? TEST_DIR/t.qcow2 TEST_= DIR/t.qcow2.base @@ -325,6 +341,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: convert -O qcow2 -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_DI= R/t.qcow2 TEST_DIR/t.qcow2.base @@ -353,6 +370,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key =20 Testing: convert -o help Supported options: @@ -412,6 +430,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2 @@ -425,6 +444,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o cluster_size=3D4k,help TEST_DIR/t.qcow2 @@ -438,6 +458,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o cluster_size=3D4k,? TEST_DIR/t.qcow2 @@ -451,6 +472,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o help,cluster_size=3D4k TEST_DIR/t.qcow2 @@ -464,6 +486,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o ?,cluster_size=3D4k TEST_DIR/t.qcow2 @@ -477,6 +500,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o cluster_size=3D4k -o help TEST_DIR/t.qcow2 @@ -490,6 +514,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o cluster_size=3D4k -o ? TEST_DIR/t.qcow2 @@ -503,6 +528,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key nocow Turn off copy-on-write (valid only on btrfs) =20 Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_DIR/= t.qcow2 @@ -533,6 +559,7 @@ cluster_size qcow2 cluster size preallocation Preallocation mode (allowed values: off, metadata, falloc= , full) lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits +aes-key-secret ID of the secret that provides the AES encryption key =20 Testing: convert -o help Supported options: diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index 9de57dd..55a9e06 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -124,24 +124,18 @@ echo echo =3D=3D=3D Encrypted image =3D=3D=3D echo =20 -_make_test_img -o encryption=3Don $size -run_qemu -S <