%define with_fuse 0
%define with_sanlock 0
%define with_numad 0
+%define with_nbdkit 0
%define with_firewalld_zone 0
%define with_netcf 0
%define with_libssh2 0
%endif
%endif
+# We should only enable nbdkit support if the OS ships a SELinux policy that
+# allows libvirt to launch it. Right now that's not the case anywhere, but
+# things should be fine by the time Fedora 40 is released.
+#
+# TODO: add RHEL 9 once a minor release that contains the necessary SELinux
+# bits exists (we only support the most recent minor release)
+%if %{with_qemu}
+ %if 0%{?fedora} >= 40
+ %define with_nbdkit 0%{!?_without_nbdkit:1}
+ %endif
+%endif
+
%ifarch %{arches_dmidecode}
%define with_dmidecode 0%{!?_without_dmidecode:1}
%endif
BuildRequires: libacl-devel
# From QEMU RPMs, used by virstoragetest
BuildRequires: /usr/bin/qemu-img
+%endif
+# nbdkit support requires libnbd
+%if %{with_nbdkit}
BuildRequires: libnbd-devel
%endif
# For LVM drivers
Recommends: passt
Recommends: passt-selinux
%endif
+ %if %{with_nbdkit}
Recommends: nbdkit
Recommends: nbdkit-curl-plugin
Recommends: nbdkit-ssh-plugin
+ %endif
%description daemon-driver-qemu
The qemu driver plugin for the libvirtd daemon, providing
%if %{with_qemu}
%define arg_qemu -Ddriver_qemu=enabled
- %define arg_libnbd -Dlibnbd=enabled
%else
%define arg_qemu -Ddriver_qemu=disabled
- %define arg_libnbd -Dlibnbd=disabled
%endif
%if %{with_openvz}
%define arg_numad -Dnumad=disabled
%endif
+%if %{with_nbdkit}
+ %define arg_nbdkit -Dnbdkit=enabled
+%else
+ %define arg_nbdkit -Dnbdkit=disabled
+%endif
+
%if %{with_fuse}
%define arg_fuse -Dfuse=enabled
%else
-Dyajl=enabled \
%{?arg_sanlock} \
-Dlibpcap=enabled \
- %{?arg_libnbd} \
+ %{?arg_nbdkit} \
-Dlibnl=enabled \
-Daudit=enabled \
-Ddtrace=enabled \
libiscsi_version = '1.18.0'
libiscsi_dep = dependency('libiscsi', version: '>=' + libiscsi_version, required: get_option('libiscsi'))
-libnbd_version = '1.0'
-libnbd_dep = dependency('libnbd', version: '>=' + libnbd_version, required: get_option('libnbd'))
-if libnbd_dep.found()
- conf.set('WITH_LIBNBD', 1)
+if not get_option('nbdkit').disabled()
+ libnbd_version = '1.0'
+ libnbd_dep = dependency('libnbd', version: '>=' + libnbd_version, required: false)
+
+ nbdkit_requested = get_option('nbdkit').enabled()
+ nbdkit_syscall_ok = conf.has('WITH_DECL_SYS_PIDFD_OPEN')
+ nbdkit_libnbd_ok = libnbd_dep.found()
+
+ if not nbdkit_syscall_ok and nbdkit_requested
+ error('nbdkit support requires pidfd_open(2)')
+ endif
+ if not nbdkit_libnbd_ok and nbdkit_requested
+ error('nbdkit support requires libnbd')
+ endif
+
+ if nbdkit_syscall_ok and nbdkit_libnbd_ok
+ conf.set('WITH_NBDKIT', 1)
+ endif
+endif
+if not conf.has('WITH_NBDKIT')
+ libnbd_dep = dependency('', required: false)
endif
libnl_version = '3.0'
conf.set_quoted('TLS_PRIORITY', get_option('tls_priority'))
-if conf.has('WITH_DECL_SYS_PIDFD_OPEN')
- conf.set('WITH_NBDKIT', 1)
-endif
-
# Various definitions
# Python3 < 3.7 treats the C locale as 7-bit only. We must force env vars so
option('fuse', type: 'feature', value: 'auto', description: 'fuse support')
option('glusterfs', type: 'feature', value: 'auto', description: 'glusterfs support')
option('libiscsi', type: 'feature', value: 'auto', description: 'libiscsi support')
-option('libnbd', type: 'feature', value: 'auto', description: 'libnbd support')
option('libnl', type: 'feature', value: 'auto', description: 'libnl support')
option('libpcap', type: 'feature', value: 'auto', description: 'libpcap support')
option('libssh', type: 'feature', value: 'auto', description: 'libssh support')
option('login_shell', type: 'feature', value: 'auto', description: 'build virt-login-shell')
option('nss', type: 'feature', value: 'auto', description: 'enable Name Service Switch plugin for resolving guest IP addresses')
option('numad', type: 'feature', value: 'auto', description: 'use numad to manage CPU placement dynamically')
+option('nbdkit', type: 'feature', value: 'auto', description: 'use nbdkit to access network disks')
option('pm_utils', type: 'feature', value: 'auto', description: 'use pm-utils for power management')
option('sysctl_config', type: 'feature', value: 'auto', description: 'Whether to install sysctl configs')
option('tls_priority', type: 'string', value: 'NORMAL', description: 'set the default TLS session priority string')
#include <config.h>
#include <glib.h>
-#if WITH_LIBNBD
+#if WITH_NBDKIT
# include <libnbd.h>
#endif
#include <sys/syscall.h>
g_autofree char *basename = g_strdup_printf("%s-nbdkit-%i", vm->def->name, proc->source->id);
int logfd = -1;
g_autoptr(qemuLogContext) logContext = NULL;
-#if WITH_LIBNBD
+#if WITH_NBDKIT
struct nbd_handle *nbd = NULL;
#endif
while (virTimeBackOffWait(&timebackoff)) {
if (virFileExists(proc->socketfile)) {
-#if WITH_LIBNBD
+#if WITH_NBDKIT
/* if the disk source was misconfigured, nbdkit will not produce an error
* until somebody connects to the socket and tries to access the nbd
* export. This results in poor user experience because the only error we