diff mbox series

[RFC,v2,25/25] job.h: assertions in the callers of JobDriver funcion pointers

Message ID 20211005143215.29500-26-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. 5, 2021, 2:32 p.m. UTC
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 job.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Stefan Hajnoczi Oct. 7, 2021, 2:54 p.m. UTC | #1
On Tue, Oct 05, 2021 at 10:32:15AM -0400, Emanuele Giuseppe Esposito wrote:
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>  job.c | 9 +++++++++
>  1 file changed, 9 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox series

Patch

diff --git a/job.c b/job.c
index e7a5d28854..62a13b6982 100644
--- a/job.c
+++ b/job.c
@@ -373,6 +373,8 @@  void job_ref(Job *job)
 
 void job_unref(Job *job)
 {
+    g_assert(qemu_in_main_thread());
+
     if (--job->refcnt == 0) {
         assert(job->status == JOB_STATUS_NULL);
         assert(!timer_pending(&job->sleep_timer));
@@ -594,6 +596,7 @@  bool job_user_paused(Job *job)
 void job_user_resume(Job *job, Error **errp)
 {
     assert(job);
+    g_assert(qemu_in_main_thread());
     if (!job->user_paused || job->pause_count <= 0) {
         error_setg(errp, "Can't resume a job that was not paused");
         return;
@@ -664,6 +667,7 @@  static void job_update_rc(Job *job)
 static void job_commit(Job *job)
 {
     assert(!job->ret);
+    g_assert(qemu_in_main_thread());
     if (job->driver->commit) {
         job->driver->commit(job);
     }
@@ -672,6 +676,7 @@  static void job_commit(Job *job)
 static void job_abort(Job *job)
 {
     assert(job->ret);
+    g_assert(qemu_in_main_thread());
     if (job->driver->abort) {
         job->driver->abort(job);
     }
@@ -679,6 +684,7 @@  static void job_abort(Job *job)
 
 static void job_clean(Job *job)
 {
+    g_assert(qemu_in_main_thread());
     if (job->driver->clean) {
         job->driver->clean(job);
     }
@@ -718,6 +724,7 @@  static int job_finalize_single(Job *job)
 
 static void job_cancel_async(Job *job, bool force)
 {
+    g_assert(qemu_in_main_thread());
     if (job->driver->cancel) {
         job->driver->cancel(job, force);
     }
@@ -786,6 +793,7 @@  static void job_completed_txn_abort(Job *job)
 
 static int job_prepare(Job *job)
 {
+    g_assert(qemu_in_main_thread());
     if (job->ret == 0 && job->driver->prepare) {
         job->ret = job->driver->prepare(job);
         job_update_rc(job);
@@ -991,6 +999,7 @@  void job_complete(Job *job, Error **errp)
 {
     /* Should not be reachable via external interface for internal jobs */
     assert(job->id);
+    g_assert(qemu_in_main_thread());
     if (job_apply_verb(job, JOB_VERB_COMPLETE, errp)) {
         return;
     }