block: reduce files included by block/aio.h

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>
This commit is contained in:
Paolo Bonzini
2025-12-03 12:09:49 +01:00
parent ddab0ef124
commit 238449947d
12 changed files with 23 additions and 11 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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

View File

@@ -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"

View File

@@ -108,7 +108,7 @@ int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask)
}
QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name,
MemReentrancyGuard *reentrancy_guard)
struct MemReentrancyGuard *reentrancy_guard)
{
QEMUBH *bh = g_new(QEMUBH, 1);

View File

@@ -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"