From nobody Sun Feb 8 11:22:29 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1563732958; cv=none; d=zoho.com; s=zohoarc; b=N9UFi10NY/5+aL0xr0CUh1ViXmEvX2kDN9MdeJ80UJZugnDlRbJNh45Gf1vbPDxI35VQTXfIRguAaD/uDat6xgLADy8ZPxqEVOogL7V7LV6HF6kNgswnAXrvDvddlYYBeoAqYdQvcuA8I/TydtdQ+KHEMdGBC20W3zgd75sou2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563732958; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gk5JI9VOb57SMd8NRFYA3dACzVf+L+I2F+dhv8scsCg=; b=UnmaeaclLMtuc9RQj8IlebFCEbr8u5dUutmWqXKjnVaV7zbRQajF0wBTgMQ/fHNXWQM3A/MS18WqVoO0tt7OMBNoukJ6fq359uiUbtY9EwRWcvJEQZsarDJXnRx0X7cT14GxHcRT9OtpBTAADRpqlk/YMtUxxfjw8qXWuADvnBQ= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563732958463729.7514786657864; Sun, 21 Jul 2019 11:15:58 -0700 (PDT) Received: from localhost ([::1]:57198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpGNE-0004KB-Ru for importer@patchew.org; Sun, 21 Jul 2019 14:15:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34706) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpGMh-0002w8-Nw for qemu-devel@nongnu.org; Sun, 21 Jul 2019 14:15:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpGMg-0001T5-Jw for qemu-devel@nongnu.org; Sun, 21 Jul 2019 14:15:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54242) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hpGMe-0001RD-8L; Sun, 21 Jul 2019 14:15:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84EAF3082DDD; Sun, 21 Jul 2019 18:15:15 +0000 (UTC) Received: from maximlenovopc.usersys.redhat.com (unknown [10.35.206.70]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CAFA1017E3F; Sun, 21 Jul 2019 18:15:13 +0000 (UTC) From: Maxim Levitsky To: qemu-devel@nongnu.org Date: Sun, 21 Jul 2019 21:15:07 +0300 Message-Id: <20190721181508.28608-2-mlevitsk@redhat.com> In-Reply-To: <20190721181508.28608-1-mlevitsk@redhat.com> References: <20190721181508.28608-1-mlevitsk@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 21 Jul 2019 18:15:15 +0000 (UTC) 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 1/2] LUKS: better error message when creating too large files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-trivial@nongnu.org, Michael Tokarev , Laurent Vivier , Max Reitz , Maxim Levitsky Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently if you attampt to create too large file with luks you get the following error message: Formatting 'test.luks', fmt=3Dluks size=3D17592186044416 key-secret=3Dsec0 qemu-img: test.luks: Could not resize file: File too large While for raw format the error message is qemu-img: test.img: The image size is too large for file format 'raw' The reason for this is that qemu-img checks for errono of the failure, and presents the later error when it is -EFBIG However crypto generic code 'swallows' the errno and replaces it with -EIO. As an attempt to make it better, we can make luks driver, detect -EFBIG and in this case present a better error message, which is what this patch does The new error message is: qemu-img: error creating test.luks: The requested file size is too large Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1534898 Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 --- block/crypto.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/block/crypto.c b/block/crypto.c index 8237424ae6..73b1013fa1 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -102,18 +102,35 @@ static ssize_t block_crypto_init_func(QCryptoBlock *b= lock, Error **errp) { struct BlockCryptoCreateData *data =3D opaque; + Error *local_error =3D NULL; + int ret; =20 if (data->size > INT64_MAX || headerlen > INT64_MAX - data->size) { - error_setg(errp, "The requested file size is too large"); - return -EFBIG; + ret =3D -EFBIG; + goto error; } =20 /* User provided size should reflect amount of space made * available to the guest, so we must take account of that * which will be used by the crypto header */ - return blk_truncate(data->blk, data->size + headerlen, PREALLOC_MODE_O= FF, - errp); + ret =3D blk_truncate(data->blk, data->size + headerlen, PREALLOC_MODE_= OFF, + &local_error); + + if (ret >=3D 0) { + return ret; + } + +error: + if (ret =3D=3D -EFBIG) { + /* Replace the error message with a better one */ + error_free(local_error); + error_setg(errp, "The requested file size is too large"); + } else { + error_propagate(errp, local_error); + } + + return ret; } =20 =20 --=20 2.17.2 From nobody Sun Feb 8 11:22:29 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1563732958; cv=none; d=zoho.com; s=zohoarc; b=CW44DnmgovfVPTaG1RGXX1igAVgl4CyP1GNBdVGaoyGXzS2A36GBU5DlCSjzvb1xxUHeLSDGjDNyDBxEGA4zqtebW/rRauUY2FgBz6g4jj7Nn/Ixd9xld/jJPzdNFkxrvH6gyKRA673328QYZX7PNz+0V+NaZD7YxOF+xZjuFJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563732958; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=J2dmyxH5Sy97X040axzwdGk856a6z2TpIzNlj+szb04=; b=Zl8Gad3nHODJIBfWxV9FIIMRcX3BFkZNMgBTg09sbv4bCUBeKUbiZsp3VOoN1iWXl1Kg2l+W5HAB/s8jP2YA2CQBng+f/G0aq7Jkfzjzh4oNtiblvpzeSsAXJXmU7VREXFAhvzxo94endQO5ZuTK/JBxqe0uJj/8J3qHO5erRR0= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563732958847218.8156030947831; Sun, 21 Jul 2019 11:15:58 -0700 (PDT) Received: from localhost ([::1]:57200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpGNJ-0004bN-Fi for importer@patchew.org; Sun, 21 Jul 2019 14:15:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34747) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpGMk-00032Z-2l for qemu-devel@nongnu.org; Sun, 21 Jul 2019 14:15:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpGMi-0001VR-Vu for qemu-devel@nongnu.org; Sun, 21 Jul 2019 14:15:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hpGMg-0001Si-K3; Sun, 21 Jul 2019 14:15:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC779307D88C; Sun, 21 Jul 2019 18:15:17 +0000 (UTC) Received: from maximlenovopc.usersys.redhat.com (unknown [10.35.206.70]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAF8A1017E3F; Sun, 21 Jul 2019 18:15:15 +0000 (UTC) From: Maxim Levitsky To: qemu-devel@nongnu.org Date: Sun, 21 Jul 2019 21:15:08 +0300 Message-Id: <20190721181508.28608-3-mlevitsk@redhat.com> In-Reply-To: <20190721181508.28608-1-mlevitsk@redhat.com> References: <20190721181508.28608-1-mlevitsk@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 21 Jul 2019 18:15:17 +0000 (UTC) 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 2/2] qemu-img: better error message when opening a backing file fails X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-trivial@nongnu.org, Michael Tokarev , Laurent Vivier , Max Reitz , Maxim Levitsky Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently we print message like that: " new_file.qcow2 : error message " However the error could have come from opening the backing file (e.g when i= t missing encryption keys), thus try to clarify this by using this format: " qemu-img: error creating new_file.qcow2: base_file.qcow2: error message Could not open backing image to determine size. " Test used: qemu-img create -f qcow2 \ --object secret,id=3Dsec0,data=3Dhunter9 \ --object secret,id=3Dsec1,data=3Dmy_new_secret_password \ -b 'json:{ "encrypt.key-secret": "sec1", "driver": "qcow2", "file":= { "driver": "file", "filename": "base.qcow2" }}' \ -o encrypt.format=3Dluks,encrypt.key-secret=3Dsec1 \ sn.qcow2 Error message before: qemu-img: sn.qcow2: Invalid password, cannot unlock any keyslot Could not open backing image to determine size. Error message after: qemu-img: error creating sn.qcow2: \ json:{ "encrypt.key-secret": "sec1", "driver": "qcow2", "file": { "driver"= : "file", "filename": "base.qcow2" }}: \ Invalid password, cannot unlock any keyslot Could not open backing image to determine size. Signed-off-by: Maxim Levitsky --- block.c | 1 + qemu-img.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 29e931e217..5eb47b2199 100644 --- a/block.c +++ b/block.c @@ -5790,6 +5790,7 @@ void bdrv_img_create(const char *filename, const char= *fmt, "This may become an error in future versions.\= n"); local_err =3D NULL; } else if (!bs) { + error_prepend(&local_err, "%s: ", backing_file); /* Couldn't open bs, do not have size */ error_append_hint(&local_err, "Could not open backing image to determine s= ize.\n"); diff --git a/qemu-img.c b/qemu-img.c index 79983772de..134bf2fbe0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -545,7 +545,7 @@ static int img_create(int argc, char **argv) bdrv_img_create(filename, fmt, base_filename, base_fmt, options, img_size, flags, quiet, &local_err); if (local_err) { - error_reportf_err(local_err, "%s: ", filename); + error_reportf_err(local_err, "error creating %s: ", filename); goto fail; } =20 --=20 2.17.2