[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 03/15] blockjob: Add block_job_get()
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH 03/15] blockjob: Add block_job_get() |
Date: |
Thu, 9 Jun 2016 11:20:08 +0300 |
Currently the way to look for a specific block job is to iterate the
list manually using block_job_next().
Since we want to be able to identify a job primarily by its ID it
makes sense to have a function that does just that.
Signed-off-by: Alberto Garcia <address@hidden>
---
blockjob.c | 13 +++++++++++++
include/block/blockjob.h | 10 ++++++++++
2 files changed, 23 insertions(+)
diff --git a/blockjob.c b/blockjob.c
index 4d42987..a4a1caf 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -61,6 +61,19 @@ BlockJob *block_job_next(BlockJob *job)
return QLIST_NEXT(job, job_list);
}
+BlockJob *block_job_get(const char *id)
+{
+ BlockJob *job;
+
+ QLIST_FOREACH(job, &block_jobs, job_list) {
+ if (!strcmp(id, job->id)) {
+ return job;
+ }
+ }
+
+ return NULL;
+}
+
void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
int64_t speed, BlockCompletionFunc *cb,
void *opaque, Error **errp)
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index 1533006..46d2af2 100644
--- a/include/block/blockjob.h
+++ b/include/block/blockjob.h
@@ -191,6 +191,16 @@ struct BlockJob {
BlockJob *block_job_next(BlockJob *job);
/**
+ * block_job_get:
+ * @id: The id of the block job.
+ *
+ * Get the block job identified by @id (which must not be %NULL).
+ *
+ * Returns the requested job, or %NULL if it doesn't exist.
+ */
+BlockJob *block_job_get(const char *id);
+
+/**
* block_job_create:
* @job_type: The class object for the newly-created job.
* @bs: The block
--
2.8.1
- [Qemu-block] [PATCH 08/15] stream: Add 'job-id' parameter to 'block-stream', (continued)
- [Qemu-block] [PATCH 08/15] stream: Add 'job-id' parameter to 'block-stream', Alberto Garcia, 2016/06/09
- [Qemu-block] [PATCH 07/15] backup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup', Alberto Garcia, 2016/06/09
- [Qemu-block] [PATCH 13/15] blockjob: Add 'id' parameter to 'block-job-resume', Alberto Garcia, 2016/06/09
- [Qemu-block] [PATCH 09/15] stream: Add 'job-id' parameter to 'block-commit', Alberto Garcia, 2016/06/09
- [Qemu-block] [PATCH 14/15] blockjob: Add 'id' parameter to 'block-job-complete', Alberto Garcia, 2016/06/09
- [Qemu-block] [PATCH 03/15] blockjob: Add block_job_get(),
Alberto Garcia <=
- [Qemu-block] [PATCH 01/15] stream: Fix prototype of stream_start(), Alberto Garcia, 2016/06/09
- [Qemu-block] [PATCH 06/15] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror', Alberto Garcia, 2016/06/09