From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 2/4] emulator/hciemu: Add debug messages to error paths
Date: Tue, 5 May 2026 16:47:17 -0400 [thread overview]
Message-ID: <20260505204719.1348473-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260505204719.1348473-1-luiz.dentz@gmail.com>
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
next prev parent reply other threads:[~2026-05-05 20:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20260505204719.1348473-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox