2011-02-11 19:46:10 +01:00
|
|
|
Index: libvirt-0.8.8/tools/Makefile.am
|
2011-01-12 00:41:45 +01:00
|
|
|
===================================================================
|
2011-02-11 19:46:10 +01:00
|
|
|
--- libvirt-0.8.8.orig/tools/Makefile.am
|
|
|
|
+++ libvirt-0.8.8/tools/Makefile.am
|
2011-01-13 00:13:53 +01:00
|
|
|
@@ -129,18 +129,18 @@ install-data-local: install-init
|
2011-01-12 00:41:45 +01:00
|
|
|
|
|
|
|
uninstall-local: uninstall-init
|
|
|
|
|
|
|
|
-if LIBVIRT_INIT_SCRIPT_RED_HAT
|
|
|
|
install-init: libvirt-guests.init
|
|
|
|
- mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
|
|
|
|
+ mkdir -p $(DESTDIR)$(sysconfdir)/init.d
|
|
|
|
$(INSTALL_SCRIPT) libvirt-guests.init \
|
|
|
|
- $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests
|
|
|
|
- mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
|
|
|
|
+ $(DESTDIR)$(sysconfdir)/init.d/libvirt-guests
|
|
|
|
+ mkdir -p $(DESTDIR)/var/adm/fillup-templates
|
|
|
|
$(INSTALL_DATA) $(srcdir)/libvirt-guests.sysconf \
|
|
|
|
- $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
|
|
|
|
+ $(DESTDIR)/var/adm/fillup-templates/sysconfig.libvirt-guests
|
|
|
|
|
|
|
|
uninstall-init:
|
|
|
|
- rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests \
|
2011-01-13 00:13:53 +01:00
|
|
|
- $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
|
2011-01-12 00:41:45 +01:00
|
|
|
+ rm -f $(DESTDIR)$(sysconfdir)/init.d/libvirt-guests \
|
2011-01-13 00:13:53 +01:00
|
|
|
+ $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests \
|
|
|
|
+ $(DESTDIR)/var/adm/fillup-templates/sysconfig.libvirt-guests
|
2011-01-12 00:41:45 +01:00
|
|
|
|
|
|
|
BUILT_SOURCES += libvirt-guests.init
|
2011-01-13 00:13:53 +01:00
|
|
|
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -155,11 +155,6 @@ libvirt-guests.init: libvirt-guests.init
|
2011-01-12 00:41:45 +01:00
|
|
|
< $< > $@-t && \
|
|
|
|
chmod a+x $@-t && \
|
|
|
|
mv $@-t $@
|
|
|
|
-else
|
|
|
|
-install-init:
|
|
|
|
-uninstall-init:
|
|
|
|
-libvirt-guests.init:
|
|
|
|
-endif # LIBVIRT_INIT_SCRIPT_RED_HAT
|
|
|
|
|
|
|
|
|
|
|
|
CLEANFILES = $(bin_SCRIPTS) $(man1_MANS)
|
2011-02-11 19:46:10 +01:00
|
|
|
Index: libvirt-0.8.8/tools/libvirt-guests.sysconf
|
2011-01-12 00:41:45 +01:00
|
|
|
===================================================================
|
2011-02-11 19:46:10 +01:00
|
|
|
--- libvirt-0.8.8.orig/tools/libvirt-guests.sysconf
|
|
|
|
+++ libvirt-0.8.8/tools/libvirt-guests.sysconf
|
2011-01-12 00:41:45 +01:00
|
|
|
@@ -1,15 +1,23 @@
|
|
|
|
+## Path: System/Virtualization/libvirt
|
|
|
|
+
|
|
|
|
+## Type: string
|
|
|
|
+## Default: default
|
|
|
|
# URIs to check for running guests
|
|
|
|
# example: URIS='default xen:/// vbox+tcp://host/system lxc:///'
|
|
|
|
-#URIS=default
|
|
|
|
+URIS=default
|
|
|
|
|
|
|
|
+## Type: string
|
|
|
|
+## Default: start
|
|
|
|
# action taken on host boot
|
|
|
|
# - start all guests which were running on shutdown are started on boot
|
|
|
|
# regardless on their autostart settings
|
|
|
|
# - 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=start
|
|
|
|
|
|
|
|
+## Type: string
|
|
|
|
+## Default: suspend
|
|
|
|
# action taken on host shutdown
|
|
|
|
# - suspend all running guests are suspended using virsh managedsave
|
|
|
|
# - shutdown all running guests are asked to shutdown. Please be careful with
|
|
|
|
@@ -18,7 +26,9 @@
|
|
|
|
# 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=suspend
|
|
|
|
|
|
|
|
+## Type: integer
|
|
|
|
+## Default: 120
|
|
|
|
# number of seconds we're willing to wait for a guest to shut down
|
|
|
|
-#SHUTDOWN_TIMEOUT=0
|
|
|
|
+SHUTDOWN_TIMEOUT=120
|
2011-02-11 19:46:10 +01:00
|
|
|
Index: libvirt-0.8.8/tools/libvirt-guests.init.sh
|
2011-01-12 00:41:45 +01:00
|
|
|
===================================================================
|
2011-02-11 19:46:10 +01:00
|
|
|
--- libvirt-0.8.8.orig/tools/libvirt-guests.init.sh
|
|
|
|
+++ libvirt-0.8.8/tools/libvirt-guests.init.sh
|
2011-01-12 00:41:45 +01:00
|
|
|
@@ -4,10 +4,10 @@
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: libvirt-guests
|
|
|
|
-# Required-Start: libvirtd
|
|
|
|
-# Required-Stop: libvirtd
|
|
|
|
-# Default-Start: 2 3 4 5
|
|
|
|
-# Default-Stop: 0 1 6
|
|
|
|
+# Required-Start: $network $remote_fs libvirtd
|
|
|
|
+# Required-Stop: $network $remote_fs libvirtd
|
|
|
|
+# Default-Start: 3 5
|
|
|
|
+# Default-Stop: 0 1 2 4 6
|
|
|
|
# Short-Description: suspend/resume libvirt guests on shutdown/boot
|
|
|
|
# Description: This is a script for suspending active libvirt guests
|
|
|
|
# on shutdown and resuming them on next boot
|
|
|
|
@@ -24,14 +24,13 @@
|
|
|
|
# See http://libvirt.org
|
|
|
|
#
|
|
|
|
|
|
|
|
+. /etc/rc.status
|
|
|
|
+rc_reset
|
|
|
|
+
|
2011-02-11 19:46:10 +01:00
|
|
|
sysconfdir="@sysconfdir@"
|
|
|
|
localstatedir="@localstatedir@"
|
|
|
|
libvirtd="@sbindir@"/libvirtd
|
2011-01-12 00:41:45 +01:00
|
|
|
|
|
|
|
-# Source function library.
|
|
|
|
-test ! -r "$sysconfdir"/rc.d/init.d/functions ||
|
2011-02-11 19:46:10 +01:00
|
|
|
- . "$sysconfdir"/rc.d/init.d/functions
|
2011-01-12 00:41:45 +01:00
|
|
|
-
|
2011-02-11 19:46:10 +01:00
|
|
|
# Source gettext library.
|
|
|
|
# Make sure this file is recognized as having translations: _("dummy")
|
|
|
|
. "@bindir@"/gettext.sh
|
|
|
|
@@ -49,12 +48,10 @@ test -f "$sysconfdir"/sysconfig/libvirt-
|
2011-01-12 00:41:45 +01:00
|
|
|
LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
|
|
|
|
VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
|
|
|
|
|
|
|
|
-RETVAL=0
|
|
|
|
-
|
|
|
|
retval() {
|
|
|
|
"$@"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
- RETVAL=1
|
|
|
|
+ rc_failed 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -78,12 +75,31 @@ run_virsh_c() {
|
2011-01-12 00:41:45 +01:00
|
|
|
( export LC_ALL=C; run_virsh "$@" )
|
|
|
|
}
|
|
|
|
|
|
|
|
+await_daemon_up()
|
|
|
|
+{
|
|
|
|
+ uri=$1
|
|
|
|
+ i=1
|
|
|
|
+ rets=10
|
|
|
|
+ run_virsh $uri list > /dev/null 2>&1
|
|
|
|
+ while [ $? -ne 0 -a $i -lt $rets ]; do
|
|
|
|
+ sleep 1
|
|
|
|
+ echo -n .
|
|
|
|
+ i=$(($i + 1))
|
|
|
|
+ run_virsh $uri list > /dev/null 2>&1
|
|
|
|
+ done
|
|
|
|
+ if [ $i -eq $rets ]; then
|
|
|
|
+ echo $"libvirt-guests unable to connect to URI: $uri"
|
|
|
|
+ return 1
|
|
|
|
+ fi
|
|
|
|
+ return 0
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
list_guests() {
|
|
|
|
uri=$1
|
|
|
|
|
|
|
|
list=$(run_virsh_c $uri list)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
- RETVAL=1
|
|
|
|
+ rc_failed 1
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -91,7 +107,7 @@ list_guests() {
|
2011-01-12 00:41:45 +01:00
|
|
|
for id in $(echo "$list" | awk 'NR > 2 {print $1}'); do
|
|
|
|
uuid=$(run_virsh_c $uri dominfo $id | awk '/^UUID:/{print $2}')
|
|
|
|
if [ -z "$uuid" ]; then
|
|
|
|
- RETVAL=1
|
|
|
|
+ rc_failed 1
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
uuids="$uuids $uuid"
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -118,7 +134,7 @@ guest_is_on() {
|
2011-01-12 00:41:45 +01:00
|
|
|
guest_running=false
|
|
|
|
info=$(run_virsh_c $uri dominfo $uuid)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
- RETVAL=1
|
|
|
|
+ rc_failed 1
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -156,6 +172,12 @@ start() {
|
2011-01-12 00:41:45 +01:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
+ await_daemon_up $uri
|
|
|
|
+ if [ $? -ne 0 ]; then
|
|
|
|
+ echo $"Ignoring guests on $uri URI, can't connect"
|
|
|
|
+ continue
|
|
|
|
+ fi
|
|
|
|
+
|
2011-02-11 19:46:10 +01:00
|
|
|
eval_gettext "Resuming guests on \$uri URI..."; echo
|
2011-01-12 00:41:45 +01:00
|
|
|
for guest in $list; do
|
|
|
|
name=$(guest_name $uri $guest)
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -237,7 +259,7 @@ stop() {
|
2011-01-12 00:41:45 +01:00
|
|
|
if [ $SHUTDOWN_TIMEOUT -le 0 ]; then
|
2011-02-11 19:46:10 +01:00
|
|
|
gettext "Shutdown action requested but SHUTDOWN_TIMEOUT was not set"
|
|
|
|
echo
|
2011-01-12 00:41:45 +01:00
|
|
|
- RETVAL=6
|
|
|
|
+ rc_failed 6
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -301,14 +323,13 @@ gueststatus() {
|
2011-01-12 00:41:45 +01:00
|
|
|
rh_status() {
|
|
|
|
if [ -f "$LISTFILE" ]; then
|
2011-02-11 19:46:10 +01:00
|
|
|
gettext "stopped, with saved guests"; echo
|
2011-01-12 00:41:45 +01:00
|
|
|
- RETVAL=3
|
|
|
|
+ rc_failed 3
|
|
|
|
else
|
|
|
|
if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then
|
2011-02-11 19:46:10 +01:00
|
|
|
gettext "started"; echo
|
2011-01-12 00:41:45 +01:00
|
|
|
else
|
2011-02-11 19:46:10 +01:00
|
|
|
gettext "stopped, with no saved guests"; echo
|
2011-01-12 00:41:45 +01:00
|
|
|
fi
|
|
|
|
- RETVAL=0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-02-11 19:46:10 +01:00
|
|
|
@@ -352,4 +373,4 @@ case "$1" in
|
2011-01-12 00:41:45 +01:00
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
-exit $RETVAL
|
|
|
|
+rc_exit
|