[libvirt] [PATCH 0/4] Improve testing of augeas lens & fix lens bugs

This improves testing of the augeas lens to ensure that all possible config options are handled

From: "Daniel P. Berrange" <berrange@redhat.com> Instead of doing # example_config use #example_config so it is possible to programatically uncomment example config options, as distinct from their comment/descriptions Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.conf | 13 +++++----- src/lxc/lxc.conf | 8 +++--- src/qemu/qemu.conf | 66 +++++++++++++++++++++++++------------------------- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf index 50eda1b..aa3fa2e 100644 --- a/daemon/libvirtd.conf +++ b/daemon/libvirtd.conf @@ -303,10 +303,9 @@ # Multiple filter can be defined in a single @filters, they just need to be # separated by spaces. # -# e.g: -# log_filters="3:remote 4:event" -# to only get warning or errors from the remote layer and only errors from -# the event layer. +# e.g: to only get warning or errors from the remote layer and only errors +# from the event layer +#log_filters="3:remote 4:event" # Logging outputs: # An output is one of the places to save logging information @@ -324,9 +323,9 @@ # 4: ERROR # # Multiple output can be defined, they just need to be separated by spaces. -# e.g.: -# log_outputs="3:syslog:libvirtd" -# to log all warnings and errors to syslog under the libvirtd ident +# e.g. to log all warnings and errors to syslog under the libvirtd ident: +#log_outputs="3:syslog:libvirtd" +# # Log debug buffer size: default 64 # The daemon keeps an internal debug log buffer which will be dumped in case diff --git a/src/lxc/lxc.conf b/src/lxc/lxc.conf index 09dc95f..8df4601 100644 --- a/src/lxc/lxc.conf +++ b/src/lxc/lxc.conf @@ -10,7 +10,7 @@ # # This is disabled by default, uncomment below to enable it. # -# log_with_libvirtd = 1 +#log_with_libvirtd = 1 # The default security driver is SELinux. If SELinux is disabled @@ -19,13 +19,13 @@ # leaving SELinux enabled for the host in general, then set this # to 'none' instead. # -# security_driver = "selinux" +#security_driver = "selinux" # If set to non-zero, then the default security labeling # will make guests confined. If set to zero, then guests # will be unconfined by default. Defaults to 0. -# security_default_confined = 1 +#security_default_confined = 1 # If set to non-zero, then attempts to create unconfined # guests will be blocked. Defaults to 0. -# security_require_confined = 1 +#security_require_confined = 1 diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index cb87728..c78d551 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -9,7 +9,7 @@ # NB, strong recommendation to enable TLS + x509 certificate # verification when allowing public access # -# vnc_listen = "0.0.0.0" +#vnc_listen = "0.0.0.0" # Enable this option to have VNC served over an automatically created # unix socket. This prevents unprivileged access from users on the @@ -19,7 +19,7 @@ # a hardcoded 'listen' or 'socket' value. This setting takes preference # over vnc_listen. # -# vnc_auto_unix_socket = 1 +#vnc_auto_unix_socket = 1 # Enable use of TLS encryption on the VNC server. This requires # a VNC client which supports the VeNCrypt protocol extension. @@ -29,7 +29,7 @@ # It is necessary to setup CA and issue a server certificate # before enabling this. # -# vnc_tls = 1 +#vnc_tls = 1 # Use of TLS requires that x509 certificates be issued. The @@ -42,7 +42,7 @@ # # This option allows the certificate directory to be changed # -# vnc_tls_x509_cert_dir = "/etc/pki/libvirt-vnc" +#vnc_tls_x509_cert_dir = "/etc/pki/libvirt-vnc" # The default TLS configuration only uses certificates for the server @@ -55,7 +55,7 @@ # Enabling this option will reject any client who does not have a # certificate signed by the CA in /etc/pki/libvirt-vnc/ca-cert.pem # -# vnc_tls_x509_verify = 1 +#vnc_tls_x509_verify = 1 # The default VNC password. Only 8 letters are significant for @@ -66,7 +66,7 @@ # effectively preventing any use of VNC. Obviously change this # example here before you set this. # -# vnc_password = "XYZ12345" +#vnc_password = "XYZ12345" # Enable use of SASL encryption on the VNC server. This requires @@ -77,7 +77,7 @@ # It is necessary to configure /etc/sasl2/qemu.conf to choose # the desired SASL plugin (eg, GSSPI for Kerberos) # -# vnc_sasl = 1 +#vnc_sasl = 1 # The default SASL configuration file is located in /etc/sasl2/ @@ -85,7 +85,7 @@ # override the configs in this location. Set this parameter to # point to the directory, and create a qemu.conf in that location # -# vnc_sasl_dir = "/some/directory/sasl2" +#vnc_sasl_dir = "/some/directory/sasl2" @@ -96,7 +96,7 @@ # NB, strong recommendation to enable TLS + x509 certificate # verification when allowing public access # -# spice_listen = "0.0.0.0" +#spice_listen = "0.0.0.0" # Enable use of TLS encryption on the SPICE server. @@ -104,7 +104,7 @@ # It is necessary to setup CA and issue a server certificate # before enabling this. # -# spice_tls = 1 +#spice_tls = 1 # Use of TLS requires that x509 certificates be issued. The @@ -117,7 +117,7 @@ # # This option allows the certificate directory to be changed. # -# spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice" +#spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice" # The default SPICE password. This parameter is only used if the @@ -127,7 +127,7 @@ # QEMU, effectively preventing any use of SPICE. Obviously change # this example here before you set this. # -# spice_password = "XYZ12345" +#spice_password = "XYZ12345" # The default security driver is SELinux. If SELinux is disabled @@ -136,16 +136,16 @@ # leaving SELinux enabled for the host in general, then set this # to 'none' instead. # -# security_driver = "selinux" +#security_driver = "selinux" # If set to non-zero, then the default security labeling # will make guests confined. If set to zero, then guests # will be unconfined by default. Defaults to 1. -# security_default_confined = 1 +#security_default_confined = 1 # If set to non-zero, then attempts to create unconfined # guests will be blocked. Defaults to 0. -# security_require_confined = 1 +#security_require_confined = 1 # The user ID for QEMU processes run by the system instance. #user = "root" @@ -178,7 +178,7 @@ # can be mounted in different locations. libvirt will detect # where they are located. # -# cgroup_controllers = [ "cpu", "devices", "memory", "blkio", "cpuset", "cpuacct" ] +#cgroup_controllers = [ "cpu", "devices", "memory", "blkio", "cpuset", "cpuacct" ] # This is the basic set of devices allowed / required by # all virtual machines. @@ -193,7 +193,7 @@ # "/dev/null", "/dev/full", "/dev/zero", # "/dev/random", "/dev/urandom", # "/dev/ptmx", "/dev/kvm", "/dev/kqemu", -# "/dev/rtc", "/dev/hpet", +# "/dev/rtc","/dev/hpet" #] @@ -215,14 +215,14 @@ # the requested compression program can't be found, this falls # back to "raw" compression. # -# save_image_format = "raw" -# dump_image_format = "raw" +#save_image_format = "raw" +#dump_image_format = "raw" # When a domain is configured to be auto-dumped when libvirtd receives a # watchdog event from qemu guest, libvirtd will save dump files in directory # specified by auto_dump_path. Default value is /var/lib/libvirt/qemu/dump # -# auto_dump_path = "/var/lib/libvirt/qemu/dump" +#auto_dump_path = "/var/lib/libvirt/qemu/dump" # When a domain is configured to be auto-dumped, enabling this flag # has the same effect as using the VIR_DUMP_BYPASS_CACHE flag with the @@ -230,7 +230,7 @@ # file system cache while writing the dump file, but may cause # slower operation. # -# auto_dump_bypass_cache = 0 +#auto_dump_bypass_cache = 0 # When a domain is configured to be auto-started, enabling this flag # has the same effect as using the VIR_DOMAIN_START_BYPASS_CACHE flag @@ -238,7 +238,7 @@ # avoid using the file system cache when restoring any managed state # file, but may cause slower operation. # -# auto_start_bypass_cache = 0 +#auto_start_bypass_cache = 0 # If provided by the host and a hugetlbfs mount point is configured, # a guest may request huge page backing. When this mount point is @@ -250,20 +250,20 @@ # NB, within this mount point, guests will create memory backing files # in a location of $MOUNTPOINT/libvirt/qemu # -# hugetlbfs_mount = "/dev/hugepages" +#hugetlbfs_mount = "/dev/hugepages" # mac_filter enables MAC addressed based filtering on bridge ports. # This currently requires ebtables to be installed. # -# mac_filter = 1 +#mac_filter = 1 # By default, PCI devices below non-ACS switch are not allowed to be assigned # to guests. By setting relaxed_acs_check to 1 such devices will be allowed to # be assigned to guests. # -# relaxed_acs_check = 1 +#relaxed_acs_check = 1 # QEMU implements an extension for providing audio over a VNC connection, @@ -273,7 +273,7 @@ # permissions issues. Enabling this option will make libvirtd honor the # QEMU_AUDIO_DRV environment variable when using VNC. # -# vnc_allow_host_audio = 0 +#vnc_allow_host_audio = 0 # If clear_emulator_capabilities is enabled, libvirt will drop all @@ -283,7 +283,7 @@ # Warning: Disabling this option means that a compromised guest can # exploit the privileges and possibly do damage to the host. # -# clear_emulator_capabilities = 1 +#clear_emulator_capabilities = 1 # If allow_disk_format_probing is enabled, libvirt will probe disk @@ -295,7 +295,7 @@ # guest XML <disk> elements to include <driver type='XXXX'/> # elements instead of enabling this option. # -# allow_disk_format_probing = 1 +#allow_disk_format_probing = 1 # If enabled, libvirt will have QEMU set its process name to @@ -305,7 +305,7 @@ # its process title, so the complete QEMU command (emulator and # its arguments) appear in process listings. # -# set_process_name = 1 +#set_process_name = 1 # If max_processes is set to a positive integer, libvirt will use @@ -314,21 +314,21 @@ # The same applies to max_files which sets the limit on the maximum # number of opened files. # -# max_processes = 0 -# max_files = 0 +#max_processes = 0 +#max_files = 0 # To enable 'Sanlock' project based locking of the file # content (to prevent two VMs writing to the same # disk), uncomment this # -# lock_manager = "sanlock" +#lock_manager = "sanlock" # Set limit of maximum APIs queued on one domain. All other APIs # over this threshold will fail on acquiring job lock. Specially, # setting to zero turns this feature off. # Note, that job lock is per domain. # -# max_queued = 0 +#max_queued = 0 ################################################################### # Keepalive protocol: -- 1.7.10.1

