Skip to contentSkip to conversation

package/libvirt: new package

PATCH Superseded Jared Bents 3 participants 3 messages Jun 30, 2020 – Aug 27, 2020

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v7 1/1 package/libvirt: new package

Libvirt is collection of software that provides a convenient way to manage virtual machines and other virtualization functionality, such as storage and network interface management. These software pieces include an API library, a daemon (libvirtd), and a command line utility (virsh).

http://libvirt.org/

--
History:
v1: primitive package, for experimental purposes only v1->v2:
- Clarify dependence on !BR2_TOOLCHAIN_USES_MUSL
- Add run-time dependence on dnsmask
- Add dependence on eudev and libpciaccess when eudev is selected (thus detected by configure).
v2->v3:
- Condition the use of libtirpc to !BR2_TOOLCHAIN_HAS_NATIVE_RPC
- Check for BR2_PACKAGE_HAS_UDEV instead of BR2_PACKAGE_EUDEV
v3->v4:
- Fix version history :-).
- Add optional dependency on several packages (e.g. attr, libpcap), depending on wether they are selected or not, and explicitly disable features whose required packages are not selected. This is very important to prevent selection of features based on leaks from the host environment (e.g. finding /usr/bin/numad on the host machine).
- Enable the "interface" driver if either udev or netcf is available.
- Disable pm-utils support, since there is no package for Buildroot.
- Use either openssl or gnutls, if available.
- Run qemu as user "qemu", group "kvm", not as root.
- Add a LIBVIRT_USERS variable to create user "qemu" an group "kvm".
- Add a device table file to set the ownership and permissions of the libvirt directories under /etc, /run and /var.
- If udev is not available, add an init script to set the ownership and permissions of /dev/kvm to root:kvm and 0660; otherwise create a corresponding /etc/udev/rules.d/90-kvm.rules file.
- Enable support for systemd, if applicable; otherwise install an init script to start/stop/restart libvirtd.
- Ensure that a modern netcat is available.
v4->v5:
- Changed SOB, since I don't work for DATACOM anymore.
- Bump to version 5.8.0.
- Add hash for license file.
- Drop OpenSSL options, since it's not supported anymore.
- Use https to access libvirt.org, since http is always redirected to https.
- Make libvirt daemon optional. If not selected, build only the client utilities. Reorganize run-time dependencies accordingly.
- Load all vfio modules on startup, if they exist, otherwise virtual machines that depend on the PCI Passthrough feature fail to load. vfio-pci is not enough. Other modules, like vfio_iommu_type1, may be necessary.
- Fix stopping dnsmasq in start/stop script. dnsmasq is not always started by libvirtd, so we must chech if it is running before attempting to stop it.
- Move /etc/libvirt/{qemu,secrets,storage} to /var/lib/libvirt. It may be necessary to create persistent files (e.g. VM definitions) in these directories. Move them to /var/lib because /etc may be on a read-only or volatile (initramfs) filesystem. We could tweak the code to change these paths but the patch would be large and would break compatibility with ordinary installations and with the documentation.
- Prevent an error message if pid file dissappears. start-stop-daemon sends a TERM signal to the process but does not wait for its termination, so we may reach rm_stale_pidfile while libvirtd.pid still exists but execute the cat command when the file is already gone, which leads cat to show an error message. We could use the '--retry' option to wait for the process termination but it is not supported by BusyBox. Let's just send the error messages to /dev/null and attempt to remove the file if any command fails, since 'rm -f' does nothing if the file does not exist.
- Move device table creation to LIBVIRT_DEVICES instead of using the device_table.txt file.
- Select libseccomp to enable seccomp support in qemu, as required by libvirt.
- Select hwdata (pci.ids). It is required by libvirt to show device names when we use virtual machine manager to add hardware via PCI passthrough, otherwise only the PCI bus information (slot, port, function) is shown.
- Add systemd support.
- Restrict to libvirt with udev support. Drop netcf usage, which requires a new package and is hard to test. Support for non-udev systems will be added later.
- Remove package/libvirt/S30devkvmperms
- Fine-tune the configuration and pass host/target executable paths in ac_cv_path_* variables via LIBVIRT_CONF_ENV.
- Use LIBVIRT_PERMISSIONS to set directory permissions.
- Drop hook to set user/group in /etc/libvirt/qemu.conf, since it's not necessary.
- Pull two upstream patches that fix building with musl.
- Do not check for executables existence in the startup script.
- Use separate init scripts for virtlogd and libvirtd. Make them compliant to the current pattern (as much as possible).
- Do not start/stop virtlockd, since it is controlled by libvirtd.
v5->v6:
- Remove stray '\' in S91virtlogd

v6->v7:
- Carlos Santos is no longer contributing to buildroot.
- Adjusted handling of bash-completion to add dependency if it is enabled.
- Bump to version 6.4.0

---
 DEVELOPERS                                    |   3 +
 package/Config.in                             |   1 +
 ...nfigure-remove-build-directory-check.patch |  34 ++
 package/libvirt/90-kvm.rules                  |   1 +
 package/libvirt/Config.in                     | 111 +++++
 package/libvirt/S91virtlogd                   |  65 +++
 package/libvirt/S92libvirtd                   | 132 ++++++
 package/libvirt/libvirt.hash                  |   3 +
 package/libvirt/libvirt.mk                    | 389 ++++++++++++++++++
 9 files changed, 739 insertions(+)
 create mode 100644 package/libvirt/0001-configure-remove-build-directory-check.patch
 create mode 100644 package/libvirt/90-kvm.rules
 create mode 100644 package/libvirt/Config.in
 create mode 100644 package/libvirt/S91virtlogd
 create mode 100644 package/libvirt/S92libvirtd
 create mode 100644 package/libvirt/libvirt.hash
 create mode 100644 package/libvirt/libvirt.mk
DEVELOPERS +3 -0
index 3915bba477..3d20e9bed2 100644
@@ -1174,6 +1174,9 @@ F:	package/python-pexpect/
 F:	package/python-ptyprocess/
 F:	package/zynq-boot-bin/
 
+N:	Jared Bents <[email protected]>
+F:	package/libvirt/
+
 N:	Jarkko Sakkinen <[email protected]>
 F:	package/quota/
 
package/Config.in +1 -0
index 3447dee034..ab61a5faf1 100644
@@ -2320,6 +2320,7 @@ menu "System tools"
 	source "package/kmod/Config.in"
 	source "package/kvmtool/Config.in"
 	source "package/libostree/Config.in"
+	source "package/libvirt/Config.in"
 	source "package/lxc/Config.in"
 	source "package/mender/Config.in"
 	source "package/mender-grubenv/Config.in"
package/libvirt/0001-configure-remove-build-directory-check.patch new file +34 -0
new file mode 100644
index 0000000000..60f3c8de02
@@ -0,0 +1,34 @@
+From a9dbda8f59a780d82f65718254ab627bda376e52 Mon Sep 17 00:00:00 2001
+From: Jared Bents <[email protected]>
+Date: Tue, 30 Jun 2020 13:55:06 -0500
+Subject: [PATCH] configure: remove build directory check
+
+remove build directory location check so that autotools still
+works as this check is for the eventual move to being a meson
+package which libvirt has not moved to yet.
+
+Signed-off-by: Jared Bents <[email protected]>
+---
+ configure.ac | 5 -----
+ 1 files changed, 5 deletions(-)
+
+diff --git a/configure b/configure
+index 013e8f5..57dad7f 100755
+--- a/configure
++++ b/configure
+@@ -3413,12 +3413,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ 
+ 
+ 
+-if test $srcdir = "."
+-then
+-  as_fn_error $? "Build directory must be different from source directory" "$LINENO" 5
+-fi
+-
+-
+ ac_aux_dir=
+ for ac_dir in build-aux "$srcdir"/build-aux; do
+   if test -f "$ac_dir/install-sh"; then
+-- 
+2.17.1
+
package/libvirt/90-kvm.rules new file +1 -0
new file mode 100644
index 0000000000..5145c27e79
@@ -0,0 +1 @@
+KERNEL=="kvm", OWNER="root", GROUP="kvm", MODE="0660"
package/libvirt/Config.in new file +111 -0

111 lines not on this page · raw message

package/libvirt/S91virtlogd new file +65 -0

65 lines not on this page · raw message

package/libvirt/S92libvirtd new file +132 -0

132 lines not on this page · raw message

package/libvirt/libvirt.hash new file +3 -0
new file mode 100644
index 0000000000..93104cf5e4
@@ -0,0 +1,3 @@
+# locally computed
+sha256 586ebcf220369d08a07c6cc17035e8a91bb3741e4300199459904e9e02478be7  libvirt-6.4.0.tar.xz
+sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643  COPYING
package/libvirt/libvirt.mk new file +389 -0

389 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v7 1/1 package/libvirt: new package

In reply to Jared Bents

Hello Jared,

Quoted 8 lines · On Tue, 30 Jun 2020 16:16:41 -0500 Jared Bents…

Libvirt is collection of software that provides a convenient way to manage virtual machines and other virtualization functionality, such as storage and network interface management. These software pieces include an API library, a daemon (libvirtd), and a command line utility (virsh).

   http://libvirt.org/

So, I was having a look at this package, which has been waiting for too long. I think one thing that is holding off the package from being merged is that this patch is quite long, and doing a lot of things. Do you think it would be possible to split it into several parts ? For example, the qemu and lxc support could be additional patches. Even perhaps the init scripts could be added separately, since they are non-trivial and will need their own discussion. This would help get the base libvirt package merged, and then discuss on top of each it each addition separately.

Would this make sense?

I've nevertheless spotted a few things, see below.

package/libvirt/Config.in line 6

Quoted 12 lines
package/libvirt/Config.in new file +6 -0
new file mode 100644
index 0000000000..2a82c3146d
@@ -0,0 +1,111 @@
+config BR2_PACKAGE_LIBVIRT
+	bool "libvirt"
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_aarch64 || BR2_i386 || BR2_x86_64 # dmidecode
+	depends on BR2_PACKAGE_HAS_UDEV
+	select BR2_PACKAGE_GNUTLS

gnutls has:

depends on !BR2_STATIC_LIBS
depends on BR2_USE_WCHAR

which you need to propagate here.

package/libvirt/Config.in line 7

Quoted 1 line
package/libvirt/Config.in new file +1 -0
+	select BR2_PACKAGE_LIBTIRPC if !BR2_TOOLCHAIN_HAS_NATIVE_RPC

libtirpc has a BR2_TOOLCHAIN_HAS_THREADS dependency

package/libvirt/Config.in line 10

Quoted 3 lines
package/libvirt/Config.in new file +3 -0
+	# configure: You must install the pciaccess module to build with udev
+	select BR2_PACKAGE_LIBPCIACCESS
+	select BR2_PACKAGE_LIBGLIB2

libglib2 has BR2_TOOLCHAIN_HAS_THREADS, BR2_USE_WCHAR dependencies.

package/libvirt/Config.in line 14

Quoted 4 lines
package/libvirt/Config.in new file +4 -0
+	select BR2_PACKAGE_LIBXML2
+	# run-time dependencies
+	select BR2_PACKAGE_CGROUPFS_MOUNT if !BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_DMIDECODE

It feels odd that it requires dmidecode. Is it really true ?

If so, could you add a BR2_PACKAGE_DMIDECODE_ARCH_SUPPORTS, use it in package/dmidecode/Config.in and package/collectd/Config.in.

Then, in libvirt, you can do:

config BR2_PACKAGE_LIBVIRT_ARCH_SUPPORTS
bool
default y if BR2_PACKAGE_DMIDECODE_ARCH_SUPPORTS

you will see later why.

package/libvirt/Config.in line 26

Quoted 3 lines
package/libvirt/Config.in new file +3 -0
+if BR2_PACKAGE_LIBVIRT
+
+# The daemon requires remote support.

I am not sure what this means / how this comment is useful.

package/libvirt/Config.in line 30

Quoted 4 lines
package/libvirt/Config.in new file +4 -0
+config BR2_PACKAGE_LIBVIRT_DAEMON
+	bool "libvirtd"
+	default y
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS

Can we turn this into a "select" ?

package/libvirt/Config.in line 34

Quoted 4 lines
package/libvirt/Config.in new file +4 -0
+	select BR2_PACKAGE_DNSMASQ
+	select BR2_PACKAGE_EBTABLES
+	select BR2_PACKAGE_IPTABLES
+	select BR2_PACKAGE_IPROUTE2

iproute2 needs kernel headers >= 3.4

Quoted 5 lines
package/libvirt/Config.in new file +5 -0
+	# These are required because there is no way to unequivocally select a modern netcat
+	select BR2_PACKAGE_NMAP      if !BR2_PACKAGE_NETCAT_OPENBSD
+	select BR2_PACKAGE_NMAP_NCAT if !BR2_PACKAGE_NETCAT_OPENBSD
+	select BR2_PACKAGE_RADVD
+	help

package/libvirt/Config.in line 49

Quoted 10 lines
package/libvirt/Config.in new file +10 -0
+	  Build the libvirt daemon (libvirtd) otherwise build only the
+	  utility programs.
+
+# Stateful drivers are useful only when building the daemon.
+if BR2_PACKAGE_LIBVIRT_DAEMON
+
+config BR2_PACKAGE_LIBVIRT_QEMU
+	bool "qemu"
+	depends on BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS # libseccomp->qemu
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12  # libseccomp->qemu

I'm not sure what you mean by "libseccomp->qemu". These two dependencies are needed by libseccomp, and that's it.

package/libvirt/Config.in line 52

Quoted 3 lines
package/libvirt/Config.in new file +3 -0
+	depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
+	select BR2_PACKAGE_HWDATA         # libpciaccess->qemu
+	select BR2_PACKAGE_HWDATA_PCI_IDS # libpciaccess->qemu

Not clear what the comments libpciaccess->qemu mean here.

package/libvirt/Config.in line 62

Quoted 10 lines
package/libvirt/Config.in new file +10 -0
+	select BR2_PACKAGE_LIBSECCOMP
+	select BR2_PACKAGE_QEMU
+	select BR2_PACKAGE_QEMU_SYSTEM if BR2_PACKAGE_QEMU_CUSTOM_TARGETS = ""
+	select BR2_PACKAGE_YAJL
+	help
+	  QEMU/KVM support
+
+comment "qemu is not supported on this architecture"
+	depends on !BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET \
+		|| !BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS

We normally don't put comments about architecture dependencies.

package/libvirt/Config.in line 71

Quoted 3 lines
package/libvirt/Config.in new file +3 -0
+config BR2_PACKAGE_LIBVIRT_LXC
+	bool "lxc"
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # lxc

LXC also needs headers >= 3.0, which you capture properly in the comment below.

package/libvirt/Config.in line 77

Quoted 6 lines
package/libvirt/Config.in new file +6 -0
+	select BR2_PACKAGE_LXC
+	help
+	  Linux Container support
+
+comment "lxc needs a toolchain w/ threads, headers >= 3.0, dynamic library, gcc >= 4.7"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7

The comment doesn't match the actual dependencies.

package/libvirt/Config.in line 91

Quoted 13 lines
package/libvirt/Config.in new file +13 -0
+endif
+
+comment "libvirtd needs 'nmap-ncat' or 'netcat-openbsd'"
+	depends on BR2_USE_MMU
+	depends on !BR2_STATIC_LIBS
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+
+comment "libvirtd needs 'nmap-ncat' or 'netcat-openbsd' but netcat is selected"
+	depends on BR2_USE_MMU
+	depends on !BR2_STATIC_LIBS
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_PACKAGE_NETCAT

Why do we need those comments ? Aren't you already ensuring above using the NMAP_NCAT select that you will have a good enough netcat implementation ?

package/libvirt/Config.in line 96

Quoted 4 lines
package/libvirt/Config.in new file +4 -0
+endif
+
+comment "libvirt needs udev /dev management"
+	depends on BR2_USE_MMU

You need:

depends on BR2_PACKAGE_LIBVIRT_ARCH_SUPPORTS

here.

package/libvirt/Config.in line 104

Quoted 8 lines
package/libvirt/Config.in new file +8 -0
+	depends on !BR2_PACKAGE_HAS_UDEV
+
+comment "libvirt needs a toolchain w/ headers >= 3.12"
+	depends on BR2_USE_MMU
+	depends on BR2_PACKAGE_HAS_UDEV
+	depends on !BR2_PACKAGE_NETCAT
+	depends on !BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS || \
+		!BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12

Why is libseccomp coming into play here ? And netcat ? The kernel headers dependencies are normally listed together with the comment below.

package/libvirt/Config.in line 111

