diff mbox series

[v2,08/10] blockjob: query driver-specific info via a new 'query' driver method

Message ID 20231009094619.469668-9-f.ebner@proxmox.com
State New
Headers show
Series mirror: allow switching from background to active mode | expand

Commit Message

Fiona Ebner Oct. 9, 2023, 9:46 a.m. UTC
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

No changes in v2.

 blockjob.c                   | 4 ++++
 include/block/blockjob_int.h | 5 +++++
 2 files changed, 9 insertions(+)

Comments

Vladimir Sementsov-Ogievskiy Oct. 10, 2023, 7:51 p.m. UTC | #1
On 09.10.23 12:46, Fiona Ebner wrote:
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
> 
> No changes in v2.
> 
>   blockjob.c                   | 4 ++++
>   include/block/blockjob_int.h | 5 +++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/blockjob.c b/blockjob.c
> index f8cf6e58e2..7e8cfad0fd 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -376,6 +376,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();
>   
> @@ -405,6 +406,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);

Other handlers are called with job lock dropped.

> +    }
>       return info;
>   }
>   
> diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
> index f604985315..4ab88b3c97 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);
>   };
>   
>   /*
diff mbox series

Patch

diff --git a/blockjob.c b/blockjob.c
index f8cf6e58e2..7e8cfad0fd 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -376,6 +376,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();
 
@@ -405,6 +406,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 f604985315..4ab88b3c97 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);
 };
 
 /*