These contain the part that is common to all existing service
and socket definitions.
Each section of each template ends with a placeholder, which
marks the spot where additional, service-specific lines should
be injected.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/meson.build | 10 ++++++++++
src/virtd-admin.socket.in | 16 ++++++++++++++++
src/virtd-ro.socket.in | 16 ++++++++++++++++
src/virtd-tcp.socket.in | 15 +++++++++++++++
src/virtd-tls.socket.in | 15 +++++++++++++++
src/virtd.service.in | 28 ++++++++++++++++++++++++++++
src/virtd.socket.in | 15 +++++++++++++++
7 files changed, 115 insertions(+)
create mode 100644 src/virtd-admin.socket.in
create mode 100644 src/virtd-ro.socket.in
create mode 100644 src/virtd-tcp.socket.in
create mode 100644 src/virtd-tls.socket.in
create mode 100644 src/virtd.service.in
create mode 100644 src/virtd.socket.in
diff --git a/src/meson.build b/src/meson.build
index fdd15906b9..d7133d1293 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -203,6 +203,8 @@ libvirtd_socket_admin_in = files('remote' /
'libvirtd-admin.socket.in')
# * sockets - array of additional sockets (optional, default [ 'main',
'ro', 'admin' ])
# * service_in - service source file (optional, default remote/libvirtd.service.in)
# * socket_$name_in - additional socket source files (optional, default
remote/libvirtd.socket.in )
+# * service_$name_extra - additional lines for service's [$name] section (optional,
default [])
+# * socket_$name_extra - additional lines for socket's [$name] section (optional,
default [])
# * deps - socket dependencies (optional, default '')
virt_daemon_units = []
@@ -817,11 +819,19 @@ if conf.has('WITH_LIBVIRTD')
'initconfdir': initconfdir,
'name': unit['name'],
'service': unit['service'],
+ 'SERVICE': unit['service'].to_upper(),
'sockprefix': unit.get('sockprefix', unit['service']),
'deps': unit.get('deps', ''),
'sockmode': sockmode,
})
+ foreach extra : [ 'service_unit', 'service_service',
'service_install',
+ 'socket_unit', 'socket_socket',
'socket_install' ]
+ extra_key = '@0(a)_extra'.format(extra)
+ extra_value = '\n'.join(unit.get(extra_key, []))
+ unit_conf.set(extra_key, extra_value)
+ endforeach
+
configure_file(
input: unit.get('service_in', service_in_default),
output: '@0@.service'.format(unit['service']),
diff --git a/src/virtd-admin.socket.in b/src/virtd-admin.socket.in
new file mode 100644
index 0000000000..3a09951b12
--- /dev/null
+++ b/src/virtd-admin.socket.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=@name@ admin socket
+Before=@service@.service
+BindsTo=@service@.socket
+After=@service@.socket
+@socket_unit_extra@
+
+[Socket]
+ListenStream=@runstatedir@/libvirt/@sockprefix@-admin-sock
+Service=@service@.service
+SocketMode=0600
+@socket_socket_extra@
+
+[Install]
+WantedBy=sockets.target
+@socket_install_extra@
diff --git a/src/virtd-ro.socket.in b/src/virtd-ro.socket.in
new file mode 100644
index 0000000000..e882f25a7b
--- /dev/null
+++ b/src/virtd-ro.socket.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=@name@ local read-only socket
+Before=@service@.service
+BindsTo=@service@.socket
+After=@service@.socket
+@socket_unit_extra@
+
+[Socket]
+ListenStream=@runstatedir@/libvirt/@sockprefix@-sock-ro
+Service=@service@.service
+SocketMode=0666
+@socket_socket_extra@
+
+[Install]
+WantedBy=sockets.target
+@socket_install_extra@
diff --git a/src/virtd-tcp.socket.in b/src/virtd-tcp.socket.in
new file mode 100644
index 0000000000..26c6dfa75b
--- /dev/null
+++ b/src/virtd-tcp.socket.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=@name@ non-TLS IP socket
+Before=@service@.service
+BindsTo=@service@.socket
+After=@service@.socket
+@socket_unit_extra@
+
+[Socket]
+ListenStream=16509
+Service=@service@.service
+@socket_socket_extra@
+
+[Install]
+WantedBy=sockets.target
+@socket_install_extra@
diff --git a/src/virtd-tls.socket.in b/src/virtd-tls.socket.in
new file mode 100644
index 0000000000..077c320cce
--- /dev/null
+++ b/src/virtd-tls.socket.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=@name@ TLS IP socket
+Before=@service@.service
+BindsTo=@service@.socket
+After=@service@.socket
+@socket_unit_extra@
+
+[Socket]
+ListenStream=16514
+Service=@service@.service
+@socket_socket_extra@
+
+[Install]
+WantedBy=sockets.target
+@socket_install_extra@
diff --git a/src/virtd.service.in b/src/virtd.service.in
new file mode 100644
index 0000000000..c9afecad73
--- /dev/null
+++ b/src/virtd.service.in
@@ -0,0 +1,28 @@
+[Unit]
+Description=@name@ daemon
+Conflicts=libvirtd.service
+Requires=@service@.socket
+Requires=@service(a)-ro.socket
+Requires=@service(a)-admin.socket
+After=network.target
+After=dbus.service
+After=apparmor.service
+Documentation=man:@service@(8)
+Documentation=https://libvirt.org
+@service_unit_extra@
+
+[Service]
+Type=notify
+Environment=@SERVICE@_ARGS="--timeout 120"
+EnvironmentFile=-@initconfdir@/@service@
+ExecStart=@sbindir@/@service@ $@SERVICE@_ARGS
+ExecReload=/bin/kill -HUP $MAINPID
+Restart=on-failure
+@service_service_extra@
+
+[Install]
+WantedBy=multi-user.target
+Also=@service@.socket
+Also=@service(a)-ro.socket
+Also=@service(a)-admin.socket
+@service_install_extra@
diff --git a/src/virtd.socket.in b/src/virtd.socket.in
new file mode 100644
index 0000000000..278f59ef1c
--- /dev/null
+++ b/src/virtd.socket.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=@name@ local socket
+Before=@service@.service
+@socket_unit_extra@
+
+[Socket]
+ListenStream=@runstatedir@/libvirt/@sockprefix@-sock
+Service=@service@.service
+SocketMode=@sockmode@
+RemoveOnStop=yes
+@socket_socket_extra@
+
+[Install]
+WantedBy=sockets.target
+@socket_install_extra@
--
2.41.0