Blob Blame History Raw
From d7836fb0a7131c725e3c02be7e48e99c671637c3 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 12 Dec 2019 08:57:15 +0000
Subject: [PATCH 01/19] server: Allow -D nbdkit.* debug flags for the core
 server.

These work like plugin/filter debug flags, but apply to the internals
of the server.

(cherry picked from commit 3b45db234a691f8ff926a6fef583e11c3601f112)
---
 docs/nbdkit.pod    | 7 +++++++
 docs/synopsis.txt  | 2 +-
 server/main.c      | 3 +++
 server/nbdkit.syms | 2 ++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/docs/nbdkit.pod b/docs/nbdkit.pod
index a2e72b13..346d8332 100644
--- a/docs/nbdkit.pod
+++ b/docs/nbdkit.pod
@@ -177,6 +177,13 @@ Display brief command line usage information and exit.
 Set the plugin or filter Debug Flag called C<FLAG> to the integer
 value C<N>.  See L<nbdkit-plugin(3)/Debug Flags>.
 
+=item B<-D> nbdkit.FLAG=N
+
+=item B<--debug> nbdkit.FLAG=N
+
+Set the nbdkit server Debug Flag called C<FLAG> to the integer value
+C<N>.
+
 =item B<--dump-config>
 
 Dump out the compile-time configuration values and exit.
diff --git a/docs/synopsis.txt b/docs/synopsis.txt
index 3c239373..c3675422 100644
--- a/docs/synopsis.txt
+++ b/docs/synopsis.txt
@@ -1,4 +1,4 @@
-nbdkit [-D|--debug PLUGIN|FILTER.FLAG=N]
+nbdkit [-D|--debug PLUGIN|FILTER|nbdkit.FLAG=N]
        [-e|--exportname EXPORTNAME] [--exit-with-parent]
        [--filter FILTER ...] [-f|--foreground]
        [-g|--group GROUP] [-i|--ipaddr IPADDR]
diff --git a/server/main.c b/server/main.c
index d39941b1..11ba1e6d 100644
--- a/server/main.c
+++ b/server/main.c
@@ -563,6 +563,9 @@ main (int argc, char *argv[])
     free (t);
   }
 
+  /* Apply nbdkit.* flags for the server. */
+  apply_debug_flags (NULL, "nbdkit");
+
   /* Check all debug flags were used, and free them. */
   free_debug_flags ();
 
diff --git a/server/nbdkit.syms b/server/nbdkit.syms
index 390972e2..96c22c07 100644
--- a/server/nbdkit.syms
+++ b/server/nbdkit.syms
@@ -67,6 +67,8 @@
     nbdkit_vdebug;
     nbdkit_verror;
 
+    nbdkit_debug_*;
+
   # Everything else is hidden.
   local: *;
 };
-- 
2.18.2