diff mbox

[v5,04/12] blockjob: Add "ready" field

Message ID 1397771992-31126-5-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz April 17, 2014, 9:59 p.m. UTC
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: Max Reitz <mreitz@redhat.com>
---
 blockjob.c               | 7 ++++++-
 include/block/blockjob.h | 5 +++++
 qapi-schema.json         | 4 +++-
 3 files changed, 14 insertions(+), 2 deletions(-)

Comments

Eric Blake April 22, 2014, 2:34 p.m. UTC | #1
On 04/17/2014 03:59 PM, Max Reitz wrote:
> 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: Max Reitz <mreitz@redhat.com>
> ---
>  blockjob.c               | 7 ++++++-
>  include/block/blockjob.h | 5 +++++
>  qapi-schema.json         | 4 +++-
>  3 files changed, 14 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
Kevin Wolf April 22, 2014, 2:57 p.m. UTC | #2
Am 17.04.2014 um 23:59 hat Max Reitz geschrieben:
> 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: Max Reitz <mreitz@redhat.com>

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
diff mbox

Patch

diff --git a/blockjob.c b/blockjob.c
index e10c1f3..8cc2b5d 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -242,6 +242,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;
 }
 
@@ -270,7 +271,11 @@  QObject *qobject_from_block_job(BlockJob *job)
 
 void block_job_ready(BlockJob *job)
 {
-    QObject *data = qobject_from_block_job(job);
+    QObject *data;
+
+    job->ready = true;
+
+    data = qobject_from_block_job(job);
     monitor_protocol_event(QEVENT_BLOCK_JOB_READY, data);
     qobject_decref(data);
 }
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index 626ea42..4a920e7 100644
--- a/include/block/blockjob.h
+++ b/include/block/blockjob.h
@@ -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;
 
diff --git a/qapi-schema.json b/qapi-schema.json
index 391356f..1097090 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1573,12 +1573,14 @@ 
 #
 # @io-status: the status of the job (since 1.3)
 #
+# @ready: true if the job may be completed (since 2.1)
+#
 # 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: