qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v14 05/14] blockjob: Add "ready" field
Date: Fri, 24 Oct 2014 15:57:34 +0200	[thread overview]
Message-ID: <1414159063-25977-6-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1414159063-25977-1-git-send-email-mreitz@redhat.com>

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: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
 blockjob.c               | 3 +++
 include/block/blockjob.h | 5 +++++
 qapi/block-core.json     | 4 +++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/blockjob.c b/blockjob.c
index a7d57e3..448b9ce 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -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,
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index ab11a0f..9694f13 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/block-core.json b/qapi/block-core.json
index 8f7089e..77a0cfb 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -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:
-- 
1.9.3

  parent reply	other threads:[~2014-10-24 13:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24 13:57 [Qemu-devel] [PATCH v14 00/14] qemu-img: Implement commit like QMP Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 01/14] qcow2: Allow "full" discard Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 02/14] qcow2: Implement bdrv_make_empty() Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 03/14] qcow2: Optimize bdrv_make_empty() Max Reitz
2014-10-24 14:33   ` Eric Blake
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 04/14] blockjob: Introduce block_job_complete_sync() Max Reitz
2014-10-24 13:57 ` Max Reitz [this message]
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 06/14] iotests: Omit length/offset test in 040 and 041 Max Reitz
2014-10-24 15:14   ` Eric Blake
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 07/14] block/mirror: Improve progress report Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 08/14] qemu-img: Implement commit like QMP Max Reitz
2014-10-24 16:08   ` Eric Blake
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 09/14] qemu-img: Empty image after commit Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 10/14] qemu-img: Enable progress output for commit Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 11/14] qemu-img: Specify backing file " Max Reitz
2014-10-24 16:23   ` Eric Blake
2014-10-27  9:11     ` Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 12/14] iotests: Add _filter_qemu_img_map Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 13/14] iotests: Add test for backing-chain commits Max Reitz
2014-10-24 13:57 ` [Qemu-devel] [PATCH v14 14/14] iotests: Add test for qcow2's bdrv_make_empty Max Reitz
2014-10-24 16:31   ` Eric Blake
2014-10-27  8:06     ` Max Reitz
2014-10-27 15:44       ` Eric Blake
2014-10-28 10:38 ` [Qemu-devel] [PATCH v14 00/14] qemu-img: Implement commit like QMP Kevin Wolf
2014-10-29 10:25 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414159063-25977-6-git-send-email-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).