summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiangyu Chen <xiangyu.chen@windriver.com>2024-02-21 15:29:42 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-21 22:20:10 +0000
commite31be0b0e6ed6855787ebfbacc15bdbf1b9e511c (patch)
treef57d9b1eb0e602f4ab6cf5348a0db7652efff815
parent8112d617203cff56652d993c265797ba76687696 (diff)
downloadpoky-e31be0b0e6ed6855787ebfbacc15bdbf1b9e511c.tar.gz
systemd-systemctl: fix dead loop when multi services enable each other
libvirt has added a feature that all sockets for a service being enabled when a single one of them is enabled since 9.9.x[1], it likes serviceA enable serviceB, serviceB enable serviceA, that cause our systemctl script trap into a dead loop in postinstall stage, the error message as below: Traceback (most recent call last): File "/usr/lib/python3.8/pathlib.py", line 722, in __str__ return self._str AttributeError: _str During handling of the above exception, another exception occurred: Traceback (most recent call last): File "recipe-sysroot-native/usr/bin/systemctl", line 255, in enable SystemdUnit(self.root, also).enable(unit) File "recipe-sysroot-native/usr/bin/systemctl", line 255, in enable SystemdUnit(self.root, also).enable(unit) File "recipe-sysroot-native/usr/bin/systemctl", line 255, in enable SystemdUnit(self.root, also).enable(unit) [Previous line repeated 988 more times] ...... RecursionError: maximum recursion depth exceeded while calling a Python object Here using an array to record the services which has been enabled to filter the duplicates. Ref: [1] https://github.com/libvirt/libvirt/commit/826931e95a38af8322f8ad069dc89117c6404a00 (From OE-Core rev: 4c45f975310184a773b25b8e7d7ef50fba2f7bd6) Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xmeta/recipes-core/systemd/systemd-systemctl/systemctl7
1 files changed, 4 insertions, 3 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 7fe751b397..2229bc7b6d 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -209,7 +209,7 @@ class SystemdUnit():
209 except KeyError: 209 except KeyError:
210 pass 210 pass
211 211
212 def enable(self, caller_unit=None): 212 def enable(self, units_enabled=[]):
213 # if we're enabling an instance, first extract the actual instance 213 # if we're enabling an instance, first extract the actual instance
214 # then figure out what the template unit is 214 # then figure out what the template unit is
215 template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit) 215 template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit)
@@ -248,8 +248,9 @@ class SystemdUnit():
248 try: 248 try:
249 for also in config.get('Install', 'Also'): 249 for also in config.get('Install', 'Also'):
250 try: 250 try:
251 if caller_unit != also: 251 units_enabled.append(unit)
252 SystemdUnit(self.root, also).enable(unit) 252 if also not in units_enabled:
253 SystemdUnit(self.root, also).enable(units_enabled)
253 except SystemdUnitNotFoundError as e: 254 except SystemdUnitNotFoundError as e:
254 sys.exit("Error: Systemctl also enable issue with %s (%s)" % (service, e.unit)) 255 sys.exit("Error: Systemctl also enable issue with %s (%s)" % (service, e.unit))
255 256