diff mbox

[23/47] block: add target info to QMP query-blockjobs command

Message ID 1343127865-16608-24-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini July 24, 2012, 11:04 a.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 blockjob.c       |    3 +++
 blockjob.h       |    6 ++++++
 qapi-schema.json |   21 ++++++++++++++++++++-
 3 files changed, 29 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/blockjob.c b/blockjob.c
index 562e0b5..651ee8d 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -197,6 +197,9 @@  BlockJobInfo *block_job_query(BlockJob *job)
     info->offset    = job->offset;
     info->speed     = job->speed;
     info->io_status = job->iostatus;
+    if (job->job_type->query) {
+        job->job_type->query(job, info);
+    }
     return info;
 }
 
diff --git a/blockjob.h b/blockjob.h
index b17ee2e..5e03b5d 100644
--- a/blockjob.h
+++ b/blockjob.h
@@ -41,6 +41,12 @@  typedef struct BlockJobType {
 
     /** Optional callback for job types that support setting a speed limit */
     void (*set_speed)(BlockJob *job, int64_t speed, Error **errp);
+
+    /**
+     * Optional callback for job types that can fill the target member
+     * of BlockJobInfo.
+     */
+    void (*query)(BlockJob *job, BlockJobInfo *info);
 } BlockJobType;
 
 /**
diff --git a/qapi-schema.json b/qapi-schema.json
index b00d8c6..2697220 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -926,6 +926,21 @@ 
   'data': ['report', 'ignore', 'enospc', 'stop'] }
 
 ##
+# @BlockJobTargetInfo:
+#
+# Information about the target device for a long-running block device
+# operation.
+#
+# @info: information on the target device
+#
+# @stats: statistics about a target device
+#
+# Since: 1.2
+##
+{ 'type': 'BlockJobTargetInfo',
+  'data': {'info': 'BlockInfo', 'stats': 'BlockStats'} }
+
+##
 # @BlockJobInfo:
 #
 # Information about a long-running block device operation.
@@ -944,12 +959,16 @@ 
 #
 # @io-status: the status of the job (since 1.2)
 #
+# @target: the target device, if applicable to this particular type of
+#          job.
+#
 # Since: 1.1
 ##
 { 'type': 'BlockJobInfo',
   'data': {'type': 'str', 'device': 'str', 'len': 'int',
            'offset': 'int', 'paused': 'bool', 'speed': 'int',
-           'io-status': 'BlockDeviceIoStatus'} }
+           'io-status': 'BlockDeviceIoStatus',
+            '*target': 'BlockJobTargetInfo'} }
 
 ##
 # @query-block-jobs: