From ffb1f10cd1118393627e1bd2dad0a68152d2e539 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Date: Tue, 5 Jul 2016 17:28:54 +0300 Subject: blockjob: Add block_job_get() 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 Reviewed-by: Max Reitz Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- blockjob.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'blockjob.c') diff --git a/blockjob.c b/blockjob.c index ce0e27c124..ca2291b5c5 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. -- cgit v1.2.1