diff mbox series

[PULL,25/27] blockjob: query driver-specific info via a new 'query' driver method

Message ID 20231031185918.346940-26-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,01/27] qemu-img: rebase: stop when reaching EOF of old backing file | expand

Commit Message

Kevin Wolf Oct. 31, 2023, 6:59 p.m. UTC
From: Fiona Ebner <f.ebner@proxmox.com>

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <20231031135431.393137-9-f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/block/blockjob_int.h | 5 +++++
 blockjob.c                   | 6 ++++++
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
index a4656d4cb5..18ee6f7bf0 100644
--- a/include/block/blockjob_int.h
+++ b/include/block/blockjob_int.h
@@ -74,6 +74,11 @@  struct BlockJobDriver {
      * Note that this can already be called before the job coroutine is running.
      */
     void (*change)(BlockJob *job, BlockJobChangeOptions *opts, Error **errp);
+
+    /*
+     * Query information specific to this kind of block job.
+     */
+    void (*query)(BlockJob *job, BlockJobInfo *info);
 };
 
 /*
diff --git a/blockjob.c b/blockjob.c
index 5b4786a70f..5b24de356d 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -378,6 +378,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();
 
@@ -407,6 +408,11 @@  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) {
+        job_unlock();
+        drv->query(job, info);
+        job_lock();
+    }
     return info;
 }