aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-04-12 17:54:37 +0200
committerKevin Wolf <kwolf@redhat.com>2018-05-23 14:30:49 +0200
commite7c1d78bbd5867804debeb7159b137fd9a6c44d3 (patch)
tree1048aef4f48fe88812d896b0fe4f4497d79e5da0 /include
parentfd61a701f1de8e4c1d89b3716ba9ca749cf5c724 (diff)
downloadqemu-e7c1d78bbd5867804debeb7159b137fd9a6c44d3.zip
qemu-e7c1d78bbd5867804debeb7159b137fd9a6c44d3.tar.gz
qemu-e7c1d78bbd5867804debeb7159b137fd9a6c44d3.tar.bz2
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 <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/block/blockjob.h3
-rw-r--r--include/qemu/job.h19
2 files changed, 19 insertions, 3 deletions
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index 640e649..10bd9f7 100644
--- a/include/block/blockjob.h
+++ b/include/block/blockjob.h
@@ -105,9 +105,6 @@ typedef struct BlockJob {
*/
bool deferred_to_main_loop;
- /** Element of the list of block jobs */
- QLIST_ENTRY(BlockJob) job_list;
-
/** Status that is published by the query-block-jobs QMP API */
BlockDeviceIoStatus iostatus;
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