aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2016-10-27 12:06:55 -0400
committerJeff Cody <jcody@redhat.com>2016-11-01 07:55:57 -0400
commit559b935f8c5c3139c2e275651da719ffa425cc14 (patch)
tree5d84cd5adcdf2c4cae14b925510b45d57202c6d0 /blockdev.c
parent53d9837fb8906b8512143d5eaacc4d6a65b29cc6 (diff)
blockjobs: hide internal jobs from management API
If jobs are not created directly by the user, do not allow them to be seen by the user/management utility. At the moment, 'internal' jobs are those that do not have an ID. As of this patch it is impossible to create such jobs. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1477584421-1399-2-git-send-email-jsnow@redhat.com Signed-off-by: Jeff Cody <jcody@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/blockdev.c b/blockdev.c
index ded13268f7..d57cb0c7d6 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3946,13 +3946,22 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp)
BlockJob *job;
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
- BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1);
- AioContext *aio_context = blk_get_aio_context(job->blk);
+ BlockJobInfoList *elem;
+ AioContext *aio_context;
+ if (block_job_is_internal(job)) {
+ continue;
+ }
+ elem = g_new0(BlockJobInfoList, 1);
+ aio_context = blk_get_aio_context(job->blk);
aio_context_acquire(aio_context);
- elem->value = block_job_query(job);
+ elem->value = block_job_query(job, errp);
aio_context_release(aio_context);
-
+ if (!elem->value) {
+ g_free(elem);
+ qapi_free_BlockJobInfoList(head);
+ return NULL;
+ }
*p_next = elem;
p_next = &elem->next;
}