Skip to contentSkip to conversation

coroutine: Clean up includes

PATCH Superseded Markus Armbruster 2 participants 8 messages Dec 20, 2022 – Dec 21, 2022

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover coroutine: Clean up includes

v2:
* Rebased
* PATCH 4: Rewritten [Paolo]
* PATCH 5: New

Markus Armbruster (5):
coroutine: Clean up superfluous inclusion of qemu/coroutine.h
coroutine: Move coroutine_fn to qemu/osdep.h, trim includes
coroutine: Clean up superfluous inclusion of qemu/lockable.h
coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h
coroutine: Use Coroutine typedef name instead of structure tag

 crypto/block-luks-priv.h      |   1 -
 hw/9pfs/coth.h                |   2 +-
 include/block/aio.h           |   9 +-
 include/block/aio_task.h      |   2 -
 include/block/block-common.h  |   1 -
 include/block/graph-lock.h    |   2 -
 include/block/raw-aio.h       |   1 -
 include/io/channel.h          |   2 +-
 include/monitor/hmp.h         |   1 -
 include/qemu/coroutine-core.h | 154 ++++++++++++++++++++++++++++++++++
 include/qemu/coroutine.h      | 113 ++-----------------------
 include/qemu/lockable.h       |   2 +-
 include/qemu/osdep.h          |  16 ++++
 include/qemu/progress_meter.h |   2 +-
 include/qemu/typedefs.h       |   1 -
 include/scsi/pr-manager.h     |   1 -
 nbd/nbd-internal.h            |   1 -
 block.c                       |   2 +-
 block/block-copy.c            |   2 +-
 block/io_uring.c              |   2 +-
 block/linux-aio.c             |   2 +-
 block/mirror.c                |   2 +-
 block/progress_meter.c        |   2 +
 block/vdi.c                   |   2 +-
 blockjob.c                    |   1 -
 chardev/char.c                |   2 +-
 crypto/block-luks.c           |   1 -
 hw/9pfs/codir.c               |   1 -
 hw/9pfs/cofile.c              |   1 -
 hw/9pfs/cofs.c                |   1 -
 hw/9pfs/coth.c                |   2 +-
 hw/9pfs/coxattr.c             |   1 -
 hw/block/virtio-blk.c         |   2 +-
 migration/rdma.c              |   2 +-
 nbd/client-connection.c       |   1 +
 net/colo-compare.c            |   2 +-
 qapi/qmp-dispatch.c           |   2 +-
 tests/unit/test-aio.c         |   2 +-
 tests/unit/test-coroutine.c   |   2 -
 tests/unit/test-vmstate.c     |   1 -
 ui/console.c                  |   1 +
 util/async.c                  |   4 +-
 util/qemu-coroutine-lock.c    |   1 -
 util/qemu-coroutine-sleep.c   |   1 -
 util/qemu-coroutine.c         |   1 -
 util/thread-pool.c            |   2 +-
 46 files changed, 205 insertions(+), 154 deletions(-)
 create mode 100644 include/qemu/coroutine-core.h
Signature · 1 line
2.38.1
#1 lore raw

PATCH v2 1/5 coroutine: Clean up superfluous inclusion of qemu/coroutine.h

---
 crypto/block-luks-priv.h    | 1 -
 include/block/raw-aio.h     | 1 -
 include/scsi/pr-manager.h   | 1 -
 nbd/nbd-internal.h          | 1 -
 blockjob.c                  | 1 -
 crypto/block-luks.c         | 1 -
 hw/9pfs/codir.c             | 1 -
 hw/9pfs/cofile.c            | 1 -
 hw/9pfs/cofs.c              | 1 -
 hw/9pfs/coxattr.c           | 1 -
 tests/unit/test-coroutine.c | 1 -
 tests/unit/test-vmstate.c   | 1 -
 util/qemu-coroutine-lock.c  | 1 -
 util/qemu-coroutine-sleep.c | 1 -
 util/qemu-coroutine.c       | 1 -
 15 files changed, 15 deletions(-)
