diff mbox series

[v4,10/25] assertions for blockjob_int.h

Message ID 20211025101735.2060852-11-eesposit@redhat.com (mailing list archive)
State New, archived
Headers show
Series block layer: split block APIs in global state and I/O | expand

Commit Message

Emanuele Giuseppe Esposito Oct. 25, 2021, 10:17 a.m. UTC
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 blockjob.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Hanna Czenczek Nov. 12, 2021, 3:17 p.m. UTC | #1
On 25.10.21 12:17, Emanuele Giuseppe Esposito wrote:
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   blockjob.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/blockjob.c b/blockjob.c
> index 4bad1408cb..fbd6c7d873 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -83,6 +83,7 @@ BlockJob *block_job_get(const char *id)
>   
>   void block_job_free(Job *job)
>   {
> +    assert(qemu_in_main_thread());
>       BlockJob *bjob = container_of(job, BlockJob, job);

Our coding style (docs/devel/style.rst) requires all statements to come 
after all declarations in a block, so the assert() may not precede the 
bjob declaration.

>   
>       block_job_remove_all_bdrv(bjob);
> @@ -436,6 +437,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
>       BlockBackend *blk;
>       BlockJob *job;
>   
> +    assert(qemu_in_main_thread());
> +
>       if (job_id == NULL && !(flags & JOB_INTERNAL)) {
>           job_id = bdrv_get_device_name(bs);
>       }
> @@ -504,6 +507,7 @@ void block_job_iostatus_reset(BlockJob *job)
>   
>   void block_job_user_resume(Job *job)
>   {
> +    assert(qemu_in_main_thread());
>       BlockJob *bjob = container_of(job, BlockJob, job);

Same here.

(And now I see that I’ve missed such instances in the other assertion 
patches, like in bdrv_save_vmstate(), those should be fixed, too)

Hanna

>       block_job_iostatus_reset(bjob);
>   }
diff mbox series

Patch

diff --git a/blockjob.c b/blockjob.c
index 4bad1408cb..fbd6c7d873 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -83,6 +83,7 @@  BlockJob *block_job_get(const char *id)
 
 void block_job_free(Job *job)
 {
+    assert(qemu_in_main_thread());
     BlockJob *bjob = container_of(job, BlockJob, job);
 
     block_job_remove_all_bdrv(bjob);
@@ -436,6 +437,8 @@  void *block_job_create(const char *job_id, const BlockJobDriver *driver,
     BlockBackend *blk;
     BlockJob *job;
 
+    assert(qemu_in_main_thread());
+
     if (job_id == NULL && !(flags & JOB_INTERNAL)) {
         job_id = bdrv_get_device_name(bs);
     }
@@ -504,6 +507,7 @@  void block_job_iostatus_reset(BlockJob *job)
 
 void block_job_user_resume(Job *job)
 {
+    assert(qemu_in_main_thread());
     BlockJob *bjob = container_of(job, BlockJob, job);
     block_job_iostatus_reset(bjob);
 }