From: Kevin Wolf <kwolf@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
John Snow <jsnow@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH] blockjob: report a better error message
Date: Wed, 24 Feb 2021 15:36:20 +0100 [thread overview]
Message-ID: <20210224143620.GB11025@merkur.fritz.box> (raw)
In-Reply-To: <20210223131150.124867-1-sgarzare@redhat.com>
Am 23.02.2021 um 14:11 hat Stefano Garzarella geschrieben:
> When a block job fails, we report 'strerror(-job->job.ret)' error
> message, also if the job set an error object.
> Let's report a better error message using 'error_get_pretty(job->job.err)'.
>
> If an error object was not set, strerror(-job->ret) is used as fallback,
> as explained in include/qemu/job.h:
>
> typedef struct Job {
> ...
> /**
> * Error object for a failed job.
> * If job->ret is nonzero and an error object was not set, it will be set
> * to strerror(-job->ret) during job_completed.
> */
> Error *err;
> }
This is true, but there is a short time where job->ret is already set,
but not turned into job->err yet if necessary. The latter is done in a
bottom half scheduled after the former has happened.
It doesn't matter for block_job_event_completed(), which is called only
after both, but block_job_query() could in theory be called in this
window.
> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> blockjob.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/blockjob.c b/blockjob.c
> index f2feff051d..a696f3408d 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -319,7 +319,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
> info->auto_finalize = job->job.auto_finalize;
> info->auto_dismiss = job->job.auto_dismiss;
> info->has_error = job->job.ret != 0;
> - info->error = job->job.ret ? g_strdup(strerror(-job->job.ret)) : NULL;
> + info->error = job->job.ret ?
> + g_strdup(error_get_pretty(job->job.err)) : NULL;
So I think we can't rely on job->job.err being non-NULL here.
> return info;
> }
>
> @@ -356,7 +357,7 @@ static void block_job_event_completed(Notifier *n, void *opaque)
> }
>
> if (job->job.ret < 0) {
> - msg = strerror(-job->job.ret);
> + msg = error_get_pretty(job->job.err);
> }
>
> qapi_event_send_block_job_completed(job_type(&job->job),
Kevin
next prev parent reply other threads:[~2021-02-24 15:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 13:11 [PATCH] blockjob: report a better error message Stefano Garzarella
2021-02-24 14:36 ` Kevin Wolf [this message]
2021-02-24 15:59 ` Stefano Garzarella
2021-02-24 17:04 ` Kevin Wolf
2021-02-24 17:12 ` Stefano Garzarella
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=20210224143620.GB11025@merkur.fritz.box \
--to=kwolf@redhat.com \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=vsementsov@virtuozzo.com \
/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).