crypto/block-luks-priv.h +0 -1
index 90a20d432b..dc2dd14e52 100644
@@ -31,7 +31,6 @@
 #include "crypto/random.h"
 #include "qemu/uuid.h"
 
-#include "qemu/coroutine.h"
 #include "qemu/bitmap.h"
 
 /*
include/block/raw-aio.h +0 -1
index 21fc10c4c9..f8cda9df91 100644
@@ -17,7 +17,6 @@
 #define QEMU_RAW_AIO_H
 
 #include "block/aio.h"
-#include "qemu/coroutine.h"
 #include "qemu/iov.h"
 
 /* AIO request types */
include/scsi/pr-manager.h +0 -1
index e4ecbe00f6..45de28d354 100644
@@ -5,7 +5,6 @@
 #include "qapi/visitor.h"
 #include "qom/object_interfaces.h"
 #include "block/aio.h"
-#include "qemu/coroutine.h"
 
 #define TYPE_PR_MANAGER "pr-manager"
 
nbd/nbd-internal.h +0 -1
index 1b2141ab4b..df42fef706 100644
@@ -13,7 +13,6 @@
 #include "sysemu/block-backend.h"
 #include "io/channel-tls.h"
 
-#include "qemu/coroutine.h"
 #include "qemu/iov.h"
 
 #ifndef _WIN32
blockjob.c +0 -1
index b7daf2a9f6..54b4091a36 100644
@@ -32,7 +32,6 @@
 #include "qapi/error.h"
 #include "qapi/qapi-events-block-core.h"
 #include "qapi/qmp/qerror.h"
-#include "qemu/coroutine.h"
 #include "qemu/main-loop.h"
 #include "qemu/timer.h"
 
crypto/block-luks.c +0 -1
index ff9e3945d1..5688783ab1 100644
@@ -32,7 +32,6 @@
 #include "crypto/random.h"
 #include "qemu/uuid.h"
 
