aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2023-05-16 15:02:38 -0400
committerKevin Wolf <kwolf@redhat.com>2023-05-30 17:37:26 +0200
commit60f782b6b78211c125970768be726c9f380dbd61 (patch)
tree44c131946293943ddf967271ac5ff52450af6b07 /tests
parent03d7162a21e60d87cfa39a8d078c784487fa5f30 (diff)
downloadqemu-60f782b6b78211c125970768be726c9f380dbd61.zip
qemu-60f782b6b78211c125970768be726c9f380dbd61.tar.gz
qemu-60f782b6b78211c125970768be726c9f380dbd61.tar.bz2
aio: remove aio_disable_external() API
All callers now pass is_external=false to aio_set_fd_handler() and aio_set_event_notifier(). The aio_disable_external() API that temporarily disables fd handlers that were registered is_external=true is therefore dead code. Remove aio_disable_external(), aio_enable_external(), and the is_external arguments to aio_set_fd_handler() and aio_set_event_notifier(). The entire test-fdmon-epoll test is removed because its sole purpose was testing aio_disable_external(). Parts of this patch were generated using the following coccinelle (https://coccinelle.lip6.fr/) semantic patch: @@ expression ctx, fd, is_external, io_read, io_write, io_poll, io_poll_ready, opaque; @@ - aio_set_fd_handler(ctx, fd, is_external, io_read, io_write, io_poll, io_poll_ready, opaque) + aio_set_fd_handler(ctx, fd, io_read, io_write, io_poll, io_poll_ready, opaque) @@ expression ctx, notifier, is_external, io_read, io_poll, io_poll_ready; @@ - aio_set_event_notifier(ctx, notifier, is_external, io_read, io_poll, io_poll_ready) + aio_set_event_notifier(ctx, notifier, io_read, io_poll, io_poll_ready) Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20230516190238.8401-21-stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/meson.build3
-rw-r--r--tests/unit/test-aio.c27
-rw-r--r--tests/unit/test-bdrv-drain.c1
-rw-r--r--tests/unit/test-fdmon-epoll.c73
-rw-r--r--tests/unit/test-nested-aio-poll.c9
5 files changed, 5 insertions, 108 deletions
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index 3a63142..93977cc 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -125,9 +125,6 @@ if have_block
if nettle.found() or gcrypt.found()
tests += {'test-crypto-pbkdf': [io]}
endif
- if config_host_data.get('CONFIG_EPOLL_CREATE1')
- tests += {'test-fdmon-epoll': [testblock]}
- endif
endif
if have_system
diff --git a/tests/unit/test-aio.c b/tests/unit/test-aio.c
index 321d7ab..519440e 100644
--- a/tests/unit/test-aio.c
+++ b/tests/unit/test-aio.c
@@ -130,7 +130,7 @@ static void *test_acquire_thread(void *opaque)
static void set_event_notifier(AioContext *ctx, EventNotifier *notifier,
EventNotifierHandler *handler)
{
- aio_set_event_notifier(ctx, notifier, false, handler, NULL, NULL);
+ aio_set_event_notifier(ctx, notifier, handler, NULL, NULL);
}
static void dummy_notifier_read(EventNotifier *n)
@@ -383,30 +383,6 @@ static void test_flush_event_notifier(void)
event_notifier_cleanup(&data.e);
}
-static void test_aio_external_client(void)
-{
- int i, j;
-
- for (i = 1; i < 3; i++) {
- EventNotifierTestData data = { .n = 0, .active = 10, .auto_set = true };
- event_notifier_init(&data.e, false);
- aio_set_event_notifier(ctx, &data.e, true, event_ready_cb, NULL, NULL);
- event_notifier_set(&data.e);
- for (j = 0; j < i; j++) {
- aio_disable_external(ctx);
- }
- for (j = 0; j < i; j++) {
- assert(!aio_poll(ctx, false));
- assert(event_notifier_test_and_clear(&data.e));
- event_notifier_set(&data.e);
- aio_enable_external(ctx);
- }
- assert(aio_poll(ctx, false));
- set_event_notifier(ctx, &data.e, NULL);
- event_notifier_cleanup(&data.e);
- }
-}
-
static void test_wait_event_notifier_noflush(void)
{
EventNotifierTestData data = { .n = 0 };
@@ -935,7 +911,6 @@ int main(int argc, char **argv)
g_test_add_func("/aio/event/wait", test_wait_event_notifier);
g_test_add_func("/aio/event/wait/no-flush-cb", test_wait_event_notifier_noflush);
g_test_add_func("/aio/event/flush", test_flush_event_notifier);
- g_test_add_func("/aio/external-client", test_aio_external_client);
g_test_add_func("/aio/timer/schedule", test_timer_schedule);
g_test_add_func("/aio/coroutine/queue-chaining", test_queue_chaining);
diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
index d53a633..ccc453c 100644
--- a/tests/unit/test-bdrv-drain.c
+++ b/tests/unit/test-bdrv-drain.c
@@ -473,7 +473,6 @@ static void test_graph_change_drain_all(void)
g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
g_assert_cmpint(b_s->drain_count, ==, 0);
- g_assert_cmpint(qemu_get_aio_context()->external_disable_cnt, ==, 0);
bdrv_unref(bs_b);
blk_unref(blk_b);
diff --git a/tests/unit/test-fdmon-epoll.c b/tests/unit/test-fdmon-epoll.c
deleted file mode 100644
index ef5a856..0000000
--- a/tests/unit/test-fdmon-epoll.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * fdmon-epoll tests
- *
- * Copyright (c) 2020 Red Hat, Inc.
- */
-
-#include "qemu/osdep.h"
-#include "block/aio.h"
-#include "qapi/error.h"
-#include "qemu/main-loop.h"
-
-static AioContext *ctx;
-
-static void dummy_fd_handler(EventNotifier *notifier)
-{
- event_notifier_test_and_clear(notifier);
-}
-
-static void add_event_notifiers(EventNotifier *notifiers, size_t n)
-{
- for (size_t i = 0; i < n; i++) {
- event_notifier_init(&notifiers[i], false);
- aio_set_event_notifier(ctx, &notifiers[i], false,
- dummy_fd_handler, NULL, NULL);
- }
-}
-
-static void remove_event_notifiers(EventNotifier *notifiers, size_t n)
-{
- for (size_t i = 0; i < n; i++) {
- aio_set_event_notifier(ctx, &notifiers[i], false, NULL, NULL, NULL);
- event_notifier_cleanup(&notifiers[i]);
- }
-}
-
-/* Check that fd handlers work when external clients are disabled */
-static void test_external_disabled(void)
-{
- EventNotifier notifiers[100];
-
- /* fdmon-epoll is only enabled when many fd handlers are registered */
- add_event_notifiers(notifiers, G_N_ELEMENTS(notifiers));
-
- event_notifier_set(&notifiers[0]);
- assert(aio_poll(ctx, true));
-
- aio_disable_external(ctx);
- event_notifier_set(&notifiers[0]);
- assert(aio_poll(ctx, true));
- aio_enable_external(ctx);
-
- remove_event_notifiers(notifiers, G_N_ELEMENTS(notifiers));
-}
-
-int main(int argc, char **argv)
-{
- /*
- * This code relies on the fact that fdmon-io_uring disables itself when
- * the glib main loop is in use. The main loop uses fdmon-poll and upgrades
- * to fdmon-epoll when the number of fds exceeds a threshold.
- */
- qemu_init_main_loop(&error_fatal);
- ctx = qemu_get_aio_context();
-
- while (g_main_context_iteration(NULL, false)) {
- /* Do nothing */
- }
-
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/fdmon-epoll/external-disabled", test_external_disabled);
- return g_test_run();
-}
diff --git a/tests/unit/test-nested-aio-poll.c b/tests/unit/test-nested-aio-poll.c
index 9bbe18b..db33742 100644
--- a/tests/unit/test-nested-aio-poll.c
+++ b/tests/unit/test-nested-aio-poll.c
@@ -91,12 +91,12 @@ static void test(void)
/* Make the event notifier active (set) right away */
event_notifier_init(&td.poll_notifier, 1);
- aio_set_event_notifier(td.ctx, &td.poll_notifier, false,
+ aio_set_event_notifier(td.ctx, &td.poll_notifier,
io_read, io_poll_true, io_poll_ready);
/* This event notifier will be used later */
event_notifier_init(&td.dummy_notifier, 0);
- aio_set_event_notifier(td.ctx, &td.dummy_notifier, false,
+ aio_set_event_notifier(td.ctx, &td.dummy_notifier,
io_read, io_poll_false, io_poll_never_ready);
/* Consume aio_notify() */
@@ -114,9 +114,8 @@ static void test(void)
/* Run io_poll()/io_poll_ready() one more time to show it keeps working */
g_assert(aio_poll(td.ctx, true));
- aio_set_event_notifier(td.ctx, &td.dummy_notifier, false,
- NULL, NULL, NULL);
- aio_set_event_notifier(td.ctx, &td.poll_notifier, false, NULL, NULL, NULL);
+ aio_set_event_notifier(td.ctx, &td.dummy_notifier, NULL, NULL, NULL);
+ aio_set_event_notifier(td.ctx, &td.poll_notifier, NULL, NULL, NULL);
event_notifier_cleanup(&td.dummy_notifier);
event_notifier_cleanup(&td.poll_notifier);
aio_context_unref(td.ctx);