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 2/2] qemu-img: better error message when opening a backing file fails
Date: Sun, 21 Jul 2019 21:15:08 +0300 [thread overview]
Message-ID: <20190721181508.28608-3-mlevitsk@redhat.com> (raw)
In-Reply-To: <20190721181508.28608-1-mlevitsk@redhat.com>
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 it 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=sec0,data=hunter9 \
--object secret,id=sec1,data=my_new_secret_password \
-b 'json:{ "encrypt.key-secret": "sec1", "driver": "qcow2", "file": { "driver": "file", "filename": "base.qcow2" }}' \
-o encrypt.format=luks,encrypt.key-secret=sec1 \
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 <mlevitsk@redhat.com>
---
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 = 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 size.\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;
}
--
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 ` [Qemu-trivial] [PATCH 1/2] LUKS: better error message when creating too large files Maxim Levitsky
2019-07-22 9:05 ` [Qemu-trivial] [Qemu-devel] " 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 ` Maxim Levitsky [this message]
2019-07-22 9:15 ` [Qemu-trivial] [Qemu-devel] [PATCH 2/2] qemu-img: better error message when opening a backing file fails 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-3-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).