-#include "qemu/coroutine.h"
 #include "qemu/bitmap.h"
 
 /*
hw/9pfs/codir.c +0 -1
index 93ba44fb75..7ba63be489 100644
@@ -19,7 +19,6 @@
 #include "qemu/osdep.h"
 #include "fsdev/qemu-fsdev.h"
 #include "qemu/thread.h"
-#include "qemu/coroutine.h"
 #include "qemu/main-loop.h"
 #include "coth.h"
 #include "9p-xattr.h"
hw/9pfs/cofile.c +0 -1
index 20f93a90e7..9c5344039e 100644
@@ -19,7 +19,6 @@
 #include "qemu/osdep.h"
 #include "fsdev/qemu-fsdev.h"
 #include "qemu/thread.h"
-#include "qemu/coroutine.h"
 #include "qemu/main-loop.h"
 #include "coth.h"
 
hw/9pfs/cofs.c +0 -1
index 9d0adc2e78..67e3ae5c5c 100644
@@ -19,7 +19,6 @@
 #include "qemu/osdep.h"
 #include "fsdev/qemu-fsdev.h"
 #include "qemu/thread.h"
-#include "qemu/coroutine.h"
 #include "qemu/main-loop.h"
 #include "coth.h"
 
hw/9pfs/coxattr.c +0 -1
index dbcd09e0fd..cd0f8488ac 100644
@@ -19,7 +19,6 @@
 #include "qemu/osdep.h"
 #include "fsdev/qemu-fsdev.h"
 #include "qemu/thread.h"
-#include "qemu/coroutine.h"
 #include "qemu/main-loop.h"
 #include "coth.h"
 
tests/unit/test-coroutine.c +0 -1
index e16b80c245..513800d3db 100644
@@ -12,7 +12,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/coroutine.h"
 #include "qemu/coroutine_int.h"
 #include "qemu/lockable.h"
 
tests/unit/test-vmstate.c +0 -1
index 541bb4f63e..79357b29ca 100644
@@ -29,7 +29,6 @@
 #include "migration/qemu-file-types.h"
 #include "../migration/qemu-file.h"
 #include "../migration/savevm.h"
-#include "qemu/coroutine.h"
 #include "qemu/module.h"
 #include "io/channel-file.h"
 
util/qemu-coroutine-lock.c +0 -1
index 45c6b57374..58f3f77181 100644
@@ -27,7 +27,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/coroutine.h"
 #include "qemu/coroutine_int.h"
 #include "qemu/processor.h"
 #include "qemu/queue.h"
util/qemu-coroutine-sleep.c +0 -1
index 571ab521ff..af59f9af98 100644
@@ -12,7 +12,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/coroutine.h"
 #include "qemu/coroutine_int.h"
 #include "qemu/timer.h"
 #include "block/aio.h"
util/qemu-coroutine.c +0 -1
index 356b746f0b..8494523692 100644
@@ -16,7 +16,6 @@
 #include "trace.h"
 #include "qemu/thread.h"
 #include "qemu/atomic.h"
-#include "qemu/coroutine.h"
 #include "qemu/coroutine_int.h"
 #include "qemu/coroutine-tls.h"
 #include "block/aio.h"
Signature · 1 line
2.38.1
#2 lore raw

PATCH v2 2/5 coroutine: Move coroutine_fn to qemu/osdep.h, trim includes

In reply to Markus Armbruster

block/block-hmp-cmds.h and qemu/co-shared-resource.h use coroutine_fn without including qemu/coroutine.h. They compile only if it's already included from elsewhere.

I could fix that, but pulling in qemu/coroutine.h and everything it includes just for a macro that expands into nothing feels silly. Instead, move the macro to qemu/osdep.h.

Inclusions of qemu/coroutine.h just for coroutine_fn become superfluous. Drop them.

---
 include/block/aio_task.h     |  2 --
 include/block/block-common.h |  1 -
 include/block/graph-lock.h   |  2 --
 include/monitor/hmp.h        |  1 -
 include/qemu/coroutine.h     | 18 +++++++-----------
 include/qemu/osdep.h         | 16 ++++++++++++++++
 6 files changed, 23 insertions(+), 17 deletions(-)
include/block/aio_task.h +0 -2
index 50bc1e1817..18a9c41f4e 100644
@@ -25,8 +25,6 @@
 #ifndef BLOCK_AIO_TASK_H
 #define BLOCK_AIO_TASK_H
 
-#include "qemu/coroutine.h"
-
 typedef struct AioTaskPool AioTaskPool;
 typedef struct AioTask AioTask;
 typedef int coroutine_fn (*AioTaskFunc)(AioTask *task);
include/block/block-common.h +0 -1
index 4749c46a5e..434ffc5d34 100644
@@ -27,7 +27,6 @@
 #include "block/aio.h"
 #include "block/aio-wait.h"
 #include "qemu/iov.h"
-#include "qemu/coroutine.h"
 #include "block/accounting.h"
 #include "qemu/hbitmap.h"
 #include "qemu/transactions.h"
include/block/graph-lock.h +0 -2
index 4c92cd8edf..3ab924d5e2 100644
@@ -23,8 +23,6 @@
 #include "qemu/osdep.h"
 #include "qemu/clang-tsa.h"
 
-#include "qemu/coroutine.h"
-
 /**
  * Graph Lock API
  * This API provides a rwlock used to protect block layer
include/monitor/hmp.h +0 -1
index dfbc0c9a2f..c92f69da8b 100644
@@ -15,7 +15,6 @@
 #define HMP_H
 
 #include "qemu/readline.h"
-#include "qemu/coroutine.h"
 #include "qapi/qapi-types-common.h"
 
 bool hmp_handle_error(Monitor *mon, Error *err);
include/qemu/coroutine.h +7 -11
index 89650a2d7f..2496a4f4ef 100644
@@ -26,23 +26,19 @@
  * waiting for events to complete.
  *
  * These functions are re-entrant and may be used outside the global mutex.
- */
-
-/**
- * Mark a function that executes in coroutine context
  *
- * Functions that execute in coroutine context cannot be called directly from
- * normal functions.  In the future it would be nice to enable compiler or
- * static checker support for catching such errors.  This annotation might make
- * it possible and in the meantime it serves as documentation.
- *
- * For example:
+ * Functions that execute in coroutine context cannot be called
+ * directly from normal functions.  Use @coroutine_fn to mark such
+ * functions.  For example:
  *
  *   static void coroutine_fn foo(void) {
  *       ....
  *   }
+ *
+ * In the future it would be nice to have the compiler or a static
+ * checker catch misuse of such functions.  This annotation might make
+ * it possible and in the meantime it serves as documentation.
  */
