Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libvirt for openSUSE:Factory checked in at 2022-12-29 13:08:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libvirt (Old) and /work/SRC/openSUSE:Factory/.libvirt.new.1563 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libvirt" Thu Dec 29 13:08:50 2022 rev:366 rq:1045553 version:8.10.0 Changes: -------- --- /work/SRC/openSUSE:Factory/libvirt/libvirt.changes 2022-12-07 17:34:48.704488778 +0100 +++ /work/SRC/openSUSE:Factory/.libvirt.new.1563/libvirt.changes 2022-12-29 13:08:56.200874819 +0100 @@ -1,0 +2,7 @@ +Tue Dec 27 17:49:38 UTC 2022 - James Fehlig <jfeh...@suse.com> + +- Fix lxc container initialization with systemd and hybrid cgroups + suse-fix-lxc-container-init.patch + boo#1183247 + +------------------------------------------------------------------- New: ---- suse-fix-lxc-container-init.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libvirt.spec ++++++ --- /var/tmp/diff_new_pack.wb6Wfw/_old 2022-12-29 13:08:57.660883701 +0100 +++ /var/tmp/diff_new_pack.wb6Wfw/_new 2022-12-29 13:08:57.664883726 +0100 @@ -326,6 +326,7 @@ Patch208: suse-libxl-disable-autoballoon.patch Patch209: suse-xen-ovmf-paths.patch Patch210: virt-create-rootfs.patch +Patch211: suse-fix-lxc-container-init.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %description ++++++ suse-fix-lxc-container-init.patch ++++++ >From 5152717ba78312ec5415ba19ed83bb313b7670f8 Mon Sep 17 00:00:00 2001 From: Eric van Blokland <m...@ericvanblokland.nl> Date: Wed, 7 Dec 2022 21:45:11 +0100 Subject: [PATCH] Fix lxc container initialization with systemd and hybrid cgroups In an environment with hybrid cgroups and systemd the v2 backend is not available. This causes a few checks to fail during container initialization. To work around this we retrieve the lxc control process child process pid (the process that is registered with machined) and perform the checks using that pid. Signed-off-by: Eric van Blokland <m...@ericvanblokland.nl> --- src/lxc/lxc_process.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) Index: libvirt-8.10.0/src/lxc/lxc_process.c =================================================================== --- libvirt-8.10.0.orig/src/lxc/lxc_process.c +++ libvirt-8.10.0/src/lxc/lxc_process.c @@ -49,6 +49,9 @@ #include "virprocess.h" #include "netdev_bandwidth_conf.h" #include "virutil.h" +#include "virstring.h" +#include "vircgroupbackend.h" +#include "virsystemd.h" #define VIR_FROM_THIS VIR_FROM_LXC @@ -1200,6 +1203,11 @@ int virLXCProcessStart(virLXCDriver * dr int status; g_autofree char *pidfile = NULL; unsigned int stopFlags = 0; + virCgroupBackend **cgroupBackends = virCgroupBackendGetAll(); + g_autofree char *pidFile = NULL; + g_autofree char *pidStr = NULL; + g_auto(GStrv) pidList = NULL; + pid_t checkPid = 0; if (virCgroupNewSelf(&selfcgroup) < 0) return -1; @@ -1463,7 +1471,28 @@ int virLXCProcessStart(virLXCDriver * dr goto cleanup; } - priv->machineName = virLXCDomainGetMachineName(vm->def, vm->pid); + /* In an environment with hybrid cgroups and systemd the v2 backend is not available. + * Systemd however depends on V2 for unit naming. This causes the next two checks to fail. + * To work around this issue we retrieve the actual container pid and check on that instead. */ + if (virSystemdHasMachined() == 0 && cgroupBackends[VIR_CGROUP_BACKEND_TYPE_V2]->available() == false) { + pidFile = g_strdup_printf("/proc/%lld/task/%lld/children", (long long int)vm->pid, (long long int)vm->pid); + if (virFileReadAll(pidFile, 1024 * 1024, &pidStr) < 0) + goto cleanup; + + virTrimSpaces(pidStr, NULL); + + pidList = g_strsplit(pidStr, " ", 2); + if (!pidList) + goto cleanup; + + if (virStrToLong_i(pidList[0], NULL, 10, &checkPid) < 0) + goto cleanup; + + } else { + checkPid = vm->pid; + } + + priv->machineName = virLXCDomainGetMachineName(vm->def, checkPid); if (!priv->machineName) goto cleanup; @@ -1472,7 +1501,7 @@ int virLXCProcessStart(virLXCDriver * dr * more reliable way to kill everything off if something * goes wrong from here onwards ... */ if (virCgroupNewDetectMachine(vm->def->name, "lxc", - vm->pid, -1, priv->machineName, + checkPid, -1, priv->machineName, &priv->cgroup) < 0) goto cleanup;