]> xenbits.xensource.com Git - libvirt.git/commitdiff
systemd: Make modular daemons conflict with libvirtd
authorAndrea Bolognani <abologna@redhat.com>
Mon, 25 Sep 2023 15:24:10 +0000 (17:24 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 2 Oct 2023 08:41:07 +0000 (10:41 +0200)
We want to make sure that, at any given time, we have either the
modular daemons or the monolithic one running, never both. In
order to achieve that, make every single modular unit conflict
with the corresponding libvirtd unit.

We set both Conflicts=libvirtd.unit and After=libvirtd.unit: this
tells systemd that, whenever virtfood.unit and libvirtd.unit are
part of the same transaction, the former should win out.

Thanks to this, if both the modular daemons and the monolithic
one have been enabled because of outdated automation or a simple
mistake of the administrator, the request to start libvirtd at
boot will be ignored and the result will be a regular modular
deployment.

If the request to start libvirtd is made when the modular daemons
are already running, we have no way to prevent systemd from
complying with that request; however, thanks to the way the
conflict relationship has been declared, they will be shut down
cleanly before libvirtd is started. From the user's point of
view, the transition from modular to monolithic will be
completely transparent: it's basically the same scenario as a
regular package upgrade, just with an extra twist.

Note that, while switching from modular to monolithic at runtime
happens automatically, going back requires manual intervention,
i.e. starting all the necessary sockets one by one. That's okay:
the goal here is to prevent misconfiguration and force of habit
to accidentally disrupt a working setup, not to encourage the
scenario. In a correctly configured and managed host, it should
never occur.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/virtd-admin.socket.in
src/virtd-ro.socket.in
src/virtd-tcp.socket.in
src/virtd-tls.socket.in
src/virtd.service.in
src/virtd.socket.in

index 39bb0badeae2f149871e49d0c766882b7b898474..42cc1f670fa97f1f1f236b116a96fa12c8982f4f 100644 (file)
@@ -3,6 +3,8 @@ Description=@name@ admin socket
 Before=@service@.service
 BindsTo=@service@.socket
 After=@service@.socket
+Conflicts=libvirtd-admin.socket
+After=libvirtd-admin.socket
 
 [Socket]
 ListenStream=@runstatedir@/libvirt/@sockprefix@-admin-sock
index b7b7ae0dd854111151b5f78926b52310bc74d26d..7b8cbdba2030776203890ecbdd6bbaa2d3be0397 100644 (file)
@@ -3,6 +3,8 @@ Description=@name@ local read-only socket
 Before=@service@.service
 BindsTo=@service@.socket
 After=@service@.socket
+Conflicts=libvirtd-ro.socket
+After=libvirtd-ro.socket
 
 [Socket]
 ListenStream=@runstatedir@/libvirt/@sockprefix@-sock-ro
index 7c8bcdb525f20b8405ab3c26f36c6b0cf01585aa..9fe90ed0a0fb4264d39155b308eff4f3d0374b67 100644 (file)
@@ -3,6 +3,8 @@ Description=@name@ non-TLS IP socket
 Before=@service@.service
 BindsTo=@service@.socket
 After=@service@.socket
+Conflicts=libvirtd-tcp.socket
+After=libvirtd-tcp.socket
 
 [Socket]
 ListenStream=16509
index c6dceb2d4ec2c46006b7ff9632e43db27d0c5509..bb89daddb52b7aeb8a2415d7cac9aeac9eb0a675 100644 (file)
@@ -3,6 +3,8 @@ Description=@name@ TLS IP socket
 Before=@service@.service
 BindsTo=@service@.socket
 After=@service@.socket
+Conflicts=libvirtd-tls.socket
+After=libvirtd-tls.socket
 
 [Socket]
 ListenStream=16514
index 76f9c60351852f2b2b3385eb6ae9dffc8e128a86..60ab122cbcd09a18cef1ef71d57a7a24c4f487a2 100644 (file)
@@ -1,9 +1,10 @@
 [Unit]
 Description=@name@ daemon
-Conflicts=libvirtd.service
 Requires=@service@.socket
 Requires=@service@-ro.socket
 Requires=@service@-admin.socket
+Conflicts=libvirtd.service
+After=libvirtd.service
 After=network.target
 After=dbus.service
 After=apparmor.service
index aec0708fd472cd72ff795bce6fe4b1d286a1ac25..053dc1c7826ae71e337cbb59545a704beafa1999 100644 (file)
@@ -1,6 +1,8 @@
 [Unit]
 Description=@name@ local socket
 Before=@service@.service
+Conflicts=libvirtd.socket
+After=libvirtd.socket
 
 [Socket]
 ListenStream=@runstatedir@/libvirt/@sockprefix@-sock