]> git.proxmox.com Git - mirror_qemu.git/blobdiff - job-qmp.c
meson: convert hw/tpm
[mirror_qemu.git] / job-qmp.c
index 410775df61870060f3af5768ea45f506b6b1566e..645601b2ccc1873b5fae2d97dbd8c34a68d42c90 100644 (file)
--- a/job-qmp.c
+++ b/job-qmp.c
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/job.h"
 #include "qapi/qapi-commands-job.h"
 #include "qapi/error.h"
-#include "trace-root.h"
+#include "trace/trace-root.h"
 
 /* Get a job using its ID and acquire its AioContext */
 static Job *find_job(const char *id, AioContext **aio_context, Error **errp)
@@ -115,7 +114,16 @@ void qmp_job_finalize(const char *id, Error **errp)
     }
 
     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);
 }
 
@@ -144,10 +152,11 @@ static JobInfo *job_query_single(Job *job, Error **errp)
         .id                 = g_strdup(job->id),
         .type               = job_type(job),
         .status             = job->status,
-        .current_progress   = job->progress_current,
-        .total_progress     = job->progress_total,
-        .has_error          = !!job->error,
-        .error              = g_strdup(job->error),
+        .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;