Quoted 7 lines
package/libvirt/Config.in new file +7 -0
+
+comment "libvirt needs a toolchain w/ threads, dynamic library"
+	depends on BR2_USE_MMU
+	depends on BR2_PACKAGE_HAS_UDEV
+	depends on !BR2_PACKAGE_NETCAT
+	depends on BR2_STATIC_LIBS || !BR2_USE_MMU || \
+		!BR2_TOOLCHAIN_HAS_THREADS

So here you have the threads dependency, but this dependency does not exist on the top level BR2_PACKAGE_LIBVIRT option. Ditto for BR2_STATIC_LIBS.

To me, this is another sign that this patch is doing too much stuff at
once: we can hardly verify that all those dependencies are correct.

package/libvirt/S91virtlogd

Quoted 5 lines
package/libvirt/S91virtlogd new file +0 -0
new file mode 100644
index 0000000000..03d17b5dbd

This init script looks reasonable to me.

package/libvirt/S92libvirtd

Quoted 5 lines
package/libvirt/S92libvirtd new file +0 -0
new file mode 100644
index 0000000000..736519f3d0

This one feels a lot more custom/specific, with the module loading logic, the dnsmasq handling, etc. Having the libvirt init script do start-stop-daemon actions on dnsmasq feels odd.

Again, I believe this is trying to solve too many problems in one-go.

Quoted 14 lines
package/libvirt/libvirt.mk new file +8 -0
new file mode 100644
index 0000000000..c7ee5dbed3
@@ -0,0 +1,389 @@
+################################################################################
+#
+# libvirt
+#
+################################################################################
+
+LIBVIRT_VERSION = 6.4.0
+LIBVIRT_SITE = https://libvirt.org/sources

package/libvirt/libvirt.mk line 18

Quoted 10 lines
package/libvirt/libvirt.mk new file +10 -0
+LIBVIRT_SOURCE = libvirt-$(LIBVIRT_VERSION).tar.xz
+LIBVIRT_LICENSE = LGPL-2.1+
+LIBVIRT_LICENSE_FILES = COPYING
+LIBVIRT_DEPENDENCIES = \
+	host-nfs-utils \
+	host-python-docutils \
+	gnutls \
+	libxml2 \
+	libglib2 \
+	udev

You're selecting libpciaccess but not depending on it here ?

Quoted 22 lines
package/libvirt/libvirt.mk new file +22 -0
+LIBVIRT_CONF_OPTS = \
+	--disable-rpath \
+	--without-apparmor \
+	--without-bhyve \
+	--without-dtrace \
+	--without-esx \
+	--without-firewalld \
+	--without-firewalld-zone \
+	--without-glusterfs \
+	--without-hal \
+	--with-host-validate \
+	--without-hyperv \
+	--with-init-script=$(if $(BR2_INIT_SYSTEMD),systemd,none) \
+	--with-interface \
+	--without-libxl \
+	--without-login-shell \
+	--without-netcf \
+	--without-numad \
+	--without-openwsman \
+	--without-openvz \
+	--without-phyp \
+	--without-pm-utils \

package/libvirt/libvirt.mk line 89

Quoted 10 lines
package/libvirt/libvirt.mk new file +10 -0
+	--with-remote \
+	--without-sanlock \
+	--without-secdriver-apparmor \
+	--with-secrets \
+	--without-storage-mpath \
+	--without-storage-iscsi \
+	--without-storage-iscsi-direct \
+	--with-sysctl \
+	--without-test-suite \
+	--with-udev \

So there is a way to get going without udev ?

package/libvirt/libvirt.mk line 217

Quoted 6 lines
package/libvirt/libvirt.mk new file +6 -0
+ifeq ($(BR2_PACKAGE_LIBPCIACCESS),y)
+LIBVIRT_CONF_OPTS += --with-pciaccess
+LIBVIRT_DEPENDENCIES += libpciaccess
+else
+LIBVIRT_CONF_OPTS += --without-pciaccess
+endif

Ah, so libpciaccess is an optional dependency in the end ?

package/libvirt/libvirt.mk line 253

Quoted 5 lines
package/libvirt/libvirt.mk new file +5 -0
+ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
+LIBVIRT_CONF_OPTS += --with-selinux --with-secdriver-selinux
+LIBVIRT_DEPENDENCIES += libselinux
+else
+LIBVIRT_CONF_OPTS += --without-selinux --with-selinux-mount=/sys/fs/selinux \

You're providing the SELinux mount path when selinux is disabled ?

