diff options
author | Markus Armbruster <armbru@redhat.com> | 2014-10-07 13:59:10 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-10-20 13:41:26 +0200 |
commit | fea68bb6e9fa65c7cc6caa6adda810d1d0fdbde4 (patch) | |
tree | a7e6e95a740ae028023b921b7048b9fd3bfa4297 /blockdev.c | |
parent | b9fe8a7a12f18adebba5616a3e9f44143a78c07e (diff) |
block: Eliminate bdrv_iterate(), use bdrv_next()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/blockdev.c b/blockdev.c index 30382031b8..c99df8f3f1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2608,26 +2608,21 @@ fail: qmp_output_visitor_cleanup(ov); } -static void do_qmp_query_block_jobs_one(void *opaque, BlockDriverState *bs) +BlockJobInfoList *qmp_query_block_jobs(Error **errp) { - BlockJobInfoList **prev = opaque; - BlockJob *job = bs->job; + BlockJobInfoList *head = NULL, **p_next = &head; + BlockDriverState *bs; - if (job) { - BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1); - elem->value = block_job_query(bs->job); - (*prev)->next = elem; - *prev = elem; + for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) { + if (bs->job) { + BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1); + elem->value = block_job_query(bs->job); + *p_next = elem; + p_next = &elem->next; + } } -} -BlockJobInfoList *qmp_query_block_jobs(Error **errp) -{ - /* Dummy is a fake list element for holding the head pointer */ - BlockJobInfoList dummy = {}; - BlockJobInfoList *prev = &dummy; - bdrv_iterate(do_qmp_query_block_jobs_one, &prev); - return dummy.next; + return head; } QemuOptsList qemu_common_drive_opts = { |