[systemd-devel] Still confused with socket activation

Andrei Borzenkov arvidjaar at gmail.com
Wed Feb 3 18:13:35 UTC 2021


02.02.2021 12:43, Ulrich Windl пишет:
> Hi!
> 
> Having:
> ---
> # /usr/lib/systemd/system/virtlockd.service
> [Unit]
> Description=Virtual machine lock manager
> Requires=virtlockd.socket
> Requires=virtlockd-admin.socket

That's always wrong with After for the same units unless you can prove
that both socket units are always ordered Before service unit due to
dependency chain, at least if intention is to ensure socket units are
active *before* service unit. In real life nobody notices it because
both sockets are started much earlier which papers over race condition.

And if after 10 years of software existence everyone still gets it wrong
I strongly suspect something is not right with software, not with everyone.

> Before=libvirtd.service
> ...
> ---
> 
> How would I start both sockets successfully unter program control?

I do not understand what you want to say here, sorry. What "program
control" means? What exactly are you trying to do?

> If I start one socket, I cannot start the other without an error (as libvirtd.service is running already, see my earlier message from last week).

I do not see how starting socket unit is related to starting service
unit. Unless there was incoming traffic on socket. Also I do not
understand why you need to start socket units if you *already* started
service unit. Again, you do not really provide much coherent information
to do any suggestion.

And I do not really understand the reason to use two different socket
units that apparently are always started together and activate the same
service. Just create single socket unit that listens on both sockets.

> If I mask the socket units, I cannot start the libvirtd.service.
> So would I disable the socket units and start libvirtd.service?

You misunderstand what "disable" means in systemd (see remark above).
You cannot disable (in common sense) starting of socket units together
with virtlockd.service because starting of virtlockd.service will always
attempt to start both socket units (that is exactly what Requires/Wants
are about).

Actually if they are "enabled" (in systemd sense) then they are started
very early during boot, long before service unit. What exact problem you
have in this case?

> Unfortunately if someone (update when vendor-preset is enabled) re-enables the socket units, it would break things, so I tried to mask them, but that failed, too.
> error: Could not issue start for prm_virtlockd: Unit virtlockd.socket is masked.
> 
> Regards,
> Ulrich
> 
> 
> 
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 



More information about the systemd-devel mailing list