qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.omc
Subject: [PATCH 3/5] block: reduce files included by block/aio.h
Date: Wed,  3 Dec 2025 19:51:31 +0100	[thread overview]
Message-ID: <20251203185133.2458207-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20251203185133.2458207-1-pbonzini@redhat.com>

Avoid including all of qdev everywhere (the hw/core/qdev.h header in fact
brings in a lot more headers too), instead declare a couple structs for
which only a pointer type is needed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/block/aio.h                |  7 +++----
 include/block/block-copy.h         |  1 +
 include/block/block-global-state.h |  1 +
 include/block/block-io.h           |  1 +
 include/block/dirty-bitmap.h       |  1 +
 include/hw/core/qdev.h             |  6 +-----
 include/qemu/job.h                 |  1 +
 include/qemu/main-loop.h           |  2 +-
 include/qemu/mem-reentrancy.h      | 10 ++++++++++
 net/net.c                          |  1 +
 util/async.c                       |  1 +
 11 files changed, 22 insertions(+), 10 deletions(-)
 create mode 100644 include/qemu/mem-reentrancy.h

diff --git a/include/block/aio.h b/include/block/aio.h
index 59c56d695ee..8cca2360d1a 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -23,9 +23,8 @@
 #include "qemu/lockcnt.h"
 #include "qemu/thread.h"
 #include "qemu/timer.h"
-#include "block/graph-lock.h"
-#include "hw/core/qdev.h"
 
+struct MemReentrancyGuard;
 
 typedef struct AioHandler AioHandler;
 typedef QLIST_HEAD(, AioHandler) AioHandlerList;
@@ -211,7 +210,7 @@ struct AioContext {
      * of nodes and edges from block graph while some
      * other thread is traversing it.
      */
-    BdrvGraphRWlock *bdrv_graph;
+    struct BdrvGraphRWlock *bdrv_graph;
 
     /* The list of registered AIO handlers.  Protected by ctx->list_lock. */
     AioHandlerList aio_handlers;
@@ -393,7 +392,7 @@ void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
  * device-reentrancy issues
  */
 QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,
-                        const char *name, MemReentrancyGuard *reentrancy_guard);
+                        const char *name, struct MemReentrancyGuard *reentrancy_guard);
 
 /**
  * aio_bh_new: Allocate a new bottom half structure
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
index dd5cc82f3b2..0df2771181b 100644
--- a/include/block/block-copy.h
+++ b/include/block/block-copy.h
@@ -16,6 +16,7 @@
 #define BLOCK_COPY_H
 
 #include "block/block-common.h"
+#include "block/graph-lock.h"
 #include "qemu/progress_meter.h"
 
 /* All APIs are thread-safe */
diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h
index c2127f17249..ed89999f0fb 100644
--- a/include/block/block-global-state.h
+++ b/include/block/block-global-state.h
@@ -25,6 +25,7 @@
 #define BLOCK_GLOBAL_STATE_H
 
 #include "qemu/aiocb.h"
+#include "block/graph-lock.h"
 #include "block/block-common.h"
 #include "qemu/coroutine.h"
 #include "qemu/transactions.h"
diff --git a/include/block/block-io.h b/include/block/block-io.h
index e5efe0efb2f..7925e2241e6 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -27,6 +27,7 @@
 #include "qemu/aiocb.h"
 #include "block/aio-wait.h"
 #include "block/block-common.h"
+#include "block/graph-lock.h"
 #include "qemu/coroutine.h"
 #include "qemu/iov.h"
 
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index fa956debfb2..28029bbc2bc 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -2,6 +2,7 @@
 #define BLOCK_DIRTY_BITMAP_H
 
 #include "block/block-common.h"
+#include "block/graph-lock.h"
 #include "qapi/qapi-types-block-core.h"
 #include "qemu/hbitmap.h"
 
diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h
index e211d807e82..4b2730e9d8e 100644
--- a/include/hw/core/qdev.h
+++ b/include/hw/core/qdev.h
@@ -4,6 +4,7 @@
 #include "qemu/atomic.h"
 #include "qemu/queue.h"
 #include "qemu/bitmap.h"
+#include "qemu/mem-reentrancy.h"
 #include "qemu/rcu.h"
 #include "qemu/rcu_queue.h"
 #include "qom/object.h"
