From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "P J P" <ppandit@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-block@nongnu.org, "Max Reitz" <mreitz@redhat.com>
Subject: [PATCH 3/3] block: switch to use qemu_open_err for improved errors
Date: Wed, 1 Jul 2020 17:05:09 +0100 [thread overview]
Message-ID: <20200701160509.1523847-4-berrange@redhat.com> (raw)
In-Reply-To: <20200701160509.1523847-1-berrange@redhat.com>
Currently at startup if using cache=none on a filesystem lacking
O_DIRECT such as tmpfs, at startup QEMU prints
qemu-system-x86_64: -drive file=/tmp/foo.img,cache=none: file system may not support O_DIRECT
qemu-system-x86_64: -drive file=/tmp/foo.img,cache=none: Could not open '/tmp/foo.img': Invalid argument
while at QMP level the hint is missing, so QEMU reports just
"error": {
"class": "GenericError",
"desc": "Could not open '/tmp/foo.img': Invalid argument"
}
which is close to useless for the end user trying to figure out what
they did wrong
With this change at startup QEMU prints
qemu-system-x86_64: -drive file=/tmp/foo.img,cache=none: Unable to open '/tmp/foo.img' flags 0x4000: filesystem does not support O_DIRECT
while at the QMP level QEMU reports a massively more informative
"error": {
"class": "GenericError",
"desc": "Unable to open '/tmp/foo.img' flags 0x4002: filesystem does not support O_DIRECT"
}
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
block/file-posix.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index 3ab8f5a0fa..2865b789fb 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -574,11 +574,10 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
raw_parse_flags(bdrv_flags, &s->open_flags, false);
s->fd = -1;
- fd = qemu_open(filename, s->open_flags, 0644);
+ fd = qemu_open_err(filename, s->open_flags, errp, 0644);
ret = fd < 0 ? -errno : 0;
if (ret < 0) {
- error_setg_file_open(errp, -ret, filename);
if (ret == -EROFS) {
ret = -EACCES;
}
@@ -970,9 +969,8 @@ static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,
ret = raw_normalize_devicepath(&normalized_filename, errp);
if (ret >= 0) {
assert(!(*open_flags & O_CREAT));
- fd = qemu_open(normalized_filename, *open_flags);
+ fd = qemu_open_err(normalized_filename, *open_flags, errp);
if (fd == -1) {
- error_setg_errno(errp, errno, "Could not reopen file");
return -1;
}
}
@@ -2324,10 +2322,10 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
}
/* Create file */
- fd = qemu_open(file_opts->filename, O_RDWR | O_CREAT | O_BINARY, 0644);
+ fd = qemu_open_err(file_opts->filename, O_RDWR | O_CREAT | O_BINARY,
+ errp, 0644);
if (fd < 0) {
result = -errno;
- error_setg_errno(errp, -result, "Could not create file");
goto out;
}
--
2.26.2
next prev parent reply other threads:[~2020-07-01 16:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 16:05 [PATCH 0/3] block: improve error reporting for unsupported O_DIRECT Daniel P. Berrangé
2020-07-01 16:05 ` [PATCH 1/3] util: validate whether O_DIRECT is supported after failure Daniel P. Berrangé
2020-07-02 10:10 ` Philippe Mathieu-Daudé
2020-07-01 16:05 ` [PATCH 2/3] util: support detailed error reporting for qemu_open Daniel P. Berrangé
2020-07-02 5:13 ` Markus Armbruster
2020-07-02 9:30 ` Daniel P. Berrangé
2020-07-01 16:05 ` Daniel P. Berrangé [this message]
2020-07-01 16:58 ` [PATCH 0/3] block: improve error reporting for unsupported O_DIRECT no-reply
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=20200701160509.1523847-4-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.