[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 09/19] tools/vhost-user-rpmb: add a --verbose/debug flags for
From: |
Alex Bennée |
Subject: |
[RFC PATCH 09/19] tools/vhost-user-rpmb: add a --verbose/debug flags for logging |
Date: |
Fri, 25 Sep 2020 13:51:37 +0100 |
This gives us two levels of informational output when tracing what the
daemon is doing.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tools/vhost-user-rpmb/main.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tools/vhost-user-rpmb/main.c b/tools/vhost-user-rpmb/main.c
index 269c86cbb633..1be0d4b8a567 100644
--- a/tools/vhost-user-rpmb/main.c
+++ b/tools/vhost-user-rpmb/main.c
@@ -6,6 +6,9 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
+#define G_LOG_DOMAIN "vhost-user-rpmb"
+#define G_LOG_USE_STRUCTURED 1
+
#include <glib.h>
#include <gio/gio.h>
#include <gio/gunixsocketaddress.h>
@@ -25,12 +28,16 @@
static gchar *socket_path;
static gint socket_fd = -1;
static gboolean print_cap;
+static gboolean verbose;
+static gboolean debug;
static GOptionEntry options[] =
{
{ "socket-path", 0, 0, G_OPTION_ARG_FILENAME, &socket_path, "Location of
vhost-user Unix domain socket, incompatible with --fd", "PATH" },
{ "fd", 0, 0, G_OPTION_ARG_INT, &socket_fd, "Specify the file-descriptor
of the backend, incompatible with --socket-path", "FD" },
{ "print-capabilities", 0, 0, G_OPTION_ARG_NONE, &print_cap, "Output to
stdout the backend capabilities in JSON format and exit", NULL},
+ { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be more verbose in
output", NULL},
+ { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "Include debug output", NULL},
{ NULL }
};
@@ -84,6 +91,7 @@ static void vrpmb_panic(VuDev *dev, const char *msg)
static uint64_t vrpmb_get_features(VuDev *dev)
{
+ g_info("%s: replying", __func__);
return 0;
}
@@ -209,6 +217,17 @@ int main (int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ if (verbose || debug) {
+ g_log_set_handler(NULL, G_LOG_LEVEL_MASK, g_log_default_handler, NULL);
+ if (debug) {
+ g_setenv("G_MESSAGES_DEBUG", "all", true);
+ }
+ } else {
+ g_log_set_handler(NULL,
+ G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_ERROR,
+ g_log_default_handler, NULL);
+ }
+
/*
* Now create a vhost-user socket that we will receive messages
* on. Once we have our handler set up we can enter the glib main
--
2.20.1
- [RFC PATCH 00/19] vhost-user-rpmb (Replay Protected Memory Block), Alex Bennée, 2020/09/25
- [RFC PATCH 01/19] tools/virtiofsd: add support for --socket-group, Alex Bennée, 2020/09/25
- [RFC PATCH 02/19] hw/block: add boilerplate for vhost-user-rpmb device, Alex Bennée, 2020/09/25
- [RFC PATCH 04/19] hw/block: add vhost-user-rpmb-pci boilerplate, Alex Bennée, 2020/09/25
- [RFC PATCH 05/19] virtio-pci: add notification trace points, Alex Bennée, 2020/09/25
- [RFC PATCH 03/19] hw/virtio: move virtio-pci.h into shared include space, Alex Bennée, 2020/09/25
- [RFC PATCH 06/19] tools/vhost-user-rpmb: add boilerplate and initial main, Alex Bennée, 2020/09/25
- [RFC PATCH 07/19] tools/vhost-user-rpmb: implement --print-capabilities, Alex Bennée, 2020/09/25
- [RFC PATCH 08/19] tools/vhost-user-rpmb: connect to fd and instantiate basic run loop, Alex Bennée, 2020/09/25
- [RFC PATCH 09/19] tools/vhost-user-rpmb: add a --verbose/debug flags for logging,
Alex Bennée <=
- [RFC PATCH 11/19] tools/vhost-user-rpmb: add --flash-path for backing store, Alex Bennée, 2020/09/25
- [RFC PATCH 12/19] tools/vhost-user-rpmb: import hmac_sha256 functions, Alex Bennée, 2020/09/25
- [RFC PATCH 10/19] tools/vhost-user-rpmb: handle shutdown and SIGINT/SIGHUP cleanly, Alex Bennée, 2020/09/25
- [RFC PATCH 17/19] tools/vhost-user-rpmb: add key persistence, Alex Bennée, 2020/09/25
- [RFC PATCH 15/19] tools/vhost-user-rpmb: implement VIRTIO_RPMB_REQ_DATA_WRITE, Alex Bennée, 2020/09/25
- [RFC PATCH 16/19] tools/vhost-user-rpmb: implement VIRTIO_RPMB_REQ_DATA_READ, Alex Bennée, 2020/09/25
- [RFC PATCH 18/19] tools/vhost-user-rpmb: allow setting of the write_count, Alex Bennée, 2020/09/25