mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 11:23:43 +08:00
blockjob: use qapi enum helpers
QAPI generator provide #define helpers for looking up enum string. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 20180327153011.29569-1-marcandre.lureau@redhat.com Signed-off-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
parent
a865cebb82
commit
604343ced7
14
blockjob.c
14
blockjob.c
@ -75,10 +75,8 @@ static void block_job_state_transition(BlockJob *job, BlockJobStatus s1)
|
|||||||
assert(s1 >= 0 && s1 <= BLOCK_JOB_STATUS__MAX);
|
assert(s1 >= 0 && s1 <= BLOCK_JOB_STATUS__MAX);
|
||||||
trace_block_job_state_transition(job, job->ret, BlockJobSTT[s0][s1] ?
|
trace_block_job_state_transition(job, job->ret, BlockJobSTT[s0][s1] ?
|
||||||
"allowed" : "disallowed",
|
"allowed" : "disallowed",
|
||||||
qapi_enum_lookup(&BlockJobStatus_lookup,
|
BlockJobStatus_str(s0),
|
||||||
s0),
|
BlockJobStatus_str(s1));
|
||||||
qapi_enum_lookup(&BlockJobStatus_lookup,
|
|
||||||
s1));
|
|
||||||
assert(BlockJobSTT[s0][s1]);
|
assert(BlockJobSTT[s0][s1]);
|
||||||
job->status = s1;
|
job->status = s1;
|
||||||
}
|
}
|
||||||
@ -86,17 +84,15 @@ static void block_job_state_transition(BlockJob *job, BlockJobStatus s1)
|
|||||||
static int block_job_apply_verb(BlockJob *job, BlockJobVerb bv, Error **errp)
|
static int block_job_apply_verb(BlockJob *job, BlockJobVerb bv, Error **errp)
|
||||||
{
|
{
|
||||||
assert(bv >= 0 && bv <= BLOCK_JOB_VERB__MAX);
|
assert(bv >= 0 && bv <= BLOCK_JOB_VERB__MAX);
|
||||||
trace_block_job_apply_verb(job, qapi_enum_lookup(&BlockJobStatus_lookup,
|
trace_block_job_apply_verb(job, BlockJobStatus_str(job->status),
|
||||||
job->status),
|
BlockJobVerb_str(bv),
|
||||||
qapi_enum_lookup(&BlockJobVerb_lookup, bv),
|
|
||||||
BlockJobVerbTable[bv][job->status] ?
|
BlockJobVerbTable[bv][job->status] ?
|
||||||
"allowed" : "prohibited");
|
"allowed" : "prohibited");
|
||||||
if (BlockJobVerbTable[bv][job->status]) {
|
if (BlockJobVerbTable[bv][job->status]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
error_setg(errp, "Job '%s' in state '%s' cannot accept command verb '%s'",
|
error_setg(errp, "Job '%s' in state '%s' cannot accept command verb '%s'",
|
||||||
job->id, qapi_enum_lookup(&BlockJobStatus_lookup, job->status),
|
job->id, BlockJobStatus_str(job->status), BlockJobVerb_str(bv));
|
||||||
qapi_enum_lookup(&BlockJobVerb_lookup, bv));
|
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user