-#define coroutine_fn
 
 typedef struct Coroutine Coroutine;
 
include/qemu/osdep.h +16 -0
index b9c4307779..8e97e5d79a 100644
@@ -157,6 +157,22 @@ extern "C" {
 
 #include "qemu/typedefs.h"
 
+/**
+ * Mark a function that executes in coroutine context
+ *
+ * Functions that execute in coroutine context cannot be called directly from
+ * normal functions.  In the future it would be nice to enable compiler or
+ * static checker support for catching such errors.  This annotation might make
+ * it possible and in the meantime it serves as documentation.
+ *
+ * For example:
+ *
+ *   static void coroutine_fn foo(void) {
+ *       ....
+ *   }
+ */
+#define coroutine_fn
+
 /*
  * For mingw, as of v6.0.0, the function implementing the assert macro is
  * not marked as noreturn, so the compiler cannot delete code following an
Signature · 1 line
2.38.1
#3 lore raw

PATCH v2 3/5 coroutine: Clean up superfluous inclusion of qemu/lockable.h

In reply to Markus Armbruster
---
 include/qemu/progress_meter.h | 2 +-
 block/progress_meter.c        | 2 ++
 tests/unit/test-coroutine.c   | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)
include/qemu/progress_meter.h +1 -1
index dadf822bbf..0f2c0a32d2 100644
@@ -27,7 +27,7 @@
 #ifndef QEMU_PROGRESS_METER_H
 #define QEMU_PROGRESS_METER_H
 
-#include "qemu/lockable.h"
+#include "qemu/thread.h"
 
 typedef struct ProgressMeter {
     /**
block/progress_meter.c +2 -0
index aa2e60248c..31a170a2cd 100644
@@ -23,7 +23,9 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 #include "qemu/osdep.h"
+#include "qemu/coroutine.h"
 #include "qemu/progress_meter.h"
 
 void progress_init(ProgressMeter *pm)
tests/unit/test-coroutine.c +0 -1
index 513800d3db..b0d21d673a 100644
@@ -13,7 +13,6 @@
 
 #include "qemu/osdep.h"
 #include "qemu/coroutine_int.h"
-#include "qemu/lockable.h"
 
 /*
  * Check that qemu_in_coroutine() works
Signature · 1 line
2.38.1
#4 lore raw

PATCH v2 4/5 coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h

In reply to Markus Armbruster

qemu/coroutine.h and qemu/lockable.h include each other.

They need each other only in macro expansions, so we could simply drop both inclusions to break the loop, and add suitable includes to files that expand the macros.

Instead, move a part of qemu/coroutine.h to new qemu/coroutine-core.h so that qemu/coroutine-core.h doesn't need qemu/lockable.h, and qemu/lockable.h only needs qemu/coroutine-core.h. Result:
qemu/coroutine.h includes qemu/lockable.h includes qemu/coroutine-core.h.

---
 hw/9pfs/coth.h                |   2 +-
 include/block/aio.h           |   2 +-
 include/io/channel.h          |   2 +-
 include/qemu/coroutine-core.h | 154 ++++++++++++++++++++++++++++++++++
 include/qemu/coroutine.h      |  97 +--------------------
 include/qemu/lockable.h       |   2 +-
 include/qemu/typedefs.h       |   1 -
 block.c                       |   2 +-
 block/block-copy.c            |   2 +-
 block/io_uring.c              |   2 +-
 block/linux-aio.c             |   2 +-
 block/mirror.c                |   2 +-
 block/vdi.c                   |   2 +-
 chardev/char.c                |   2 +-
 hw/9pfs/coth.c                |   2 +-
 hw/block/virtio-blk.c         |   2 +-
 migration/rdma.c              |   2 +-
 nbd/client-connection.c       |   1 +
 net/colo-compare.c            |   2 +-
 qapi/qmp-dispatch.c           |   2 +-
 tests/unit/test-aio.c         |   2 +-
 ui/console.c                  |   1 +
 util/thread-pool.c            |   2 +-
 23 files changed, 175 insertions(+), 115 deletions(-)
 create mode 100644 include/qemu/coroutine-core.h
hw/9pfs/coth.h +1 -1
index 1a1edbdc2a..2c54249b35 100644
@@ -16,7 +16,7 @@
 #define QEMU_9P_COTH_H
 
 #include "qemu/thread.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "9p.h"
 
 /*
include/block/aio.h +1 -1
index 0f65a3cc9e..3a546e7515 100644
@@ -17,7 +17,7 @@
 #ifdef CONFIG_LINUX_IO_URING
 #include <liburing.h>
 #endif
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/queue.h"
 #include "qemu/event_notifier.h"
 #include "qemu/thread.h"
include/io/channel.h +1 -1
index f1b7e05f81..78b15f7870 100644
@@ -22,7 +22,7 @@
 #define QIO_CHANNEL_H
 
 #include "qom/object.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "block/aio.h"
 
 #define TYPE_QIO_CHANNEL "qio-channel"
include/qemu/coroutine-core.h new file +154 -0

154 lines not on this page · raw message

include/qemu/coroutine.h +1 -96

115 lines not on this page · raw message

include/qemu/lockable.h +1 -1
index 86db7cb04c..9823220446 100644
@@ -13,7 +13,7 @@
 #ifndef QEMU_LOCKABLE_H
 #define QEMU_LOCKABLE_H
 
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/thread.h"
 
 typedef void QemuLockUnlockFunc(void *);
include/qemu/typedefs.h +0 -1
index 688408e048..0f7329b70f 100644
@@ -37,7 +37,6 @@ typedef struct BusState BusState;
 typedef struct Chardev Chardev;
 typedef struct Clock Clock;
 typedef struct CompatProperty CompatProperty;
-typedef struct CoMutex CoMutex;
 typedef struct ConfidentialGuestSupport ConfidentialGuestSupport;
 typedef struct CPUAddressSpace CPUAddressSpace;
 typedef struct CPUArchState CPUArchState;
block.c +1 -1
index 9c2ac757e4..be78be95f9 100644
@@ -44,7 +44,7 @@
 #include "sysemu/block-backend.h"
 #include "qemu/notify.h"
 #include "qemu/option.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "block/qapi.h"
 #include "qemu/timer.h"
 #include "qemu/cutils.h"
block/block-copy.c +1 -1
index 5e59d6262f..3261a6a0d2 100644
@@ -20,7 +20,7 @@
 #include "block/reqlist.h"
 #include "sysemu/block-backend.h"
 #include "qemu/units.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "block/aio_task.h"
 #include "qemu/error-report.h"
 #include "qemu/memalign.h"
block/io_uring.c +1 -1
index 973e15d876..1ece7a75c8 100644
@@ -14,7 +14,7 @@
 #include "qemu/queue.h"
 #include "block/block.h"
 #include "block/raw-aio.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qapi/error.h"
 #include "trace.h"
 
block/linux-aio.c +1 -1
index d2cfb7f523..9740cae864 100644
@@ -13,7 +13,7 @@
 #include "block/block.h"
 #include "block/raw-aio.h"
 #include "qemu/event_notifier.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qapi/error.h"
 
 #include <libaio.h>
block/mirror.c +1 -1
index 251adc5ae0..ef3a111b4e 100644
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/range.h"
 #include "trace.h"
 #include "block/blockjob_int.h"
block/vdi.c +1 -1
index 479bcfe820..fed390a939 100644
@@ -61,7 +61,7 @@
 #include "qemu/option.h"
 #include "qemu/bswap.h"
 #include "migration/blocker.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/cutils.h"
 #include "qemu/uuid.h"
 #include "qemu/memalign.h"
chardev/char.c +1 -1
index 4c5de16402..e98cb0f13b 100644
@@ -37,7 +37,7 @@
 #include "qemu/module.h"
 #include "qemu/option.h"
 #include "qemu/id.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/yank.h"
 
 #include "chardev-internal.h"
hw/9pfs/coth.c +1 -1
index 2802d41cce..706fa2b272 100644
@@ -19,7 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "block/thread-pool.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/main-loop.h"
 #include "coth.h"
 
hw/block/virtio-blk.c +1 -1
index f717550fdc..c55f8eb119 100644
@@ -34,7 +34,7 @@
 #include "migration/qemu-file-types.h"
 #include "hw/virtio/virtio-access.h"
 #include "hw/virtio/virtio-blk-common.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 
 static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
                                     VirtIOBlockReq *req)
migration/rdma.c +1 -1
index 94a55dd95b..70dcf51b6e 100644
@@ -27,7 +27,7 @@
 #include "qemu/rcu.h"
 #include "qemu/sockets.h"
 #include "qemu/bitmap.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "exec/memory.h"
 #include <sys/socket.h>
 #include <netdb.h>
nbd/client-connection.c +1 -0
index 0c5f917efa..e5b1046a1c 100644
@@ -29,6 +29,7 @@
 
 #include "qapi/qapi-visit-sockets.h"
 #include "qapi/clone-visitor.h"
+#include "qemu/coroutine.h"
 
 struct NBDClientConnection {
     /* Initialization constants, never change */
net/colo-compare.c +1 -1
index 7f9e6f89ce..d6591aa0ea 100644
@@ -32,7 +32,7 @@
 #include "util.h"
 
 #include "block/aio-wait.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 
 #define TYPE_COLO_COMPARE "colo-compare"
 typedef struct CompareState CompareState;
qapi/qmp-dispatch.c +1 -1
index 0990873ec8..2352eeeb23 100644
@@ -22,7 +22,7 @@
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qobject-output-visitor.h"
 #include "qapi/qmp/qbool.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/main-loop.h"
 
 Visitor *qobject_input_visitor_new_qmp(QObject *obj)
tests/unit/test-aio.c +1 -1
index 178048d2f2..321d7ab01a 100644
@@ -16,7 +16,7 @@
 #include "qemu/timer.h"
 #include "qemu/sockets.h"
 #include "qemu/error-report.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "qemu/main-loop.h"
 
 static AioContext *ctx;
ui/console.c +1 -0
index 9ff9217f9b..ab43561fe1 100644
@@ -27,6 +27,7 @@
 #include "hw/qdev-core.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-ui.h"
+#include "qemu/coroutine.h"
 #include "qemu/fifo8.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
util/thread-pool.c +1 -1
index 31113b5860..f98f090287 100644
@@ -17,7 +17,7 @@
 #include "qemu/osdep.h"
 #include "qemu/queue.h"
 #include "qemu/thread.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "trace.h"
 #include "block/thread-pool.h"
 #include "qemu/main-loop.h"
Signature · 1 line
2.38.1
#5 lore raw

Re: [PATCH v2 4/5] coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h

Quoted 13 lines · Markus Armbruster

qemu/coroutine.h and qemu/lockable.h include each other.

They need each other only in macro expansions, so we could simply drop both inclusions to break the loop, and add suitable includes to files that expand the macros.

Instead, move a part of qemu/coroutine.h to new qemu/coroutine-core.h so that qemu/coroutine-core.h doesn't need qemu/lockable.h, and qemu/lockable.h only needs qemu/coroutine-core.h. Result:
qemu/coroutine.h includes qemu/lockable.h includes qemu/coroutine-core.h.

[...]

block.c line 50

Quoted 13 lines
block.c +1 -1
index 9c2ac757e4..be78be95f9 100644
@@ -44,7 +44,7 @@
 #include "sysemu/block-backend.h"
 #include "qemu/notify.h"
 #include "qemu/option.h"
-#include "qemu/coroutine.h"
+#include "qemu/coroutine-core.h"
 #include "block/qapi.h"
 #include "qemu/timer.h"
 #include "qemu/cutils.h"

Err, the include is useless before and after the patch: we get coroutine.h from headers. I'll drop the hunk to reduce churn.

Same for

block/block-copy.c block/io_uring.c block/linux-aio.c block/mirror.c block/vdi.c chardev/char.c hw/9pfs/coth.c hw/block/virtio-blk.c migration/rdma.c net/colo-compare.c qapi/qmp-dispatch.c util/thread-pool.c

[...]

#6 lore raw

PATCH v2 5/5 coroutine: Use Coroutine typedef name instead of structure tag

In reply to Markus Armbruster
---
 include/block/aio.h | 7 +++----
 util/async.c        | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)