@@ -208,11 +209,6 @@ struct NamedClockList {
     QLIST_ENTRY(NamedClockList) node;
 };
 
-typedef struct MemReentrancyGuard {
-    bool engaged_in_io;
-} MemReentrancyGuard;
-
-
 typedef QLIST_HEAD(, NamedGPIOList) NamedGPIOListHead;
 typedef QLIST_HEAD(, NamedClockList) NamedClockListHead;
 typedef QLIST_HEAD(, BusState) BusStateHead;
diff --git a/include/qemu/job.h b/include/qemu/job.h
index af29b8c6531..2b163602c56 100644
--- a/include/qemu/job.h
+++ b/include/qemu/job.h
@@ -32,6 +32,7 @@
 #include "qemu/progress_meter.h"
 #include "qemu/coroutine.h"
 #include "block/aio.h"
+#include "block/graph-lock.h"
 
 typedef struct JobDriver JobDriver;
 typedef struct JobTxn JobTxn;
diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h
index 0d55c636b21..241dc87be50 100644
--- a/include/qemu/main-loop.h
+++ b/include/qemu/main-loop.h
@@ -431,7 +431,7 @@ void qemu_cond_timedwait_bql(QemuCond *cond, int ms);
 #define qemu_bh_new(cb, opaque) \
     qemu_bh_new_full((cb), (opaque), (stringify(cb)), NULL)
 QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name,
-                         MemReentrancyGuard *reentrancy_guard);
+                         struct MemReentrancyGuard *reentrancy_guard);
 void qemu_bh_schedule_idle(QEMUBH *bh);
 
 enum {
diff --git a/include/qemu/mem-reentrancy.h b/include/qemu/mem-reentrancy.h
new file mode 100644
index 00000000000..07cafd47179
--- /dev/null
+++ b/include/qemu/mem-reentrancy.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef QEMU_MEM_REENTRANCY_H
+#define QEMU_MEM_REENTRANCY_H 1
+
+typedef struct MemReentrancyGuard {
+    bool engaged_in_io;
+} MemReentrancyGuard;
+
+#endif
diff --git a/net/net.c b/net/net.c
index 4930b573ed3..a176936f9bc 100644
--- a/net/net.c
+++ b/net/net.c
@@ -39,6 +39,7 @@
 #include "qobject/qdict.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
+#include "qemu/mem-reentrancy.h"
 #include "qemu/sockets.h"
 #include "qemu/cutils.h"
 #include "qemu/config-file.h"
diff --git a/util/async.c b/util/async.c
index 48f88286369..39f391fb71a 100644
--- a/util/async.c
+++ b/util/async.c
@@ -29,6 +29,7 @@
 #include "block/thread-pool.h"
 #include "block/graph-lock.h"
 #include "qemu/main-loop.h"
+#include "qemu/mem-reentrancy.h"
 #include "qemu/atomic.h"
 #include "qemu/lockcnt.h"
 #include "qemu/rcu_queue.h"
-- 
2.52.0



  parent reply	other threads:[~2025-12-03 18:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-03 18:51 [PATCH 0/5] block: move AioContext and AIOCB out of include/block/ Paolo Bonzini
2025-12-03 18:51 ` [PATCH 1/5] hw: add missing includes hidden by block/aio.h Paolo Bonzini
2025-12-04  8:32   ` Philippe Mathieu-Daudé
2025-12-03 18:51 ` [PATCH 2/5] block: extract include/qemu/aiocb.h out of include/block/aio.h Paolo Bonzini
2025-12-04  8:33   ` Philippe Mathieu-Daudé
2025-12-03 18:51 ` Paolo Bonzini [this message]
2025-12-04  8:35   ` [PATCH 3/5] block: reduce files included by block/aio.h Philippe Mathieu-Daudé
2025-12-04  9:25     ` Paolo Bonzini
2025-12-04 17:03       ` Philippe Mathieu-Daudé
2025-12-04 17:46         ` Paolo Bonzini
2025-12-03 18:51 ` [PATCH 4/5] block: rename block/aio.h to qemu/aio.h Paolo Bonzini
2025-12-04  8:35   ` Philippe Mathieu-Daudé
2025-12-03 18:51 ` [PATCH 5/5] block: rename block/aio-wait.h to qemu/aio-wait.h Paolo Bonzini
2025-12-04  8:36   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251203185133.2458207-4-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.omc \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).