From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org
Cc: den@openvz.org, qemu-block@nongnu.org,
Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Subject: [PATCH 07/13] tests/unit: prefix the iothread test helper
Date: Wed, 30 Sep 2026 18:49:53 +0200 [thread overview]
Message-ID: <20260930165000.303236-8-den@openvz.org> (raw)
In-Reply-To: <20260930165000.303236-1-den@openvz.org>
From: Denis V. Lunev <den@openvz.org>
tests/unit/iothread.c defines a struct IOThread and an
iothread_get_aio_context() under the same names as the IOThread QOM
object in iothread.c, so nothing that links the real object can use
the helper. Prefix the helper and its type with test_ and Test.
This is preparation for building the QOM object into the block layer.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
CC: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
tests/unit/iothread.c | 28 +++++++++++++--------------
tests/unit/iothread.h | 8 ++++----
tests/unit/test-aio-multithread.c | 8 ++++----
tests/unit/test-bdrv-drain.c | 32 +++++++++++++++----------------
tests/unit/test-block-iothread.c | 28 +++++++++++++--------------
5 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/tests/unit/iothread.c b/tests/unit/iothread.c
index a363bf8f70..ff05ae8b11 100644
--- a/tests/unit/iothread.c
+++ b/tests/unit/iothread.c
@@ -19,7 +19,7 @@
#include "qemu/rcu.h"
#include "iothread.h"
-struct IOThread {
+struct TestIOThread {
AioContext *ctx;
GMainContext *worker_context;
GMainLoop *main_loop;
@@ -30,20 +30,20 @@ struct IOThread {
bool stopping;
};
-static void iothread_init_gcontext(IOThread *iothread)
+static void test_iothread_init_gcontext(TestIOThread *iothread)
{
GSource *source;
iothread->worker_context = g_main_context_new();
- source = aio_get_g_source(iothread_get_aio_context(iothread));
+ source = aio_get_g_source(test_iothread_get_aio_context(iothread));
g_source_attach(source, iothread->worker_context);
g_source_unref(source);
iothread->main_loop = g_main_loop_new(iothread->worker_context, TRUE);
}
-static void *iothread_run(void *opaque)
+static void *test_iothread_run(void *opaque)
{
- IOThread *iothread = opaque;
+ TestIOThread *iothread = opaque;
rcu_register_thread();
@@ -56,7 +56,7 @@ static void *iothread_run(void *opaque)
* of glib the g_source_ref()/unref() functions are not threadsafe
* on sources without a context.
*/
- iothread_init_gcontext(iothread);
+ test_iothread_init_gcontext(iothread);
/*
* g_main_context_push_thread_default() must be called before anything
@@ -76,16 +76,16 @@ static void *iothread_run(void *opaque)
return NULL;
}
-static void iothread_stop_bh(void *opaque)
+static void test_iothread_stop_bh(void *opaque)
{
- IOThread *iothread = opaque;
+ TestIOThread *iothread = opaque;
iothread->stopping = true;
}
-void iothread_join(IOThread *iothread)
+void test_iothread_join(TestIOThread *iothread)
{
- aio_bh_schedule_oneshot(iothread->ctx, iothread_stop_bh, iothread);
+ aio_bh_schedule_oneshot(iothread->ctx, test_iothread_stop_bh, iothread);
qemu_thread_join(&iothread->thread);
g_main_context_unref(iothread->worker_context);
g_main_loop_unref(iothread->main_loop);
@@ -95,13 +95,13 @@ void iothread_join(IOThread *iothread)
g_free(iothread);
}
-IOThread *iothread_new(void)
+TestIOThread *test_iothread_new(void)
{
- IOThread *iothread = g_new0(IOThread, 1);
+ TestIOThread *iothread = g_new0(TestIOThread, 1);
qemu_mutex_init(&iothread->init_done_lock);
qemu_cond_init(&iothread->init_done_cond);
- qemu_thread_create(&iothread->thread, NULL, iothread_run,
+ qemu_thread_create(&iothread->thread, NULL, test_iothread_run,
iothread, QEMU_THREAD_JOINABLE);
/* Wait for initialization to complete */
@@ -114,7 +114,7 @@ IOThread *iothread_new(void)
return iothread;
}
-AioContext *iothread_get_aio_context(IOThread *iothread)
+AioContext *test_iothread_get_aio_context(TestIOThread *iothread)
{
return iothread->ctx;
}
diff --git a/tests/unit/iothread.h b/tests/unit/iothread.h
index eb4d0c77f8..8475170eaa 100644
--- a/tests/unit/iothread.h
+++ b/tests/unit/iothread.h
@@ -16,10 +16,10 @@
#include "qemu/aio.h"
#include "qemu/thread.h"
-typedef struct IOThread IOThread;
+typedef struct TestIOThread TestIOThread;
-IOThread *iothread_new(void);
-void iothread_join(IOThread *iothread);
-AioContext *iothread_get_aio_context(IOThread *iothread);
+TestIOThread *test_iothread_new(void);
+void test_iothread_join(TestIOThread *iothread);
+AioContext *test_iothread_get_aio_context(TestIOThread *iothread);
#endif
diff --git a/tests/unit/test-aio-multithread.c b/tests/unit/test-aio-multithread.c
index 9179cdc6a3..d07376455b 100644
--- a/tests/unit/test-aio-multithread.c
+++ b/tests/unit/test-aio-multithread.c
@@ -21,7 +21,7 @@
#define NUM_CONTEXTS 5
-static IOThread *threads[NUM_CONTEXTS];
+static TestIOThread *threads[NUM_CONTEXTS];
static AioContext *ctx[NUM_CONTEXTS];
static __thread int id = -1;
@@ -68,8 +68,8 @@ static void create_aio_contexts(void)
int i;
for (i = 0; i < NUM_CONTEXTS; i++) {
- threads[i] = iothread_new();
- ctx[i] = iothread_get_aio_context(threads[i]);
+ threads[i] = test_iothread_new();
+ ctx[i] = test_iothread_get_aio_context(threads[i]);
}
qemu_event_init(&done_event, false);
@@ -88,7 +88,7 @@ static void join_aio_contexts(void)
aio_context_ref(ctx[i]);
}
for (i = 0; i < NUM_CONTEXTS; i++) {
- iothread_join(threads[i]);
+ test_iothread_join(threads[i]);
}
for (i = 0; i < NUM_CONTEXTS; i++) {
aio_context_unref(ctx[i]);
diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
index 43b0ba8648..a852874f74 100644
--- a/tests/unit/test-bdrv-drain.c
+++ b/tests/unit/test-bdrv-drain.c
@@ -535,10 +535,10 @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread)
int aio_ret;
struct test_iothread_data data;
- IOThread *a = iothread_new();
- IOThread *b = iothread_new();
- AioContext *ctx_a = iothread_get_aio_context(a);
- AioContext *ctx_b = iothread_get_aio_context(b);
+ TestIOThread *a = test_iothread_new();
+ TestIOThread *b = test_iothread_new();
+ AioContext *ctx_a = test_iothread_get_aio_context(a);
+ AioContext *ctx_b = test_iothread_get_aio_context(b);
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, 0);
@@ -614,8 +614,8 @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread)
blk_unref(blk);
out:
- iothread_join(a);
- iothread_join(b);
+ test_iothread_join(a);
+ test_iothread_join(b);
}
static void test_iothread_drain_all(void)
@@ -727,7 +727,7 @@ static void test_blockjob_common_drain_node(enum drain_type drain_type,
BlockDriverState *src, *src_backing, *src_overlay, *target, *drain_bs;
BlockJob *job;
TestBlockJob *tjob;
- IOThread *iothread = NULL;
+ TestIOThread *iothread = NULL;
int ret = -1;
src = bdrv_new_open_driver(&bdrv_test, "source", BDRV_O_RDWR,
@@ -761,8 +761,8 @@ static void test_blockjob_common_drain_node(enum drain_type drain_type,
if (use_iothread) {
AioContext *ctx;
- iothread = iothread_new();
- ctx = iothread_get_aio_context(iothread);
+ iothread = test_iothread_new();
+ ctx = test_iothread_get_aio_context(iothread);
blk_set_aio_context(blk_src, ctx, &error_abort);
}
@@ -893,7 +893,7 @@ static void test_blockjob_common_drain_node(enum drain_type drain_type,
bdrv_unref(target);
if (iothread) {
- iothread_join(iothread);
+ test_iothread_join(iothread);
}
}
@@ -1396,10 +1396,10 @@ static void test_append_to_drained(void)
static void test_set_aio_context(void)
{
BlockDriverState *bs;
- IOThread *a = iothread_new();
- IOThread *b = iothread_new();
- AioContext *ctx_a = iothread_get_aio_context(a);
- AioContext *ctx_b = iothread_get_aio_context(b);
+ TestIOThread *a = test_iothread_new();
+ TestIOThread *b = test_iothread_new();
+ AioContext *ctx_a = test_iothread_get_aio_context(a);
+ AioContext *ctx_b = test_iothread_get_aio_context(b);
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
&error_abort);
@@ -1410,8 +1410,8 @@ static void test_set_aio_context(void)
bdrv_try_change_aio_context(bs, qemu_get_aio_context(), NULL, &error_abort);
bdrv_unref(bs);
- iothread_join(a);
- iothread_join(b);
+ test_iothread_join(a);
+ test_iothread_join(b);
}
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
index 5273ff235a..5a150adfe8 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
@@ -465,8 +465,8 @@ const SyncOpTest sync_op_tests[] = {
static void test_sync_op(const void *opaque)
{
const SyncOpTest *t = opaque;
- IOThread *iothread = iothread_new();
- AioContext *ctx = iothread_get_aio_context(iothread);
+ TestIOThread *iothread = test_iothread_new();
+ AioContext *ctx = test_iothread_get_aio_context(iothread);
BlockBackend *blk;
BlockDriverState *bs;
BdrvChild *c;
@@ -548,8 +548,8 @@ BlockJobDriver test_job_driver = {
static void test_attach_blockjob(void)
{
- IOThread *iothread = iothread_new();
- AioContext *ctx = iothread_get_aio_context(iothread);
+ TestIOThread *iothread = test_iothread_new();
+ AioContext *ctx = test_iothread_get_aio_context(iothread);
BlockBackend *blk;
BlockDriverState *bs;
TestBlockJob *tjob;
@@ -611,8 +611,8 @@ static void test_attach_blockjob(void)
*/
static void test_propagate_basic(void)
{
- IOThread *iothread = iothread_new();
- AioContext *ctx = iothread_get_aio_context(iothread);
+ TestIOThread *iothread = test_iothread_new();
+ AioContext *ctx = test_iothread_get_aio_context(iothread);
AioContext *main_ctx;
BlockBackend *blk;
BlockDriverState *bs_a, *bs_b, *bs_verify;
@@ -675,8 +675,8 @@ static void test_propagate_basic(void)
*/
static void test_propagate_diamond(void)
{
- IOThread *iothread = iothread_new();
- AioContext *ctx = iothread_get_aio_context(iothread);
+ TestIOThread *iothread = test_iothread_new();
+ AioContext *ctx = test_iothread_get_aio_context(iothread);
AioContext *main_ctx;
BlockBackend *blk;
BlockDriverState *bs_a, *bs_b, *bs_c, *bs_verify;
@@ -740,8 +740,8 @@ static void test_propagate_diamond(void)
static void test_propagate_mirror(void)
{
- IOThread *iothread = iothread_new();
- AioContext *ctx = iothread_get_aio_context(iothread);
+ TestIOThread *iothread = test_iothread_new();
+ AioContext *ctx = test_iothread_get_aio_context(iothread);
AioContext *main_ctx = qemu_get_aio_context();
BlockDriverState *src, *target, *filter;
BlockBackend *blk;
@@ -811,8 +811,8 @@ static void test_propagate_mirror(void)
static void test_attach_second_node(void)
{
- IOThread *iothread = iothread_new();
- AioContext *ctx = iothread_get_aio_context(iothread);
+ TestIOThread *iothread = test_iothread_new();
+ AioContext *ctx = test_iothread_get_aio_context(iothread);
AioContext *main_ctx = qemu_get_aio_context();
BlockBackend *blk;
BlockDriverState *bs, *filter;
@@ -844,8 +844,8 @@ static void test_attach_second_node(void)
static void test_attach_preserve_blk_ctx(void)
{
- IOThread *iothread = iothread_new();
- AioContext *ctx = iothread_get_aio_context(iothread);
+ TestIOThread *iothread = test_iothread_new();
+ AioContext *ctx = test_iothread_get_aio_context(iothread);
BlockBackend *blk;
BlockDriverState *bs;
--
2.53.0
next prev parent reply other threads:[~2026-09-30 16:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 16:49 [PATCH 00/13] block: fix data loss in the preallocate filter Denis V. Lunev
2026-09-30 16:49 ` [PATCH 01/13] block/file-posix: drop the XFS workaround for post-EOF fallocate Denis V. Lunev
2026-10-02 16:16 ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 02/13] block/preallocate: keep zero_start above written data Denis V. Lunev
2026-10-02 16:16 ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 03/13] block/preallocate: collect the state assignments in one place Denis V. Lunev
2026-10-02 16:16 ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 04/13] block/preallocate: serialise the filter state Denis V. Lunev
2026-10-02 16:16 ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 05/13] block/preallocate: hold back writes into a preallocation in flight Denis V. Lunev
2026-10-02 16:16 ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 06/13] iotests/298: add testcase for async writes with preallocation filter Denis V. Lunev
2026-09-30 16:49 ` Denis V. Lunev [this message]
2026-10-05 20:06 ` [PATCH 07/13] tests/unit: prefix the iothread test helper Eric Blake
2026-09-30 16:49 ` [PATCH 08/13] qemu-io: accept --object iothread Denis V. Lunev
2026-10-05 20:11 ` Eric Blake
2026-09-30 16:49 ` [PATCH 09/13] qemu-io: add -t to run an aio request in a named iothread Denis V. Lunev
2026-10-05 20:28 ` Eric Blake
2026-09-30 16:49 ` [PATCH 10/13] qemu-io: add -g to write past the end of the image Denis V. Lunev
2026-10-05 20:36 ` Eric Blake
2026-09-30 16:49 ` [PATCH 11/13] block/blkdebug: make a breakpoint work across AioContexts Denis V. Lunev
2026-10-05 20:42 ` Eric Blake
2026-09-30 16:49 ` [PATCH 12/13] block: add blkdebug events for a write before it is tracked Denis V. Lunev
2026-10-05 20:45 ` Eric Blake
2026-09-30 16:49 ` [PATCH 13/13] iotests/298: cover the preallocation races Denis V. Lunev
2026-10-05 21:06 ` Eric Blake
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=20260930165000.303236-8-den@openvz.org \
--to=den@openvz.org \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.