From: Daniel P. Berrange berra...@redhat.com
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
In v5:
- Actually include the changes to configure.ac I mentioned
in v4.
* 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
---
configure.ac| 46 ++
daemon/.gitignore |1 +
daemon/Makefile.am | 98 +-
daemon/libvirtd.service.in | 20
daemon/libvirtd.sysconf |3 +
libvirt.spec.in | 93 +++-
po/POTFILES.in |2 +-
tools/Makefile.am | 61 +++-
tools/libvirt-guests.service.in | 13 +
9 files changed, 288 insertions(+), 49 deletions(-)
create mode 100644 daemon/libvirtd.service.in
create mode 100644 tools/libvirt-guests.service.in
diff --git a/configure.ac b/configure.ac
index 3b7535e..58c2740 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,16 +329,41 @@ dnl init script flavor
dnl
AC_MSG_CHECKING([for init script flavor])
AC_ARG_WITH([init-script],
-[AC_HELP_STRING([--with-init-script=@:@redhat|auto|none@:@],
-[Style of init script to install @:@default=auto@:@])])
-if test x$with_init_script = x || test x$with_init_script = xauto; then
-if test $cross_compiling = yes || test ! -f /etc/redhat-release; then
-with_init_script=none
-else
-with_init_script=redhat
-fi
-fi
-AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test x$with_init_script =
xredhat)
+[AC_HELP_STRING([--with-init-script@:@=STYLE@:@],
+[Style of init script to install: redhat, systemd,
systemd+redhat,
+ upstart, auto, none
@:@default=auto@:@])],[],[with_init_script=check])
+init_redhat=no
+init_systemd=no
+init_upstart=no
+case $with_init_script in
+systemd+redhat)
+ init_redhat=yes
+ init_systemd=yes
+ ;;
+systemd)
+ init_systemd=yes
+ ;;
+upstart)
+ init_upstart=yes
+ ;;
+redhat)
+ init_redhat=yes
+ ;;
+none)
+ ;;
+check)
+ if test $cross_compiling != yes test -f /etc/redhat-release; then
+ init_redhat=yes
+ with_init_script=redhat
+ fi
+ ;;
+*)
+ AC_MSG_ERROR([Unknown initscript flavour $with_init_script])
+;;
+esac
+AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test $init_redhat = yes)
+AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_UPSTART], test $init_upstart = yes)
+AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_SYSTEMD], test $init_systemd = yes)
AC_MSG_RESULT($with_init_script)
dnl RHEL-5 has a peculiar version of Xen, which requires some special casing
@@ -2680,6 +2705,7 @@ AC_MSG_NOTICE([ Readline: $lv_use_readline])
AC_MSG_NOTICE([ Python: $with_python])
AC_MSG_NOTICE([ DTrace: $with_dtrace])
AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE])
+AC_MSG_NOTICE([ Init script: $with_init_script])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Privileges])
AC_MSG_NOTICE([])
diff --git a/daemon/.gitignore b/daemon/.gitignore
index ab3d093..2873143 100644
--- a/daemon/.gitignore
+++ b/daemon/.gitignore
@@ -7,6 +7,7 @@ Makefile.in
libvirt_qemud
libvirtd
libvirtd.init
+libvirtd.service
libvirtd*.logrotate
libvirtd.8
libvirtd.8.in
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 59db217..9ccbb5b 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -174,22 +174,25 @@ policyfile = libvirtd.policy-1
endif
endif
-install-data-local: install-init install-data-sasl install-data-polkit \
- install-logrotate
+install-data-local: install-init-redhat install-init-systemd
install-init-upstart \
+ install-data-sasl install-data-polkit \
+ install-logrotate install-sysctl
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt