job: Add job_is_ready()

Instead of having a 'bool ready' in BlockJob, add a function that
derives its value from the job status.

At the same time, this fixes the behaviour to match what the QAPI
documentation promises for query-block-job: 'true if the job may be
completed'. When the ready flag was introduced in commit ef6dbf1e46,
the flag never had to be reset to match the description because after
being ready, the jobs would immediately complete and disappear.

Job transactions and manual job finalisation were introduced only later.
With these changes, jobs may stay around even after having completed
(and they are not ready to be completed a second time), however their
patches forgot to reset the ready flag.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Kevin Wolf 2018-04-25 15:09:58 +02:00
parent 5f9a6a08e8
commit df956ae201
6 changed files with 28 additions and 9 deletions

View file

@ -49,11 +49,6 @@ typedef struct BlockJob {
/** The block device on which the job is operating. */
BlockBackend *blk;
/**
* Set to true when the job is ready to be completed.
*/
bool ready;
/** Status that is published by the query-block-jobs QMP API */
BlockDeviceIoStatus iostatus;