[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 10/8] save: support direct flag in libvirt-guests init script



libvirt-guests is a perfect use case for O_DIRECT - lots of filesystem
traffic done at system shutdown, where caching is pointless, and
startup, where caching gets in the way.  Make this a configurable
option in the init script, but defaulting to existing behavior.

* tools/libvirt-guests.sysconf (SAVE_DIRECT): New variable.
* tools/libvirt-guests.init.sh (suspend_guest): Use it.
---
 tools/libvirt-guests.init.sh |    5 ++++-
 tools/libvirt-guests.sysconf |    4 ++++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh
index 30f957a..4e383c4 100644
--- a/tools/libvirt-guests.init.sh
+++ b/tools/libvirt-guests.init.sh
@@ -43,6 +43,7 @@ ON_BOOT=start
 ON_SHUTDOWN=suspend
 SHUTDOWN_TIMEOUT=0
 START_DELAY=0
+SAVE_DIRECT=0

 test -f "$sysconfdir"/sysconfig/libvirt-guests &&
     . "$sysconfdir"/sysconfig/libvirt-guests
@@ -190,8 +191,10 @@ suspend_guest()

     name=$(guest_name "$uri" "$guest")
     label=$(eval_gettext "Suspending \$name: ")
+    direct=
+    test "x$SAVE_DIRECT" = x0 || direct=--direct
     printf %s "$label"
-    run_virsh "$uri" managedsave "$guest" >/dev/null &
+    run_virsh "$uri" managedsave "$direct" "$guest" >/dev/null &
     virsh_pid=$!
     while true; do
         sleep 1
diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf
index 37b258e..da465ad 100644
--- a/tools/libvirt-guests.sysconf
+++ b/tools/libvirt-guests.sysconf
@@ -25,3 +25,7 @@

 # number of seconds we're willing to wait for a guest to shut down
 #SHUTDOWN_TIMEOUT=0
+
+# If non-zero, try to use O_DIRECT when saving and restoring guests,
+# for less filesystem cache pollution, but possibly slower operation.
+#SAVE_DIRECT=0
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]