block: add block_job_query
Extract it out of the implementation of info block-jobs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
2f0c9fe64c
commit
30e628b709
15
blockdev.c
15
blockdev.c
@ -1232,19 +1232,8 @@ static void do_qmp_query_block_jobs_one(void *opaque, BlockDriverState *bs)
|
|||||||
BlockJob *job = bs->job;
|
BlockJob *job = bs->job;
|
||||||
|
|
||||||
if (job) {
|
if (job) {
|
||||||
BlockJobInfoList *elem;
|
BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1);
|
||||||
BlockJobInfo *info = g_new(BlockJobInfo, 1);
|
elem->value = block_job_query(bs->job);
|
||||||
*info = (BlockJobInfo){
|
|
||||||
.type = g_strdup(job->job_type->job_type),
|
|
||||||
.device = g_strdup(bdrv_get_device_name(bs)),
|
|
||||||
.len = job->len,
|
|
||||||
.offset = job->offset,
|
|
||||||
.speed = job->speed,
|
|
||||||
};
|
|
||||||
|
|
||||||
elem = g_new0(BlockJobInfoList, 1);
|
|
||||||
elem->value = info;
|
|
||||||
|
|
||||||
(*prev)->next = elem;
|
(*prev)->next = elem;
|
||||||
*prev = elem;
|
*prev = elem;
|
||||||
}
|
}
|
||||||
|
11
blockjob.c
11
blockjob.c
@ -161,3 +161,14 @@ void block_job_sleep_ns(BlockJob *job, QEMUClock *clock, int64_t ns)
|
|||||||
job->busy = true;
|
job->busy = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlockJobInfo *block_job_query(BlockJob *job)
|
||||||
|
{
|
||||||
|
BlockJobInfo *info = g_new0(BlockJobInfo, 1);
|
||||||
|
info->type = g_strdup(job->job_type->job_type);
|
||||||
|
info->device = g_strdup(bdrv_get_device_name(job->bs));
|
||||||
|
info->len = job->len;
|
||||||
|
info->offset = job->offset;
|
||||||
|
info->speed = job->speed;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
@ -162,6 +162,14 @@ void block_job_cancel(BlockJob *job);
|
|||||||
*/
|
*/
|
||||||
bool block_job_is_cancelled(BlockJob *job);
|
bool block_job_is_cancelled(BlockJob *job);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* block_job_query:
|
||||||
|
* @job: The job to get information about.
|
||||||
|
*
|
||||||
|
* Return information about a job.
|
||||||
|
*/
|
||||||
|
BlockJobInfo *block_job_query(BlockJob *job);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* block_job_cancel_sync:
|
* block_job_cancel_sync:
|
||||||
* @job: The job to be canceled.
|
* @job: The job to be canceled.
|
||||||
|
Loading…
Reference in New Issue
Block a user