From: Maxim Levitsky <mlevitsk@redhat.com>
To: qemu-devel@nongnu.org
Cc: Max Reitz <mreitz@redhat.com>, Michael Tokarev <mjt@tls.msk.ru>,
Laurent Vivier <laurent@vivier.eu>, Kevin Wolf <kwolf@redhat.com>,
qemu-trivial@nongnu.org, qemu-block@nongnu.org,
Maxim Levitsky <mlevitsk@redhat.com>
Subject: [Qemu-trivial] [PATCH 1/2] LUKS: better error message when creating too large files
Date: Sun, 21 Jul 2019 21:15:07 +0300 [thread overview]
Message-ID: <20190721181508.28608-2-mlevitsk@redhat.com> (raw)
In-Reply-To: <20190721181508.28608-1-mlevitsk@redhat.com>
Currently if you attampt to create too large file with luks you
get the following error message:
Formatting 'test.luks', fmt=luks size=17592186044416 key-secret=sec0
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=1534898
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
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 *block,
Error **errp)
{
struct BlockCryptoCreateData *data = opaque;
+ Error *local_error = NULL;
+ int ret;
if (data->size > INT64_MAX || headerlen > INT64_MAX - data->size) {
- error_setg(errp, "The requested file size is too large");
- return -EFBIG;
+ ret = -EFBIG;
+ goto error;
}
/* 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_OFF,
- errp);
+ ret = blk_truncate(data->blk, data->size + headerlen, PREALLOC_MODE_OFF,
+ &local_error);
+
+ if (ret >= 0) {
+ return ret;
+ }
+
+error:
+ if (ret == -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;
}
--
2.17.2
next prev parent reply other threads:[~2019-07-21 18:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-21 18:15 [Qemu-trivial] [PATCH 0/2] RFC: Trivial error message fixes for luks format Maxim Levitsky
2019-07-21 18:15 ` Maxim Levitsky [this message]
2019-07-22 9:05 ` [Qemu-trivial] [Qemu-devel] [PATCH 1/2] LUKS: better error message when creating too large files Daniel P. Berrangé
2019-09-12 22:44 ` Maxim Levitsky
2020-04-30 12:18 ` Maxim Levitsky
2020-04-30 13:03 ` Maxim Levitsky
2019-07-21 18:15 ` [Qemu-trivial] [PATCH 2/2] qemu-img: better error message when opening a backing file fails Maxim Levitsky
2019-07-22 9:15 ` [Qemu-trivial] [Qemu-devel] " Daniel P. Berrangé
2019-07-22 10:01 ` Maxim Levitsky
2019-07-22 9:41 ` [Qemu-trivial] " Kevin Wolf
2019-07-22 9:46 ` Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190721181508.28608-2-mlevitsk@redhat.com \
--to=mlevitsk@redhat.com \
--cc=kwolf@redhat.com \
--cc=laurent@vivier.eu \
--cc=mjt@tls.msk.ru \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).