From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 02/10] tools/test-runner: Unbind virtio devices before powering off UML
Date: Fri, 30 Oct 2026 17:29:31 -0400 [thread overview]
Message-ID: <20261030212940.753771-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261030212940.753771-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
User Mode Linux unregisters its virtio driver when powering off, in
atomic context, where removing devices that sleep, like virtio_bt in
hci_unregister_dev(), triggers scheduling while atomic bugs and, with
lock debugging enabled, an endless loop of warnings.
Unbind the virtio-uml devices before powering off, so they are removed
in process context.
Fixes: a7e9a42a791a ("tools/test-runner: Add User Mode Linux support")
Assisted-by: Claude:claude-opus-5-5
---
tools/test-runner.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/tools/test-runner.c b/tools/test-runner.c
index b4947f113607..0bca31a46351 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -232,6 +232,39 @@ static bool is_uml_guest(void)
return uml;
}
+#define VIRTIO_UML_DRIVER "/sys/bus/platform/drivers/virtio-uml"
+
+/* User Mode Linux unbinds its virtio devices when powering off, in atomic
+ * context where their drivers cannot sleep, so unbind them before.
+ */
+static void uml_unbind_virtio(void)
+{
+ struct dirent *d;
+ DIR *dir;
+ int fd;
+
+ dir = opendir(VIRTIO_UML_DRIVER);
+ if (!dir)
+ return;
+
+ fd = open(VIRTIO_UML_DRIVER "/unbind", O_WRONLY | O_CLOEXEC);
+ if (fd < 0) {
+ closedir(dir);
+ return;
+ }
+
+ while ((d = readdir(dir))) {
+ if (strncmp(d->d_name, "virtio-uml.", 11))
+ continue;
+
+ if (write(fd, d->d_name, strlen(d->d_name)) < 0)
+ perror("Failed to unbind virtio device");
+ }
+
+ close(fd);
+ closedir(dir);
+}
+
static bool find_kernel(const char *root, char path[PATH_MAX])
{
struct stat st;
@@ -2213,7 +2246,11 @@ int main(int argc, char *argv[])
sync();
/* Rebooting User Mode Linux starts it again */
- reboot(is_uml_guest() ? RB_POWER_OFF : RB_AUTOBOOT);
+ if (is_uml_guest()) {
+ uml_unbind_virtio();
+ reboot(RB_POWER_OFF);
+ } else
+ reboot(RB_AUTOBOOT);
return EXIT_SUCCESS;
}
--
2.56.0
next prev parent reply other threads:[~2026-10-30 21:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 21:29 [PATCH BlueZ v1 00/10] Run test-functional under User Mode Linux Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 01/10] tools/test-runner: Default to time travel with " Luiz Augusto von Dentz
2026-10-30 23:58 ` Run test-functional under " bluez.test.bot
2026-10-30 21:29 ` Luiz Augusto von Dentz [this message]
2026-10-30 21:29 ` [PATCH BlueZ v1 03/10] emulator: Answer the time of a guest with a skew Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 04/10] adapter: Don't return Busy when a pending change sets the same value Luiz Augusto von Dentz
2026-10-30 21:34 ` Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 05/10] test: functional: wait for BAP transports to be configured Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 06/10] shared/mcp: Don't drop commands before supported opcodes are read Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 07/10] doc/test-functional: Document User Mode Linux VM hosts Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 08/10] a2dp: Fix refusing the AVDTP connection of a new link Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 09/10] adapter: Don't cancel requests of a new link on stale disconnection Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 10/10] test: Cover A2DP reconnection with a pending disconnection Luiz Augusto von Dentz
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=20261030212940.753771-3-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.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 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.