include/block/aio.h +3 -4
index 3a546e7515..8fba6a3584 100644
@@ -52,7 +52,6 @@ typedef void QEMUBHFunc(void *opaque);
 typedef bool AioPollFn(void *opaque);
 typedef void IOHandler(void *opaque);
 
-struct Coroutine;
 struct ThreadPool;
 struct LinuxAioState;
 struct LuringState;
@@ -694,7 +693,7 @@ static inline bool aio_node_check(AioContext *ctx, bool is_external)
  * is the context in which the coroutine is running (i.e. the value of
  * qemu_get_current_aio_context() from the coroutine itself).
  */
-void aio_co_schedule(AioContext *ctx, struct Coroutine *co);
+void aio_co_schedule(AioContext *ctx, Coroutine *co);
 
 /**
  * aio_co_reschedule_self:
@@ -717,7 +716,7 @@ void coroutine_fn aio_co_reschedule_self(AioContext *new_ctx);
  * context.  The coroutine must not be entered by anyone else while
  * aio_co_wake() is active.
  */
-void aio_co_wake(struct Coroutine *co);
+void aio_co_wake(Coroutine *co);
 
 /**
  * aio_co_enter:
@@ -726,7 +725,7 @@ void aio_co_wake(struct Coroutine *co);
  *
  * Enter a coroutine in the specified AioContext.
  */
-void aio_co_enter(AioContext *ctx, struct Coroutine *co);
+void aio_co_enter(AioContext *ctx, Coroutine *co);
 
 /**
  * Return the AioContext whose event loop runs in the current thread.
util/async.c +2 -2
index 14d63b3091..0657b75397 100644
@@ -640,7 +640,7 @@ void coroutine_fn aio_co_reschedule_self(AioContext *new_ctx)
     }
 }
 
-void aio_co_wake(struct Coroutine *co)
+void aio_co_wake(Coroutine *co)
 {
     AioContext *ctx;
 
@@ -653,7 +653,7 @@ void aio_co_wake(struct Coroutine *co)
     aio_co_enter(ctx, co);
 }
 
-void aio_co_enter(AioContext *ctx, struct Coroutine *co)
+void aio_co_enter(AioContext *ctx, Coroutine *co)
 {
     if (ctx != qemu_get_current_aio_context()) {
         aio_co_schedule(ctx, co);
Signature · 1 line
2.38.1