mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
job: Add error message for failing jobs
So far we relied on job->ret and strerror() to produce an error message for failed jobs. Not surprisingly, this tends to result in completely useless messages. This adds a Job.error field that can contain an error string for a failing job, and a parameter to job_completed() that sets the field. As a default, if NULL is passed, we continue to use strerror(job->ret). All existing callers are changed to pass NULL. They can be improved in separate patches. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
@ -136,14 +136,9 @@ void qmp_job_dismiss(const char *id, Error **errp)
|
||||
static JobInfo *job_query_single(Job *job, Error **errp)
|
||||
{
|
||||
JobInfo *info;
|
||||
const char *errmsg = NULL;
|
||||
|
||||
assert(!job_is_internal(job));
|
||||
|
||||
if (job->ret < 0) {
|
||||
errmsg = strerror(-job->ret);
|
||||
}
|
||||
|
||||
info = g_new(JobInfo, 1);
|
||||
*info = (JobInfo) {
|
||||
.id = g_strdup(job->id),
|
||||
@ -151,8 +146,8 @@ static JobInfo *job_query_single(Job *job, Error **errp)
|
||||
.status = job->status,
|
||||
.current_progress = job->progress_current,
|
||||
.total_progress = job->progress_total,
|
||||
.has_error = !!errmsg,
|
||||
.error = g_strdup(errmsg),
|
||||
.has_error = !!job->error,
|
||||
.error = g_strdup(job->error),
|
||||
};
|
||||
|
||||
return info;
|
||||
|
Reference in New Issue
Block a user