[libvirt PATCH 00/26] meson: Various fixes and improvements

Test pipeline: https://gitlab.com/abologna/libvirt/-/pipelines/312508056 Andrea Bolognani (26): spec: Be explicit about more features meson: Whitespace tweaks meson: Don't use 'required: true' meson: Drop curl workaround meson: Drop netinet workaround meson: Use get_pkgconfig_variable('cflags') meson: Use built-in pcap detection meson: Make libm a required dependency meson: Drop numactl_version meson: Fix vstorage detection meson: Fix sanlock detection meson: Rewrite polkit check meson: Tweak XDR check meson: Fix disabling netcf meson: Rewrite firewalld check meson: Fix firewalld check meson: Rewrite libacl check meson: Use dependency() when possible meson: Rewrite apparmor_profiles check meson: Turn apparmor_profiles into a feature meson: Switch to autodetection for apparmor_profiles meson: Switch to autodetection for driver_remote meson: Switch to autodetection for driver_test meson: Style tweaks meson: Reorganize summary meson: Don't include warning flags in summary libvirt.spec.in | 3 + meson.build | 301 +++++++++++++++++++------------------ meson_options.txt | 6 +- mingw-libvirt.spec.in | 2 + src/locking/meson.build | 4 +- src/qemu/qemu_namespace.c | 2 +- src/util/virfile.c | 8 +- src/util/virnetdevbridge.c | 18 --- 8 files changed, 166 insertions(+), 178 deletions(-) -- 2.31.1

We want to be explicit about which features are enabled in our RPM build instead of relying on default values. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- libvirt.spec.in | 3 +++ mingw-libvirt.spec.in | 2 ++ 2 files changed, 5 insertions(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index 7920599498..cc04efe081 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1098,6 +1098,8 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec) -Dsasl=enabled \ -Dpolkit=enabled \ -Ddriver_libvirtd=enabled \ + -Ddriver_remote=enabled \ + -Ddriver_test=enabled \ %{?arg_esx} \ %{?arg_hyperv} \ %{?arg_vmware} \ @@ -1126,6 +1128,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec) -Dselinux=enabled \ %{?arg_selinux_mount} \ -Dapparmor=disabled \ + -Dapparmor_profiles=false \ -Dsecdriver_apparmor=disabled \ -Dudev=enabled \ -Dyajl=enabled \ diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in index 4674d7887a..87223e205c 100644 --- a/mingw-libvirt.spec.in +++ b/mingw-libvirt.spec.in @@ -103,10 +103,12 @@ exit 1 %mingw_meson \ --auto-features=enabled \ -Ddriver_remote=enabled \ + -Ddriver_test=enabled \ -Ddriver_esx=enabled \ -Dcurl=enabled \ -Ddocs=enabled \ -Dapparmor=disabled \ + -Dapparmor_profiles=false \ -Dattr=disabled \ -Daudit=disabled \ -Dbash_completion=disabled \ -- 2.31.1

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 24 ++++++++++++------------ src/locking/meson.build | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 4f23f9104e..4d76e1f651 100644 --- a/meson.build +++ b/meson.build @@ -420,7 +420,7 @@ if get_option('warning_level') == '2' if supported_cc_flags.contains('-Wlogical-op') # Broken in 6.0 and later # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602 - w_logical_op_args = ['-O2', '-Wlogical-op', '-Werror'] + w_logical_op_args = [ '-O2', '-Wlogical-op', '-Werror' ] w_logical_op_code = ''' #define TEST1 1 #define TEST2 TEST1 @@ -436,7 +436,7 @@ if get_option('warning_level') == '2' endif # Check whether clang gives bogus warning for -Wdouble-promotion. - w_double_promotion_args = ['-O2', '-Wdouble-promotion', '-Werror'] + w_double_promotion_args = [ '-O2', '-Wdouble-promotion', '-Werror' ] w_double_promotion_code = ''' #include <math.h> @@ -446,12 +446,12 @@ if get_option('warning_level') == '2' } ''' if cc.compiles(w_double_promotion_code, args: w_double_promotion_args, name: '-Wdouble-promotion') - supported_cc_flags += ['-Wdouble-promotion'] + supported_cc_flags += [ '-Wdouble-promotion' ] endif # Clang complains about unused static inline functions which are common # with G_DEFINE_AUTOPTR_CLEANUP_FUNC. - w_unused_function_args = ['-Wunused-function', '-Werror'] + w_unused_function_args = [ '-Wunused-function', '-Werror' ] w_unused_function_code = ''' static inline void foo(void) {} @@ -459,7 +459,7 @@ if get_option('warning_level') == '2' ''' # -Wunused-function is implied by -Wall, we must turn it off explicitly. if not cc.compiles(w_unused_function_code, args: w_unused_function_args) - supported_cc_flags += ['-Wno-unused-function'] + supported_cc_flags += [ '-Wno-unused-function' ] endif endif @@ -794,9 +794,9 @@ required_programs = [ ] required_programs_groups = [ - {'name':'rpcgen', 'prog':['rpcgen', 'portable-rpcgen']}, - {'name':'rst2html', 'prog':['rst2html5', 'rst2html5.py', 'rst2html5-3']}, - {'name':'rst2man', 'prog':['rst2man', 'rst2man.py', 'rst2man-3']}, + { 'name': 'rpcgen', 'prog': [ 'rpcgen', 'portable-rpcgen' ] }, + { 'name': 'rst2html', 'prog': [ 'rst2html5', 'rst2html5.py', 'rst2html5-3' ] }, + { 'name': 'rst2man', 'prog': [ 'rst2man', 'rst2man.py', 'rst2man-3' ] }, ] if host_machine.system() == 'freebsd' @@ -1060,7 +1060,7 @@ endif libxml_version = '2.9.1' libxml_dep = dependency('libxml-2.0', version: '>=' + libxml_version) -libm_dep = cc.find_library('m', required : false) +libm_dep = cc.find_library('m', required: false) netcf_version = '0.1.8' netcf_dep = dependency('netcf', version: '>=' + netcf_version, required: get_option('netcf')) @@ -1602,7 +1602,7 @@ if not get_option('driver_qemu').disabled() endif conf.set_quoted('QEMU_MODDIR', qemu_moddir) - if host_machine.system() in ['freebsd', 'darwin'] + if host_machine.system() in [ 'freebsd', 'darwin' ] default_qemu_user = 'root' default_qemu_group = 'wheel' else @@ -1894,7 +1894,7 @@ if conf.has('WITH_LIBVIRTD') if not get_option('storage_zfs').disabled() zfs_enable = true - foreach name : ['zfs', 'zpool'] + foreach name : [ 'zfs', 'zpool' ] set_variable( '@0@_prog'.format(name), find_program(name, required: get_option('storage_zfs'), dirs: libvirt_sbin_path) @@ -1907,7 +1907,7 @@ if conf.has('WITH_LIBVIRTD') if zfs_enable use_storage = true conf.set('WITH_STORAGE_ZFS', 1) - foreach name : ['zfs', 'zpool'] + foreach name : [ 'zfs', 'zpool' ] conf.set_quoted(name.to_upper(), get_variable('@0@_prog'.format(name)).path()) endforeach endif diff --git a/src/locking/meson.build b/src/locking/meson.build index 8a28310e40..184d3c3f56 100644 --- a/src/locking/meson.build +++ b/src/locking/meson.build @@ -184,7 +184,7 @@ if conf.has('WITH_LIBVIRTD') virt_conf_files += qemu_lockd_conf virt_test_aug_files += { 'name': 'test_libvirt_lockd.aug', - 'aug' : files('test_libvirt_lockd.aug.in'), + 'aug': files('test_libvirt_lockd.aug.in'), 'conf': qemu_lockd_conf, 'test_name': 'libvirt_lockd', 'test_srcdir': meson.current_source_dir(), @@ -213,7 +213,7 @@ if conf.has('WITH_LIBVIRTD') virt_conf_files += qemu_sanlock_conf virt_test_aug_files += { 'name': 'test_libvirt_sanlock.aug', - 'aug' : files('test_libvirt_sanlock.aug.in'), + 'aug': files('test_libvirt_sanlock.aug.in'), 'conf': qemu_sanlock_conf, 'test_name': 'libvirt_sanlock', 'test_srcdir': meson.current_source_dir(), -- 2.31.1

It's the default. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 4d76e1f651..2544880732 100644 --- a/meson.build +++ b/meson.build @@ -804,7 +804,7 @@ if host_machine.system() == 'freebsd' endif foreach name : required_programs - prog = find_program(name, required: true, dirs: libvirt_sbin_path) + prog = find_program(name, dirs: libvirt_sbin_path) varname = name.underscorify() conf.set_quoted(varname.to_upper(), prog.path()) conf.set_quoted('@0@_PATH'.format(varname.to_upper()), prog.path()) @@ -812,7 +812,7 @@ foreach name : required_programs endforeach foreach item : required_programs_groups - prog = find_program(item.get('prog'), required: true, dirs: libvirt_sbin_path) + prog = find_program(item.get('prog'), dirs: libvirt_sbin_path) varname = item.get('name').underscorify() conf.set_quoted(varname.to_upper(), prog.path()) set_variable('@0@_prog'.format(varname), prog) @@ -1219,7 +1219,7 @@ if selinux_dep.found() conf.set('WITH_SELINUX', 1) endif -thread_dep = dependency('threads', required: true) +thread_dep = dependency('threads') pthread_sigmask_code = ''' #include <sys/types.h> #include <signal.h> -- 2.31.1

It appears to no longer be necessary. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/meson.build b/meson.build index 2544880732..1360dd325e 100644 --- a/meson.build +++ b/meson.build @@ -904,16 +904,6 @@ endif curl_version = '7.19.1' curl_dep = dependency('libcurl', version: '>=' + curl_version, required: get_option('curl')) if curl_dep.found() - # XXX as of libcurl-devel-7.20.1-3.fc13.x86_64, curl ships a version - # of <curl/curl.h> that #defines several wrapper macros around underlying - # functions to add type safety for gcc only. However, these macros - # spuriously trip gcc's -Wlogical-op warning. Avoid the warning by - # disabling the wrappers; even if it removes some type-check safety. - curl_dep = declare_dependency( - compile_args: [ '-DCURL_DISABLE_TYPECHECK' ], - dependencies: [ curl_dep ], - ) - conf.set('WITH_CURL', 1) endif -- 2.31.1

It appears to no longer be necessary. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 16 ---------------- src/util/virnetdevbridge.c | 18 ------------------ 2 files changed, 34 deletions(-) diff --git a/meson.build b/meson.build index 1360dd325e..9c494faa5c 100644 --- a/meson.build +++ b/meson.build @@ -622,22 +622,6 @@ endforeach # check for kernel headers required by src/util/virnetdevbridge.c if host_machine.system() == 'linux' - # Various kernel versions have headers that are not self-standing, but - # yet are incompatible with the corresponding glibc headers. In order - # to guarantee compilation across a wide range of versions (from RHEL 5 - # to rawhide), we first have to probe whether glibc and kernel can be - # used in tandem; and if not, provide workarounds that ensure that - # ABI-compatible IPv6 types are present for use by the kernel headers. - netinet_workaround_code = ''' - #include <netinet/in.h> - #include <linux/in6.h> - - int main(void) { return 0; } - ''' - if not cc.compiles(netinet_workaround_code) - conf.set('NETINET_LINUX_WORKAROUND', 1) - endif - required_headers = [ 'linux/param.h', 'linux/sockios.h', diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index 4fe84cc162..a9667b48ce 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -37,26 +37,8 @@ # endif # include <linux/sockios.h> # include <linux/param.h> /* HZ */ -# if NETINET_LINUX_WORKAROUND -/* Depending on the version of kernel vs. glibc, there may be a collision - * between <net/in.h> and kernel IPv6 structures. The different types - * are ABI compatible, but choke the C type system; work around it by - * using temporary redefinitions. */ -# define in6_addr in6_addr_ -# define sockaddr_in6 sockaddr_in6_ -# define ipv6_mreq ipv6_mreq_ -# define in6addr_any in6addr_any_ -# define in6addr_loopback in6addr_loopback_ -# endif # include <linux/in6.h> # include <linux/if_bridge.h> /* SYSFS_BRIDGE_ATTR */ -# if NETINET_LINUX_WORKAROUND -# undef in6_addr -# undef sockaddr_in6 -# undef ipv6_mreq -# undef in6addr_any -# undef in6addr_loopback -# endif # define JIFFIES_TO_MS(j) (((j)*1000)/HZ) # define MS_TO_JIFFIES(ms) (((ms)*HZ)/1000) -- 2.31.1

Meson offers a native convenience method that can be used to fetch pkg-config variables from a dependency, so we can use that instead of calling pkg-config manually. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 9c494faa5c..7f6756abca 100644 --- a/meson.build +++ b/meson.build @@ -1309,9 +1309,7 @@ if yajl_dep.found() # # [1] https://github.com/Homebrew/homebrew-core/pull/74516 if host_machine.system() != 'linux' - pkg_config_prog = find_program('pkg-config') - rc = run_command(pkg_config_prog, '--cflags', 'yajl', check: true) - cflags = rc.stdout().strip() + cflags = yajl_dep.get_pkgconfig_variable('cflags') if cflags.contains('include/yajl') rc = run_command( 'python3', '-c', -- 2.31.1

Meson already knows how to look for pcap using pkg-config first, and falling back to pcap-config if that didn't work. https://mesonbuild.com/Dependencies.html#pcap Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/meson.build b/meson.build index 7f6756abca..81f8caae06 100644 --- a/meson.build +++ b/meson.build @@ -978,19 +978,7 @@ endif libpcap_version = '1.5.0' if not get_option('libpcap').disabled() - libpcap_dep = dependency('libpcap', version: '>=' + libpcap_version, required: false) - - if not libpcap_dep.found() - pcap_config_prog = find_program('pcap-config', required: get_option('libpcap')) - if pcap_config_prog.found() - pcap_args = run_command(pcap_config_prog, '--cflags').stdout().strip().split() - pcap_libs = run_command(pcap_config_prog, '--libs').stdout().strip().split() - libpcap_dep = declare_dependency( - compile_args: pcap_args, - link_args: pcap_libs, - ) - endif - endif + libpcap_dep = dependency('pcap', version: '>=' + libpcap_version, required: get_option('libpcap')) else libpcap_dep = dependency('', required: false) endif -- 2.31.1

We use it unconditionally. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 81f8caae06..922bf93659 100644 --- a/meson.build +++ b/meson.build @@ -1022,7 +1022,7 @@ endif libxml_version = '2.9.1' libxml_dep = dependency('libxml-2.0', version: '>=' + libxml_version) -libm_dep = cc.find_library('m', required: false) +libm_dep = cc.find_library('m') netcf_version = '0.1.8' netcf_dep = dependency('netcf', version: '>=' + netcf_version, required: get_option('netcf')) -- 2.31.1

On Tue, Jun 01, 2021 at 10:37:39AM +0200, Andrea Bolognani wrote:
We use it unconditionally.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build index 81f8caae06..922bf93659 100644 --- a/meson.build +++ b/meson.build @@ -1022,7 +1022,7 @@ endif libxml_version = '2.9.1' libxml_dep = dependency('libxml-2.0', version: '>=' + libxml_version)
-libm_dep = cc.find_library('m', required: false) +libm_dep = cc.find_library('m')
netcf_version = '0.1.8' netcf_dep = dependency('netcf', version: '>=' + netcf_version, required: get_option('netcf'))
You should drop it from summary as we don't list non-optional dependencies there. Pavel

It's not used. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 922bf93659..8aaa0ce370 100644 --- a/meson.build +++ b/meson.build @@ -1071,7 +1071,6 @@ else intl_dep = dependency('', required: false) endif -numactl_version = '2.0.6' numactl_dep = cc.find_library('numa', required: get_option('numactl')) if numactl_dep.found() conf.set('WITH_NUMACTL', 1) -- 2.31.1

We're supposed to error out if the user has explicitly asked for vstorage support to be enabled and that can't be done, but we've been looking at the wrong option. Fixes: 2127d53f2f90443f3e4919c1082350ee2b3096f1 Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 8aaa0ce370..35dbec6522 100644 --- a/meson.build +++ b/meson.build @@ -1838,7 +1838,7 @@ if conf.has('WITH_LIBVIRTD') if not get_option('storage_vstorage').disabled() vstorage_enable = true if host_machine.system() != 'linux' - if get_option('storage_fs').enabled() + if get_option('storage_vstorage').enabled() error('Vstorage is supported only on Linux') else vstorage_enable = false -- 2.31.1

If the user explicitly asked for sanlock support to be enabled, then failure to find the corresponding library should result in an error. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 35dbec6522..328d4d1c5f 100644 --- a/meson.build +++ b/meson.build @@ -1145,7 +1145,7 @@ if readline_dep.found() endif if not get_option('sanlock').disabled() - sanlock_dep = dependency('libsanlock_client', required: false) + sanlock_dep = dependency('libsanlock_client', required: get_option('sanlock')) if sanlock_dep.found() conf.set('WITH_SANLOCK', 1) -- 2.31.1

The new version will report an error if the user asks for polkit support to be enabled on Windows instead of silently ignoring such requests. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 328d4d1c5f..3ee8694886 100644 --- a/meson.build +++ b/meson.build @@ -1085,12 +1085,6 @@ parallels_sdk_dep = dependency('parallels-sdk', version: '>=' + parallels_sdk_ve pciaccess_version = '0.10.0' pciaccess_dep = dependency('pciaccess', version: '>=' + pciaccess_version, required: get_option('pciaccess')) -if not get_option('polkit').disabled() and host_machine.system() != 'windows' - pkcheck_prog = find_program('pkcheck', required: false, dirs: libvirt_sbin_path) -else - pkcheck_prog = dependency('', required: false) -endif - rbd_dep = cc.find_library('rbd', required: false) rados_dep = cc.find_library('rados', required: false) if rbd_dep.found() and not cc.has_function('rbd_get_features', dependencies: rbd_dep) @@ -1353,8 +1347,24 @@ elif get_option('firewalld_zone').enabled() error('You must have firewalld support enabled to enable firewalld_zone') endif -if (pkcheck_prog.found() or get_option('polkit').enabled()) - conf.set('WITH_POLKIT', 1) +if not get_option('polkit').disabled() + polkit_enable = true + + if get_option('polkit').auto() + pkcheck_prog = find_program('pkcheck', required: false, dirs: libvirt_sbin_path) + polkit_enable = pkcheck_prog.found() + endif + + if host_machine.system() == 'windows' + polkit_enable = false + if get_option('polkit').enabled() + error('polkit support cannot be enabled on Windows') + endif + endif + + if polkit_enable + conf.set('WITH_POLKIT', 1) + endif endif if udev_dep.found() and not pciaccess_dep.found() -- 2.31.1

Keep all the platform-specific code in one place. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 3ee8694886..14d6ce039f 100644 --- a/meson.build +++ b/meson.build @@ -1266,6 +1266,8 @@ if host_machine.system() == 'windows' xdr_dep = cc.find_library('portablexdr', required: false) elif host_machine.system() == 'linux' xdr_dep = dependency('libtirpc', required: false) +elif host_machine.system() in [ 'freebsd', 'darwin' ] + xdr_dep = cc.find_library('c', required: false) else xdr_dep = declare_dependency() endif @@ -1375,7 +1377,7 @@ endif # build driver options if get_option('driver_remote').enabled() - if not xdr_dep.found() and host_machine.system() not in [ 'freebsd', 'darwin' ] + if not xdr_dep.found() error('XDR is required for remote driver') endif conf.set('WITH_REMOTE', 1) -- 2.31.1

If the feature is disabled, the corresponding flags should not show up in the compiler command line. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 14d6ce039f..9b5de6daa1 100644 --- a/meson.build +++ b/meson.build @@ -1025,11 +1025,13 @@ libxml_dep = dependency('libxml-2.0', version: '>=' + libxml_version) libm_dep = cc.find_library('m') netcf_version = '0.1.8' -netcf_dep = dependency('netcf', version: '>=' + netcf_version, required: get_option('netcf')) if not get_option('netcf').disabled() + netcf_dep = dependency('netcf', version: '>=' + netcf_version, required: get_option('netcf')) if netcf_dep.found() conf.set('WITH_NETCF', 1) endif +else + netcf_dep = dependency('', required: false) endif have_gnu_gettext_tools = false -- 2.31.1

This makes it possible to explicitly disable firewalld support regardless of the platform that's been targeted. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 9b5de6daa1..faccbd750c 100644 --- a/meson.build +++ b/meson.build @@ -1339,8 +1339,14 @@ if bash_completion_dep.found() endif endif -if host_machine.system() != 'freebsd' - if not get_option('firewalld').disabled() +if not get_option('firewalld').disabled() + firewalld_enable = true + + if host_machine.system() == 'freebsd' + firewalld_enable = false + endif + + if firewalld_enable conf.set('WITH_FIREWALLD', 1) endif endif -- 2.31.1

firewalld is Linux-only, so it should be disabled by default everywhere else and attempts to explicitly enable firewalld support on non-Linux targets should result in an error. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index faccbd750c..0b2e3e062e 100644 --- a/meson.build +++ b/meson.build @@ -1342,8 +1342,11 @@ endif if not get_option('firewalld').disabled() firewalld_enable = true - if host_machine.system() == 'freebsd' + if host_machine.system() != 'linux' firewalld_enable = false + if get_option('firewalld').enabled() + error('firewalld support can only be enabled on Linux') + endif endif if firewalld_enable -- 2.31.1

libacl is Linux-only, so we don't need to explicitly check for either the target platform or header availability, and we can simply rely on cc.find_library() instead. The corresponding preprocessor define is renamed to more accurately reflect the nature of the check. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 8 +++----- src/qemu/qemu_namespace.c | 2 +- src/util/virfile.c | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 0b2e3e062e..301cebab5c 100644 --- a/meson.build +++ b/meson.build @@ -844,11 +844,9 @@ endforeach # generic build dependencies -if host_machine.system() == 'linux' and cc.has_header('sys/acl.h') - acl_dep = cc.find_library('acl', required: false) - conf.set('WITH_SYS_ACL_H', 1) -else - acl_dep = dependency('', required: false) +acl_dep = cc.find_library('acl', required: false) +if acl_dep.found() + conf.set('WITH_LIBACL', 1) endif apparmor_dep = dependency('libapparmor', required: get_option('apparmor')) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 6a97863d92..98495e8ef8 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -852,7 +852,7 @@ qemuDomainNamespaceAvailable(qemuDomainNamespace ns G_GNUC_UNUSED) switch (ns) { case QEMU_DOMAIN_NS_MOUNT: -# if !defined(WITH_SYS_ACL_H) || !defined(WITH_SELINUX) +# if !defined(WITH_LIBACL) || !defined(WITH_SELINUX) /* We can't create the exact copy of paths if either of * these is not available. */ return false; diff --git a/src/util/virfile.c b/src/util/virfile.c index 03a7725dd3..cd63eceb16 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -56,7 +56,7 @@ #if WITH_SYS_SYSCALL_H # include <sys/syscall.h> #endif -#if WITH_SYS_ACL_H +#if WITH_LIBACL # include <sys/acl.h> #endif #include <sys/file.h> @@ -3752,7 +3752,7 @@ virFileMoveMount(const char *src G_GNUC_UNUSED, #endif /* !defined(__linux__) || !defined(WITH_SYS_MOUNT_H) */ -#if defined(WITH_SYS_ACL_H) +#if defined(WITH_LIBACL) int virFileGetACLs(const char *file, void **acl) @@ -3782,7 +3782,7 @@ virFileFreeACLs(void **acl) *acl = NULL; } -#else /* !defined(WITH_SYS_ACL_H) */ +#else /* !defined(WITH_LIBACL) */ int virFileGetACLs(const char *file G_GNUC_UNUSED, @@ -3808,7 +3808,7 @@ virFileFreeACLs(void **acl) *acl = NULL; } -#endif /* !defined(WITH_SYS_ACL_H) */ +#endif /* !defined(WITH_LIBACL) */ int virFileCopyACLs(const char *src, -- 2.31.1

This is the preferred way to figure out whether a library is available, and for the most part we can just adopt it right away; in a few cases, unfortunately, we're stuck with using cc.find_library() until further down the road, when all our target platforms ship with pkg-config enabled versions of the various libraries. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 301cebab5c..a9f87473db 100644 --- a/meson.build +++ b/meson.build @@ -844,6 +844,7 @@ endforeach # generic build dependencies +# FIXME rewrite to use dependency() acl_dep = cc.find_library('acl', required: false) if acl_dep.found() conf.set('WITH_LIBACL', 1) @@ -859,12 +860,13 @@ if apparmor_dep.found() conf.set_quoted('APPARMOR_PROFILES_PATH', '/sys/kernel/security/apparmor/profiles') endif +# FIXME rewrite to use dependency() once we can use 2.4.48 attr_dep = cc.find_library('attr', required: get_option('attr')) if attr_dep.found() conf.set('WITH_LIBATTR', 1) endif -audit_dep = cc.find_library('audit', required: get_option('audit')) +audit_dep = dependency('audit', required: get_option('audit')) if audit_dep.found() conf.set('WITH_AUDIT', 1) endif @@ -878,7 +880,7 @@ if blkid_dep.found() conf.set('WITH_BLKID', 1) endif -capng_dep = cc.find_library('cap-ng', required: get_option('capng')) +capng_dep = dependency('libcap-ng', required: get_option('capng')) if capng_dep.found() conf.set('WITH_CAPNG', 1) endif @@ -1071,6 +1073,7 @@ else intl_dep = dependency('', required: false) endif +# FIXME rewrite to use dependency() once we can use 2.0.14 numactl_dep = cc.find_library('numa', required: get_option('numactl')) if numactl_dep.found() conf.set('WITH_NUMACTL', 1) @@ -1160,7 +1163,7 @@ else sasl_dep = dependency('', required: false) endif -selinux_dep = cc.find_library('selinux', required: get_option('selinux')) +selinux_dep = dependency('libselinux', required: get_option('selinux')) if selinux_dep.found() selinux_mount = get_option('selinux_mount') if selinux_mount == '' @@ -1269,7 +1272,7 @@ elif host_machine.system() == 'linux' elif host_machine.system() in [ 'freebsd', 'darwin' ] xdr_dep = cc.find_library('c', required: false) else - xdr_dep = declare_dependency() + xdr_dep = dependency('', required: false) endif yajl_version = '2.0.3' @@ -1469,16 +1472,16 @@ if not get_option('driver_libxl').disabled() and conf.has('WITH_LIBVIRTD') if cc.has_header('libxlutil.h') conf.set('WITH_LIBXLUTIL_H', 1) endif - xl_util_dep = cc.find_library('xlutil') + xl_util_dep = dependency('xlutil') - xen_store_dep = cc.find_library('xenstore') + xen_store_dep = dependency('xenstore') # xtl_* infrastructure is in libxentoollog since Xen 4.7 previously # it was in libxenctrl. if libxl_dep.version().version_compare('>=4.7.0') - xtl_link_dep = cc.find_library('xentoollog') + xtl_link_dep = dependency('xentoollog') else - xtl_link_dep = cc.find_library('xenctrl') + xtl_link_dep = dependency('xenctrl') endif if libxl_dep.version().version_compare('>=4.13.0') -- 2.31.1

Attempting to enable apparmor_profiles when apparmor support is not enabled should result in an error. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index a9f87473db..55bb724a52 100644 --- a/meson.build +++ b/meson.build @@ -852,14 +852,18 @@ endif apparmor_dep = dependency('libapparmor', required: get_option('apparmor')) if apparmor_dep.found() - if get_option('apparmor_profiles') - conf.set('WITH_APPARMOR_PROFILES', 1) - endif conf.set('WITH_APPARMOR', 1) conf.set_quoted('APPARMOR_DIR', sysconfdir / 'apparmor.d') conf.set_quoted('APPARMOR_PROFILES_PATH', '/sys/kernel/security/apparmor/profiles') endif +if get_option('apparmor_profiles') + if not conf.has('WITH_APPARMOR') + error('Cannot enable apparmor_profiles without apparmor') + endif + conf.set('WITH_APPARMOR_PROFILES', 1) +endif + # FIXME rewrite to use dependency() once we can use 2.4.48 attr_dep = cc.find_library('attr', required: get_option('attr')) if attr_dep.found() -- 2.31.1

Similar knobs, such as firewalld_zone and sysctl_config, are already features, so convert this one as well to comply with expectations. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- libvirt.spec.in | 2 +- meson.build | 14 +++++++++++--- meson_options.txt | 2 +- mingw-libvirt.spec.in | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index cc04efe081..529c29214d 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1128,7 +1128,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec) -Dselinux=enabled \ %{?arg_selinux_mount} \ -Dapparmor=disabled \ - -Dapparmor_profiles=false \ + -Dapparmor_profiles=disabled \ -Dsecdriver_apparmor=disabled \ -Dudev=enabled \ -Dyajl=enabled \ diff --git a/meson.build b/meson.build index 55bb724a52..be6765a034 100644 --- a/meson.build +++ b/meson.build @@ -857,11 +857,19 @@ if apparmor_dep.found() conf.set_quoted('APPARMOR_PROFILES_PATH', '/sys/kernel/security/apparmor/profiles') endif -if get_option('apparmor_profiles') +if not get_option('apparmor_profiles').disabled() + apparmor_profiles_enable = true + if not conf.has('WITH_APPARMOR') - error('Cannot enable apparmor_profiles without apparmor') + apparmor_profiles_enable = false + if get_option('apparmor_profiles').enabled() + error('Cannot enable apparmor_profiles without apparmor') + endif + endif + + if apparmor_profiles_enable + conf.set('WITH_APPARMOR_PROFILES', 1) endif - conf.set('WITH_APPARMOR_PROFILES', 1) endif # FIXME rewrite to use dependency() once we can use 2.4.48 diff --git a/meson_options.txt b/meson_options.txt index 2606648b64..f4f40fe9b5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -69,7 +69,7 @@ option('driver_vmware', type: 'feature', value: 'auto', description: 'VMware dri option('driver_vz', type: 'feature', value: 'auto', description: 'Virtuozzo driver') option('secdriver_apparmor', type: 'feature', value: 'auto', description: 'use AppArmor security driver') -option('apparmor_profiles', type: 'boolean', value: false, description: 'install apparmor profiles') +option('apparmor_profiles', type: 'feature', value: 'disabled', description: 'install apparmor profiles') option('secdriver_selinux', type: 'feature', value: 'auto', description: 'use SELinux security driver') diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in index 87223e205c..bcc2bd93e3 100644 --- a/mingw-libvirt.spec.in +++ b/mingw-libvirt.spec.in @@ -108,7 +108,7 @@ exit 1 -Dcurl=enabled \ -Ddocs=enabled \ -Dapparmor=disabled \ - -Dapparmor_profiles=false \ + -Dapparmor_profiles=disabled \ -Dattr=disabled \ -Daudit=disabled \ -Dbash_completion=disabled \ -- 2.31.1

Match the behavior of most other features. This will result in a change in behavior, because profiles will now be installed whenever AppArmor support is enabled; on the other hand, this is probably the behavior users expected in the first place. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson_options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index f4f40fe9b5..df921c9243 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -69,7 +69,7 @@ option('driver_vmware', type: 'feature', value: 'auto', description: 'VMware dri option('driver_vz', type: 'feature', value: 'auto', description: 'Virtuozzo driver') option('secdriver_apparmor', type: 'feature', value: 'auto', description: 'use AppArmor security driver') -option('apparmor_profiles', type: 'feature', value: 'disabled', description: 'install apparmor profiles') +option('apparmor_profiles', type: 'feature', value: 'auto', description: 'install apparmor profiles') option('secdriver_selinux', type: 'feature', value: 'auto', description: 'use SELinux security driver') -- 2.31.1

Match the behavior of most other features. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 14 +++++++++++--- meson_options.txt | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index be6765a034..53c9a038d0 100644 --- a/meson.build +++ b/meson.build @@ -1400,11 +1400,19 @@ endif # build driver options -if get_option('driver_remote').enabled() +if not get_option('driver_remote').disabled() + use_remote = true + if not xdr_dep.found() - error('XDR is required for remote driver') + use_remote = false + if get_option('driver_remote').enabled() + error('XDR is required for remote driver') + endif + endif + + if use_remote + conf.set('WITH_REMOTE', 1) endif - conf.set('WITH_REMOTE', 1) endif remote_default_mode = get_option('remote_default_mode').to_upper() diff --git a/meson_options.txt b/meson_options.txt index df921c9243..fd23469431 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -59,7 +59,7 @@ option('driver_qemu', type: 'feature', value: 'auto', description: 'QEMU/KVM dri option('qemu_user', type: 'string', value: '', description: 'username to run QEMU system instance as') option('qemu_group', type: 'string', value: '', description: 'groupname to run QEMU system instance as') option('qemu_moddir', type: 'string', value: '', description: 'set the directory where QEMU modules are located') -option('driver_remote', type: 'feature', value: 'enabled', description: 'remote driver') +option('driver_remote', type: 'feature', value: 'auto', description: 'remote driver') option('remote_default_mode', type: 'combo', choices: ['legacy', 'direct'], value: 'legacy', description: 'remote driver default mode') option('driver_secrets', type: 'feature', value: 'auto', description: 'local secrets management driver') option('driver_test', type: 'feature', value: 'enabled', description: 'test driver') -- 2.31.1

Match the behavior of most other features. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 2 +- meson_options.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 53c9a038d0..1a2503488a 100644 --- a/meson.build +++ b/meson.build @@ -1704,7 +1704,7 @@ if not get_option('driver_secrets').disabled() and conf.has('WITH_LIBVIRTD') conf.set('WITH_SECRETS', 1) endif -if get_option('driver_test').enabled() +if not get_option('driver_test').disabled() conf.set('WITH_TEST', 1) endif diff --git a/meson_options.txt b/meson_options.txt index fd23469431..e2877d5a92 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -62,7 +62,7 @@ option('qemu_moddir', type: 'string', value: '', description: 'set the directory option('driver_remote', type: 'feature', value: 'auto', description: 'remote driver') option('remote_default_mode', type: 'combo', choices: ['legacy', 'direct'], value: 'legacy', description: 'remote driver default mode') option('driver_secrets', type: 'feature', value: 'auto', description: 'local secrets management driver') -option('driver_test', type: 'feature', value: 'enabled', description: 'test driver') +option('driver_test', type: 'feature', value: 'auto', description: 'test driver') option('driver_vbox', type: 'feature', value: 'auto', description: 'VirtualBox XPCOMC driver') option('vbox_xpcomc_dir', type: 'string', value: '', description: 'Location of directory containing VirtualBox XPCOMC library') option('driver_vmware', type: 'feature', value: 'auto', description: 'VMware driver') -- 2.31.1

These checks look different than most similar ones for no particular reason. This commit is better viewed with 'git show -w'. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index 1a2503488a..1d9c878fd0 100644 --- a/meson.build +++ b/meson.build @@ -991,12 +991,12 @@ endif libpcap_version = '1.5.0' if not get_option('libpcap').disabled() libpcap_dep = dependency('pcap', version: '>=' + libpcap_version, required: get_option('libpcap')) + if libpcap_dep.found() + conf.set('WITH_LIBPCAP', 1) + endif else libpcap_dep = dependency('', required: false) endif -if libpcap_dep.found() - conf.set('WITH_LIBPCAP', 1) -endif libssh_version = '0.7' if get_option('driver_remote').enabled() @@ -1139,19 +1139,19 @@ if not get_option('readline').disabled() endif endif endif + if readline_dep.found() + # We need this to avoid compilation issues with modern compilers. + # See 9ea3424a178 for a more detailed explanation + readline_dep = declare_dependency( + compile_args: [ '-D_FUNCTION_DEF' ], + dependencies: [ readline_dep ], + ) + + conf.set('WITH_READLINE', 1) + endif else readline_dep = dependency('', required: false) endif -if readline_dep.found() - # We need this to avoid compilation issues with modern compilers. - # See 9ea3424a178 for a more detailed explanation - readline_dep = declare_dependency( - compile_args: [ '-D_FUNCTION_DEF' ], - dependencies: [ readline_dep ], - ) - - conf.set('WITH_READLINE', 1) -endif if not get_option('sanlock').disabled() sanlock_dep = dependency('libsanlock_client', required: get_option('sanlock')) @@ -1882,10 +1882,9 @@ if conf.has('WITH_LIBVIRTD') if not get_option('storage_vstorage').disabled() vstorage_enable = true if host_machine.system() != 'linux' + vstorage_enable = false if get_option('storage_vstorage').enabled() error('Vstorage is supported only on Linux') - else - vstorage_enable = false endif endif -- 2.31.1

On Tue, Jun 01, 2021 at 10:37:55AM +0200, Andrea Bolognani wrote:
These checks look different than most similar ones for no particular reason.
This commit is better viewed with 'git show -w'.
Drop this line as I don't agree that it's better. It obscures the fact that the code "if something.found() ..." is moved inside the check. Pavel
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/meson.build b/meson.build index 1a2503488a..1d9c878fd0 100644 --- a/meson.build +++ b/meson.build @@ -991,12 +991,12 @@ endif libpcap_version = '1.5.0' if not get_option('libpcap').disabled() libpcap_dep = dependency('pcap', version: '>=' + libpcap_version, required: get_option('libpcap')) + if libpcap_dep.found() + conf.set('WITH_LIBPCAP', 1) + endif else libpcap_dep = dependency('', required: false) endif -if libpcap_dep.found() - conf.set('WITH_LIBPCAP', 1) -endif
libssh_version = '0.7' if get_option('driver_remote').enabled() @@ -1139,19 +1139,19 @@ if not get_option('readline').disabled() endif endif endif + if readline_dep.found() + # We need this to avoid compilation issues with modern compilers. + # See 9ea3424a178 for a more detailed explanation + readline_dep = declare_dependency( + compile_args: [ '-D_FUNCTION_DEF' ], + dependencies: [ readline_dep ], + ) + + conf.set('WITH_READLINE', 1) + endif else readline_dep = dependency('', required: false) endif -if readline_dep.found() - # We need this to avoid compilation issues with modern compilers. - # See 9ea3424a178 for a more detailed explanation - readline_dep = declare_dependency( - compile_args: [ '-D_FUNCTION_DEF' ], - dependencies: [ readline_dep ], - ) - - conf.set('WITH_READLINE', 1) -endif
if not get_option('sanlock').disabled() sanlock_dep = dependency('libsanlock_client', required: get_option('sanlock')) @@ -1882,10 +1882,9 @@ if conf.has('WITH_LIBVIRTD') if not get_option('storage_vstorage').disabled() vstorage_enable = true if host_machine.system() != 'linux' + vstorage_enable = false if get_option('storage_vstorage').enabled() error('Vstorage is supported only on Linux') - else - vstorage_enable = false endif endif
-- 2.31.1

Different types of drivers are more accurately sorted into separate categories, the "Windows" section has been absorbed into a more generic "Target" section which also contains other information about the OS configuration, and some other smaller tweaks have been applied. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 90 ++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/meson.build b/meson.build index 1d9c878fd0..a5f6ed6f9f 100644 --- a/meson.build +++ b/meson.build @@ -2208,7 +2208,7 @@ endforeach # print configuration summary -driver_summary = { +hypervisordriver_summary = { 'QEMU': conf.has('WITH_QEMU'), 'OpenVZ': conf.has('WITH_OPENVZ'), 'VMware': conf.has('WITH_VMWARE'), @@ -2219,13 +2219,8 @@ driver_summary = { 'Hyper-V': conf.has('WITH_HYPERV'), 'vz': conf.has('WITH_VZ'), 'Bhyve': conf.has('WITH_BHYVE'), - 'Test': conf.has('WITH_TEST'), - 'Remote': conf.has('WITH_REMOTE'), - 'Network': conf.has('WITH_NETWORK'), - 'Libvirtd': conf.has('WITH_LIBVIRTD'), - 'Interface': conf.has('WITH_INTERFACE'), } -summary(driver_summary, section: 'Drivers', bool_yn: true) +summary(hypervisordriver_summary, section: 'Hypervisor drivers', bool_yn: true) storagedriver_summary = { 'Dir': conf.has('WITH_STORAGE_DIR'), @@ -2243,18 +2238,21 @@ storagedriver_summary = { 'ZFS': conf.has('WITH_STORAGE_ZFS'), 'Virtuozzo storage': conf.has('WITH_STORAGE_VSTORAGE'), } -summary(storagedriver_summary, section: 'Storage Drivers', bool_yn: true) +summary(storagedriver_summary, section: 'Storage drivers', bool_yn: true) secdriver_summary = { 'SELinux': conf.has('WITH_SECDRIVER_SELINUX'), 'AppArmor': conf.has('WITH_SECDRIVER_APPARMOR'), } -summary(secdriver_summary, section: 'Security Drivers', bool_yn: true) +summary(secdriver_summary, section: 'Security drivers', bool_yn: true) -drivermod_summary = { - 'driver_modules': driver_modules_flags.length() > 0, +otherdriver_summary = { + 'Test': conf.has('WITH_TEST'), + 'Remote': conf.has('WITH_REMOTE'), + 'Network': conf.has('WITH_NETWORK'), + 'Interface': conf.has('WITH_INTERFACE'), } -summary(drivermod_summary, section: 'Driver Loadable Modules', bool_yn: true) +summary(otherdriver_summary, section: 'Other drivers', bool_yn: true) libs_summary = { 'acl': acl_dep.found(), @@ -2296,54 +2294,60 @@ libs_summary = { } summary(libs_summary, section: 'Libraries', bool_yn: true) -win_summary = { - 'MinGW': host_machine.system() == 'windows', - 'windres': host_machine.system() == 'windows', +feature_summary = { + 'DTrace': conf.has('WITH_DTRACE_PROBES'), + 'Libvirtd': conf.has('WITH_LIBVIRTD'), + 'driver_modules': driver_modules_flags.length() > 0, + 'firewalld': conf.has('WITH_FIREWALLD'), + 'firewalld-zone': conf.has('WITH_FIREWALLD_ZONE'), + 'nss': conf.has('WITH_NSS'), + 'numad': conf.has('WITH_NUMAD'), + 'pm_utils': conf.has('WITH_PM_UTILS'), + 'virt-host-validate': conf.has('WITH_HOST_VALIDATE'), + 'virt-login-shell': conf.has('WITH_LOGIN_SHELL'), + 'wireshark_dissector': wireshark_dep.found(), } -summary(win_summary, section: 'Windows', bool_yn: true) +summary(feature_summary, section: 'Other features', bool_yn: true) test_summary = { + 'Enabled': build_tests, 'Expensive': use_expensive_tests, 'Coverage': coverage_flags.length() > 0, } summary(test_summary, section: 'Test suite', bool_yn: true) -if conf.has('DEFAULT_LOADER_NVRAM') - loader_res = '@0@ !!! Using this configure option is strongly discouraged !!!'.format(conf.get_unquoted('DEFAULT_LOADER_NVRAM')) -else - loader_res = '' -endif -misc_summary = { +docs_summary = { + 'Enabled': gen_docs, +} +summary(docs_summary, section: 'Documentation', bool_yn: true) + +build_summary = { 'Warning Flags': supported_cc_flags, - 'docs': gen_docs, - 'tests': build_tests, - 'DTrace': conf.has('WITH_DTRACE_PROBES'), - 'firewalld': conf.has('WITH_FIREWALLD'), - 'firewalld-zone': conf.has('WITH_FIREWALLD_ZONE'), - 'nss': conf.has('WITH_NSS'), - 'numad': conf.has('WITH_NUMAD'), - 'Init script': init_script, - 'Char device locks': chrdev_lock_files, - 'Loader/NVRAM': loader_res, - 'pm_utils': conf.has('WITH_PM_UTILS'), - 'virt-login-shell': conf.has('WITH_LOGIN_SHELL'), - 'virt-host-validate': conf.has('WITH_HOST_VALIDATE'), - 'TLS priority': conf.get_unquoted('TLS_PRIORITY'), } -summary(misc_summary, section: 'Miscellaneous', bool_yn: true, list_sep: ' ') +summary(build_summary, section: 'Build', bool_yn: true, list_sep: ' ') -devtools_summary = { - 'wireshark_dissector': wireshark_dep.found(), +target_summary = { + 'OS': host_machine.system(), + 'Init script': init_script, + 'TLS priority': conf.get_unquoted('TLS_PRIORITY'), + 'Char device locks': chrdev_lock_files, } -summary(devtools_summary, section: 'Developer Tools', bool_yn: true) +if conf.has('DEFAULT_LOADER_NVRAM') + loader_nvram = conf.get_unquoted('DEFAULT_LOADER_NVRAM') + loader_nvram_warn = ' !!! configuring loader/NVRAM is strongly discouraged !!!' + target_summary += { + 'Loader/NVRAM': '@0@@1@'.format(loader_nvram, loader_nvram_warn), + } +endif if conf.has('WITH_QEMU') qemu_warn = '' if qemu_user == 'root' qemu_warn = ' !!! running QEMU as root is strongly discouraged !!!' endif - priv_summary = { - 'QEMU': '@0@:@1@@2@'.format(qemu_user, qemu_group, qemu_warn), + target_summary += { + 'QEMU processes run as': '@0@:@1@@2@'.format(qemu_user, qemu_group, qemu_warn), } - summary(priv_summary, section: 'Privileges') endif + +summary(target_summary, section: 'Target', bool_yn: true) -- 2.31.1

On Tue, Jun 01, 2021 at 10:37:56AM +0200, Andrea Bolognani wrote:
Different types of drivers are more accurately sorted into separate categories, the "Windows" section has been absorbed into a more generic "Target" section which also contains other information about the OS configuration, and some other smaller tweaks have been applied.
Too many changes in a single commit to follow, I'm sure it can be split into multiple commits to make it easier for reviewers. Pavel
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 90 ++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 43 deletions(-)
diff --git a/meson.build b/meson.build index 1d9c878fd0..a5f6ed6f9f 100644 --- a/meson.build +++ b/meson.build @@ -2208,7 +2208,7 @@ endforeach
# print configuration summary
-driver_summary = { +hypervisordriver_summary = { 'QEMU': conf.has('WITH_QEMU'), 'OpenVZ': conf.has('WITH_OPENVZ'), 'VMware': conf.has('WITH_VMWARE'), @@ -2219,13 +2219,8 @@ driver_summary = { 'Hyper-V': conf.has('WITH_HYPERV'), 'vz': conf.has('WITH_VZ'), 'Bhyve': conf.has('WITH_BHYVE'), - 'Test': conf.has('WITH_TEST'), - 'Remote': conf.has('WITH_REMOTE'), - 'Network': conf.has('WITH_NETWORK'), - 'Libvirtd': conf.has('WITH_LIBVIRTD'), - 'Interface': conf.has('WITH_INTERFACE'), } -summary(driver_summary, section: 'Drivers', bool_yn: true) +summary(hypervisordriver_summary, section: 'Hypervisor drivers', bool_yn: true)
storagedriver_summary = { 'Dir': conf.has('WITH_STORAGE_DIR'), @@ -2243,18 +2238,21 @@ storagedriver_summary = { 'ZFS': conf.has('WITH_STORAGE_ZFS'), 'Virtuozzo storage': conf.has('WITH_STORAGE_VSTORAGE'), } -summary(storagedriver_summary, section: 'Storage Drivers', bool_yn: true) +summary(storagedriver_summary, section: 'Storage drivers', bool_yn: true)
secdriver_summary = { 'SELinux': conf.has('WITH_SECDRIVER_SELINUX'), 'AppArmor': conf.has('WITH_SECDRIVER_APPARMOR'), } -summary(secdriver_summary, section: 'Security Drivers', bool_yn: true) +summary(secdriver_summary, section: 'Security drivers', bool_yn: true)
-drivermod_summary = { - 'driver_modules': driver_modules_flags.length() > 0, +otherdriver_summary = { + 'Test': conf.has('WITH_TEST'), + 'Remote': conf.has('WITH_REMOTE'), + 'Network': conf.has('WITH_NETWORK'), + 'Interface': conf.has('WITH_INTERFACE'), } -summary(drivermod_summary, section: 'Driver Loadable Modules', bool_yn: true) +summary(otherdriver_summary, section: 'Other drivers', bool_yn: true)
libs_summary = { 'acl': acl_dep.found(), @@ -2296,54 +2294,60 @@ libs_summary = { } summary(libs_summary, section: 'Libraries', bool_yn: true)
-win_summary = { - 'MinGW': host_machine.system() == 'windows', - 'windres': host_machine.system() == 'windows', +feature_summary = { + 'DTrace': conf.has('WITH_DTRACE_PROBES'), + 'Libvirtd': conf.has('WITH_LIBVIRTD'), + 'driver_modules': driver_modules_flags.length() > 0, + 'firewalld': conf.has('WITH_FIREWALLD'), + 'firewalld-zone': conf.has('WITH_FIREWALLD_ZONE'), + 'nss': conf.has('WITH_NSS'), + 'numad': conf.has('WITH_NUMAD'), + 'pm_utils': conf.has('WITH_PM_UTILS'), + 'virt-host-validate': conf.has('WITH_HOST_VALIDATE'), + 'virt-login-shell': conf.has('WITH_LOGIN_SHELL'), + 'wireshark_dissector': wireshark_dep.found(), } -summary(win_summary, section: 'Windows', bool_yn: true) +summary(feature_summary, section: 'Other features', bool_yn: true)
test_summary = { + 'Enabled': build_tests, 'Expensive': use_expensive_tests, 'Coverage': coverage_flags.length() > 0, } summary(test_summary, section: 'Test suite', bool_yn: true)
-if conf.has('DEFAULT_LOADER_NVRAM') - loader_res = '@0@ !!! Using this configure option is strongly discouraged !!!'.format(conf.get_unquoted('DEFAULT_LOADER_NVRAM')) -else - loader_res = '' -endif -misc_summary = { +docs_summary = { + 'Enabled': gen_docs, +} +summary(docs_summary, section: 'Documentation', bool_yn: true) + +build_summary = { 'Warning Flags': supported_cc_flags, - 'docs': gen_docs, - 'tests': build_tests, - 'DTrace': conf.has('WITH_DTRACE_PROBES'), - 'firewalld': conf.has('WITH_FIREWALLD'), - 'firewalld-zone': conf.has('WITH_FIREWALLD_ZONE'), - 'nss': conf.has('WITH_NSS'), - 'numad': conf.has('WITH_NUMAD'), - 'Init script': init_script, - 'Char device locks': chrdev_lock_files, - 'Loader/NVRAM': loader_res, - 'pm_utils': conf.has('WITH_PM_UTILS'), - 'virt-login-shell': conf.has('WITH_LOGIN_SHELL'), - 'virt-host-validate': conf.has('WITH_HOST_VALIDATE'), - 'TLS priority': conf.get_unquoted('TLS_PRIORITY'), } -summary(misc_summary, section: 'Miscellaneous', bool_yn: true, list_sep: ' ') +summary(build_summary, section: 'Build', bool_yn: true, list_sep: ' ')
-devtools_summary = { - 'wireshark_dissector': wireshark_dep.found(), +target_summary = { + 'OS': host_machine.system(), + 'Init script': init_script, + 'TLS priority': conf.get_unquoted('TLS_PRIORITY'), + 'Char device locks': chrdev_lock_files, } -summary(devtools_summary, section: 'Developer Tools', bool_yn: true)
+if conf.has('DEFAULT_LOADER_NVRAM') + loader_nvram = conf.get_unquoted('DEFAULT_LOADER_NVRAM') + loader_nvram_warn = ' !!! configuring loader/NVRAM is strongly discouraged !!!' + target_summary += { + 'Loader/NVRAM': '@0@@1@'.format(loader_nvram, loader_nvram_warn), + } +endif if conf.has('WITH_QEMU') qemu_warn = '' if qemu_user == 'root' qemu_warn = ' !!! running QEMU as root is strongly discouraged !!!' endif - priv_summary = { - 'QEMU': '@0@:@1@@2@'.format(qemu_user, qemu_group, qemu_warn), + target_summary += { + 'QEMU processes run as': '@0@:@1@@2@'.format(qemu_user, qemu_group, qemu_warn), } - summary(priv_summary, section: 'Privileges') endif + +summary(target_summary, section: 'Target', bool_yn: true) -- 2.31.1

The list takes up half a screen on my machine and it doesn't seem useful enough for that to be warranted, especially when it results in other, arguably more relevant parts of the summary being pushed off-screen. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 5 ----- 1 file changed, 5 deletions(-) diff --git a/meson.build b/meson.build index a5f6ed6f9f..28c953067c 100644 --- a/meson.build +++ b/meson.build @@ -2321,11 +2321,6 @@ docs_summary = { } summary(docs_summary, section: 'Documentation', bool_yn: true) -build_summary = { - 'Warning Flags': supported_cc_flags, -} -summary(build_summary, section: 'Build', bool_yn: true, list_sep: ' ') - target_summary = { 'OS': host_machine.system(), 'Init script': init_script, -- 2.31.1

On Tue, Jun 01, 2021 at 10:37:57AM +0200, Andrea Bolognani wrote:
The list takes up half a screen on my machine and it doesn't seem useful enough for that to be warranted, especially when it results in other, arguably more relevant parts of the summary being pushed off-screen.
It might be useful in some cases when users report that libvirt fails to compile and they will provide meson configure output but it is possible to get the list of flags by other means as well so I agree with you that we can drop it from summary. I would way for others to express their opinion as well. Pavel
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 5 ----- 1 file changed, 5 deletions(-)
diff --git a/meson.build b/meson.build index a5f6ed6f9f..28c953067c 100644 --- a/meson.build +++ b/meson.build @@ -2321,11 +2321,6 @@ docs_summary = { } summary(docs_summary, section: 'Documentation', bool_yn: true)
-build_summary = { - 'Warning Flags': supported_cc_flags, -} -summary(build_summary, section: 'Build', bool_yn: true, list_sep: ' ') - target_summary = { 'OS': host_machine.system(), 'Init script': init_script, -- 2.31.1

On Tue, Jun 01, 2021 at 10:37:31AM +0200, Andrea Bolognani wrote:
Test pipeline: https://gitlab.com/abologna/libvirt/-/pipelines/312508056
Andrea Bolognani (26): spec: Be explicit about more features meson: Whitespace tweaks meson: Don't use 'required: true' meson: Drop curl workaround meson: Drop netinet workaround meson: Use get_pkgconfig_variable('cflags') meson: Use built-in pcap detection meson: Make libm a required dependency meson: Drop numactl_version meson: Fix vstorage detection meson: Fix sanlock detection meson: Rewrite polkit check meson: Tweak XDR check meson: Fix disabling netcf meson: Rewrite firewalld check meson: Fix firewalld check meson: Rewrite libacl check meson: Use dependency() when possible meson: Rewrite apparmor_profiles check meson: Turn apparmor_profiles into a feature meson: Switch to autodetection for apparmor_profiles meson: Switch to autodetection for driver_remote meson: Switch to autodetection for driver_test meson: Style tweaks
For the above patches with the issues fixed. Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
meson: Reorganize summary
I would post the changes as separate series so it's not blocking this one.
meson: Don't include warning flags in summary
Once we have some other opinions as well. Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

On Tue, Jun 01, 2021 at 11:41:37AM +0200, Pavel Hrdina wrote:
On Tue, Jun 01, 2021 at 10:37:31AM +0200, Andrea Bolognani wrote:
Test pipeline: https://gitlab.com/abologna/libvirt/-/pipelines/312508056
Andrea Bolognani (26): spec: Be explicit about more features meson: Whitespace tweaks meson: Don't use 'required: true' meson: Drop curl workaround meson: Drop netinet workaround meson: Use get_pkgconfig_variable('cflags') meson: Use built-in pcap detection meson: Make libm a required dependency meson: Drop numactl_version meson: Fix vstorage detection meson: Fix sanlock detection meson: Rewrite polkit check meson: Tweak XDR check meson: Fix disabling netcf meson: Rewrite firewalld check meson: Fix firewalld check meson: Rewrite libacl check meson: Use dependency() when possible meson: Rewrite apparmor_profiles check meson: Turn apparmor_profiles into a feature meson: Switch to autodetection for apparmor_profiles meson: Switch to autodetection for driver_remote meson: Switch to autodetection for driver_test meson: Style tweaks
For the above patches with the issues fixed.
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Thanks, I've pushed these now.
meson: Reorganize summary
I would post the changes as separate series so it's not blocking this one.
Fair point. I actually have more changes lined up that would alter the summary further, so I might end up rolling the two together.
meson: Don't include warning flags in summary
Once we have some other opinions as well.
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
I'll rework this so that it's stand-alone and repost it. Thanks again! -- Andrea Bolognani / Red Hat / Virtualization
participants (2)
-
Andrea Bolognani
-
Pavel Hrdina