qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH 14/15] blockjob: Add 'id' parameter to 'block-job-co


From: Alberto Garcia
Subject: [Qemu-block] [PATCH 14/15] blockjob: Add 'id' parameter to 'block-job-complete'
Date: Thu, 9 Jun 2016 11:20:19 +0300

This patch allows the 'block-job-complete' 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_complete' command remains unchanged.

Signed-off-by: Alberto Garcia <address@hidden>
---
 blockdev.c           | 7 +++++--
 hmp.c                | 2 +-
 qapi/block-core.json | 7 ++++++-
 qmp-commands.hx      | 2 +-
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 97e5fef..63135d1 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3819,10 +3819,13 @@ void qmp_block_job_resume(bool has_id, const char *id,
     aio_context_release(aio_context);
 }
 
-void qmp_block_job_complete(const char *device, Error **errp)
+void qmp_block_job_complete(bool has_id, const char *id,
+                            bool has_device, const char *device, 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 dae1735..a2548f2 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1535,7 +1535,7 @@ void hmp_block_job_complete(Monitor *mon, const QDict 
*qdict)
     Error *error = NULL;
     const char *device = qdict_get_str(qdict, "device");
 
-    qmp_block_job_complete(device, &error);
+    qmp_block_job_complete(false, NULL, true, device, &error);
 
     hmp_handle_error(mon, &error);
 }
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0efa73d..f15e62f 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1593,6 +1593,11 @@
 #
 # A cancelled or paused job cannot be completed.
 #
+# 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: the device name
 #
 # Returns: Nothing on success
@@ -1600,7 +1605,7 @@
 #
 # Since: 1.3
 ##
-{ 'command': 'block-job-complete', 'data': { 'device': 'str' } }
+{ 'command': 'block-job-complete', 'data': { '*id': 'str', '*device': 'str' } }
 
 ##
 # @BlockdevDiscardOptions
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 716d493..d0242dc 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1305,7 +1305,7 @@ EQMP
     },
     {
         .name       = "block-job-complete",
-        .args_type  = "device:B",
+        .args_type  = "id:s?,device:B?",
         .mhandler.cmd_new = qmp_marshal_block_job_complete,
     },
     {
-- 
2.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]