Skip to content
Snippets Groups Projects
Commit 7d7aed44 authored by Laurent Léonard's avatar Laurent Léonard
Browse files

New patch 0010-Debianize-libvirt-guests.patch

parent 12e7a2c2
No related branches found
No related tags found
No related merge requests found
From: =?UTF-8?q?Laurent=20L=C3=A9onard?= <laurent@open-minds.org>
Date: Thu, 9 Dec 2010 22:36:29 +0100
Subject: [PATCH] Debianize libvirt-guests
Origin: vendor
---
tools/libvirt-guests.init.in | 78 +++++++++++++++++------------------------
tools/libvirt-guests.sysconf | 6 ++--
2 files changed, 35 insertions(+), 49 deletions(-)
diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in
index 5dab36b..0fe82fb 100644
--- a/tools/libvirt-guests.init.in
+++ b/tools/libvirt-guests.init.in
@@ -4,8 +4,8 @@
#
### BEGIN INIT INFO
# Provides: libvirt-guests
-# Required-Start: libvirtd
-# Required-Stop: libvirtd
+# Required-Start: $remote_fs libvirt-bin
+# Required-Stop: $remote_fs libvirt-bin
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: suspend/resume libvirt guests on shutdown/boot
@@ -14,32 +14,19 @@
# See http://libvirt.org
### END INIT INFO
-# the following is chkconfig init header
-#
-# libvirt-guests: suspend/resume libvirt guests on shutdown/boot
-#
-# chkconfig: 345 99 01
-# description: This is a script for suspending active libvirt guests \
-# on shutdown and resuming them on next boot \
-# See http://libvirt.org
-#
-
-sysconfdir=@sysconfdir@
-localstatedir=@localstatedir@
-libvirtd=@sbindir@/libvirtd
-
-# Source function library.
-. "$sysconfdir"/rc.d/init.d/functions
+sysconfdir=/etc
+localstatedir=/var
+libvirtd=/usr/sbin/libvirtd
URIS=default
-ON_BOOT=start
-ON_SHUTDOWN=suspend
-SHUTDOWN_TIMEOUT=0
+ON_BOOT=ignore
+ON_SHUTDOWN=shutdown
+SHUTDOWN_TIMEOUT=30
-test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests
+test -f "$sysconfdir"/default/libvirt-guests && . "$sysconfdir"/default/libvirt-guests
LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
-VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
+VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/libvirt-guests
RETVAL=0
@@ -128,7 +115,7 @@ start() {
[ -f "$LISTFILE" ] || { started; return 0; }
if [ "x$ON_BOOT" != xstart ]; then
- echo $"libvirt-guests is configured not to start any guests on boot"
+ echo "libvirt-guests is configured not to start any guests on boot"
rm -f "$LISTFILE"
started
return 0
@@ -143,20 +130,20 @@ start() {
fi
done
if ! $configured; then
- echo $"Ignoring guests on $uri URI"
+ echo "Ignoring guests on $uri URI"
continue
fi
- echo $"Resuming guests on $uri URI..."
+ echo "Resuming guests on $uri URI..."
for guest in $list; do
name=$(guest_name $uri $guest)
- echo -n $"Resuming guest $name: "
+ echo -n "Resuming guest $name: "
if guest_is_on $uri $guest; then
if $guest_running; then
- echo $"already active"
+ echo "already active"
else
retval run_virsh $uri start "$name" >/dev/null && \
- echo $"done"
+ echo "done"
fi
fi
done
@@ -172,7 +159,7 @@ suspend_guest()
guest=$2
name=$(guest_name $uri $guest)
- label=$"Suspending $name: "
+ label="Suspending $name: "
echo -n "$label"
run_virsh $uri managedsave $guest >/dev/null &
virsh_pid=$!
@@ -187,7 +174,7 @@ suspend_guest()
printf '\r%s%-12s ' "$label" "..."
fi
done
- retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done"
+ retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "done"
}
shutdown_guest()
@@ -196,7 +183,7 @@ shutdown_guest()
guest=$2
name=$(guest_name $uri $guest)
- label=$"Shutting down $name: "
+ label="Shutting down $name: "
echo -n "$label"
retval run_virsh $uri shutdown $guest >/dev/null || return
timeout=$SHUTDOWN_TIMEOUT
@@ -210,9 +197,9 @@ shutdown_guest()
if guest_is_on $uri $guest; then
if $guest_running; then
- printf '\r%s%-12s\n' "$label" $"failed to shutdown in time"
+ printf '\r%s%-12s\n' "$label" "failed to shutdown in time"
else
- printf '\r%s%-12s\n' "$label" $"done"
+ printf '\r%s%-12s\n' "$label" "done"
fi
fi
}
@@ -225,7 +212,7 @@ stop() {
if [ "x$ON_SHUTDOWN" = xshutdown ]; then
suspending=false
if [ $SHUTDOWN_TIMEOUT -le 0 ]; then
- echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set"
+ echo "Shutdown action requested but SHUTDOWN_TIMEOUT was not set"
RETVAL=6
return
fi
@@ -233,10 +220,10 @@ stop() {
: >"$LISTFILE"
for uri in $URIS; do
- echo -n $"Running guests on $uri URI: "
+ echo -n "Running guests on $uri URI: "
if [ "x$uri" = xdefault ] && [ ! -x "$libvirtd" ]; then
- echo $"libvirtd not installed; skipping this URI."
+ echo "libvirtd not installed; skipping this URI."
continue
fi
@@ -249,7 +236,7 @@ stop() {
empty=false
done
if $empty; then
- echo $"no running guests."
+ echo "no running guests."
else
echo
echo $uri $list >>"$LISTFILE"
@@ -259,9 +246,9 @@ stop() {
while read uri list; do
if $suspending; then
- echo $"Suspending guests on $uri URI..."
+ echo "Suspending guests on $uri URI..."
else
- echo $"Shutting down guests on $uri URI..."
+ echo "Shutting down guests on $uri URI..."
fi
for guest in $list; do
@@ -285,17 +272,16 @@ gueststatus() {
# rh_status
# Display current status: whether saved state exists, and whether start
-# has been executed. We cannot use status() from the functions library,
-# since there is no external daemon process matching this init script.
+# has been executed.
rh_status() {
if [ -f "$LISTFILE" ]; then
- echo $"stopped, with saved guests"
+ echo "stopped, with saved guests"
RETVAL=3
else
if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then
- echo $"started"
+ echo "started"
else
- echo $"stopped, with no saved guests"
+ echo "stopped, with no saved guests"
fi
RETVAL=0
fi
@@ -304,7 +290,7 @@ rh_status() {
# usage [val]
# Display usage string, then exit with VAL (defaults to 2).
usage() {
- echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"
+ echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"
exit ${1-2}
}
diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf
index cd58728..53d89bd 100644
--- a/tools/libvirt-guests.sysconf
+++ b/tools/libvirt-guests.sysconf
@@ -8,7 +8,7 @@
# - ignore libvirt-guests init script won't start any guest on boot, however,
# guests marked as autostart will still be automatically started by
# libvirtd
-#ON_BOOT=start
+#ON_BOOT=ignore
# action taken on host shutdown
# - suspend all running guests are suspended using virsh managedsave
@@ -18,7 +18,7 @@
# which just needs a long time to shutdown. When setting
# ON_SHUTDOWN=shutdown, you must also set SHUTDOWN_TIMEOUT to a
# value suitable for your guests.
-#ON_SHUTDOWN=suspend
+#ON_SHUTDOWN=shutdown
# number of seconds we're willing to wait for a guest to shut down
-#SHUTDOWN_TIMEOUT=0
+#SHUTDOWN_TIMEOUT=30
--
......@@ -7,3 +7,4 @@
0007-Disable-CHECKSUM-rule.patch
0008-syntax-error-Bad-fd-number-when-stopping-libvirt-gue.patch
0009-Missing-Default-Stop-field-in-LSB-comment-in-libvirt.patch
0010-Debianize-libvirt-guests.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment