mirror of
https://github.com/libvirt/libvirt.git
synced 2026-07-31 08:38:16 -05:00
Add support for systemd init service
This patch adds support for a systemd init service for libvirtd and libvirt-guests. The libvirtd.service is *not* written to use socket activation, since we want libvirtd to start on boot so it can do guest auto-start. The libvirt-guests.service is pretty lame, just exec'ing the original init script for now. Ideally we would factor out the functionality, into some shared tool. Instead of ./configure --with-init-script=redhat You can now do ./configure --with-init-script=systemd Or better still: ./configure --with-init-script=systemd+redhat We can also now support install of the upstart init script * configure.ac: Add systemd, and systemd+redhat options to --with-init-script option * daemon/Makefile.am: Install systemd services * daemon/libvirtd.sysconf: Add note about unused env variable with systemd * daemon/libvirtd.service.in: libvirtd systemd service unit * libvirt.spec.in: Add scripts to installing systemd services and migrating from legacy init scripts * tools/Makefile.am: Install systemd services * tools/libvirt-guests.init.sh: Rename to tools/libvirt-guests.init.in * tools/libvirt-guests.service.in: systemd service unit
This commit is contained in:
+50
-13
@@ -25,7 +25,6 @@ EXTRA_DIST = \
|
||||
virt-sanlock-cleanup.in \
|
||||
virt-sanlock-cleanup.8 \
|
||||
virsh.pod \
|
||||
libvirt-guests.init.sh \
|
||||
libvirt-guests.sysconf
|
||||
|
||||
DISTCLEANFILES =
|
||||
@@ -153,21 +152,32 @@ install-data-local: install-init
|
||||
|
||||
uninstall-local: uninstall-init
|
||||
|
||||
if LIBVIRT_INIT_SCRIPT_RED_HAT
|
||||
install-init: libvirt-guests.init
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
|
||||
$(INSTALL_SCRIPT) libvirt-guests.init \
|
||||
$(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests
|
||||
install-sysconfig:
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
|
||||
$(INSTALL_DATA) $(srcdir)/libvirt-guests.sysconf \
|
||||
$(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
|
||||
|
||||
uninstall-init:
|
||||
rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests \
|
||||
$(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
|
||||
uninstall-sysconfig:
|
||||
rm -f $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
|
||||
|
||||
EXTRA_DIST += libvirt-guests.init.sh
|
||||
|
||||
if LIBVIRT_INIT_SCRIPT_RED_HAT
|
||||
install-init: libvirt-guests.init install-sysconfig
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
|
||||
$(INSTALL_SCRIPT) libvirt-guests.init \
|
||||
$(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests
|
||||
|
||||
uninstall-init: install-sysconfig
|
||||
rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests
|
||||
|
||||
BUILT_SOURCES += libvirt-guests.init
|
||||
|
||||
else
|
||||
install-init:
|
||||
uninstall-init:
|
||||
endif # LIBVIRT_INIT_SCRIPT_RED_HAT
|
||||
|
||||
libvirt-guests.init: libvirt-guests.init.sh $(top_builddir)/config.status
|
||||
$(AM_V_GEN)sed \
|
||||
-e 's!\@PACKAGE\@!$(PACKAGE)!g' \
|
||||
@@ -179,11 +189,38 @@ libvirt-guests.init: libvirt-guests.init.sh $(top_builddir)/config.status
|
||||
< $< > $@-t && \
|
||||
chmod a+x $@-t && \
|
||||
mv $@-t $@
|
||||
|
||||
|
||||
|
||||
EXTRA_DIST += libvirt-guests.service.in
|
||||
|
||||
if LIBVIRT_INIT_SCRIPT_SYSTEMD
|
||||
install-systemd: libvirt-guests.service install-sysconfig
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/systemd.d
|
||||
$(INSTALL_SCRIPT) libvirt-guests.service \
|
||||
$(DESTDIR)$(sysconfdir)/rc.d/systemd.d/libvirt-guests
|
||||
|
||||
uninstall-systemd: install-sysconfig
|
||||
rm -f $(DESTDIR)$(sysconfdir)/rc.d/systemd.d/libvirt-guests
|
||||
|
||||
BUILT_SOURCES += libvirt-guests.service
|
||||
|
||||
else
|
||||
install-init:
|
||||
uninstall-init:
|
||||
libvirt-guests.init:
|
||||
endif # LIBVIRT_INIT_SCRIPT_RED_HAT
|
||||
install-systemd:
|
||||
uninstall-systemd:
|
||||
endif # LIBVIRT_INIT_SCRIPT_SYSTEMD
|
||||
|
||||
libvirt-guests.service: libvirt-guests.service.in $(top_builddir)/config.status
|
||||
$(AM_V_GEN)sed \
|
||||
-e 's!\@PACKAGE\@!$(PACKAGE)!g' \
|
||||
-e 's!\@bindir\@!$(bindir)!g' \
|
||||
-e 's!\@localedir\@!$(localedir)!g' \
|
||||
-e 's!\@localstatedir\@!$(localstatedir)!g' \
|
||||
-e 's!\@sbindir\@!$(sbindir)!g' \
|
||||
-e 's!\@sysconfdir\@!$(sysconfdir)!g' \
|
||||
< $< > $@-t && \
|
||||
chmod a+x $@-t && \
|
||||
mv $@-t $@
|
||||
|
||||
|
||||
CLEANFILES = $(bin_SCRIPTS)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Suspend Active Libvirt Guests
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=-/etc/sysconfig/libvirt-guests
|
||||
# Hack just call traditional service until we factor
|
||||
# out the code
|
||||
ExecStart=/etc/init.d/libvirt-guests start
|
||||
ExecStop=/etc/init.d/libvirt-guests stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user