On 05/25/2012 06:36 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Instead of doing
# example_config
use
#example_config
so it is possible to programatically uncomment example config options, as distinct from their comment/descriptions
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.conf | 13 +++++----- src/lxc/lxc.conf | 8 +++--- src/qemu/qemu.conf | 66 +++++++++++++++++++++++++------------------------- 3 files changed, 43 insertions(+), 44 deletions(-)
Mechanical, and very nice. ACK with nits fixed:
diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf index 50eda1b..aa3fa2e 100644 --- a/daemon/libvirtd.conf +++ b/daemon/libvirtd.conf @@ -303,10 +303,9 @@ # Multiple filter can be defined in a single @filters, they just need to be # separated by spaces. # -# e.g: -# log_filters="3:remote 4:event" -# to only get warning or errors from the remote layer and only errors from -# the event layer. +# e.g: to only get warning or errors from the remote layer and only errors +# from the event layer
s/$/:/, to match...
+#log_filters="3:remote 4:event"
# Logging outputs: # An output is one of the places to save logging information @@ -324,9 +323,9 @@ # 4: ERROR # # Multiple output can be defined, they just need to be separated by spaces. -# e.g.: -# log_outputs="3:syslog:libvirtd" -# to log all warnings and errors to syslog under the libvirtd ident +# e.g. to log all warnings and errors to syslog under the libvirtd ident:
this line.
+#log_outputs="3:syslog:libvirtd" +#
@@ -178,7 +178,7 @@ # can be mounted in different locations. libvirt will detect # where they are located. # -# cgroup_controllers = [ "cpu", "devices", "memory", "blkio", "cpuset", "cpuacct" ] +#cgroup_controllers = [ "cpu", "devices", "memory", "blkio", "cpuset", "cpuacct" ]
# This is the basic set of devices allowed / required by # all virtual machines. @@ -193,7 +193,7 @@ # "/dev/null", "/dev/full", "/dev/zero", # "/dev/random", "/dev/urandom", # "/dev/ptmx", "/dev/kvm", "/dev/kqemu", -# "/dev/rtc", "/dev/hpet", +# "/dev/rtc","/dev/hpet" #]
Deleting a trailing comma seems unrelated. Any reason to keep this change, and should the commit message mention it? -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Add nmissing 'host_uuid' entry to libvirtd.conf lens and rename spice_passwd to spice_password in qemu.conf lens Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.aug | 4 ++++ src/qemu/libvirtd_qemu.aug | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon/libvirtd.aug b/daemon/libvirtd.aug index 9d78bd7..f32b3a1 100644 --- a/daemon/libvirtd.aug +++ b/daemon/libvirtd.aug @@ -62,6 +62,7 @@ module Libvirtd = let logging_entry = int_entry "log_level" | str_entry "log_filters" | str_entry "log_outputs" + | int_entry "log_buffer_size" let auditing_entry = int_entry "audit_level" | bool_entry "audit_logging" @@ -70,6 +71,8 @@ module Libvirtd = | int_entry "keepalive_count" | bool_entry "keepalive_required" + let misc_entry = str_entry "host_uuid" + (* Each enty in the config is one of the following three ... *) let entry = network_entry | sock_acl_entry @@ -80,6 +83,7 @@ module Libvirtd = | logging_entry | auditing_entry | keepalive_entry + | misc_entry let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] let empty = [ label "#empty" . eol ] diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 9120d4e..359f8f1 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -35,7 +35,7 @@ module Libvirtd_qemu = | str_entry "spice_listen" | bool_entry "spice_tls" | str_entry "spice_tls_x509_cert_dir" - | str_entry "spice_passwd" + | str_entry "spice_password" | str_entry "security_driver" | bool_entry "security_default_confined" | bool_entry "security_require_confined" -- 1.7.10.1

On 05/25/2012 06:36 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Add nmissing 'host_uuid' entry to libvirtd.conf lens and rename spice_passwd to spice_password in qemu.conf lens
Aargh - that means I just typo'd that, and in Douglas' name in commit cdd762e. Sorry.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.aug | 4 ++++ src/qemu/libvirtd_qemu.aug | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Currently all the config options are listed under a 'vnc_entry' group. Create a bunch of new groups & move options to the right place Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/qemu/libvirtd_qemu.aug | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 359f8f1..683aadb 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -32,11 +32,14 @@ module Libvirtd_qemu = | str_entry "vnc_password" | bool_entry "vnc_sasl" | str_entry "vnc_sasl_dir" - | str_entry "spice_listen" + | bool_entry "vnc_allow_host_audio" + + let spice_entry = str_entry "spice_listen" | bool_entry "spice_tls" | str_entry "spice_tls_x509_cert_dir" | str_entry "spice_password" - | str_entry "security_driver" + + let security_entry = str_entry "security_driver" | bool_entry "security_default_confined" | bool_entry "security_require_confined" | str_entry "user" @@ -44,27 +47,37 @@ module Libvirtd_qemu = | bool_entry "dynamic_ownership" | str_array_entry "cgroup_controllers" | str_array_entry "cgroup_device_acl" - | str_entry "save_image_format" + + let save_entry = str_entry "save_image_format" | str_entry "dump_image_format" | str_entry "auto_dump_path" | bool_entry "auto_dump_bypass_cache" | bool_entry "auto_start_bypass_cache" - | str_entry "hugetlbfs_mount" - | bool_entry "mac_filter" - | bool_entry "relaxed_acs_check" - | bool_entry "vnc_allow_host_audio" + + let process_entry = str_entry "hugetlbfs_mount" | bool_entry "clear_emulator_capabilities" - | bool_entry "allow_disk_format_probing" | bool_entry "set_process_name" | int_entry "max_processes" | int_entry "max_files" + + let device_entry = bool_entry "mac_filter" + | bool_entry "relaxed_acs_check" + | bool_entry "allow_disk_format_probing" | str_entry "lock_manager" - | int_entry "max_queued" + + let rpc_entry = int_entry "max_queued" | int_entry "keepalive_interval" | int_entry "keepalive_count" (* Each enty in the config is one of the following three ... *) let entry = vnc_entry + | spice_entry + | security_entry + | save_entry + | process_entry + | device_entry + | rpc_entry + let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] let empty = [ label "#empty" . eol ] -- 1.7.10.1

