]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: Add option to control building libvirtd
authorJim Fehlig <jfehlig@suse.com>
Mon, 20 Apr 2026 17:36:48 +0000 (11:36 -0600)
committerJim Fehlig <jfehlig@suse.com>
Mon, 6 Jul 2026 17:39:53 +0000 (11:39 -0600)
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 <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/manpages/meson.build
meson.build
meson_options.txt
src/remote/meson.build
src/security/apparmor/meson.build
tests/meson.build

index 6504e68a71b389bb4295d660ef21fc68896b4fc1..ee686bfd1b7ba5474fb335affc35aeda733e6b3d 100644 (file)
@@ -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') },
index 40d32c269719fb9511fb11c33eb55f9d3d021d94..ad1a5da1a57032522c733d3ef63c18c2ec33fddc 100644 (file)
@@ -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'),
index e12ace4e115a79078c53e587017a035377f88c43..8592880b7b150d575bab41e966226334fe47259d 100644 (file)
@@ -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')
index 3dab585d80cc543a0a4db799da154bbd5d475c39..3525bc34b2defa173eb38f040dafaad1b7839efa 100644 (file)
@@ -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,
   })
index 09d9fac02c201c7e376bd04338460e08000d710c..7585fb71004853e2f1a7b1e081d5a8a0f58cfa97 100644 (file)
@@ -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,
index d1d26fcea2c7935f5f98c43db25db54dfbeb5547..ea50f89fb53e6648cd3163f1f9e31bcc89539fe9 100644 (file)
@@ -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' ],