KVM: use cache=unsafe
authorAlexander Graf <agraf@suse.de>
Fri, 30 Sep 2011 09:49:14 +0000 (11:49 +0200)
committerAdrian Schröter <adrian@suse.de>
Sat, 1 Oct 2011 07:31:37 +0000 (09:31 +0200)
When running with raw image files, we're not passing in any cache= parameter,
making KVM use the default. Unfortunately, the default is horribly slow and
way too secure about data which doesn't matter for our build use case.

So instead, we should just use cache=unsafe, rendering flush requests from the
guest as nops, making builds faster by many times.

Signed-off-by: Alexander Graf <agraf@suse.de>
build

diff --git a/build b/build
index 3edbccd..777bd2f 100755 (executable)
--- a/build
+++ b/build
@@ -1527,10 +1527,12 @@ for SPECFILE in "${SPECFILES[@]}" ; do
        elif [ "$VM_TYPE" = 'qemu' -o "$VM_TYPE" = 'kvm' ]; then
                echo "booting $VM_TYPE ..."
                if [ "$kvm_virtio" = 1 ]; then
-                   CACHE=""
                     if [ "$VM_TYPE" = 'kvm' -a -b "$VM_IMAGE" ]; then
                       # speed optimization when using kvm with raw devices
                      CACHE=",cache=none"
+                    else
+                      # speed optimization when using kvm with raw files
+                     CACHE=",cache=unsafe"
                     fi
                    qemu_args=(-drive file="$VM_IMAGE",if=virtio$CACHE -hda "$VM_IMAGE")
                    if [ -n "$VM_SWAP" ]; then