Commit ef6dbf1e authored by Max Reitz's avatar Max Reitz Committed by Stefan Hajnoczi
Browse files

blockjob: Add "ready" field



When a block job signals readiness, this is currently reported only
through QMP. If qemu wants to use block jobs for internal tasks, there
needs to be another way to correctly detect when a block job may be
completed.

For this reason, introduce a bool "ready" which is set when the block
job may be completed.

Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
Message-id: 1414159063-25977-6-git-send-email-mreitz@redhat.com
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 345f9e1b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -261,6 +261,7 @@ BlockJobInfo *block_job_query(BlockJob *job)
    info->offset    = job->offset;
    info->speed     = job->speed;
    info->io_status = job->iostatus;
    info->ready     = job->ready;
    return info;
}

@@ -296,6 +297,8 @@ void block_job_event_completed(BlockJob *job, const char *msg)

void block_job_event_ready(BlockJob *job)
{
    job->ready = true;

    qapi_event_send_block_job_ready(job->driver->job_type,
                                    bdrv_get_device_name(job->bs),
                                    job->len,
+5 −0
Original line number Diff line number Diff line
@@ -91,6 +91,11 @@ struct BlockJob {
     */
    bool busy;

    /**
     * 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;

+3 −1
Original line number Diff line number Diff line
@@ -514,12 +514,14 @@
#
# @io-status: the status of the job (since 1.3)
#
# @ready: true if the job may be completed (since 2.2)
#
# Since: 1.1
##
{ 'type': 'BlockJobInfo',
  'data': {'type': 'str', 'device': 'str', 'len': 'int',
           'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int',
           'io-status': 'BlockDeviceIoStatus'} }
           'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} }

##
# @query-block-jobs: