From nobody Wed Nov 27 00:44:59 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 ARC-Seal: i=1; a=rsa-sha256; t=1703483298; cv=none; d=zohomail.com; s=zohoarc; b=XDrCp7hojhvFGj/jNCgBg6cYKh5vZyxHamLmQBOrT96GwcD1hZkwO3t1LZQe/DYIFFKXwK5l/B9iYIdYa59NhQ1KJX7wYtl0dHYlpd2brudkYqqktv+/XQohCdvGbc7kJREQtzTv/9vWmlBO0I7v5E0tLj5DG6NL0Ueco0E8C7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703483298; h=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=AdL9uW9EvZjhGBTaXUAVF2PzM+GCkP3v2dbTBdBWS6M=; b=NmP1uP17p40apovghHivzbmE/5KWpY7I9DAtQzd1cuoctYNcNagDPyvq4OQe9BLRbOm2IUqfif1RSbRPxTuoo31sU2xdSb02CAiGgs4r2Wv7hdGy3ZGVQBMhKOshb4ENiBrwmqy1L+cQSFtH1WY6jZw3WEPBKraBsU+oG0BhXSM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1703483297722426.634602679914; Sun, 24 Dec 2023 21:48:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rHdoS-0004gv-Eu; Mon, 25 Dec 2023 00:47:40 -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 1rHdoQ-0004gk-BR for qemu-devel@nongnu.org; Mon, 25 Dec 2023 00:47:38 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rHdoO-00023U-Um for qemu-devel@nongnu.org; Mon, 25 Dec 2023 00:47:38 -0500 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3bb82a52002so3157178b6e.2 for ; Sun, 24 Dec 2023 21:45:36 -0800 (PST) Received: from localhost.localdomain ([118.114.58.28]) by smtp.gmail.com with ESMTPSA id y22-20020a056a00191600b006cef521b151sm7342415pfi.168.2023.12.24.21.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 21:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1703483134; x=1704087934; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AdL9uW9EvZjhGBTaXUAVF2PzM+GCkP3v2dbTBdBWS6M=; b=aoIfUzjeNZCRR3pD0vqOaROkbrqNFbpjgHRl4i7FJ9XJAMmFIINlSD5Q+O4bBDx15F yWklm21IMGPvHfsapYmaFhyC770AFUJcnTrHsEclCjt5pPysEzwDg98yV3ZE5Rmiox6j 6qogHm7XNnYrFLN/WMOiqOyJxTdsYxHqaL0xCr3yxAMPUuijNiLGGjfrWNimsA+uAq3D eGCSYOb6uwvasCF42Bti0wNtmsSGihFY6zRltTUfwqrqVkpOHvQtOXrfuV9Z/rNm13lX F7iaMn1P1P4AR146qQl5h9H7yJ4N18D/SISktyuuADqHA0JLXA1PGf61G7PTvQfJMAHI U97w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703483134; x=1704087934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AdL9uW9EvZjhGBTaXUAVF2PzM+GCkP3v2dbTBdBWS6M=; b=PWo7ahgNHr4yr9/y1h983LgoyabCfP8NLSqRlOPVhQoyIcFNrwZ+TpG5cL89PRVx9e YLXnkIMCE0ej7bMbXd7kvmsvaWjV0EzJvWCLflsG2WCuQJRx5S0v7vDBjg8buXJ9f6f8 eG6zQAaIPb459wjI1qqynl6VtCG6BJTK3puZ3XLpXw5U4JiC1qi+7ISsax2jo2DPQ+dM rJd6vyr7VH9mU0ZVOq4RU9CENlCBzGxM85+PLKDmP1RmXxBip6LVGv5eo+1sI+UP1Zz5 dXaCX4rApQV5XyVnbGq8wfpMPhj8sJnnMTF24b5tjO8T2DidipTO3qmB4IRnWD3ujive HsdA== X-Gm-Message-State: AOJu0YxwNaKteKKeY4ckhqsKrU78Gywy14jqJOV/yb9539bqbBY+1Qwb VD3yO3264bV1ukL5VWd/jDLih3R2Q3etTeIb1j9D4nCGd1MFgA== X-Google-Smtp-Source: AGHT+IGXm0QUrJSRzkJKth00XkBg6Khj8uorx2qkm7s+1A5sZw+nDJVkS5BpjQNXThcrq2QQ6jBO4w== X-Received: by 2002:a05:6808:1186:b0:3bb:6cf0:fce0 with SMTP id j6-20020a056808118600b003bb6cf0fce0mr7067688oil.34.1703483134042; Sun, 24 Dec 2023 21:45:34 -0800 (PST) From: Hyman Huang To: qemu-devel Cc: Kevin Wolf , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Hanna Reitz , Eric Blake , Markus Armbruster , Hyman Huang Subject: [PATCH RESEND v3 03/10] qapi: Make parameter 'file' optional for BlockdevCreateOptionsLUKS Date: Mon, 25 Dec 2023 13:45:05 +0800 Message-Id: <720f901d0df6ecb2da94c48c38b0abde933c3429.1703482349.git.yong.huang@smartx.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: none client-ip=2607:f8b0:4864:20::229; envelope-from=yong.huang@smartx.com; helo=mail-oi1-x229.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1703483299408100004 Content-Type: text/plain; charset="utf-8" To support detached LUKS header creation, make the existing 'file' filed in BlockdevCreateOptionsLUKS optional, while also adding an extra optional 'header' field in the next commit. Signed-off-by: Hyman Huang Reviewed-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 6063879bac..78fbe79c95 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -659,9 +659,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) { @@ -673,10 +673,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 10be08d08f..9ac256c489 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4945,7 +4945,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 # @@ -4956,7 +4957,7 @@ ## { 'struct': 'BlockdevCreateOptionsLUKS', 'base': 'QCryptoBlockCreateOptionsLUKS', - 'data': { 'file': 'BlockdevRef', + 'data': { '*file': 'BlockdevRef', 'size': 'size', '*preallocation': 'PreallocMode' } } =20 --=20 2.39.1