diff options
author | Stefano Garzarella <sgarzare@redhat.com> | 2021-02-25 11:36:33 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2021-03-08 14:55:18 +0100 |
commit | 3b6ad6230e902168f63315e47933025b016f546e (patch) | |
tree | a47904478f8652e83d76cea0a127ff68ee229670 /blockjob.c | |
parent | 4aa6fc69e8d2d64d37af382854ff5b12675248c2 (diff) | |
download | qemu-3b6ad6230e902168f63315e47933025b016f546e.zip qemu-3b6ad6230e902168f63315e47933025b016f546e.tar.gz qemu-3b6ad6230e902168f63315e47933025b016f546e.tar.bz2 |
blockjob: report a better error message
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;
}
In block_job_query() there can be a transient where 'job.err' is not set
by a scheduled bottom half. In that case we use strerror(-job->ret) as it
was before.
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20210225103633.76746-1-sgarzare@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r-- | blockjob.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -318,8 +318,12 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp) info->status = job->job.status; 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; + if (job->job.ret) { + info->has_error = true; + info->error = job->job.err ? + g_strdup(error_get_pretty(job->job.err)) : + g_strdup(strerror(-job->job.ret)); + } return info; } @@ -356,7 +360,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), |