[meta-virtualization][PATCH 2/2] libvirt: add secrets PACKAGECONFIG

Zhixiong Chi <[email protected]> Sat, 11 Apr 2026 03:18:42 -0700
Newsgroups org.yoctoproject.lists.meta-virtualization
Message-ID <[email protected]>
After being upgraded to v12.1.0, the new virt-secret-init-encryption.service
has been introduced, and it requires systemd to add openssl to PACKAGECONFIG.
Because systemd-creds encrypt command will be executed in the service file.

Meanwhile this service was added into the dependency chain of the main service
libvirtd.service.

In systemd recipe, the openssl PACKAGECONFIG is disabled at default. Finally
the service file virt-secret-init-encryption.service and libvirtd will be
failed.

So add secrets PACKAGECONFIG for libvirt and conditional removal the new
virt-secret-init-encryption in the libvirt.service.

Signed-off-by: Zhixiong Chi <[email protected]>
---
 recipes-extended/libvirt/libvirt_git.bb | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/recipes-extended/libvirt/libvirt_git.bb b/recipes-extended/libvirt/libvirt_git.bb
index fbee9c5b..3075149b 100644
--- a/recipes-extended/libvirt/libvirt_git.bb
+++ b/recipes-extended/libvirt/libvirt_git.bb
@@ -177,6 +177,8 @@ PACKAGECONFIG[firewalld] = "-Dfirewalld=enabled, -Dfirewalld=disabled,"
 PACKAGECONFIG[libpcap] = "-Dlibpcap=enabled, -Dlibpcap=disabled,libpcap,libpcap"
 PACKAGECONFIG[numad] = "-Dnumad=enabled, -Dnumad=disabled,"
 PACKAGECONFIG[nftables] = ""
+# Require systemd to add openssl to PACKAGECONFIG, so disable it at default.
+PACKAGECONFIG[secrets] = "-Ddriver_secrets=enabled, -Ddriver_secrets=disabled,"
 
 # Enable the Python tool support
 require libvirt-python.inc
@@ -225,6 +227,15 @@ do_install:append() {
                 mv ${D}${prefix}/lib/systemd/system/* ${D}${systemd_system_unitdir}
                 rmdir ${D}${prefix}/lib/systemd/system ${D}${prefix}/lib/systemd
             fi
+
+            if ! ${@bb.utils.contains('PACKAGECONFIG', 'secrets', 'true', 'false', d)}; then
+                sed -i \
+                    -e '/^Requires=virt-secret-init-encryption.service/d' \
+                    -e '/^After=virt-secret-init-encryption.service/d' \
+                    -e '/^Environment=SECRETS_ENCRYPTION_KEY=/d' \
+                    -e '/^LoadCredentialEncrypted=/d' \
+                    ${D}${systemd_system_unitdir}/libvirtd.service
+            fi
 	fi
 
 	# The /run/libvirt directories created by the Makefile are 
-- 
2.49.0