From nobody Fri Dec 19 06:57:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549483219840262.9760275502272; Wed, 6 Feb 2019 12:00:19 -0800 (PST) Received: from localhost ([127.0.0.1]:57825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grTMo-0003PQ-MS for importer@patchew.org; Wed, 06 Feb 2019 15:00:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grTIl-00005q-D7 for qemu-devel@nongnu.org; Wed, 06 Feb 2019 14:56:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grTIk-0007xx-GK for qemu-devel@nongnu.org; Wed, 06 Feb 2019 14:56:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51240) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grTIi-0007wj-B5; Wed, 06 Feb 2019 14:56:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D2F037EE7; Wed, 6 Feb 2019 19:56:03 +0000 (UTC) Received: from localhost (unknown [10.40.205.248]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D38F5D9D6; Wed, 6 Feb 2019 19:56:02 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 6 Feb 2019 20:55:47 +0100 Message-Id: <20190206195551.28893-5-mreitz@redhat.com> In-Reply-To: <20190206195551.28893-1-mreitz@redhat.com> References: <20190206195551.28893-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 06 Feb 2019 19:56:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 4/8] 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" 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: Eric Blake --- qapi/block-core.json | 31 ++++++++++++++++++++++++++++--- block/qcow2.c | 3 +++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 5f17d67d71..abf9af0c4d 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -47,6 +47,9 @@ ## # @ImageInfoSpecificQCow2Encryption: # +# @format will never be "auto", as this pseudo-format just tells the +# qcow2 driver to read the actual format from the image header. +# # Since: 2.10 ## { 'union': 'ImageInfoSpecificQCow2Encryption', @@ -2961,10 +2964,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: 4.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: 4.0 +## +{ 'struct': 'BlockdevQcow2EncryptionSecret', + 'data': { '*key-secret': 'str' } } =20 ## # @BlockdevQcow2Encryption: @@ -2972,10 +2995,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 c21452bc2f..5885f5175e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -883,6 +883,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.20.1