diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-04-30 19:09:46 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-05-23 14:30:51 +0200 |
commit | 1dac83f1a10c4c66858075970e199f4e4a8d8b71 (patch) | |
tree | 3bd1963ad8654e0644e09f2874a5caa2a15ae14c /job.c | |
parent | bf42508f24ee1368267b421e145fa90315b77936 (diff) |
job: Add JOB_STATUS_CHANGE QMP event
This adds a QMP event that is emitted whenever a job transitions from
one status to another.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'job.c')
-rw-r--r-- | job.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -30,6 +30,7 @@ #include "qemu/id.h" #include "qemu/main-loop.h" #include "trace-root.h" +#include "qapi/qapi-events-job.h" static QLIST_HEAD(, Job) jobs = QLIST_HEAD_INITIALIZER(jobs); @@ -157,6 +158,11 @@ static int job_txn_apply(JobTxn *txn, int fn(Job *), bool lock) return rc; } +static bool job_is_internal(Job *job) +{ + return (job->id == NULL); +} + static void job_state_transition(Job *job, JobStatus s1) { JobStatus s0 = job->status; @@ -166,6 +172,10 @@ static void job_state_transition(Job *job, JobStatus s1) JobStatus_str(s0), JobStatus_str(s1)); assert(JobSTT[s0][s1]); job->status = s1; + + if (!job_is_internal(job) && s1 != s0) { + qapi_event_send_job_status_change(job->id, job->status, &error_abort); + } } int job_apply_verb(Job *job, JobVerb verb, Error **errp) |