diff mbox series

[6/9] blockjob: query driver-specific info via a new 'query' driver method

Message ID 20230224144825.466375-7-f.ebner@proxmox.com (mailing list archive)
State New, archived
Headers show
Series mirror: allow switching from background to active mode | expand

Commit Message

Fiona Ebner Feb. 24, 2023, 2:48 p.m. UTC
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 blockjob.c                   | 4 ++++
 include/block/blockjob_int.h | 5 +++++
 2 files changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/blockjob.c b/blockjob.c
index 9bd51bc6ae..5570890001 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -349,6 +349,7 @@  BlockJobInfo *block_job_query_locked(BlockJob *job, Error **errp)
 {
     BlockJobInfo *info;
     uint64_t progress_current, progress_total;
+    const BlockJobDriver *drv = block_job_driver(job);
 
     GLOBAL_STATE_CODE();
 
@@ -378,6 +379,9 @@  BlockJobInfo *block_job_query_locked(BlockJob *job, Error **errp)
                         g_strdup(error_get_pretty(job->job.err)) :
                         g_strdup(strerror(-job->job.ret));
     }
+    if (drv->query) {
+        drv->query(job, info);
+    }
     return info;
 }
 
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
index 055bee5020..e4543e9885 100644
--- a/include/block/blockjob_int.h
+++ b/include/block/blockjob_int.h
@@ -72,6 +72,11 @@  struct BlockJobDriver {
      * Change the @job's options according to @opts.
      */
     void (*change)(BlockJob *job, BlockJobChangeOptions *opts, Error **errp);
+
+    /*
+     * Query information specific to this kind of block job.
+     */
+    void (*query)(BlockJob *job, BlockJobInfo *info);
 };
 
 /*