From nobody Tue Feb 10 05:50:30 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528750662688206.82906261024414; Mon, 11 Jun 2018 13:57:42 -0700 (PDT) Received: from localhost ([::1]:51314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSTsa-0005jf-9U for importer@patchew.org; Mon, 11 Jun 2018 16:57:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSTnY-0001lv-W1 for qemu-devel@nongnu.org; Mon, 11 Jun 2018 16:52:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSTnX-00086v-SC for qemu-devel@nongnu.org; Mon, 11 Jun 2018 16:52:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47826 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSTnU-00080m-UC; Mon, 11 Jun 2018 16:52:17 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E9647D668; Mon, 11 Jun 2018 20:52:16 +0000 (UTC) Received: from localhost (ovpn-204-89.brq.redhat.com [10.40.204.89]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED4821134CA1; Mon, 11 Jun 2018 20:52:15 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 11 Jun 2018 22:51:57 +0200 Message-Id: <20180611205203.2624-5-mreitz@redhat.com> In-Reply-To: <20180611205203.2624-1-mreitz@redhat.com> References: <20180611205203.2624-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 11 Jun 2018 20:52:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 11 Jun 2018 20:52:16 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 04/10] qapi: Formalize qcow2 encryption probing 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 , qemu-devel@nongnu.org, Michael Roth , Markus Armbruster , 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" Currently, you can give no encryption format for a qcow2 file while still passing a key-secret. That does not conform to the schema, so this patch changes the schema to allow it. Signed-off-by: Max Reitz Reviewed-by: Daniel P. Berrang=C3=A9 --- qapi/block-core.json | 44 ++++++++++++++++++++++++++++++++++++++++---- block/qcow2.c | 3 +++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 4bd85dd1bb..295ace42ae 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -44,6 +44,19 @@ { 'struct': 'ImageInfoSpecificQCow2EncryptionBase', 'data': { 'format': 'BlockdevQcow2EncryptionFormat'}} =20 +## +# @ImageInfoSpecificQCow2EncryptionNoInfo: +# +# Only used for the qcow2 encryption format "auto" in which the actual +# encryption format is determined from the image header. Therefore, +# this encryption format will never be reported in +# ImageInfoSpecificQCow2Encryption. +# +# Since: 3.0 +## +{ 'struct': 'ImageInfoSpecificQCow2EncryptionNoInfo', + 'data': { } } + ## # @ImageInfoSpecificQCow2Encryption: # @@ -53,7 +66,8 @@ 'base': 'ImageInfoSpecificQCow2EncryptionBase', 'discriminator': 'format', 'data': { 'aes': 'QCryptoBlockInfoQCow', - 'luks': 'QCryptoBlockInfoLUKS' } } + 'luks': 'QCryptoBlockInfoLUKS', + 'auto': 'ImageInfoSpecificQCow2EncryptionNoInfo' } } =20 ## # @ImageInfoSpecificQCow2: @@ -2658,10 +2672,30 @@ # @BlockdevQcow2EncryptionFormat: # @aes: AES-CBC with plain64 initialization venctors # +# @auto: Determine the encryption format from the image +# header. This only allows the use of the +# key-secret option. (Since: 3.0) +# # Since: 2.10 ## { 'enum': 'BlockdevQcow2EncryptionFormat', - 'data': [ 'aes', 'luks' ] } + 'data': [ 'aes', 'luks', 'auto' ] } + +## +# @BlockdevQcow2EncryptionSecret: +# +# Allows specifying a key-secret without specifying the exact +# encryption format, which is determined automatically from the image +# header. +# +# @key-secret: The ID of a QCryptoSecret object providing the +# decryption key. Mandatory except when probing +# image for metadata only. +# +# Since: 3.0 +## +{ 'struct': 'BlockdevQcow2EncryptionSecret', + 'data': { '*key-secret': 'str' } } =20 ## # @BlockdevQcow2Encryption: @@ -2669,10 +2703,12 @@ # Since: 2.10 ## { 'union': 'BlockdevQcow2Encryption', - 'base': { 'format': 'BlockdevQcow2EncryptionFormat' }, + 'base': { '*format': 'BlockdevQcow2EncryptionFormat' }, 'discriminator': 'format', + 'default-variant': 'auto', 'data': { 'aes': 'QCryptoBlockOptionsQCow', - 'luks': 'QCryptoBlockOptionsLUKS'} } + 'luks': 'QCryptoBlockOptionsLUKS', + 'auto': 'BlockdevQcow2EncryptionSecret' } } =20 ## # @BlockdevOptionsQcow2: diff --git a/block/qcow2.c b/block/qcow2.c index 945132f692..6bfcba4ee1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -868,6 +868,9 @@ static int qcow2_update_options_prepare(BlockDriverStat= e *bs, =20 qdict_extract_subqdict(options, &encryptopts, "encrypt."); encryptfmt =3D qdict_get_try_str(encryptopts, "format"); + if (!g_strcmp0(encryptfmt, "auto")) { + encryptfmt =3D NULL; + } =20 opts =3D qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); --=20 2.17.1