[libvirt] [PATCH] libvirtd: Better initscript error reporting

From time to time I bork my install, and hate it when the initscript returns no info. This patch makes things a bit more clear.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- daemon/libvirtd.init.in | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/daemon/libvirtd.init.in b/daemon/libvirtd.init.in index 071fe2c..c5d4eee 100644 --- a/daemon/libvirtd.init.in +++ b/daemon/libvirtd.init.in @@ -32,8 +32,10 @@ # pidfile: @localstatedir@/run/libvirtd.pid # +LIBVIRTD_BIN="@sbindir@/libvirtd" + # Sanity checks. -[ -x @sbindir@/libvirtd ] || exit 0 +[ ! -e $LIBVIRTD_BIN ] && echo "$LIBVIRTD_BIN not found." && exit 1 # Source function library. . @sysconfdir@/rc.d/init.d/functions -- 1.6.5.2

According to Cole Robinson on 2/24/2010 10:55 AM:
From time to time I bork my install, and hate it when the initscript returns no info. This patch makes things a bit more clear.
+LIBVIRTD_BIN="@sbindir@/libvirtd" + # Sanity checks. -[ -x @sbindir@/libvirtd ] || exit 0 +[ ! -e $LIBVIRTD_BIN ] && echo "$LIBVIRTD_BIN not found." && exit 1
Why the switch from -x to -e? If libvirtd is missing executable permissions, it can now get through this check whereas before it exited early. Group the failure, in case echo also fails (such as for a full disk); also, I'm used to not seeing trailing . on error messages, but it is polite to attribute who's printing the failure. Printing to stderr is also nice. Something like: [...] && { echo "$0: $LIBVIRTD_BIN not found" 2>&1; exit 1; } -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 02/24/2010 01:17 PM, Eric Blake wrote:
According to Cole Robinson on 2/24/2010 10:55 AM:
From time to time I bork my install, and hate it when the initscript returns no info. This patch makes things a bit more clear.
+LIBVIRTD_BIN="@sbindir@/libvirtd" + # Sanity checks. -[ -x @sbindir@/libvirtd ] || exit 0 +[ ! -e $LIBVIRTD_BIN ] && echo "$LIBVIRTD_BIN not found." && exit 1
Why the switch from -x to -e? If libvirtd is missing executable permissions, it can now get through this check whereas before it exited early.
Sorry, I meant to comment about this. I figured in that case we can just let the libvirtd command fail, which should report the lack of permissions. This saves us the hassle of having to report '$BIN not found or lacks execute permissions.' But I guess by that logic we can just drop the check and explicit error reporting altogether: this stuff should really only error if the user screwed up the install, so they can decode 'command not found' and 'permission denied' errors. I'll send a new patch. Thanks, Cole
participants (2)
-
Cole Robinson
-
Eric Blake