From nobody Mon Sep 16 19:46:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1707487780; cv=none; d=zohomail.com; s=zohoarc; b=QlePAwu4nKA8N3edK35q2sD/P3a4n8YdglYixwtGkSRoImA4pVEnNu4PtML/TsQZc5g+EypMLIg6DBVMFklgO1rnO92wqHgr5CyJZRtPlqp9P9QFjLMlQySt87iYofWgNuhDv4lMLdMK6DO+r83cOnrfzPJHQs2fM7w/yXoLtJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707487780; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hWD1cQ61IYdvGaG63O+Jbvl1sac9ZVC9mpJpAjayZWA=; b=Snvp7ksEtLoDGJ1Fh0+CgMG5pPYi/3T6cQCPE3XYJuqH+sdlo3XRuYUa1SgoJdf01VGmx+6qdDmGWINml7I1ryNiYoGddopbXTCWXkLfpkAARnuzt7Aq4qE4Lgx5jfvQtB+t2WL/gHNJcC+hf0X/ba6L+CPDYgTp5MiF908BCFY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707487780035486.07126350209865; Fri, 9 Feb 2024 06:09:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYRVn-00033I-W7; Fri, 09 Feb 2024 09:05:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rYRVj-0002u7-Tm for qemu-devel@nongnu.org; Fri, 09 Feb 2024 09:05:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rYRVi-0004MY-BV for qemu-devel@nongnu.org; Fri, 09 Feb 2024 09:05:47 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-401-h_T02WLePrynvOSBVZ8gYg-1; Fri, 09 Feb 2024 09:05:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B05EA1C0515A; Fri, 9 Feb 2024 14:05:42 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EE59112A1; Fri, 9 Feb 2024 14:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707487545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hWD1cQ61IYdvGaG63O+Jbvl1sac9ZVC9mpJpAjayZWA=; b=Ond36+5kmFfz2FcR+wZ418dB/0KT7TaE4jrHEuOYN1uQZc9I9VQHaB2c8Qct+aDYx2r3CT w4xWzeHvfT2ePe7QZQgUqUEcEqm1xHl8gEnWYKHCsijp8yWlxp5HQqi+nBmo/BJC4/2dHQ 6QQwhdxCFLchpXlF63tRHPwTX40IVBM= X-MC-Unique: h_T02WLePrynvOSBVZ8gYg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Cleber Rosa , Paolo Bonzini , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Stefan Weil , Kevin Wolf , Thomas Huth , Hyman Huang , Richard Henderson , John Snow , qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 12/17] qapi: Make parameter 'file' optional for BlockdevCreateOptionsLUKS Date: Fri, 9 Feb 2024 14:05:00 +0000 Message-ID: <20240209140505.2536635-13-berrange@redhat.com> In-Reply-To: <20240209140505.2536635-1-berrange@redhat.com> References: <20240209140505.2536635-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.269, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1707487781244100003 From: Hyman Huang To support detached LUKS header creation, make the existing 'file' field in BlockdevCreateOptionsLUKS optional. Signed-off-by: Hyman Huang Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 --- block/crypto.c | 21 ++++++++++++++------- qapi/block-core.json | 5 +++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/block/crypto.c b/block/crypto.c index 68656158e9..e87dc84111 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -663,9 +663,9 @@ block_crypto_co_create_luks(BlockdevCreateOptions *crea= te_options, Error **errp) assert(create_options->driver =3D=3D BLOCKDEV_DRIVER_LUKS); luks_opts =3D &create_options->u.luks; =20 - bs =3D bdrv_co_open_blockdev_ref(luks_opts->file, errp); - if (bs =3D=3D NULL) { - return -EIO; + if (luks_opts->file =3D=3D NULL) { + error_setg(errp, "Formatting LUKS disk requires parameter 'file'"); + return -EINVAL; } =20 create_opts =3D (QCryptoBlockCreateOptions) { @@ -677,10 +677,17 @@ block_crypto_co_create_luks(BlockdevCreateOptions *cr= eate_options, Error **errp) preallocation =3D luks_opts->preallocation; } =20 - ret =3D block_crypto_co_create_generic(bs, luks_opts->size, &create_op= ts, - preallocation, errp); - if (ret < 0) { - goto fail; + if (luks_opts->file) { + bs =3D bdrv_co_open_blockdev_ref(luks_opts->file, errp); + if (bs =3D=3D NULL) { + return -EIO; + } + + ret =3D block_crypto_co_create_generic(bs, luks_opts->size, &creat= e_opts, + preallocation, errp); + if (ret < 0) { + goto fail; + } } =20 ret =3D 0; diff --git a/qapi/block-core.json b/qapi/block-core.json index e7d4fb539b..77d1f50d55 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4955,7 +4955,8 @@ # # Driver specific image creation options for LUKS. # -# @file: Node to create the image format on +# @file: Node to create the image format on, mandatory except when +# 'preallocation' is not requested # # @size: Size of the virtual disk in bytes # @@ -4966,7 +4967,7 @@ ## { 'struct': 'BlockdevCreateOptionsLUKS', 'base': 'QCryptoBlockCreateOptionsLUKS', - 'data': { 'file': 'BlockdevRef', + 'data': { '*file': 'BlockdevRef', 'size': 'size', '*preallocation': 'PreallocMode' } } =20 --=20 2.43.0