On 05/25/2012 06:36 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Currently all the config options are listed under a 'vnc_entry' group. Create a bunch of new groups & move options to the right place
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/qemu/libvirtd_qemu.aug | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-)
Conditional ACK.
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 359f8f1..683aadb 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -32,11 +32,14 @@ module Libvirtd_qemu = | str_entry "vnc_password" | bool_entry "vnc_sasl" | str_entry "vnc_sasl_dir" - | str_entry "spice_listen" + | bool_entry "vnc_allow_host_audio"
Since you are re-ordering options here into logical groups, you should also rearrange the order in which lines are listed in qemu.conf to match. For example (although this is not all affected parameters): diff --git i/src/qemu/qemu.conf w/src/qemu/qemu.conf index c78d551..32622ca 100644 --- i/src/qemu/qemu.conf +++ w/src/qemu/qemu.conf @@ -87,6 +87,14 @@ # #vnc_sasl_dir = "/some/directory/sasl2" +# QEMU implements an extension for providing audio over a VNC connection, +# though if your VNC client does not support it, your only chance for getting +# sound output is through regular audio backends. By default, libvirt will +# disable all QEMU sound backends if using VNC, since they can cause +# permissions issues. Enabling this option will make libvirtd honor the +# QEMU_AUDIO_DRV environment variable when using VNC. +# +#vnc_allow_host_audio = 0 # SPICE is configured to listen on 127.0.0.1 by default. @@ -266,16 +274,6 @@ #relaxed_acs_check = 1 -# QEMU implements an extension for providing audio over a VNC connection, -# though if your VNC client does not support it, your only chance for getting -# sound output is through regular audio backends. By default, libvirt will -# disable all QEMU sound backends if using VNC, since they can cause -# permissions issues. Enabling this option will make libvirtd honor the -# QEMU_AUDIO_DRV environment variable when using VNC. -# -#vnc_allow_host_audio = 0 - - # If clear_emulator_capabilities is enabled, libvirt will drop all # privileged capabilities of the QEmu/KVM emulator. This is enabled by # default. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> When adding new config file parameters, the corresponding additions to the augeas lens' are constantly forgotten. Also there are augeas test cases, these don't catch the error, since they too are never updated. To address this, the augeas test cases need to be auto-generated from the example config files. * build-aux/augeas-gentest.pl: Helper to generate an augeas test file, substituting in elements from the example config files * src/Makefile.am, daemon/Makefile.am: Switch to auto-generated augeas test cases * daemon/test_libvirtd.aug, daemon/test_libvirtd.aug.in, src/locking/test_libvirt_sanlock.aug, src/locking/test_libvirt_sanlock.aug.in, src/lxc/test_libvirtd_lxc.aug, src/lxc/test_libvirtd_lxc.aug.in, src/qemu/test_libvirtd_qemu.aug, src/qemu/test_libvirtd_qemu.aug.in: Remove example config file data, replacing with a ::CONFIG:: placeholder Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- .gitignore | 4 + build-aux/augeas-gentest.pl | 51 ++ daemon/Makefile.am | 11 +- daemon/test_libvirtd.aug | 553 -------------------- daemon/test_libvirtd.aug.in | 49 ++ src/Makefile.am | 37 +- ...irt_sanlock.aug => test_libvirt_sanlock.aug.in} | 8 +- src/lxc/test_libvirtd_lxc.aug | 33 -- src/lxc/test_libvirtd_lxc.aug.in | 9 + src/qemu/test_libvirtd_qemu.aug | 252 --------- src/qemu/test_libvirtd_qemu.aug.in | 60 +++ 11 files changed, 214 insertions(+), 853 deletions(-) create mode 100755 build-aux/augeas-gentest.pl delete mode 100644 daemon/test_libvirtd.aug create mode 100644 daemon/test_libvirtd.aug.in rename src/locking/{test_libvirt_sanlock.aug => test_libvirt_sanlock.aug.in} (60%) delete mode 100644 src/lxc/test_libvirtd_lxc.aug create mode 100644 src/lxc/test_libvirtd_lxc.aug.in delete mode 100644 src/qemu/test_libvirtd_qemu.aug create mode 100644 src/qemu/test_libvirtd_qemu.aug.in diff --git a/.gitignore b/.gitignore index 65f679d..50ff3bf 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ /daemon/libvirtd.init /daemon/libvirtd.pod /daemon/libvirtd.service +/daemon/test_libvirtd.aug /docs/apibuild.py.stamp /docs/devhelp/libvirt.devhelp /docs/hvsupport.html.in @@ -101,6 +102,9 @@ /src/libvirt_*probes.h /src/libvirt_lxc /src/locking/qemu-sanlock.conf +/src/locking/test_libvirt_sanlock.aug +/src/lxc/test_libvirtd_lxc.aug +/src/qemu/test_libvirtd_qemu.aug /src/remote/*_client_bodies.h /src/remote/*_protocol.[ch] /src/rpc/virkeepaliveprotocol.[ch] diff --git a/build-aux/augeas-gentest.pl b/build-aux/augeas-gentest.pl new file mode 100755 index 0000000..153f52f --- /dev/null +++ b/build-aux/augeas-gentest.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +die "syntax: $0 CONFIG TEMPLATE AUGTEST\n" unless @ARGV == 3; + +my $config = shift @ARGV; +my $template = shift @ARGV; +my $augtest = shift @ARGV; + +open AUGTEST, ">", $augtest or die "cannot create $augtest: $!"; + +$SIG{__DIE__} = sub { + unlink $augtest; +}; + +open CONFIG, "<", $config or die "cannot read $config: $!"; +open TEMPLATE, "<", $template or die "cannot read $template: $!"; + +my $group = 0; +while (<TEMPLATE>) { + if (/::CONFIG::/) { + my $group = 0; + print AUGTEST " let conf = \""; + while (<CONFIG>) { + if (/^#\w/) { + s/^#//; + s/\"/\\\"/g; + print AUGTEST $_; + $group = /\[\s$/; + } elsif ($group) { + s/\"/\\\"/g; + if (/#\s*\]/) { + $group = 0; + } + if (/^#/) { + s/^#//; + print AUGTEST $_; + } + } + } + print AUGTEST "\"\n"; + } else { + print AUGTEST $_; + } +} + +close TEMPLATE; +close CONFIG; +close AUGTEST or die "cannot save $augtest: $!"; diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 5d4c1a7..187fa93 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -45,7 +45,7 @@ EXTRA_DIST = \ libvirtd.qemu.logrotate.in \ libvirtd.lxc.logrotate.in \ libvirtd.uml.logrotate.in \ - test_libvirtd.aug \ + test_libvirtd.aug.in \ THREADS.txt \ libvirtd.pod.in \ libvirtd.8.in \ @@ -81,6 +81,8 @@ augeas_DATA = libvirtd.aug augeastestsdir = $(datadir)/augeas/lenses/tests augeastests_DATA = test_libvirtd.aug +CLEANFILES += test_libvirtd.aug + libvirtd.8: $(srcdir)/libvirtd.8.in sed \ -e 's![@]sysconfdir[@]!$(sysconfdir)!g' \ @@ -347,7 +349,12 @@ libvirtd.service: libvirtd.service.in $(top_builddir)/config.status mv $@-t $@ -check-local: +check-local: check-augeas + +test_libvirtd.aug: test_libvirtd.aug.in libvirtd.conf + $(AM_V_GEN)$(PERL) $(top_srcdir)/build-aux/augeas-gentest.pl libvirtd.conf $< $@ + +check-augeas: test_libvirtd.aug $(AM_V_GEN)if test -x '$(AUGPARSE)'; then \ '$(AUGPARSE)' -I $(srcdir) $(srcdir)/test_libvirtd.aug; \ fi diff --git a/daemon/test_libvirtd.aug b/daemon/test_libvirtd.aug deleted file mode 100644 index dbe532a..0000000 --- a/daemon/test_libvirtd.aug +++ /dev/null @@ -1,553 +0,0 @@ -module Test_libvirtd = - let conf = "# Master libvirt daemon configuration file -# -# For further information consult http://libvirt.org/format.html - - -################################################################# -# -# Network connectivity controls -# - -# Flag listening for secure TLS connections on the public TCP/IP port. -# NB, must pass the --listen flag to the libvirtd process for this to -# have any effect. -# -# It is necessary to setup a CA and issue server certificates before -# using this capability. -# -# This is enabled by default, uncomment this to disable it -listen_tls = 0 - -# Listen for unencrypted TCP connections on the public TCP/IP port. -# NB, must pass the --listen flag to the libvirtd process for this to -# have any effect. -# -# Using the TCP socket requires SASL authentication by default. Only -# SASL mechanisms which support data encryption are allowed. This is -# DIGEST_MD5 and GSSAPI (Kerberos5) -# -# This is disabled by default, uncomment this to enable it. -listen_tcp = 1 - - - -# Override the port for accepting secure TLS connections -# This can be a port number, or service name -# -tls_port = \"16514\" - -# Override the port for accepting insecure TCP connections -# This can be a port number, or service name -# -tcp_port = \"16509\" - - -# Override the default configuration which binds to all network -# interfaces. This can be a numeric IPv4/6 address, or hostname -# -listen_addr = \"192.168.0.1\" - - -# Flag toggling mDNS advertizement of the libvirt service. -# -# Alternatively can disable for all services on a host by -# stopping the Avahi daemon -# -# This is disabled by default, uncomment this to enable it -mdns_adv = 1 - -# Override the default mDNS advertizement name. This must be -# unique on the immediate broadcast network. -# -# The default is \"Virtualization Host HOSTNAME\", where HOSTNAME -# is subsituted for the short hostname of the machine (without domain) -# -mdns_name = \"Virtualization Host Joe Demo\" - - -################################################################# -# -# UNIX socket access controls -# - -# Set the UNIX domain socket group ownership. This can be used to -# allow a 'trusted' set of users access to management capabilities -# without becoming root. -# -# This is restricted to 'root' by default. -unix_sock_group = \"libvirt\" - -# Set the UNIX socket permissions for the R/O socket. This is used -# for monitoring VM status only -# -# Default allows any user. If setting group ownership may want to -# restrict this to: -unix_sock_ro_perms = \"0777\" - -# Set the UNIX socket permissions for the R/W socket. This is used -# for full management of VMs -# -# Default allows only root. If PolicyKit is enabled on the socket, -# the default will change to allow everyone (eg, 0777) -# -# If not using PolicyKit and setting group ownership for access -# control then you may want to relax this to: -unix_sock_rw_perms = \"0770\" - - - -################################################################# -# -# Authentication. -# -# - none: do not perform auth checks. If you can connect to the -# socket you are allowed. This is suitable if there are -# restrictions on connecting to the socket (eg, UNIX -# socket permissions), or if there is a lower layer in -# the network providing auth (eg, TLS/x509 certificates) -# -# - sasl: use SASL infrastructure. The actual auth scheme is then -# controlled from /etc/sasl2/libvirt.conf. For the TCP -# socket only GSSAPI & DIGEST-MD5 mechanisms will be used. -# For non-TCP or TLS sockets, any scheme is allowed. -# -# - polkit: use PolicyKit to authenticate. This is only suitable -# for use on the UNIX sockets. The default policy will -# require a user to supply their own password to gain -# full read/write access (aka sudo like), while anyone -# is allowed read/only access. -# -# Set an authentication scheme for UNIX read-only sockets -# By default socket permissions allow anyone to connect -# -# To restrict monitoring of domains you may wish to enable -# an authentication mechanism here -auth_unix_ro = \"none\" - -# Set an authentication scheme for UNIX read-write sockets -# By default socket permissions only allow root. If PolicyKit -# support was compiled into libvirt, the default will be to -# use 'polkit' auth. -# -# If the unix_sock_rw_perms are changed you may wish to enable -# an authentication mechanism here -auth_unix_rw = \"none\" - -# Change the authentication scheme for TCP sockets. -# -# If you don't enable SASL, then all TCP traffic is cleartext. -# Don't do this outside of a dev/test scenario. For real world -# use, always enable SASL and use the GSSAPI or DIGEST-MD5 -# mechanism in /etc/sasl2/libvirt.conf -auth_tcp = \"sasl\" - -# Change the authentication scheme for TLS sockets. -# -# TLS sockets already have encryption provided by the TLS -# layer, and limited authentication is done by certificates -# -# It is possible to make use of any SASL authentication -# mechanism as well, by using 'sasl' for this option -auth_tls = \"none\" - - - -################################################################# -# -# TLS x509 certificate configuration -# - - -# Override the default server key file path -# -key_file = \"/etc/pki/libvirt/private/serverkey.pem\" - -# Override the default server certificate file path -# -cert_file = \"/etc/pki/libvirt/servercert.pem\" - -# Override the default CA certificate path -# -ca_file = \"/etc/pki/CA/cacert.pem\" - -# Specify a certificate revocation list. -# -# Defaults to not using a CRL, uncomment to enable it -crl_file = \"/etc/pki/CA/crl.pem\" - - - -################################################################# -# -# Authorization controls -# - - -# Flag to disable verification of client certificates -# -# Client certificate verification is the primary authentication mechanism. -# Any client which does not present a certificate signed by the CA -# will be rejected. -# -# Default is to always verify. Uncommenting this will disable -# verification - make sure an IP whitelist is set -tls_no_verify_certificate = 1 -tls_no_sanity_certificate = 1 - - -# A whitelist of allowed x509 Distinguished Names -# This list may contain wildcards such as -# -# \"C=GB,ST=London,L=London,O=Red Hat,CN=*\" -# -# See the POSIX fnmatch function for the format of the wildcards. -# -# NB If this is an empty list, no client can connect, so comment out -# entirely rather than using empty list to disable these checks -# -# By default, no DN's are checked - tls_allowed_dn_list = [\"DN1\", \"DN2\"] - - -# A whitelist of allowed SASL usernames. The format for usernames -# depends on the SASL authentication mechanism. Kerberos usernames -# look like username@REALM -# -# This list may contain wildcards such as -# -# \"*@EXAMPLE.COM\" -# -# See the POSIX fnmatch function for the format of the wildcards. -# -# NB If this is an empty list, no client can connect, so comment out -# entirely rather than using empty list to disable these checks -# -# By default, no Username's are checked -sasl_allowed_username_list = [ - \"joe@EXAMPLE.COM\", - \"fred@EXAMPLE.COM\" -] - - -################################################################# -# -# Processing controls -# - -# The maximum number of concurrent client connections to allow -# over all sockets combined. -max_clients = 20 - - -# The minimum limit sets the number of workers to start up -# initially. If the number of active clients exceeds this, -# then more threads are spawned, upto max_workers limit. -# Typically you'd want max_workers to equal maximum number -# of clients allowed -min_workers = 5 -max_workers = 20 - -# Total global limit on concurrent RPC calls. Should be -# at least as large as max_workers. Beyond this, RPC requests -# will be read into memory and queued. This directly impact -# memory usage, currently each request requires 256 KB of -# memory. So by default upto 5 MB of memory is used -max_requests = 20 - -# Limit on concurrent requests from a single client -# connection. To avoid one client monopolizing the server -# this should be a small fraction of the global max_requests -# and max_workers parameter -max_client_requests = 5 - -# Logging level: -log_level = 4 - -# Logging outputs: -log_outputs=\"4:stderr\" - -# Logging filters: -log_filters=\"a\" - -# Auditing: -audit_level = 2 -" - - test Libvirtd.lns get conf = - { "#comment" = "Master libvirt daemon configuration file" } - { "#comment" = "" } - { "#comment" = "For further information consult http://libvirt.org/format.html" } - { "#empty" } - { "#empty" } - { "#comment" = "################################################################" } - { "#comment" = "" } - { "#comment" = "Network connectivity controls" } - { "#comment" = "" } - { "#empty" } - { "#comment" = "Flag listening for secure TLS connections on the public TCP/IP port." } - { "#comment" = "NB, must pass the --listen flag to the libvirtd process for this to" } - { "#comment" = "have any effect." } - { "#comment" = "" } - { "#comment" = "It is necessary to setup a CA and issue server certificates before" } - { "#comment" = "using this capability." } - { "#comment" = "" } - { "#comment" = "This is enabled by default, uncomment this to disable it" } - { "listen_tls" = "0" } - { "#empty" } - { "#comment" = "Listen for unencrypted TCP connections on the public TCP/IP port." } - { "#comment" = "NB, must pass the --listen flag to the libvirtd process for this to" } - { "#comment" = "have any effect." } - { "#comment" = "" } - { "#comment" = "Using the TCP socket requires SASL authentication by default. Only" } - { "#comment" = "SASL mechanisms which support data encryption are allowed. This is" } - { "#comment" = "DIGEST_MD5 and GSSAPI (Kerberos5)" } - { "#comment" = "" } - { "#comment" = "This is disabled by default, uncomment this to enable it." } - { "listen_tcp" = "1" } - { "#empty" } - { "#empty" } - { "#empty" } - { "#comment" = "Override the port for accepting secure TLS connections" } - { "#comment" = "This can be a port number, or service name" } - { "#comment" = "" } - { "tls_port" = "16514" } - { "#empty" } - { "#comment" = "Override the port for accepting insecure TCP connections" } - { "#comment" = "This can be a port number, or service name" } - { "#comment" = "" } - { "tcp_port" = "16509" } - { "#empty" } - { "#empty" } - { "#comment" = "Override the default configuration which binds to all network" } - { "#comment" = "interfaces. This can be a numeric IPv4/6 address, or hostname" } - { "#comment" = "" } - { "listen_addr" = "192.168.0.1" } - { "#empty" } - { "#empty" } - { "#comment" = "Flag toggling mDNS advertizement of the libvirt service." } - { "#comment" = "" } - { "#comment" = "Alternatively can disable for all services on a host by" } - { "#comment" = "stopping the Avahi daemon" } - { "#comment" = "" } - { "#comment" = "This is disabled by default, uncomment this to enable it" } - { "mdns_adv" = "1" } - { "#empty" } - { "#comment" = "Override the default mDNS advertizement name. This must be" } - { "#comment" = "unique on the immediate broadcast network." } - { "#comment" = "" } - { "#comment" = "The default is \"Virtualization Host HOSTNAME\", where HOSTNAME" } - { "#comment" = "is subsituted for the short hostname of the machine (without domain)" } - { "#comment" = "" } - { "mdns_name" = "Virtualization Host Joe Demo" } - { "#empty" } - { "#empty" } - { "#comment" = "################################################################" } - { "#comment" = "" } - { "#comment" = "UNIX socket access controls" } - { "#comment" = "" } - { "#empty" } - { "#comment" = "Set the UNIX domain socket group ownership. This can be used to" } - { "#comment" = "allow a 'trusted' set of users access to management capabilities" } - { "#comment" = "without becoming root." } - { "#comment" = "" } - { "#comment" = "This is restricted to 'root' by default." } - { "unix_sock_group" = "libvirt" } - { "#empty" } - { "#comment" = "Set the UNIX socket permissions for the R/O socket. This is used" } - { "#comment" = "for monitoring VM status only" } - { "#comment" = "" } - { "#comment" = "Default allows any user. If setting group ownership may want to" } - { "#comment" = "restrict this to:" } - { "unix_sock_ro_perms" = "0777" } - { "#empty" } - { "#comment" = "Set the UNIX socket permissions for the R/W socket. This is used" } - { "#comment" = "for full management of VMs" } - { "#comment" = "" } - { "#comment" = "Default allows only root. If PolicyKit is enabled on the socket," } - { "#comment" = "the default will change to allow everyone (eg, 0777)" } - { "#comment" = "" } - { "#comment" = "If not using PolicyKit and setting group ownership for access" } - { "#comment" = "control then you may want to relax this to:" } - { "unix_sock_rw_perms" = "0770" } - { "#empty" } - { "#empty" } - { "#empty" } - { "#comment" = "################################################################" } - { "#comment" = "" } - { "#comment" = "Authentication." } - { "#comment" = "" } - { "#comment" = "- none: do not perform auth checks. If you can connect to the" } - { "#comment" = "socket you are allowed. This is suitable if there are" } - { "#comment" = "restrictions on connecting to the socket (eg, UNIX" } - { "#comment" = "socket permissions), or if there is a lower layer in" } - { "#comment" = "the network providing auth (eg, TLS/x509 certificates)" } - { "#comment" = "" } - { "#comment" = "- sasl: use SASL infrastructure. The actual auth scheme is then" } - { "#comment" = "controlled from /etc/sasl2/libvirt.conf. For the TCP" } - { "#comment" = "socket only GSSAPI & DIGEST-MD5 mechanisms will be used." } - { "#comment" = "For non-TCP or TLS sockets, any scheme is allowed." } - { "#comment" = "" } - { "#comment" = "- polkit: use PolicyKit to authenticate. This is only suitable" } - { "#comment" = "for use on the UNIX sockets. The default policy will" } - { "#comment" = "require a user to supply their own password to gain" } - { "#comment" = "full read/write access (aka sudo like), while anyone" } - { "#comment" = "is allowed read/only access." } - { "#comment" = "" } - { "#comment" = "Set an authentication scheme for UNIX read-only sockets" } - { "#comment" = "By default socket permissions allow anyone to connect" } - { "#comment" = "" } - { "#comment" = "To restrict monitoring of domains you may wish to enable" } - { "#comment" = "an authentication mechanism here" } - { "auth_unix_ro" = "none" } - { "#empty" } - { "#comment" = "Set an authentication scheme for UNIX read-write sockets" } - { "#comment" = "By default socket permissions only allow root. If PolicyKit" } - { "#comment" = "support was compiled into libvirt, the default will be to" } - { "#comment" = "use 'polkit' auth." } - { "#comment" = "" } - { "#comment" = "If the unix_sock_rw_perms are changed you may wish to enable" } - { "#comment" = "an authentication mechanism here" } - { "auth_unix_rw" = "none" } - { "#empty" } - { "#comment" = "Change the authentication scheme for TCP sockets." } - { "#comment" = "" } - { "#comment" = "If you don't enable SASL, then all TCP traffic is cleartext." } - { "#comment" = "Don't do this outside of a dev/test scenario. For real world" } - { "#comment" = "use, always enable SASL and use the GSSAPI or DIGEST-MD5" } - { "#comment" = "mechanism in /etc/sasl2/libvirt.conf" } - { "auth_tcp" = "sasl" } - { "#empty" } - { "#comment" = "Change the authentication scheme for TLS sockets." } - { "#comment" = "" } - { "#comment" = "TLS sockets already have encryption provided by the TLS" } - { "#comment" = "layer, and limited authentication is done by certificates" } - { "#comment" = "" } - { "#comment" = "It is possible to make use of any SASL authentication" } - { "#comment" = "mechanism as well, by using 'sasl' for this option" } - { "auth_tls" = "none" } - { "#empty" } - { "#empty" } - { "#empty" } - { "#comment" = "################################################################" } - { "#comment" = "" } - { "#comment" = "TLS x509 certificate configuration" } - { "#comment" = "" } - { "#empty" } - { "#empty" } - { "#comment" = "Override the default server key file path" } - { "#comment" = "" } - { "key_file" = "/etc/pki/libvirt/private/serverkey.pem" } - { "#empty" } - { "#comment" = "Override the default server certificate file path" } - { "#comment" = "" } - { "cert_file" = "/etc/pki/libvirt/servercert.pem" } - { "#empty" } - { "#comment" = "Override the default CA certificate path" } - { "#comment" = "" } - { "ca_file" = "/etc/pki/CA/cacert.pem" } - { "#empty" } - { "#comment" = "Specify a certificate revocation list." } - { "#comment" = "" } - { "#comment" = "Defaults to not using a CRL, uncomment to enable it" } - { "crl_file" = "/etc/pki/CA/crl.pem" } - { "#empty" } - { "#empty" } - { "#empty" } - { "#comment" = "################################################################" } - { "#comment" = "" } - { "#comment" = "Authorization controls" } - { "#comment" = "" } - { "#empty" } - { "#empty" } - { "#comment" = "Flag to disable verification of client certificates" } - { "#comment" = "" } - { "#comment" = "Client certificate verification is the primary authentication mechanism." } - { "#comment" = "Any client which does not present a certificate signed by the CA" } - { "#comment" = "will be rejected." } - { "#comment" = "" } - { "#comment" = "Default is to always verify. Uncommenting this will disable" } - { "#comment" = "verification - make sure an IP whitelist is set" } - { "tls_no_verify_certificate" = "1" } - { "tls_no_sanity_certificate" = "1" } - { "#empty" } - { "#empty" } - { "#comment" = "A whitelist of allowed x509 Distinguished Names" } - { "#comment" = "This list may contain wildcards such as" } - { "#comment" = "" } - { "#comment" = "\"C=GB,ST=London,L=London,O=Red Hat,CN=*\"" } - { "#comment" = "" } - { "#comment" = "See the POSIX fnmatch function for the format of the wildcards." } - { "#comment" = "" } - { "#comment" = "NB If this is an empty list, no client can connect, so comment out" } - { "#comment" = "entirely rather than using empty list to disable these checks" } - { "#comment" = "" } - { "#comment" = "By default, no DN's are checked" } - { "tls_allowed_dn_list" - { "1" = "DN1"} - { "2" = "DN2"} - } - { "#empty" } - { "#empty" } - { "#comment" = "A whitelist of allowed SASL usernames. The format for usernames" } - { "#comment" = "depends on the SASL authentication mechanism. Kerberos usernames" } - { "#comment" = "look like username@REALM" } - { "#comment" = "" } - { "#comment" = "This list may contain wildcards such as" } - { "#comment" = "" } - { "#comment" = "\"*@EXAMPLE.COM\"" } - { "#comment" = "" } - { "#comment" = "See the POSIX fnmatch function for the format of the wildcards." } - { "#comment" = "" } - { "#comment" = "NB If this is an empty list, no client can connect, so comment out" } - { "#comment" = "entirely rather than using empty list to disable these checks" } - { "#comment" = "" } - { "#comment" = "By default, no Username's are checked" } - { "sasl_allowed_username_list" - { "1" = "joe@EXAMPLE.COM" } - { "2" = "fred@EXAMPLE.COM" } - } - { "#empty" } - { "#empty" } - { "#comment" = "################################################################"} - { "#comment" = ""} - { "#comment" = "Processing controls"} - { "#comment" = ""} - { "#empty" } - { "#comment" = "The maximum number of concurrent client connections to allow"} - { "#comment" = "over all sockets combined."} - { "max_clients" = "20" } - { "#empty" } - { "#empty" } - { "#comment" = "The minimum limit sets the number of workers to start up"} - { "#comment" = "initially. If the number of active clients exceeds this,"} - { "#comment" = "then more threads are spawned, upto max_workers limit."} - { "#comment" = "Typically you'd want max_workers to equal maximum number"} - { "#comment" = "of clients allowed"} - { "min_workers" = "5" } - { "max_workers" = "20" } - { "#empty" } - { "#comment" = "Total global limit on concurrent RPC calls. Should be" } - { "#comment" = "at least as large as max_workers. Beyond this, RPC requests" } - { "#comment" = "will be read into memory and queued. This directly impact" } - { "#comment" = "memory usage, currently each request requires 256 KB of" } - { "#comment" = "memory. So by default upto 5 MB of memory is used" } - { "max_requests" = "20" } - { "#empty" } - { "#comment" = "Limit on concurrent requests from a single client" } - { "#comment" = "connection. To avoid one client monopolizing the server" } - { "#comment" = "this should be a small fraction of the global max_requests" } - { "#comment" = "and max_workers parameter" } - { "max_client_requests" = "5" } - { "#empty" } - { "#comment" = "Logging level:" } - { "log_level" = "4" } - { "#empty" } - { "#comment" = "Logging outputs:" } - { "log_outputs" = "4:stderr" } - { "#empty" } - { "#comment" = "Logging filters:" } - { "log_filters" = "a" } - { "#empty" } - { "#comment" = "Auditing:" } - { "audit_level" = "2" } diff --git a/daemon/test_libvirtd.aug.in b/daemon/test_libvirtd.aug.in new file mode 100644 index 0000000..18fc0a2 --- /dev/null +++ b/daemon/test_libvirtd.aug.in @@ -0,0 +1,49 @@ +module Test_libvirtd = + ::CONFIG:: + + test Libvirtd.lns get conf = + { "listen_tls" = "0" } + { "listen_tcp" = "1" } + { "tls_port" = "16514" } + { "tcp_port" = "16509" } + { "listen_addr" = "192.168.0.1" } + { "mdns_adv" = "1" } + { "mdns_name" = "Virtualization Host Joe Demo" } + { "unix_sock_group" = "libvirt" } + { "unix_sock_ro_perms" = "0777" } + { "unix_sock_rw_perms" = "0770" } + { "unix_sock_dir" = "/var/run/libvirt" } + { "auth_unix_ro" = "none" } + { "auth_unix_rw" = "none" } + { "auth_tcp" = "sasl" } + { "auth_tls" = "none" } + { "key_file" = "/etc/pki/libvirt/private/serverkey.pem" } + { "cert_file" = "/etc/pki/libvirt/servercert.pem" } + { "ca_file" = "/etc/pki/CA/cacert.pem" } + { "crl_file" = "/etc/pki/CA/crl.pem" } + { "tls_no_sanity_certificate" = "1" } + { "tls_no_verify_certificate" = "1" } + { "tls_allowed_dn_list" + { "1" = "DN1"} + { "2" = "DN2"} + } + { "sasl_allowed_username_list" + { "1" = "joe@EXAMPLE.COM" } + { "2" = "fred@EXAMPLE.COM" } + } + { "max_clients" = "20" } + { "min_workers" = "5" } + { "max_workers" = "20" } + { "prio_workers" = "5" } + { "max_requests" = "20" } + { "max_client_requests" = "5" } + { "log_level" = "3" } + { "log_filters" = "3:remote 4:event" } + { "log_outputs" = "3:syslog:libvirtd" } + { "log_buffer_size" = "64" } + { "audit_level" = "2" } + { "audit_logging" = "1" } + { "host_uuid" = "00000000-0000-0000-0000-000000000000" } + { "keepalive_interval" = "5" } + { "keepalive_count" = "5" } + { "keepalive_required" = "1" } diff --git a/src/Makefile.am b/src/Makefile.am index bdb0ef4..4f76bae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -777,10 +777,11 @@ conf_DATA += qemu/qemu.conf augeas_DATA += qemu/libvirtd_qemu.aug augeastest_DATA += qemu/test_libvirtd_qemu.aug +CLEANFILES += qemu/test_libvirtd_qemu.aug endif EXTRA_DIST += qemu/qemu.conf qemu/libvirtd_qemu.aug \ - qemu/test_libvirtd_qemu.aug qemu/THREADS.txt + qemu/test_libvirtd_qemu.aug.in qemu/THREADS.txt if WITH_LXC @@ -815,9 +816,10 @@ conf_DATA += lxc/lxc.conf augeas_DATA += lxc/libvirtd_lxc.aug augeastest_DATA += lxc/test_libvirtd_lxc.aug +CLEANFILES += lxc/test_libvirtd_lxc.aug endif -EXTRA_DIST += lxc/lxc.conf lxc/libvirtd_lxc.aug lxc/test_libvirtd_lxc.aug +EXTRA_DIST += lxc/lxc.conf lxc/libvirtd_lxc.aug lxc/test_libvirtd_lxc.aug.in if WITH_UML if WITH_DRIVER_MODULES @@ -1099,22 +1101,44 @@ EXTRA_DIST += \ $(VMWARE_DRIVER_SOURCES) \ $(XENXS_SOURCES) -check-local: augeas-check +check-local: check-augeas + +.PHONY: check-augeas check-augeas-qemu check-augeas-lxc check-augeas-sanlock + +check-augeas: check-augeas-qemu check-augeas-lxc check-augeas-sanlock + +AUG_GENTEST = $(top_srcdir)/build-aux/augeas-gentest.pl -.PHONY: augeas-check -augeas-check: if WITH_QEMU +qemu/test_libvirtd_qemu.aug: qemu/test_libvirtd_qemu.aug.in qemu/qemu.conf $(AUG_GENTEST) + $(AM_V_GEN)$(AUG_GENTEST) qemu/qemu.conf $< $@ + +check-augeas-qemu: qemu/test_libvirtd_qemu.aug $(AM_V_GEN)if test -x '$(AUGPARSE)'; then \ '$(AUGPARSE)' -I $(srcdir)/qemu \ $(srcdir)/qemu/test_libvirtd_qemu.aug; \ fi +else +check-augeas-qemu: endif + if WITH_LXC +lxc/test_libvirtd_lxc.aug: lxc/test_libvirtd_lxc.aug.in lxc/lxc.conf $(AUG_GENTEST) + $(AM_V_GEN)$(AUG_GENTEST) lxc/lxc.conf $< $@ + +check-augeas-lxc: lxc/test_libvirtd_lxc.aug $(AM_V_GEN)if test -x '$(AUGPARSE)'; then \ '$(AUGPARSE)' -I $(srcdir)/lxc \ $(srcdir)/lxc/test_libvirtd_lxc.aug; \ fi +else +check-augeas-lxc: endif + +locking/test_libvirt_sanlock.aug: locking/test_libvirt_sanlock.aug.in locking/qemu-sanlock.conf $(AUG_GENTEST) + $(AM_V_GEN)$(AUG_GENTEST) locking/qemu-sanlock.conf $< $@ + +check-augeas-sanlock: locking/test_libvirt_sanlock.aug $(AM_V_GEN)if test -x '$(AUGPARSE)'; then \ '$(AUGPARSE)' -I $(srcdir)/locking \ $(srcdir)/locking/test_libvirt_sanlock.aug; \ @@ -1315,6 +1339,7 @@ sanlock_la_LIBADD = -lsanlock_client \ augeas_DATA += locking/libvirt_sanlock.aug augeastest_DATA += locking/test_libvirt_sanlock.aug +CLEANFILES += locking/test_libvirt_sanlock.aug.in $(builddir)/locking/%-sanlock.conf: $(srcdir)/locking/sanlock.conf $(AM_V_GEN)$(MKDIR_P) locking ; \ @@ -1330,7 +1355,7 @@ EXTRA_DIST += $(LOCK_DRIVER_SANLOCK_SOURCES) endif EXTRA_DIST += locking/sanlock.conf \ locking/libvirt_sanlock.aug \ - locking/test_libvirt_sanlock.aug + locking/test_libvirt_sanlock.aug.in noinst_LTLIBRARIES += \ libvirt-net-rpc.la \ diff --git a/src/locking/test_libvirt_sanlock.aug b/src/locking/test_libvirt_sanlock.aug.in similarity index 60% rename from src/locking/test_libvirt_sanlock.aug rename to src/locking/test_libvirt_sanlock.aug.in index 90ab59f..1f05558 100644 --- a/src/locking/test_libvirt_sanlock.aug +++ b/src/locking/test_libvirt_sanlock.aug.in @@ -1,11 +1,5 @@ module Test_libvirt_sanlock = - - let conf = "auto_disk_leases = 1 -disk_lease_dir = \"/var/lib/libvirt/sanlock\" -host_id = 1 -require_lease_for_disks = 1 -ignore_readonly_and_shared_disks = 1 -" + ::CONFIG:: test Libvirt_sanlock.lns get conf = { "auto_disk_leases" = "1" } diff --git a/src/lxc/test_libvirtd_lxc.aug b/src/lxc/test_libvirtd_lxc.aug deleted file mode 100644 index f8544a0..0000000 --- a/src/lxc/test_libvirtd_lxc.aug +++ /dev/null @@ -1,33 +0,0 @@ -module Test_libvirtd_lxc = - - let conf = "# Master configuration file for the LXC driver. -# All settings described here are optional - if omitted, sensible -# defaults are used. - -# By default, log messages generated by the lxc controller go to the -# container logfile. It is also possible to accumulate log messages -# from all lxc controllers along with libvirtd's log outputs. In this -# case, the lxc controller will honor either LIBVIRT_LOG_OUTPUTS or -# log_outputs from libvirtd.conf. -# -# This is disabled by default, uncomment below to enable it. -# -log_with_libvirtd = 1 -security_driver = \"selinux\" -" - - test Libvirtd_lxc.lns get conf = -{ "#comment" = "Master configuration file for the LXC driver." } -{ "#comment" = "All settings described here are optional - if omitted, sensible" } -{ "#comment" = "defaults are used." } -{ "#empty" } -{ "#comment" = "By default, log messages generated by the lxc controller go to the" } -{ "#comment" = "container logfile. It is also possible to accumulate log messages" } -{ "#comment" = "from all lxc controllers along with libvirtd's log outputs. In this" } -{ "#comment" = "case, the lxc controller will honor either LIBVIRT_LOG_OUTPUTS or" } -{ "#comment" = "log_outputs from libvirtd.conf." } -{ "#comment" = "" } -{ "#comment" = "This is disabled by default, uncomment below to enable it." } -{ "#comment" = "" } -{ "log_with_libvirtd" = "1" } -{ "security_driver" = "selinux" } diff --git a/src/lxc/test_libvirtd_lxc.aug.in b/src/lxc/test_libvirtd_lxc.aug.in new file mode 100644 index 0000000..f2125e4 --- /dev/null +++ b/src/lxc/test_libvirtd_lxc.aug.in @@ -0,0 +1,9 @@ +module Test_libvirtd_lxc = + ::CONFIG:: + + test Libvirtd_lxc.lns get conf = +{ "log_with_libvirtd" = "1" } +{ "security_driver" = "selinux" } +{ "security_default_confined" = "1" } +{ "security_require_confined" = "1" } + diff --git a/src/qemu/test_libvirtd_qemu.aug b/src/qemu/test_libvirtd_qemu.aug deleted file mode 100644 index f841936..0000000 --- a/src/qemu/test_libvirtd_qemu.aug +++ /dev/null @@ -1,252 +0,0 @@ -module Test_libvirtd_qemu = - - let conf = "# Master configuration file for the QEMU driver. -# All settings described here are optional - if omitted, sensible -# defaults are used. - -# VNC is configured to listen on 127.0.0.1 by default. -# To make it listen on all public interfaces, uncomment -# this next option. -# -# NB, strong recommendation to enable TLS + x509 certificate -# verification when allowing public access -# -vnc_listen = \"0.0.0.0\" - - -# Enable use of TLS encryption on the VNC server. This requires -# a VNC client which supports the VeNCrypt protocol extension. -# Examples include vinagre, virt-viewer, virt-manager and vencrypt -# itself. UltraVNC, RealVNC, TightVNC do not support this -# -# It is necessary to setup CA and issue a server certificate -# before enabling this. -# -vnc_tls = 1 - - -# Use of TLS requires that x509 certificates be issued. The -# default it to keep them in /etc/pki/libvirt-vnc. This directory -# must contain -# -# ca-cert.pem - the CA master certificate -# server-cert.pem - the server certificate signed with ca-cert.pem -# server-key.pem - the server private key -# -# This option allows the certificate directory to be changed -# -vnc_tls_x509_cert_dir = \"/etc/pki/libvirt-vnc\" - - -# The default TLS configuration only uses certificates for the server -# allowing the client to verify the server's identity and establish -# and encrypted channel. -# -# It is possible to use x509 certificates for authentication too, by -# issuing a x509 certificate to every client who needs to connect. -# -# Enabling this option will reject any client who does not have a -# certificate signed by the CA in /etc/pki/libvirt-vnc/ca-cert.pem -# -vnc_tls_x509_verify = 1 - - -# The default VNC password. Only 8 letters are significant for -# VNC passwords. This parameter is only used if the per-domain -# XML config does not already provide a password. To allow -# access without passwords, leave this commented out. An empty -# string will still enable passwords, but be rejected by QEMU -# effectively preventing any use of VNC. Obviously change this -# example here before you set this -# -vnc_password = \"XYZ12345\" - - -# Enable use of SASL encryption on the VNC server. This requires -# a VNC client which supports the SASL protocol extension. -# Examples include vinagre, virt-viewer and virt-manager -# itself. UltraVNC, RealVNC, TightVNC do not support this -# -# It is necessary to configure /etc/sasl2/qemu.conf to choose -# the desired SASL plugin (eg, GSSPI for Kerberos) -# -vnc_sasl = 1 - - -# The default SASL configuration file is located in /etc/sasl2/ -# When running libvirtd unprivileged, it may be desirable to -# override the configs in this location. Set this parameter to -# point to the directory, and create a qemu.conf in that location -# -vnc_sasl_dir = \"/some/directory/sasl2\" - -security_driver = \"selinux\" - -user = \"root\" - -group = \"root\" - -dynamic_ownership = 1 - -cgroup_controllers = [ \"cpu\", \"devices\" ] - -cgroup_device_acl = [ \"/dev/null\", \"/dev/full\", \"/dev/zero\" ] - -save_image_format = \"gzip\" - -dump_image_format = \"gzip\" - -auto_dump_path = \"/var/lib/libvirt/qemu/dump\" - -hugetlbfs_mount = \"/dev/hugepages\" - -set_process_name = 1 - -relaxed_acs_check = 1 - -vnc_allow_host_audio = 1 - -clear_emulator_capabilities = 0 - -allow_disk_format_probing = 1 - -vnc_auto_unix_socket = 1 - -max_processes = 12345 - -max_files = 67890 - -lock_manager = \"fcntl\" - -keepalive_interval = 1 -keepalive_count = 42 -" - - test Libvirtd_qemu.lns get conf = -{ "#comment" = "Master configuration file for the QEMU driver." } -{ "#comment" = "All settings described here are optional - if omitted, sensible" } -{ "#comment" = "defaults are used." } -{ "#empty" } -{ "#comment" = "VNC is configured to listen on 127.0.0.1 by default." } -{ "#comment" = "To make it listen on all public interfaces, uncomment" } -{ "#comment" = "this next option." } -{ "#comment" = "" } -{ "#comment" = "NB, strong recommendation to enable TLS + x509 certificate" } -{ "#comment" = "verification when allowing public access" } -{ "#comment" = "" } -{ "vnc_listen" = "0.0.0.0" } -{ "#empty" } -{ "#empty" } -{ "#comment" = "Enable use of TLS encryption on the VNC server. This requires" } -{ "#comment" = "a VNC client which supports the VeNCrypt protocol extension." } -{ "#comment" = "Examples include vinagre, virt-viewer, virt-manager and vencrypt" } -{ "#comment" = "itself. UltraVNC, RealVNC, TightVNC do not support this" } -{ "#comment" = "" } -{ "#comment" = "It is necessary to setup CA and issue a server certificate" } -{ "#comment" = "before enabling this." } -{ "#comment" = "" } -{ "vnc_tls" = "1" } -{ "#empty" } -{ "#empty" } -{ "#comment" = "Use of TLS requires that x509 certificates be issued. The" } -{ "#comment" = "default it to keep them in /etc/pki/libvirt-vnc. This directory" } -{ "#comment" = "must contain" } -{ "#comment" = "" } -{ "#comment" = "ca-cert.pem - the CA master certificate" } -{ "#comment" = "server-cert.pem - the server certificate signed with ca-cert.pem" } -{ "#comment" = "server-key.pem - the server private key" } -{ "#comment" = "" } -{ "#comment" = "This option allows the certificate directory to be changed" } -{ "#comment" = "" } -{ "vnc_tls_x509_cert_dir" = "/etc/pki/libvirt-vnc" } -{ "#empty" } -{ "#empty" } -{ "#comment" = "The default TLS configuration only uses certificates for the server" } -{ "#comment" = "allowing the client to verify the server's identity and establish" } -{ "#comment" = "and encrypted channel." } -{ "#comment" = "" } -{ "#comment" = "It is possible to use x509 certificates for authentication too, by" } -{ "#comment" = "issuing a x509 certificate to every client who needs to connect." } -{ "#comment" = "" } -{ "#comment" = "Enabling this option will reject any client who does not have a" } -{ "#comment" = "certificate signed by the CA in /etc/pki/libvirt-vnc/ca-cert.pem" } -{ "#comment" = "" } -{ "vnc_tls_x509_verify" = "1" } -{ "#empty" } -{ "#empty" } -{ "#comment" = "The default VNC password. Only 8 letters are significant for" } -{ "#comment" = "VNC passwords. This parameter is only used if the per-domain" } -{ "#comment" = "XML config does not already provide a password. To allow" } -{ "#comment" = "access without passwords, leave this commented out. An empty" } -{ "#comment" = "string will still enable passwords, but be rejected by QEMU" } -{ "#comment" = "effectively preventing any use of VNC. Obviously change this" } -{ "#comment" = "example here before you set this" } -{ "#comment" = "" } -{ "vnc_password" = "XYZ12345" } -{ "#empty" } -{ "#empty" } -{ "#comment" = "Enable use of SASL encryption on the VNC server. This requires" } -{ "#comment" = "a VNC client which supports the SASL protocol extension." } -{ "#comment" = "Examples include vinagre, virt-viewer and virt-manager" } -{ "#comment" = "itself. UltraVNC, RealVNC, TightVNC do not support this" } -{ "#comment" = "" } -{ "#comment" = "It is necessary to configure /etc/sasl2/qemu.conf to choose" } -{ "#comment" = "the desired SASL plugin (eg, GSSPI for Kerberos)" } -{ "#comment" = "" } -{ "vnc_sasl" = "1" } -{ "#empty" } -{ "#empty" } -{ "#comment" = "The default SASL configuration file is located in /etc/sasl2/" } -{ "#comment" = "When running libvirtd unprivileged, it may be desirable to" } -{ "#comment" = "override the configs in this location. Set this parameter to" } -{ "#comment" = "point to the directory, and create a qemu.conf in that location" } -{ "#comment" = "" } -{ "vnc_sasl_dir" = "/some/directory/sasl2" } -{ "#empty" } -{ "security_driver" = "selinux" } -{ "#empty" } -{ "user" = "root" } -{ "#empty" } -{ "group" = "root" } -{ "#empty" } -{ "dynamic_ownership" = "1" } -{ "#empty" } -{ "cgroup_controllers" - { "1" = "cpu" } - { "2" = "devices" } -} -{ "#empty" } -{ "cgroup_device_acl" - { "1" = "/dev/null" } - { "2" = "/dev/full" } - { "3" = "/dev/zero" } -} -{ "#empty" } -{ "save_image_format" = "gzip" } -{ "#empty" } -{ "dump_image_format" = "gzip" } -{ "#empty" } -{ "auto_dump_path" = "/var/lib/libvirt/qemu/dump" } -{ "#empty" } -{ "hugetlbfs_mount" = "/dev/hugepages" } -{ "#empty" } -{ "set_process_name" = "1" } -{ "#empty" } -{ "relaxed_acs_check" = "1" } -{ "#empty" } -{ "vnc_allow_host_audio" = "1" } -{ "#empty" } -{ "clear_emulator_capabilities" = "0" } -{ "#empty" } -{ "allow_disk_format_probing" = "1" } -{ "#empty" } -{ "vnc_auto_unix_socket" = "1" } -{ "#empty" } -{ "max_processes" = "12345" } -{ "#empty" } -{ "max_files" = "67890" } -{ "#empty" } -{ "lock_manager" = "fcntl" } -{ "#empty" } -{ "keepalive_interval" = "1" } -{ "keepalive_count" = "42" } diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in new file mode 100644 index 0000000..0136bdf --- /dev/null +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -0,0 +1,60 @@ +module Test_libvirtd_qemu = + ::CONFIG:: + + test Libvirtd_qemu.lns get conf = +{ "vnc_listen" = "0.0.0.0" } +{ "vnc_auto_unix_socket" = "1" } +{ "vnc_tls" = "1" } +{ "vnc_tls_x509_cert_dir" = "/etc/pki/libvirt-vnc" } +{ "vnc_tls_x509_verify" = "1" } +{ "vnc_password" = "XYZ12345" } +{ "vnc_sasl" = "1" } +{ "vnc_sasl_dir" = "/some/directory/sasl2" } +{ "spice_listen" = "0.0.0.0" } +{ "spice_tls" = "1" } +{ "spice_tls_x509_cert_dir" = "/etc/pki/libvirt-spice" } +{ "spice_password" = "XYZ12345" } +{ "security_driver" = "selinux" } +{ "security_default_confined" = "1" } +{ "security_require_confined" = "1" } +{ "user" = "root" } +{ "group" = "root" } +{ "dynamic_ownership" = "1" } +{ "cgroup_controllers" + { "1" = "cpu" } + { "2" = "devices" } + { "3" = "memory" } + { "4" = "blkio" } + { "5" = "cpuset" } + { "6" = "cpuacct" } +} +{ "cgroup_device_acl" + { "1" = "/dev/null" } + { "2" = "/dev/full" } + { "3" = "/dev/zero" } + { "4" = "/dev/random" } + { "5" = "/dev/urandom" } + { "6" = "/dev/ptmx" } + { "7" = "/dev/kvm" } + { "8" = "/dev/kqemu" } + { "9" = "/dev/rtc" } + { "10" = "/dev/hpet" } +} +{ "save_image_format" = "raw" } +{ "dump_image_format" = "raw" } +{ "auto_dump_path" = "/var/lib/libvirt/qemu/dump" } + { "auto_dump_bypass_cache" = "0" } + { "auto_start_bypass_cache" = "0" } +{ "hugetlbfs_mount" = "/dev/hugepages" } + { "mac_filter" = "1" } +{ "relaxed_acs_check" = "1" } +{ "vnc_allow_host_audio" = "0" } +{ "clear_emulator_capabilities" = "1" } +{ "allow_disk_format_probing" = "1" } +{ "set_process_name" = "1" } +{ "max_processes" = "0" } +{ "max_files" = "0" } +{ "lock_manager" = "sanlock" } +{ "max_queued" = "0" } +{ "keepalive_interval" = "5" } +{ "keepalive_count" = "5" } -- 1.7.10.1

On 05/25/2012 06:36 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
When adding new config file parameters, the corresponding additions to the augeas lens' are constantly forgotten. Also there are augeas test cases, these don't catch the error, since they too are never updated.
To address this, the augeas test cases need to be auto-generated from the example config files.
* build-aux/augeas-gentest.pl: Helper to generate an augeas test file, substituting in elements from the example config files * src/Makefile.am, daemon/Makefile.am: Switch to auto-generated augeas test cases * daemon/test_libvirtd.aug, daemon/test_libvirtd.aug.in, src/locking/test_libvirt_sanlock.aug, src/locking/test_libvirt_sanlock.aug.in, src/lxc/test_libvirtd_lxc.aug, src/lxc/test_libvirtd_lxc.aug.in, src/qemu/test_libvirtd_qemu.aug, src/qemu/test_libvirtd_qemu.aug.in: Remove example config file data, replacing with a ::CONFIG:: placeholder
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> ---
+++ b/build-aux/augeas-gentest.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl +
Missing a copyright header. Nice! ACK, once you fix that, and silence these syntax checks: TAB_in_indentation daemon/test_libvirtd.aug.in:15: { "unix_sock_dir" = "/var/run/libvirt" } maint.mk: indent with space, not TAB, in C, sh, html, py, syms and RNG schemas make: *** [sc_TAB_in_indentation] Error 1 prohibit_empty_lines_at_EOF src/lxc/test_libvirtd_lxc.aug.in maint.mk: empty line(s) or no newline at EOF make: *** [sc_prohibit_empty_lines_at_EOF] Error 1 Also, if you rearrange qemu.conf per my comments in 3/4, you might have to adjust the test file to match here. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake