43fe83
From 07ed15bbbd7c0fc2c946620f15f1963882144633 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <07ed15bbbd7c0fc2c946620f15f1963882144633.1377873638.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Tue, 13 Aug 2013 11:36:00 +0100
43fe83
Subject: [PATCH] Add an example config file for virtlockd
43fe83
43fe83
For https://bugzilla.redhat.com/show_bug.cgi?id=991494
43fe83
43fe83
The virtlockd daemon supports an /etc/libvirt/virtlockd.conf
43fe83
config file, but we never installed a default config, nor
43fe83
created any augeas scripts. This change addresses that omission.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit 38550ae80978d590a0dccf79108ec96180771fe1)
43fe83
---
43fe83
 .gitignore                        |  1 +
43fe83
 libvirt.spec.in                   |  3 ++
43fe83
 src/Makefile.am                   | 20 ++++++++++++-
43fe83
 src/locking/test_virtlockd.aug.in | 12 ++++++++
43fe83
 src/locking/virtlockd.aug         | 44 ++++++++++++++++++++++++++++
43fe83
 src/locking/virtlockd.conf        | 60 +++++++++++++++++++++++++++++++++++++++
43fe83
 6 files changed, 139 insertions(+), 1 deletion(-)
43fe83
 create mode 100644 src/locking/test_virtlockd.aug.in
43fe83
 create mode 100644 src/locking/virtlockd.aug
43fe83
 create mode 100644 src/locking/virtlockd.conf
43fe83
43fe83
diff --git a/src/Makefile.am b/src/Makefile.am
43fe83
index 5a7e05a..12ca204 100644
43fe83
--- a/src/Makefile.am
43fe83
+++ b/src/Makefile.am
43fe83
@@ -1586,7 +1586,7 @@ check-local: check-augeas
43fe83
 	$(NULL)
43fe83
 
43fe83
 check-augeas: check-augeas-qemu check-augeas-lxc check-augeas-sanlock \
43fe83
-	check-augeas-lockd
43fe83
+	check-augeas-lockd check-augeas-virtlockd
43fe83
 
43fe83
 AUG_GENTEST = $(PERL) $(top_srcdir)/build-aux/augeas-gentest.pl
43fe83
 EXTRA_DIST += $(top_srcdir)/build-aux/augeas-gentest.pl
43fe83
@@ -1634,11 +1634,20 @@ test_libvirt_lockd.aug: locking/test_libvirt_lockd.aug.in \
43fe83
 		locking/qemu-lockd.conf $(AUG_GENTEST)
43fe83
 	$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-lockd.conf $< $@
43fe83
 
43fe83
+test_virtlockd.aug: locking/test_virtlockd.aug.in \
43fe83
+		locking/virtlockd.conf $(AUG_GENTEST)
43fe83
+	$(AM_V_GEN)$(AUG_GENTEST) locking/virtlockd.conf $< $@
43fe83
+
43fe83
 check-augeas-lockd: test_libvirt_lockd.aug
43fe83
 	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
43fe83
 	    '$(AUGPARSE)' -I $(srcdir)/locking test_libvirt_lockd.aug; \
43fe83
 	fi
43fe83
 
43fe83
+check-augeas-virtlockd: test_virtlockd.aug
43fe83
+	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
43fe83
+	    '$(AUGPARSE)' -I $(srcdir)/locking test_virtlockd.aug; \
43fe83
+	fi
43fe83
+
43fe83
 #
43fe83
 # Build our version script.  This is composed of three parts:
43fe83
 #
43fe83
@@ -2013,6 +2022,12 @@ virtlockd.8: $(srcdir)/virtlockd.8.in
43fe83
 
43fe83
 man8_MANS = virtlockd.8
43fe83
 
43fe83
+conf_DATA += locking/virtlockd.conf
43fe83
+
43fe83
+augeas_DATA += locking/virtlockd.aug
43fe83
+augeastest_DATA += test_virtlockd.aug
43fe83
+
43fe83
+CLEANFILES += test_virtlockd.aug
43fe83
 MAINTAINERCLEANFILES += $(srcdir)/virtlockd.8.in
43fe83
 
43fe83
 EXTRA_DIST += \
43fe83
@@ -2020,6 +2035,9 @@ EXTRA_DIST += \
43fe83
         locking/virtlockd.socket.in \
43fe83
         locking/virtlockd.pod.in \
43fe83
         virtlockd.8.in \
43fe83
+        locking/virtlockd.aug \
43fe83
+        locking/virtlockd.conf \
43fe83
+        locking/test_virtlockd.aug.in \
43fe83
         $(NULL)
43fe83
 
43fe83
 
43fe83
diff --git a/src/locking/test_virtlockd.aug.in b/src/locking/test_virtlockd.aug.in
43fe83
new file mode 100644
43fe83
index 0000000..dcd47c3
43fe83
--- /dev/null
43fe83
+++ b/src/locking/test_virtlockd.aug.in
43fe83
@@ -0,0 +1,12 @@
43fe83
+module Test_virtlockd =
43fe83
+  let conf = "log_level = 3
43fe83
+log_filters=\"3:remote 4:event\"
43fe83
+log_outputs=\"3:syslog:libvirtd\"
43fe83
+log_buffer_size = 64
43fe83
+"
43fe83
+
43fe83
+   test Libvirtd.lns get conf =
43fe83
+        { "log_level" = "3" }
43fe83
+        { "log_filters" = "3:remote 4:event" }
43fe83
+        { "log_outputs" = "3:syslog:libvirtd" }
43fe83
+        { "log_buffer_size" = "64" }
43fe83
diff --git a/src/locking/virtlockd.aug b/src/locking/virtlockd.aug
43fe83
new file mode 100644
43fe83
index 0000000..9d20e72
43fe83
--- /dev/null
43fe83
+++ b/src/locking/virtlockd.aug
43fe83
@@ -0,0 +1,44 @@
43fe83
+(* /etc/libvirt/libvirtd.conf *)
43fe83
+
43fe83
+module Libvirtd =
43fe83
+   autoload xfm
43fe83
+
43fe83
+   let eol   = del /[ \t]*\n/ "\n"
43fe83
+   let value_sep   = del /[ \t]*=[ \t]*/  " = "
43fe83
+   let indent = del /[ \t]*/ ""
43fe83
+
43fe83
+   let array_sep  = del /,[ \t\n]*/ ", "
43fe83
+   let array_start = del /\[[ \t\n]*/ "[ "
43fe83
+   let array_end = del /\]/ "]"
43fe83
+
43fe83
+   let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
43fe83
+   let bool_val = store /0|1/
43fe83
+   let int_val = store /[0-9]+/
43fe83
+   let str_array_element = [ seq "el" . str_val ] . del /[ \t\n]*/ ""
43fe83
+   let str_array_val = counter "el" . array_start . ( str_array_element . ( array_sep . str_array_element ) * ) ? . array_end
43fe83
+
43fe83
+   let str_entry       (kw:string) = [ key kw . value_sep . str_val ]
43fe83
+   let bool_entry      (kw:string) = [ key kw . value_sep . bool_val ]
43fe83
+   let int_entry      (kw:string) = [ key kw . value_sep . int_val ]
43fe83
+   let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
43fe83
+
43fe83
+
43fe83
+   (* Config entry grouped by function - same order as example config *)
43fe83
+   let logging_entry = int_entry "log_level"
43fe83
+                     | str_entry "log_filters"
43fe83
+                     | str_entry "log_outputs"
43fe83
+                     | int_entry "log_buffer_size"
43fe83
+
43fe83
+   (* Each enty in the config is one of the following three ... *)
43fe83
+   let entry = logging_entry
43fe83
+   let comment = [ label "#comment" . del /#[ \t]*/ "# " .  store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
43fe83
+   let empty = [ label "#empty" . eol ]
43fe83
+
43fe83
+   let record = indent . entry . eol
43fe83
+
43fe83
+   let lns = ( record | comment | empty ) *
43fe83
+
43fe83
+   let filter = incl "/etc/libvirt/virtlockd.conf"
43fe83
+              . Util.stdexcl
43fe83
+
43fe83
+   let xfm = transform lns filter
43fe83
diff --git a/src/locking/virtlockd.conf b/src/locking/virtlockd.conf
43fe83
new file mode 100644
43fe83
index 0000000..b6450b4
43fe83
--- /dev/null
43fe83
+++ b/src/locking/virtlockd.conf
43fe83
@@ -0,0 +1,60 @@
43fe83
+# Master virtlockd daemon configuration file
43fe83
+#
43fe83
+
43fe83
+#################################################################
43fe83
+#
43fe83
+# Logging controls
43fe83
+#
43fe83
+
43fe83
+# Logging level: 4 errors, 3 warnings, 2 information, 1 debug
43fe83
+# basically 1 will log everything possible
43fe83
+#log_level = 3
43fe83
+
43fe83
+# Logging filters:
43fe83
+# A filter allows to select a different logging level for a given category
43fe83
+# of logs
43fe83
+# The format for a filter is one of:
43fe83
+#    x:name
43fe83
+#    x:+name
43fe83
+#      where name is a string which is matched against source file name,
43fe83
+#      e.g., "remote", "qemu", or "util/json", the optional "+" prefix
43fe83
+#      tells libvirt to log stack trace for each message matching name,
43fe83
+#      and x is the minimal level where matching messages should be logged:
43fe83
+#    1: DEBUG
43fe83
+#    2: INFO
43fe83
+#    3: WARNING
43fe83
+#    4: ERROR
43fe83
+#
43fe83
+# Multiple filter can be defined in a single @filters, they just need to be
43fe83
+# separated by spaces.
43fe83
+#
43fe83
+# e.g. to only get warning or errors from the remote layer and only errors
43fe83
+# from the event layer:
43fe83
+#log_filters="3:remote 4:event"
43fe83
+
43fe83
+# Logging outputs:
43fe83
+# An output is one of the places to save logging information
43fe83
+# The format for an output can be:
43fe83
+#    x:stderr
43fe83
+#      output goes to stderr
43fe83
+#    x:syslog:name
43fe83
+#      use syslog for the output and use the given name as the ident
43fe83
+#    x:file:file_path
43fe83
+#      output to a file, with the given filepath
43fe83
+# In all case the x prefix is the minimal level, acting as a filter
43fe83
+#    1: DEBUG
43fe83
+#    2: INFO
43fe83
+#    3: WARNING
43fe83
+#    4: ERROR
43fe83
+#
43fe83
+# Multiple output can be defined, they just need to be separated by spaces.
43fe83
+# e.g. to log all warnings and errors to syslog under the virtlockd ident:
43fe83
+#log_outputs="3:syslog:virtlockd"
43fe83
+#
43fe83
+
43fe83
+# Log debug buffer size: default 64
43fe83
+# The daemon keeps an internal debug log buffer which will be dumped in case
43fe83
+# of crash or upon receiving a SIGUSR2 signal. This setting allows to override
43fe83
+# the default buffer size in kilobytes.
43fe83
+# If value is 0 or less the debug log buffer is deactivated
43fe83
+#log_buffer_size = 64
43fe83
-- 
43fe83
1.8.3.2
43fe83