65919e44c7
- Update to libvirt 6.9.0 - jsc#SLE-13688, jsc#SLE-16827 - Many incremental improvements and bug fixes, see https://libvirt.org/news.html OBS-URL: https://build.opensuse.org/request/show/845537 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=852
237 lines
6.8 KiB
Diff
237 lines
6.8 KiB
Diff
Adjust libvirt-guests service to conform to SUSE standards
|
|
|
|
Index: libvirt-6.9.0/tools/libvirt-guests.sh.in
|
|
===================================================================
|
|
--- libvirt-6.9.0.orig/tools/libvirt-guests.sh.in
|
|
+++ libvirt-6.9.0/tools/libvirt-guests.sh.in
|
|
@@ -16,14 +16,13 @@
|
|
# License along with this library. If not, see
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
+. /etc/rc.status
|
|
+rc_reset
|
|
+
|
|
sysconfdir="@sysconfdir@"
|
|
localstatedir="@localstatedir@"
|
|
libvirtd="@sbindir@"/libvirtd
|
|
|
|
-# Source function library.
|
|
-test ! -r "$sysconfdir"/rc.d/init.d/functions ||
|
|
- . "$sysconfdir"/rc.d/init.d/functions
|
|
-
|
|
# Source gettext library.
|
|
# Make sure this file is recognized as having translations: _("dummy")
|
|
. "@bindir@"/gettext.sh
|
|
@@ -43,9 +42,11 @@ test -f "$sysconfdir"/sysconfig/libvirt-
|
|
. "$sysconfdir"/sysconfig/libvirt-guests
|
|
|
|
LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
|
|
-VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
|
|
-
|
|
-RETVAL=0
|
|
+if [ -d "$localstatedir"/lock/subsys ]; then
|
|
+ VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
|
|
+else
|
|
+ VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/libvirt-guests
|
|
+fi
|
|
|
|
# retval COMMAND ARGUMENTS...
|
|
# run command with arguments and convert non-zero return value to 1 and set
|
|
@@ -53,7 +54,7 @@ RETVAL=0
|
|
retval() {
|
|
"$@"
|
|
if [ $? -ne 0 ]; then
|
|
- RETVAL=1
|
|
+ rc_failed 1
|
|
return 1
|
|
else
|
|
return 0
|
|
@@ -82,6 +83,26 @@ run_virsh_c() {
|
|
( export LC_ALL=C; run_virsh "$@" )
|
|
}
|
|
|
|
+await_daemon_up()
|
|
+{
|
|
+ uri=$1
|
|
+ i=1
|
|
+ rets=10
|
|
+ run_virsh $uri list > /dev/null 2>&1
|
|
+ while test $? -ne 0 && test $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
|
|
+ eval_gettext "libvirt-guests unable to connect to URI: $uri"
|
|
+ echo
|
|
+ return 1
|
|
+ fi
|
|
+ return 0
|
|
+}
|
|
+
|
|
# test_connect URI
|
|
# check if URI is reachable
|
|
test_connect()
|
|
@@ -108,7 +129,7 @@ list_guests() {
|
|
local list="$(run_virsh_c "$uri" list --uuid $persistent)"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
- RETVAL=1
|
|
+ rc_failed 1
|
|
return 1
|
|
fi
|
|
|
|
@@ -134,7 +155,7 @@ guest_is_on() {
|
|
|
|
guest_running="false"
|
|
if [ $? -ne 0 ]; then
|
|
- RETVAL=1
|
|
+ rc_failed 1
|
|
return 1
|
|
fi
|
|
|
|
@@ -190,6 +211,13 @@ start() {
|
|
|
|
test_connect "$uri" || continue
|
|
|
|
+ await_daemon_up $uri
|
|
+ if [ $? -ne 0 ]; then
|
|
+ eval_gettext "Ignoring guests on $uri URI, can't connect"
|
|
+ echo
|
|
+ continue
|
|
+ fi
|
|
+
|
|
eval_gettext "Resuming guests on \$uri URI..."; echo
|
|
for guest in $list; do
|
|
local name="$(guest_name "$uri" "$guest")"
|
|
@@ -418,7 +446,7 @@ shutdown_guests_parallel()
|
|
timeout=$(($timeout - 1))
|
|
if [ $timeout -le 0 ]; then
|
|
eval_gettext "Timeout expired while shutting down domains"; echo
|
|
- RETVAL=1
|
|
+ rc_failed 1
|
|
return
|
|
fi
|
|
else
|
|
@@ -449,7 +477,7 @@ stop() {
|
|
if [ $SHUTDOWN_TIMEOUT -lt 0 ]; then
|
|
gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0"
|
|
echo
|
|
- RETVAL=6
|
|
+ rc_failed 6
|
|
return
|
|
fi
|
|
fi
|
|
@@ -499,14 +527,14 @@ stop() {
|
|
if [ $? -ne 0 ]; then
|
|
eval_gettext "Failed to list persistent guests on \$uri"
|
|
echo
|
|
- RETVAL=1
|
|
+ rc_failed 1
|
|
set +f
|
|
return
|
|
fi
|
|
else
|
|
gettext "Failed to list transient guests"
|
|
echo
|
|
- RETVAL=1
|
|
+ rc_failed 1
|
|
set +f
|
|
return
|
|
fi
|
|
@@ -567,14 +595,13 @@ gueststatus() {
|
|
rh_status() {
|
|
if [ -f "$LISTFILE" ]; then
|
|
gettext "stopped, with saved guests"; echo
|
|
- RETVAL=3
|
|
+ rc_failed 3
|
|
else
|
|
if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then
|
|
gettext "started"; echo
|
|
- RETVAL=0
|
|
else
|
|
gettext "stopped, with no saved guests"; echo
|
|
- RETVAL=3
|
|
+ rc_failed 3
|
|
fi
|
|
fi
|
|
}
|
|
@@ -619,4 +646,4 @@ case "$1" in
|
|
usage
|
|
;;
|
|
esac
|
|
-exit $RETVAL
|
|
+rc_exit
|
|
Index: libvirt-6.9.0/tools/libvirt-guests.sysconf
|
|
===================================================================
|
|
--- libvirt-6.9.0.orig/tools/libvirt-guests.sysconf
|
|
+++ libvirt-6.9.0/tools/libvirt-guests.sysconf
|
|
@@ -1,9 +1,14 @@
|
|
+## Path: System/Virtualization/libvirt-guests
|
|
# Customizations for the libvirt-guests.service systemd unit
|
|
|
|
+## Type: string
|
|
+## Default: default
|
|
# URIs to check for running guests
|
|
# example: URIS='default xen:///system vbox+tcp://host/system lxc:///system'
|
|
#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
|
|
@@ -12,10 +17,14 @@
|
|
# libvirtd
|
|
#ON_BOOT=start
|
|
|
|
+## Type: integer
|
|
+## Default: 0
|
|
# Number of seconds to wait between each guest start. Set to 0 to allow
|
|
# parallel startup.
|
|
#START_DELAY=0
|
|
|
|
+## 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
|
|
@@ -26,12 +35,16 @@
|
|
# value suitable for your guests.
|
|
#ON_SHUTDOWN=suspend
|
|
|
|
+## Type: integer
|
|
+## Default: 0
|
|
# Number of guests will be shutdown concurrently, taking effect when
|
|
# "ON_SHUTDOWN" is set to "shutdown". If Set to 0, guests will be shutdown one
|
|
# after another. Number of guests on shutdown at any time will not exceed number
|
|
# set in this variable.
|
|
#PARALLEL_SHUTDOWN=0
|
|
|
|
+## Type: integer
|
|
+## Default: 300
|
|
# Number of seconds we're willing to wait for a guest to shut down. If parallel
|
|
# shutdown is enabled, this timeout applies as a timeout for shutting down all
|
|
# guests on a single URI defined in the variable URIS. If this is 0, then there
|
|
@@ -39,14 +52,18 @@
|
|
# request). The default value is 300 seconds (5 minutes).
|
|
#SHUTDOWN_TIMEOUT=300
|
|
|
|
+## Type: integer
|
|
+## Default: 0
|
|
# If non-zero, try to bypass the file system cache when saving and
|
|
# restoring guests, even though this may give slower operation for
|
|
# some file systems.
|
|
#BYPASS_CACHE=0
|
|
|
|
+## Type: integer
|
|
+## Default: 0
|
|
# If non-zero, try to sync guest time on domain resume. Be aware, that
|
|
# this requires guest agent with support for time synchronization
|
|
# running in the guest. For instance, qemu-ga doesn't support guest time
|
|
# synchronization on Windows guests, but Linux ones. By default, this
|
|
# functionality is turned off.
|
|
-#SYNC_TIME=1
|
|
+SYNC_TIME=0
|