From e7c1d78bbd5867804debeb7159b137fd9a6c44d3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 12 Apr 2018 17:54:37 +0200 Subject: job: Maintain a list of all jobs This moves the job list from BlockJob to Job. Now we can check for duplicate IDs in job_create(). Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: John Snow --- include/qemu/job.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/qemu') diff --git a/include/qemu/job.h b/include/qemu/job.h index 43dc2e4..bae2b09 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -27,6 +27,7 @@ #define JOB_H #include "qapi/qapi-types-block-core.h" +#include "qemu/queue.h" typedef struct JobDriver JobDriver; @@ -39,6 +40,9 @@ typedef struct Job { /** The type of this job. */ const JobDriver *driver; + + /** Element of the list of jobs */ + QLIST_ENTRY(Job) job_list; } Job; /** @@ -71,4 +75,19 @@ JobType job_type(const Job *job); /** Returns the enum string for the JobType of a given Job. */ const char *job_type_str(const Job *job); +/** + * Get the next element from the list of block jobs after @job, or the + * first one if @job is %NULL. + * + * Returns the requested job, or %NULL if there are no more jobs left. + */ +Job *job_next(Job *job); + +/** + * Get the job identified by @id (which must not be %NULL). + * + * Returns the requested job, or %NULL if it doesn't exist. + */ +Job *job_get(const char *id); + #endif -- cgit v1.1