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>
This commit is contained in:
parent
4aa6fc69e8
commit
3b6ad6230e
10
blockjob.c
10
blockjob.c
@ -318,8 +318,12 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
|
|||||||
info->status = job->job.status;
|
info->status = job->job.status;
|
||||||
info->auto_finalize = job->job.auto_finalize;
|
info->auto_finalize = job->job.auto_finalize;
|
||||||
info->auto_dismiss = job->job.auto_dismiss;
|
info->auto_dismiss = job->job.auto_dismiss;
|
||||||
info->has_error = job->job.ret != 0;
|
if (job->job.ret) {
|
||||||
info->error = job->job.ret ? g_strdup(strerror(-job->job.ret)) : NULL;
|
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;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +360,7 @@ static void block_job_event_completed(Notifier *n, void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (job->job.ret < 0) {
|
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),
|
qapi_event_send_block_job_completed(job_type(&job->job),
|
||||||
|
Loading…
Reference in New Issue
Block a user