All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Eric Blake <eblake@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
	Jeff Cody <jcody@redhat.com>, Alberto Garcia <berto@igalia.com>
Subject: [Qemu-devel] [PATCH v2 11/15] blockjob: Add 'id' parameter to 'block-job-cancel'
Date: Wed, 22 Jun 2016 15:25:08 +0300	[thread overview]
Message-ID: <dcafd044d8dc16761671d02cac9dbe7bbb92a7a3.1466598035.git.berto@igalia.com> (raw)
In-Reply-To: <cover.1466598035.git.berto@igalia.com>
In-Reply-To: <cover.1466598035.git.berto@igalia.com>

This patch allows the 'block-job-cancel' command to identify the
job by either its ID or its device name. The latter becomes now
optional since the ID alone is enough to identify the job.

The HMP 'block_job_cancel' command remains unchanged.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 blockdev.c           |  7 +++++--
 hmp.c                |  2 +-
 qapi/block-core.json | 10 ++++++++--
 qmp-commands.hx      |  2 +-
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index bd276ee..3a0b22a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3776,11 +3776,14 @@ void qmp_block_job_set_speed(bool has_id, const char *id, bool has_device,
     aio_context_release(aio_context);
 }
 
-void qmp_block_job_cancel(const char *device,
+void qmp_block_job_cancel(bool has_id, const char *id,
+                          bool has_device, const char *device,
                           bool has_force, bool force, Error **errp)
 {
     AioContext *aio_context;
-    BlockJob *job = find_block_job(NULL, device, &aio_context, errp);
+    BlockJob *job = find_block_job(has_id ? id : NULL,
+                                   has_device ? device : NULL,
+                                   &aio_context, errp);
 
     if (!job) {
         return;
diff --git a/hmp.c b/hmp.c
index f498ccd..ed5a125 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1509,7 +1509,7 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
     const char *device = qdict_get_str(qdict, "device");
     bool force = qdict_get_try_bool(qdict, "force", false);
 
-    qmp_block_job_cancel(device, true, force, &error);
+    qmp_block_job_cancel(false, NULL, true, device, true, force, &error);
 
     hmp_handle_error(mon, &error);
 }
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 64038cc..38dd3f2 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1505,7 +1505,12 @@
 # operation can be started at a later time to finish copying all data from the
 # backing file.
 #
-# @device: the device name
+# The job must be identified with the @id or @device parameters, but
+# only one of them must be set.
+#
+# @id: #optional the job identifier (Since 2.7)
+#
+# @device: #optional the device name
 #
 # @force: #optional whether to allow cancellation of a paused job (default
 #         false).  Since 1.3.
@@ -1515,7 +1520,8 @@
 #
 # Since: 1.1
 ##
-{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } }
+{ 'command': 'block-job-cancel',
+  'data': { '*id': 'str', '*device': 'str', '*force': 'bool' } }
 
 ##
 # @block-job-pause:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index cc70007..c7d207a 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1317,7 +1317,7 @@ EQMP
 
     {
         .name       = "block-job-cancel",
-        .args_type  = "device:B,force:b?",
+        .args_type  = "id:s?,device:B?,force:b?",
         .mhandler.cmd_new = qmp_marshal_block_job_cancel,
     },
     {
-- 
2.8.1

  parent reply	other threads:[~2016-06-22 12:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 12:24 [Qemu-devel] [PATCH v2 00/15] Add an 'id' field to block jobs Alberto Garcia
2016-06-22 12:24 ` [Qemu-devel] [PATCH v2 01/15] stream: Fix prototype of stream_start() Alberto Garcia
2016-06-22 12:45   ` Kevin Wolf
2016-06-22 12:24 ` [Qemu-devel] [PATCH v2 02/15] blockjob: Decouple the ID from the device name in the BlockJob struct Alberto Garcia
2016-06-22 12:42   ` Kevin Wolf
2016-06-22 14:42     ` Alberto Garcia
2016-06-22 15:49       ` Kevin Wolf
2016-06-23 12:47         ` Alberto Garcia
2016-06-29 17:20           ` Max Reitz
2016-06-30 13:03             ` Alberto Garcia
2016-07-01 18:48               ` John Snow
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 03/15] blockjob: Add block_job_get() Alberto Garcia
2016-06-22 12:45   ` Kevin Wolf
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 04/15] block: Simplify find_block_job() and make it accept a job ID Alberto Garcia
2016-06-22 12:50   ` Kevin Wolf
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 05/15] blockjob: Add 'job_id' parameter to block_job_create() Alberto Garcia
2016-06-22 13:10   ` Kevin Wolf
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 06/15] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror' Alberto Garcia
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 07/15] backup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup' Alberto Garcia
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 08/15] stream: Add 'job-id' parameter to 'block-stream' Alberto Garcia
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 09/15] commit: Add 'job-id' parameter to 'block-commit' Alberto Garcia
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 10/15] blockjob: Add 'id' parameter to 'block-job-set-speed' Alberto Garcia
2016-06-22 12:25 ` Alberto Garcia [this message]
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 12/15] blockjob: Add 'id' parameter to 'block-job-pause' Alberto Garcia
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 13/15] blockjob: Add 'id' parameter to 'block-job-resume' Alberto Garcia
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 14/15] blockjob: Add 'id' parameter to 'block-job-complete' Alberto Garcia
2016-06-22 12:25 ` [Qemu-devel] [PATCH v2 15/15] blockjob: Add 'id' field to 'BlockJobInfo' and all BLOCK_JOB_* events Alberto Garcia

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=dcafd044d8dc16761671d02cac9dbe7bbb92a7a3.1466598035.git.berto@igalia.com \
    --to=berto@igalia.com \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.