I set pkg-systemd-maintain...@lists.alioth.debian.org to CC on this as it is almost more a dh_*systemd* question/bug than of libvirt. Libvirt just happens to be the package getting into this situation. And their expertise might help to resolve this bug (#905772)
Trying an interim TL;DR: - Service A - --no-stop-on-upgrade A Requires A1.socket A Requires A2.socket - Service B - --restart-after-upgrade B Requires=A1.socket - A and B have also sysV scripts. - d/rules calls dh_installinit and dh_systemd_start - maintscripts get: - invoke.rc start A - ok - invoke.rc restart B - ok - deb-systemd-invoke A.socket - this will restart A.service and breaks --no-stop-on-upgrade This is confusing enough - re-summarize the approaches I had so far. Remember: - when there is a sysV script it will call invoke.rc - without sysV script it will call deb-systemd-invoke Original Issue: - invoke.rc on virtlogd - this will realize the new dependency to virtlogd-admin.socket - virtlogd-admin.socket can't be started because virtlogd-admin.socket: Socket service virtlogd.service already active, refusing. - virtlogd.service is running fine, but the start returns RC!=0 - that makes the upgrade fail Fix I: - drop both sysV scripts (virtlogd/libvirtd) - virtlogd will be started via deb-systemd-invoke This ignores errors in the postinst and is fine on upgrade - but libvirtd being taken over by deb-systemd-invoke is bad - the dh_systemd_start checks the service file and adds dependencies to the line deb-systemd-invoke restart 'libvirtd.service' 'virtlockd.socket' 'virtlogd.socket' - it knows that to restart a socket the service has to be stopped and started - so virtlogd is restarted ignoring the --no-restart-on-upgrade of the actual virtlogd service Fix II: - drop only virtlogd sysV script - virtlogd will be started via deb-systemd-invoke This ignores errors in the postinst and is fine on upgrade - libvirtd will continue to be started by invoke.rc which will restart "just" libvirtd (from dh_installinit) - but dh_systemd_start will have added a restart section deb-systemd-invoke $_dh_action 'virtlockd.socket' 'virtlogd.socket' >/dev/null || true - this will still restart the virtlogd service which has originally dh_installinit -p libvirt-daemon-system --name=virtlogd --no-restart-on-upgrade - We have two dh-systemd_start calls in d/rules, assuming retain order dh_systemd_start -p libvirt-daemon-system --restart-after-upgrade libvirtd.service is the one which makes it generate the restart on the sockets. It seems to realize that libvirtd will be started by invoke.rc, so it leaves that out, but will trigger the two dependencies. Fix III: - drop virtlogd sysV script and change the dh_systemds_start order - hope is that the dh_systemd_start of libvirtd considers the .socket files already handled and would no more add them with restart due to dependencies. - It changed the order in the generated maintainer script - But the section triggered by libvirtd.service still adds the sockets to the restart action deb-systemd-invoke $_dh_action 'virtlockd.socket' 'virtlogd.socket' >/dev/null || true - Please do mind, as in other cases here libvirtd itself is not here as it is taken over by the sysV start via invoke.rc Fix IV: - a try to convert to compat 11 and onyl dh_installsystemd but failed at too many compat-11 implications Fix V: - drop virtlogd sysV script (to fix the original issue) and drop the dh_systemd__start call to libvirtd (to avoid the secondary issue) - Intention: libvirtd (re)start is taken care of by dh_installinit anyway, avoid the bad restarts on virtlogd with this tweak - with that it seems to work, but it might have other implications that I missed - the new virtlogd-admin.socket is down (as it would need to restart the service) - service itself is up and still has the old PID so all is good - installation works, no more breaking the upgrade. I'm not so sure if "Fix V" has other bad implications that I miss. But currently that seems to work as needed - so feel free to consider [1] which is the code for it. I think I'd want/need a "dh_systemd_start --no-dependent-services/sockets" option to intentionally have it generate "just" for libvirt.service and not the sockets it depends on. As mentioned, for all of the complexity pulling in the systemd people might help as well. So I'm eager to see what they will reply here as well. [1]: https://git.launchpad.net/~libvirt-maintainers/ubuntu/+source/libvirt/commit/?h=ubuntu/cosmic-4.6&id=16bece58d55e50ca6d192714a3581ef981974288