[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v4 03/11] blockjob: Add block_job_get()
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH v4 03/11] blockjob: Add block_job_get() |
Date: |
Tue, 5 Jul 2016 17:28:54 +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>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
---
blockjob.c | 13 +++++++++++++
include/block/blockjob.h | 10 ++++++++++
2 files changed, 23 insertions(+)
diff --git a/blockjob.c b/blockjob.c
index ce0e27c..ca2291b 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -60,6 +60,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;
+}
+
/* Normally the job runs in its BlockBackend's AioContext. The exception is
* block_job_defer_to_main_loop() where it runs in the QEMU main loop. Code
* that supports both cases uses this helper function.
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index 5181514..0fe1540 100644
--- a/include/block/blockjob.h
+++ b/include/block/blockjob.h
@@ -211,6 +211,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 v4 05/11] blockjob: Add 'job_id' parameter to block_job_create(), (continued)
- [Qemu-block] [PATCH v4 05/11] blockjob: Add 'job_id' parameter to block_job_create(), Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 08/11] stream: Add 'job-id' parameter to 'block-stream', Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 11/11] blockjob: Update description of the 'device' field in the QMP API, Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 04/11] block: Use block_job_get() in find_block_job(), Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 07/11] backup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup', Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 10/11] qemu-img: Set the ID of the block job in img_commit(), Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 03/11] blockjob: Add block_job_get(),
Alberto Garcia <=
- [Qemu-block] [PATCH v4 01/11] stream: Fix prototype of stream_start(), Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 06/11] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror', Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 02/11] blockjob: Update description of the 'id' field, Alberto Garcia, 2016/07/05
- [Qemu-block] [PATCH v4 09/11] commit: Add 'job-id' parameter to 'block-commit', Alberto Garcia, 2016/07/05
- Re: [Qemu-block] [PATCH v4 00/11] Allow creating block jobs with a user-defined ID, Kevin Wolf, 2016/07/07