* [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths
@ 2026-05-05 20:47 Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 2/4] emulator/hciemu: " Luiz Augusto von Dentz
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-05-05 20:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add debug_callback, debug_destroy and debug_data fields to struct vhci
so vhci_set_debug stores the callback locally in addition to passing it
to btdev. Introduce a variadic vhci_debug() helper using util_debug_va
and add debug messages to the following error paths:
- vhci_write_callback: failed io_send
- vhci_read_callback: failed read
- vhci_debugfs_write: failed open and failed write
---
emulator/vhci.c | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
diff --git a/emulator/vhci.c b/emulator/vhci.c
index 22ca15796872..05fcfd0b77cb 100644
--- a/emulator/vhci.c
+++ b/emulator/vhci.c
@@ -19,6 +19,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <unistd.h>
@@ -29,6 +30,7 @@
#include "bluetooth/hci.h"
#include "src/shared/io.h"
+#include "src/shared/util.h"
#include "monitor/bt.h"
#include "btdev.h"
#include "vhci.h"
@@ -41,8 +43,23 @@ struct vhci {
uint16_t index;
struct io *io;
struct btdev *btdev;
+ vhci_debug_func_t debug_callback;
+ vhci_destroy_func_t debug_destroy;
+ void *debug_data;
};
+static void vhci_debug(struct vhci *vhci, const char *format, ...)
+{
+ va_list ap;
+
+ if (!vhci || !format || !vhci->debug_callback)
+ return;
+
+ va_start(ap, format);
+ util_debug_va(vhci->debug_callback, vhci->debug_data, format, ap);
+ va_end(ap);
+}
+
static void vhci_destroy(void *user_data)
{
struct vhci *vhci = user_data;
@@ -61,7 +78,7 @@ static void vhci_write_callback(const struct iovec *iov, int iovlen,
written = io_send(vhci->io, iov, iovlen);
if (written < 0)
- return;
+ vhci_debug(vhci, "Failed to write: %s", strerror(-written));
}
static bool vhci_read_callback(struct io *io, void *user_data)
@@ -72,8 +89,10 @@ static bool vhci_read_callback(struct io *io, void *user_data)
ssize_t len;
len = read(fd, buf, sizeof(buf));
- if (len < 1)
+ if (len < 1) {
+ vhci_debug(vhci, "Failed to read: %s", strerror(errno));
return false;
+ }
btdev_receive_h4(vhci->btdev, buf, len);
@@ -86,6 +105,13 @@ bool vhci_set_debug(struct vhci *vhci, vhci_debug_func_t callback,
if (!vhci)
return false;
+ if (vhci->debug_destroy)
+ vhci->debug_destroy(vhci->debug_data);
+
+ vhci->debug_callback = callback;
+ vhci->debug_destroy = destroy;
+ vhci->debug_data = user_data;
+
return btdev_set_debug(vhci->btdev, callback, user_data, destroy);
}
@@ -205,14 +231,20 @@ static int vhci_debugfs_write(struct vhci *vhci, char *option, const void *data,
sprintf(path, DEBUGFS_PATH "/hci%d/%s", vhci->index, option);
fd = open(path, O_RDWR);
- if (fd < 0)
+ if (fd < 0) {
+ vhci_debug(vhci, "Failed to open %s: %s", path,
+ strerror(errno));
return -errno;
+ }
n = write(fd, data, len);
if (n == len)
err = 0;
- else
+ else {
err = -errno;
+ vhci_debug(vhci, "Failed to write %s: %s", option,
+ strerror(-err));
+ }
close(fd);
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH BlueZ v1 2/4] emulator/hciemu: Add debug messages to error paths
2026-05-05 20:47 [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths Luiz Augusto von Dentz
@ 2026-05-05 20:47 ` Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 3/4] tools/gap-tester: Enable hciemu debug output Luiz Augusto von Dentz
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-05-05 20:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Introduce a variadic hciemu_debug() helper using util_debug_va and add
debug messages to the following error paths:
- create_vhci: failed to open vhci
- hciemu_client_new: failed to create btdev, bthost, or socketpair
---
emulator/hciemu.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index bff92286ed45..9534d82bac39 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
+#include <stdarg.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
@@ -60,6 +61,18 @@ struct hciemu {
unsigned int flush_id;
};
+static void hciemu_debug(struct hciemu *hciemu, const char *format, ...)
+{
+ va_list ap;
+
+ if (!hciemu || !format || !hciemu->debug_callback)
+ return;
+
+ va_start(ap, format);
+ util_debug_va(hciemu->debug_callback, hciemu->debug_data, format, ap);
+ va_end(ap);
+}
+
struct hciemu_command_hook {
hciemu_command_func_t function;
void *user_data;
@@ -249,8 +262,10 @@ static bool create_vhci(struct hciemu *hciemu)
struct vhci *vhci;
vhci = vhci_open(hciemu->btdev_type);
- if (!vhci)
+ if (!vhci) {
+ hciemu_debug(hciemu, "Failed to open vhci");
return false;
+ }
btdev_set_command_handler(vhci_get_btdev(vhci),
central_command_callback, hciemu);
@@ -343,12 +358,14 @@ static struct hciemu_client *hciemu_client_new(struct hciemu *hciemu,
client->dev = btdev_create(hciemu->btdev_type, id++);
if (!client->dev) {
+ hciemu_debug(hciemu, "Failed to create btdev");
free(client);
return NULL;
}
client->host = bthost_create();
if (!client->host) {
+ hciemu_debug(hciemu, "Failed to create bthost");
btdev_destroy(client->dev);
free(client);
return NULL;
@@ -358,6 +375,8 @@ static struct hciemu_client *hciemu_client_new(struct hciemu *hciemu,
if (socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_NONBLOCK | SOCK_CLOEXEC,
0, sv) < 0) {
+ hciemu_debug(hciemu, "Failed to create socketpair: %s",
+ strerror(errno));
bthost_destroy(client->host);
btdev_destroy(client->dev);
return NULL;
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH BlueZ v1 3/4] tools/gap-tester: Enable hciemu debug output
2026-05-05 20:47 [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 2/4] emulator/hciemu: " Luiz Augusto von Dentz
@ 2026-05-05 20:47 ` Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 4/4] tools/userchan-tester: " Luiz Augusto von Dentz
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-05-05 20:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add print_debug callback and call hciemu_set_debug when debug output is
enabled so that hciemu error paths are visible during test runs.
---
tools/gap-tester.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/gap-tester.c b/tools/gap-tester.c
index 942c37d270b8..8c69765aa9c2 100644
--- a/tools/gap-tester.c
+++ b/tools/gap-tester.c
@@ -23,11 +23,21 @@ static GDBusProxy *adapter_proxy = NULL;
static struct hciemu *hciemu_stack = NULL;
+static void print_debug(const char *str, void *user_data)
+{
+ const char *prefix = user_data;
+
+ tester_print("%s%s", prefix, str);
+}
+
static void connect_handler(DBusConnection *connection, void *user_data)
{
tester_print("Connected to daemon");
hciemu_stack = hciemu_new(HCIEMU_TYPE_BREDRLE);
+
+ if (tester_use_debug())
+ hciemu_set_debug(hciemu_stack, print_debug, "hciemu: ", NULL);
}
static void disconnect_handler(DBusConnection *connection, void *user_data)
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH BlueZ v1 4/4] tools/userchan-tester: Enable hciemu debug output
2026-05-05 20:47 [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 2/4] emulator/hciemu: " Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 3/4] tools/gap-tester: Enable hciemu debug output Luiz Augusto von Dentz
@ 2026-05-05 20:47 ` Luiz Augusto von Dentz
2026-05-05 21:53 ` [BlueZ,v1,1/4] emulator/vhci: Add debug messages to error paths bluez.test.bot
2026-05-06 13:30 ` [PATCH BlueZ v1 1/4] " patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-05-05 20:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Call hciemu_set_debug when debug output is enabled so that hciemu error
paths are visible during test runs.
---
tools/userchan-tester.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/userchan-tester.c b/tools/userchan-tester.c
index 168b757c6ae8..f61d2779ed26 100644
--- a/tools/userchan-tester.c
+++ b/tools/userchan-tester.c
@@ -158,6 +158,9 @@ static void read_index_list_callback(uint8_t status, uint16_t length,
tester_pre_setup_failed();
}
+ if (tester_use_debug())
+ hciemu_set_debug(data->hciemu, mgmt_debug, "hciemu: ", NULL);
+
tester_print("New hciemu instance created");
}
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [BlueZ,v1,1/4] emulator/vhci: Add debug messages to error paths
2026-05-05 20:47 [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths Luiz Augusto von Dentz
` (2 preceding siblings ...)
2026-05-05 20:47 ` [PATCH BlueZ v1 4/4] tools/userchan-tester: " Luiz Augusto von Dentz
@ 2026-05-05 21:53 ` bluez.test.bot
2026-05-06 13:30 ` [PATCH BlueZ v1 1/4] " patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2026-05-05 21:53 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1090123
---Test result---
Test Summary:
CheckPatch PASS 1.97 seconds
GitLint PASS 1.46 seconds
BuildEll PASS 19.86 seconds
BluezMake PASS 611.29 seconds
CheckSmatch PASS 322.85 seconds
bluezmakeextell PASS 167.27 seconds
IncrementalBuild PASS 612.35 seconds
ScanBuild PASS 896.75 seconds
https://github.com/bluez/bluez/pull/2100
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths
2026-05-05 20:47 [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths Luiz Augusto von Dentz
` (3 preceding siblings ...)
2026-05-05 21:53 ` [BlueZ,v1,1/4] emulator/vhci: Add debug messages to error paths bluez.test.bot
@ 2026-05-06 13:30 ` patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2026-05-06 13:30 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 5 May 2026 16:47:16 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> Add debug_callback, debug_destroy and debug_data fields to struct vhci
> so vhci_set_debug stores the callback locally in addition to passing it
> to btdev. Introduce a variadic vhci_debug() helper using util_debug_va
> and add debug messages to the following error paths:
>
> [...]
Here is the summary with links:
- [BlueZ,v1,1/4] emulator/vhci: Add debug messages to error paths
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d0d42d034f9f
- [BlueZ,v1,2/4] emulator/hciemu: Add debug messages to error paths
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d4c965eec4d3
- [BlueZ,v1,3/4] tools/gap-tester: Enable hciemu debug output
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=164941a6c145
- [BlueZ,v1,4/4] tools/userchan-tester: Enable hciemu debug output
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e51115ccd4df
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-06 13:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 20:47 [PATCH BlueZ v1 1/4] emulator/vhci: Add debug messages to error paths Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 2/4] emulator/hciemu: " Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 3/4] tools/gap-tester: Enable hciemu debug output Luiz Augusto von Dentz
2026-05-05 20:47 ` [PATCH BlueZ v1 4/4] tools/userchan-tester: " Luiz Augusto von Dentz
2026-05-05 21:53 ` [BlueZ,v1,1/4] emulator/vhci: Add debug messages to error paths bluez.test.bot
2026-05-06 13:30 ` [PATCH BlueZ v1 1/4] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox