From: Jim Fehlig Date: Mon, 20 Apr 2026 17:36:48 +0000 (-0600) Subject: build: Add option to control building libvirtd X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d7cfb4cdf3f0058e82df4e45f2d0e2aeb760707;p=thirdparty%2Flibvirt.git build: Add option to control building libvirtd Add meson option 'libvirtd' to control building of the monolithic libvirtd, independent from the stateful, daemon-based drivers. E.g. meson configure -Dlibvirtd=disabled build-dir The new option defaults to 'auto' and will be enabled when 'driver_libvirtd' is enabled. Setting libvirtd=disabled skips building the libvirtd binary, and related items such as config files, systemd units, etc. The existing option 'driver_libvirtd' controls building libvirtd and all stateful, daemon-based drivers, making it unsuitable for disabling only the monolithic daemon. Additionally, 'driver_libvirtd' is used by the various libvirt-ci projects to produce a minimalistic build. Signed-off-by: Jim Fehlig Reviewed-by: Michal Privoznik --- diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build index 6504e68a71..ee686bfd1b 100644 --- a/docs/manpages/meson.build +++ b/docs/manpages/meson.build @@ -23,7 +23,7 @@ docs_man_files = [ { 'name': 'virt-qemu-sev-validate', 'section': '1', 'install': conf.has('WITH_QEMU') }, { 'name': 'libvirt-guests', 'section': '8', 'install': conf.has('WITH_LIBVIRTD') }, - { 'name': 'libvirtd', 'section': '8', 'install': conf.has('WITH_LIBVIRTD') }, + { 'name': 'libvirtd', 'section': '8', 'install': conf.has('WITH_MONOLITHIC_LIBVIRTD') }, { 'name': 'virt-sanlock-cleanup', 'section': '8', 'install': conf.has('WITH_SANLOCK') }, { 'name': 'virt-ssh-helper', 'section': '8', 'install': conf.has('WITH_LIBVIRTD') }, { 'name': 'virtbhyved', 'section': '8', 'install': conf.has('WITH_BHYVE') }, diff --git a/meson.build b/meson.build index 40d32c2697..ad1a5da1a5 100644 --- a/meson.build +++ b/meson.build @@ -1483,7 +1483,6 @@ if udev_dep.found() and not pciaccess_dep.found() error('You must install the pciaccess module to build with udev') endif - # build driver options remote_default_mode = get_option('remote_default_mode') @@ -1513,6 +1512,10 @@ if not get_option('driver_libvirtd').disabled() endif endif +if not get_option('libvirtd').disabled() and conf.has('WITH_LIBVIRTD') + conf.set('WITH_MONOLITHIC_LIBVIRTD', 1) +endif + if not get_option('driver_bhyve').disabled() and host_machine.system() == 'freebsd' conf.set('WITH_BHYVE', 1) elif get_option('driver_bhyve').enabled() @@ -2252,6 +2255,7 @@ driver_summary = { 'Libvirtd': conf.has('WITH_LIBVIRTD'), 'libxl': conf.has('WITH_LIBXL'), 'LXC': conf.has('WITH_LXC'), + 'Monolithic libvirtd': conf.has('WITH_MONOLITHIC_LIBVIRTD'), 'Network': conf.has('WITH_NETWORK'), 'OpenVZ': conf.has('WITH_OPENVZ'), 'QEMU': conf.has('WITH_QEMU'), diff --git a/meson_options.txt b/meson_options.txt index e12ace4e11..8592880b7b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -52,6 +52,8 @@ option('udev', type: 'feature', value: 'auto', description: 'udev support') option('wireshark_dissector', type: 'feature', value: 'auto', description: 'wireshark support') option('wireshark_plugindir', type: 'string', value: '', description: 'wireshark plugins directory for use when installing wireshark plugin') +# build monolithic daemon option +option('libvirtd', type: 'feature', value: 'auto', description: 'monolithic libvirt daemon') # build driver options option('driver_bhyve', type: 'feature', value: 'auto', description: 'bhyve driver') diff --git a/src/remote/meson.build b/src/remote/meson.build index 3dab585d80..3525bc34b2 100644 --- a/src/remote/meson.build +++ b/src/remote/meson.build @@ -134,9 +134,14 @@ logrotate_files = [ 'libvirtd.qemu', 'libvirtd.lxc', 'libvirtd.libxl', - 'libvirtd', ] +if conf.has('WITH_MONOLITHIC_LIBVIRTD') + logrotate_files += [ + 'libvirtd', + ] +endif + if conf.has('WITH_REMOTE') remote_driver_lib = static_library( 'virt_remote_driver', @@ -176,47 +181,49 @@ if conf.has('WITH_REMOTE') if conf.has('WITH_LIBVIRTD') guest_unit_files += files('virt-guest-shutdown.target') - virt_daemons += { - 'name': 'libvirtd', - 'c_args': [ - '-DSOCK_PREFIX="libvirt"', - '-DDAEMON_NAME="libvirtd"', - '-DWITH_IP', - '-DLIBVIRTD', - ], - } - - virt_daemon_confs += { - 'name': 'libvirtd', - 'with_ip': true, - } - - virt_daemon_units += { - 'service': 'libvirtd', - 'name': 'legacy monolithic', - 'service_in': files('libvirtd.service.in'), - 'service_extra_in': [ - files('libvirtd.service.extra.in'), - systemd_service_limitnofile_extra_in, - systemd_service_tasksmax_extra_in, - systemd_service_limitmemlock_extra_in, - ], - 'sockets': [ 'main', 'ro', 'admin', 'tcp', 'tls' ], - 'socket_in': files('libvirtd.socket.in'), - 'socket_ro_in': files('libvirtd-ro.socket.in'), - 'socket_admin_in': files('libvirtd-admin.socket.in'), - 'socket_tcp_in': files('libvirtd-tcp.socket.in'), - 'socket_tls_in': files('libvirtd-tls.socket.in'), - 'socket_extra_in': [ - files('libvirtd.socket.extra.in'), - ], - } - - openrc_init_files += { - 'name': 'libvirtd', - 'in_file': files('libvirtd.init.in'), - 'confd': files('libvirtd.confd'), - } + if conf.has('WITH_MONOLITHIC_LIBVIRTD') + virt_daemons += { + 'name': 'libvirtd', + 'c_args': [ + '-DSOCK_PREFIX="libvirt"', + '-DDAEMON_NAME="libvirtd"', + '-DWITH_IP', + '-DLIBVIRTD', + ], + } + + virt_daemon_confs += { + 'name': 'libvirtd', + 'with_ip': true, + } + + virt_daemon_units += { + 'service': 'libvirtd', + 'name': 'legacy monolithic', + 'service_in': files('libvirtd.service.in'), + 'service_extra_in': [ + files('libvirtd.service.extra.in'), + systemd_service_limitnofile_extra_in, + systemd_service_tasksmax_extra_in, + systemd_service_limitmemlock_extra_in, + ], + 'sockets': [ 'main', 'ro', 'admin', 'tcp', 'tls' ], + 'socket_in': files('libvirtd.socket.in'), + 'socket_ro_in': files('libvirtd-ro.socket.in'), + 'socket_admin_in': files('libvirtd-admin.socket.in'), + 'socket_tcp_in': files('libvirtd-tcp.socket.in'), + 'socket_tls_in': files('libvirtd-tls.socket.in'), + 'socket_extra_in': [ + files('libvirtd.socket.extra.in'), + ], + } + + openrc_init_files += { + 'name': 'libvirtd', + 'in_file': files('libvirtd.init.in'), + 'confd': files('libvirtd.confd'), + } + endif virt_daemons += { 'name': 'virtproxyd', @@ -337,7 +344,7 @@ endif # The monolithic libvirt daemon only attempts to load the # secrets encryption credentials if the secret driver is enabled -if conf.has('WITH_SECRETS') and init_script == 'systemd' +if conf.has('WITH_MONOLITHIC_LIBVIRTD') and conf.has('WITH_SECRETS') and init_script == 'systemd' secret_dropin_conf = configuration_data({ 'localstatedir': localstatedir, }) diff --git a/src/security/apparmor/meson.build b/src/security/apparmor/meson.build index 09d9fac02c..7585fb7100 100644 --- a/src/security/apparmor/meson.build +++ b/src/security/apparmor/meson.build @@ -1,10 +1,13 @@ apparmor_gen_profiles = [ 'usr.lib.libvirt.virt-aa-helper', - 'usr.sbin.libvirtd', 'usr.sbin.virtqemud', 'usr.sbin.virtxend', ] +if conf.has('WITH_MONOLITHIC_LIBVIRTD') + apparmor_gen_profiles += ['usr.sbin.libvirtd'] +endif + apparmor_gen_profiles_conf = configuration_data({ 'sysconfdir': sysconfdir, 'sbindir': sbindir, diff --git a/tests/meson.build b/tests/meson.build index d1d26fcea2..ea50f89fb5 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -734,7 +734,7 @@ if conf.has('WITH_TEST') ] endif -if conf.has('WITH_LIBVIRTD') +if conf.has('WITH_MONOLITHIC_LIBVIRTD') test('libvirtd fail with missing config', libvirtd_prog, args: [ '--config=no-such-conf', '--timeout=5' ],