[Pkg-libvirt-maintainers] Bug#787973: Bug#787973: Please don't use systemctl status in postinst
Guido Günther
agx at sigxcpu.org
Tue Jun 9 09:21:20 UTC 2015
Hi,
On Sun, Jun 07, 2015 at 11:04:45AM +0200, Michael Biebl wrote:
> Package: libvirt-daemon-system
> Version: 1.2.16-2
> Severity: normal
>
> Hi,
>
> I noticed the following in postinst:
>
> # Force virtlockd to reexec if enabled
> if [ -d /run/systemd/system ] && systemctl status virtlockd.service >/dev/null; then
> systemctl reload virtlockd.service
> fi
>
>
> using systemctl status is bad, since it accesses the journal, which can
> be quite costly.
> If you only want to test if a service is active, you can use
> systemctl is-active -q virtlockd.service, which is much more
> lightweight.
> The -q makes sure, you don't need to suppress stdout.
>
> if [ -d /run/systemd/system ] && systemctl is-active -q virtlockd.service ; then
> systemctl reload virtlockd.service
> fi
Thanks for pointing this out. I went for the above solutine since ...
>
> Or even simpler for your use case
> if [ -d /run/systemd/system ] ; then
> systemctl reload-or-try-restart -q virtlockd.service
> fi
... returns 1 if the daemon is not running so we'd have to figure out
why non-zero is reported: failure to restart or not running at all.
> I think reload-or-try-restart does already exactly what you want.
See above but maybe I'm missing something.
Cheers,
-- Guido
>
> Cheers,
> Michael
>
> -- System Information:
> Debian Release: stretch/sid
> APT prefers unstable
> APT policy: (500, 'unstable'), (500, 'stable'), (200, 'experimental')
> Architecture: amd64 (x86_64)
> Foreign Architectures: i386
>
> Kernel: Linux 4.0.0-1-amd64 (SMP w/4 CPU cores)
> Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)
>
> Versions of packages libvirt-daemon-system depends on:
> ii adduser 3.113+nmu3
> ii gettext-base 0.19.4-1
> ii init-system-helpers 1.23
> ii libapparmor1 2.9.2-3
> ii libaudit1 1:2.4-1+b1
> ii libavahi-client3 0.6.31-5
> ii libavahi-common3 0.6.31-5
> ii libblkid1 2.26.2-6
> ii libc6 2.19-18
> ii libcap-ng0 0.7.6-1
> ii libdbus-1-3 1.8.18-1
> ii libdevmapper1.02.1 2:1.02.90-2.2
> ii libgnutls-deb0-28 3.3.15-5
> ii libnl-3-200 3.2.24-2
> ii libnl-route-3-200 3.2.24-2
> ii libnuma1 2.0.10-1
> ii librados2 0.80.9-2
> ii librbd1 0.80.9-2
> ii libsasl2-2 2.1.26.dfsg1-13
> ii libselinux1 2.3-2
> ii libssh2-1 1.5.0-2+b1
> ii libsystemd0 220-5~test0
> ii libvirt-clients 1.2.16-2
> ii libvirt-daemon 1.2.16-2
> ii libvirt0 1.2.16-2
> ii libxen-4.4 4.4.1-9
> ii libxml2 2.9.2+dfsg1-3
> ii libyajl2 2.1.0-2
> ii logrotate 3.8.7-2
> ii policykit-1 0.105-8
>
> Versions of packages libvirt-daemon-system recommends:
> ii bridge-utils 1.5-9
> ii dmidecode 2.12-4
> ii dnsmasq-base 2.72-3.1+b1
> ii ebtables 2.0.10.4-3
> ii iproute2 3.16.0-2
> ii iptables 1.4.21-2+b1
> ii parted 3.2-7
> pn pm-utils <none>
>
> Versions of packages libvirt-daemon-system suggests:
> pn apparmor <none>
> pn auditd <none>
> ii nfs-common 1:1.2.8-9
> ii radvd 1:2.11-1
> ii systemd 220-5~test0
> pn systemtap <none>
>
> -- Configuration Files:
> /etc/libvirt/qemu.conf [Errno 13] Keine Berechtigung: u'/etc/libvirt/qemu.conf'
> /etc/libvirt/qemu/networks/default.xml [Errno 13] Keine Berechtigung: u'/etc/libvirt/qemu/networks/default.xml'
>
> -- no debconf information
>
> _______________________________________________
> Pkg-libvirt-maintainers mailing list
> Pkg-libvirt-maintainers at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-libvirt-maintainers
>
More information about the Pkg-libvirt-maintainers
mailing list