*/
#include "qemu/osdep.h"
-#include "qemu-common.h"
#include "qemu/job.h"
#include "qapi/qapi-commands-job.h"
#include "qapi/error.h"
}
trace_qmp_job_finalize(job);
+ job_ref(job);
job_finalize(job, errp);
+
+ /*
+ * Job's context might have changed via job_finalize (and job_txn_apply
+ * automatically acquires the new one), so make sure we release the correct
+ * one.
+ */
+ aio_context = job->aio_context;
+ job_unref(job);
aio_context_release(aio_context);
}
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),
.type = job_type(job),
.status = job->status,
- .current_progress = job->progress_current,
- .total_progress = job->progress_total,
- .has_error = !!errmsg,
- .error = g_strdup(errmsg),
+ .current_progress = job->progress.current,
+ .total_progress = job->progress.total,
+ .has_error = !!job->err,
+ .error = job->err ? \
+ g_strdup(error_get_pretty(job->err)) : NULL,
};
return info;