package/libvirt/libvirt.mk line 295

Quoted 11 lines
package/libvirt/libvirt.mk new file +11 -0
+define LIBVIRT_INSTALL_UDEV_RULES
+	$(INSTALL) -D -m 644 package/libvirt/90-kvm.rules \
+		$(TARGET_DIR)/etc/udev/rules.d/90-kvm.rules
+endef
+LIBVIRT_POST_INSTALL_TARGET_HOOKS += LIBVIRT_INSTALL_UDEV_RULES
+
+define LIBVIRT_FIX_PO_MAKEFILE_IN_IN
+	test ! -f $(@D)/po/Makefile.in.in || \
+	$(SED) 's/GETTEXT_MACRO_VERSION = 0.17/GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@/' \
+		$(@D)/po/Makefile.in.in
+endef

This probably needs a comment.

Quoted 53 lines
package/libvirt/libvirt.mk new file +53 -0
+LIBVIRT_PRE_PATCH_HOOKS += LIBVIRT_FIX_PO_MAKEFILE_IN_IN
+
+# Adjust diretory ownerships and permissions. Notice /var/log is a symlink to
+# /tmp in the default sysvinit skeleton, so some directories may disappear at
+# run-time. Set the permissions anyway, since they are valid for the default
+# systemd skeleton.
+define LIBVIRT_PERMISSIONS
+	/etc/libvirt                             d  700  root  root  -  -  -  -  -
+	/etc/libvirt/nwfilter                    d  700  root  root  -  -  -  -  -
+	/var/lib/libvirt                         d  755  root  root  -  -  -  -  -
+	/var/lib/libvirt/boot                    d  711  root  root  -  -  -  -  -
+	/var/lib/libvirt/dnsmasq                 d  755  root  root  -  -  -  -  -
+	/var/lib/libvirt/filesystems             d  711  root  root  -  -  -  -  -
+	/var/lib/libvirt/images                  d  711  root  root  -  -  -  -  -
+	/var/lib/libvirt/network                 d  700  root  root  -  -  -  -  -
+	/var/lib/libvirt/qemu                    d  751  qemu  kvm   -  -  -  -  -
+	/var/lib/libvirt/qemu/autostart          d  700  root  root  -  -  -  -  -
+	/var/lib/libvirt/qemu/networks           d  700  root  root  -  -  -  -  -
+	/var/lib/libvirt/qemu/networks/autostart d  700  root  root  -  -  -  -  -
+	/var/lib/libvirt/qemu/channel            d  755  qemu  kvm   -  -  -  -  -
+	/var/lib/libvirt/qemu/channel/target     d  755  qemu  kvm   -  -  -  -  -
+	/var/lib/libvirt/qemu/dump               d  755  qemu  kvm   -  -  -  -  -
+	/var/lib/libvirt/qemu/nvram              d  755  qemu  kvm   -  -  -  -  -
+	/var/lib/libvirt/qemu/save               d  755  qemu  kvm   -  -  -  -  -
+	/var/lib/libvirt/qemu/snapshot           d  755  qemu  kvm   -  -  -  -  -
+	/var/lib/libvirt/secrets                 d  700  root  root  -  -  -  -  -
+	/var/lib/libvirt/storage                 d  755  root  root  -  -  -  -  -
+	/var/lib/libvirt/storage/autostart       d  755  root  root  -  -  -  -  -
+	/var/cache/libvirt                       d  711  root  root  -  -  -  -  -
+	/var/cache/libvirt/lxc                   d  750  root  root  -  -  -  -  -
+	/var/cache/libvirt/qemu                  d  750  qemu  kvm   -  -  -  -  -
+	/var/cache/libvirt/qemu/capabilities     d  755  root  root  -  -  -  -  -
+	/var/log/libvirt                         d  700  root  root  -  -  -  -  -
+	/var/log/libvirt/lxc                     d  750  root  root  -  -  -  -  -
+	/var/log/libvirt/qemu                    d  750  root  root  -  -  -  -  -
+	/var/log/swtpm                           d  755  root  root  -  -  -  -  -
+	/var/log/swtpm/libvirt                   d  755  root  root  -  -  -  -  -
+	/var/log/swtpm/libvirt/qemu              d  711  root  root  -  -  -  -  -
+endef
+
+# libvirt may need to create persistent files (e.g. VM definitions) in these
+# directories. Move them to /var/lib because /etc may be on a read-only or
+# volatile (initramfs) filesystem. We could tweak the code to change these
+# paths but the patch would be large and would break compatibility with
+# ordinary installations and with the documentation.
+define LIBVIRT_CREATE_SYMLINKS
+	$(INSTALL) -m 700 -d $(TARGET_DIR)/etc/libvirt
+	$(INSTALL) -m 755 -d $(TARGET_DIR)/var/lib/libvirt
+	$(INSTALL) -m 751 -d $(TARGET_DIR)/var/lib/libvirt/qemu
+	$(INSTALL) -m 700 -d $(TARGET_DIR)/var/lib/libvirt/secrets
+	$(INSTALL) -m 755 -d $(TARGET_DIR)/var/lib/libvirt/storage
+	ln -s -f ../../var/lib/libvirt/qemu $(TARGET_DIR)/etc/libvirt/
+	ln -s -f ../../var/lib/libvirt/secrets $(TARGET_DIR)/etc/libvirt/

package/libvirt/libvirt.mk line 359

Quoted 10 lines
package/libvirt/libvirt.mk new file +10 -0
+	ln -s -f ../../var/lib/libvirt/storage $(TARGET_DIR)/etc/libvirt/
+endef
+
+LIBVIRT_PRE_INSTALL_TARGET_HOOKS += LIBVIRT_CREATE_SYMLINKS
+
+# Remove directories that conflict with the default skeleton. They will be
+# created by the daemon at run-time.
+define LIBVIRT_PURGE_TMPDIR
+	rm -rf $(TARGET_DIR)/var/{cache,log,run}/libvirt
+endef

I'm a bit confusing here, since you're setting permissions for /var/cache/libvirt and /var/log/libvirt in LIBVIRT_PERMISSIONS.

package/libvirt/libvirt.mk line 365

Quoted 6 lines
package/libvirt/libvirt.mk new file +6 -0
+
+LIBVIRT_POST_INSTALL_TARGET_HOOKS += LIBVIRT_PURGE_TMPDIR
+
+ifeq ($(BR2_PACKAGE_LIBVIRT_QEMU),y)
+define LIBVIRT_USERS
+	qemu -1 kvm -1 * - - - Libvirt qemu/kvm daemon

Is it sensible for something called "libvirt" to create a user named "qemu" in a group named "kvm" ? Is it the typically installation strategy of libvirt on other systems ?

package/libvirt/libvirt.mk line 374

Quoted 6 lines
package/libvirt/libvirt.mk new file +6 -0
+ifeq ($(BR2_PACKAGE_LIBVIRT_DAEMON),y)
+define LIBVIRT_INSTALL_INIT_SYSV
+	$(INSTALL) -m 755 -d $(TARGET_DIR)/etc/init.d
+	$(INSTALL) -m 755 -t $(TARGET_DIR)/etc/init.d \
+		package/libvirt/S91virtlogd \
+		package/libvirt/S92libvirtd

I'd prefer our traditional:

	$(INSTALL) -D -m 0755 package/libvirt/S91virtlogd $(TARGET_DIR)/etc/init.d/S91virtlogd
	$(INSTALL) -D -m 0755 package/libvirt/S92libvirtd $(TARGET_DIR)/etc/init.d/S92libvirtd

package/libvirt/libvirt.mk line 385

Quoted 11 lines
package/libvirt/libvirt.mk new file +11 -0
+endef
+define LIBVIRT_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -m 755 -d $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -s -f ../../../../usr/lib/systemd/system/libvirtd.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/libvirtd.service
+	$(INSTALL) -m 755 -d $(TARGET_DIR)/etc/systemd/system/sockets.target.wants
+	ln -s -f ../../../../usr/lib/systemd/system/virtlockd.socket \
+		../../../../usr/lib/systemd/system/virtlogd.socket \
+		../../../../usr/lib/systemd/system/libvirtd.socket \
+		../../../../usr/lib/systemd/system/libvirtd-ro.socket \
+		$(TARGET_DIR)/etc/systemd/system/sockets.target.wants

I think this is no longer needed now that we have SYSTEMD_PRESET_ALL that gets called at the end of the build.

As suggested, could you split up that patches into simpler chunks so that we can make progress in the review and merging ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com