mirror of https://gitee.com/openkylin/libvirt.git
save: support bypass-cache flag in libvirt-guests init script
libvirt-guests is a perfect use case for bypassing the file system cache - lots of filesystem traffic done at system shutdown, where caching is pointless, and startup, where reading large files only once just gets in the way. Make this a configurable option in the init script, but defaulting to existing behavior. * tools/libvirt-guests.sysconf (BYPASS_CACHE): New variable. * tools/libvirt-guests.init.sh (start, suspend_guest): Use it.
This commit is contained in:
parent
a9f9545e12
commit
28d182506a
|
@ -43,6 +43,7 @@ ON_BOOT=start
|
||||||
ON_SHUTDOWN=suspend
|
ON_SHUTDOWN=suspend
|
||||||
SHUTDOWN_TIMEOUT=0
|
SHUTDOWN_TIMEOUT=0
|
||||||
START_DELAY=0
|
START_DELAY=0
|
||||||
|
BYPASS_CACHE=0
|
||||||
|
|
||||||
test -f "$sysconfdir"/sysconfig/libvirt-guests &&
|
test -f "$sysconfdir"/sysconfig/libvirt-guests &&
|
||||||
. "$sysconfdir"/sysconfig/libvirt-guests
|
. "$sysconfdir"/sysconfig/libvirt-guests
|
||||||
|
@ -143,6 +144,8 @@ start() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
isfirst=true
|
isfirst=true
|
||||||
|
bypass=
|
||||||
|
test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
|
||||||
while read uri list; do
|
while read uri list; do
|
||||||
configured=false
|
configured=false
|
||||||
set -f
|
set -f
|
||||||
|
@ -172,7 +175,8 @@ start() {
|
||||||
else
|
else
|
||||||
sleep $START_DELAY
|
sleep $START_DELAY
|
||||||
fi
|
fi
|
||||||
retval run_virsh "$uri" start "$name" >/dev/null && \
|
retval run_virsh "$uri" start $bypass "$name" \
|
||||||
|
>/dev/null && \
|
||||||
gettext "done"; echo
|
gettext "done"; echo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -190,8 +194,10 @@ suspend_guest()
|
||||||
|
|
||||||
name=$(guest_name "$uri" "$guest")
|
name=$(guest_name "$uri" "$guest")
|
||||||
label=$(eval_gettext "Suspending \$name: ")
|
label=$(eval_gettext "Suspending \$name: ")
|
||||||
|
bypass=
|
||||||
|
test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
|
||||||
printf %s "$label"
|
printf %s "$label"
|
||||||
run_virsh "$uri" managedsave "$guest" >/dev/null &
|
run_virsh "$uri" managedsave $bypass "$guest" >/dev/null &
|
||||||
virsh_pid=$!
|
virsh_pid=$!
|
||||||
while true; do
|
while true; do
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
|
@ -25,3 +25,8 @@
|
||||||
|
|
||||||
# number of seconds we're willing to wait for a guest to shut down
|
# number of seconds we're willing to wait for a guest to shut down
|
||||||
#SHUTDOWN_TIMEOUT=0
|
#SHUTDOWN_TIMEOUT=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
|
||||||
|
|
Loading…
Reference in New Issue