KVM: use cache= for non-virtio too
authorAlexander Graf <agraf@suse.de>
Fri, 30 Sep 2011 09:49:15 +0000 (11:49 +0200)
committerAdrian Schröter <adrian@suse.de>
Sat, 1 Oct 2011 07:31:54 +0000 (09:31 +0200)
Currently we're only using cache=... when running with virtio in KVM. The
parameter is generic though and also helps a lot on IDE, so let's move from
the legacy -hda -hdb syntax to -drive and also enable proper caching along
the way.

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

diff --git a/build b/build
index 777bd2f..6bfb467 100755 (executable)
--- a/build
+++ b/build
@@ -1526,15 +1526,15 @@ for SPECFILE in "${SPECFILES[@]}" ; do
                "$@"
        elif [ "$VM_TYPE" = 'qemu' -o "$VM_TYPE" = 'kvm' ]; then
                echo "booting $VM_TYPE ..."
+                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
                if [ "$kvm_virtio" = 1 ]; then
-                    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")
+                   qemu_args=(-drive file="$VM_IMAGE",if=virtio$CACHE -drive file="$VM_IMAGE",if=ide,index=0$CACHE)
                    if [ -n "$VM_SWAP" ]; then
                        qemu_args=("${qemu_args[@]}" "-drive")
                        qemu_args=("${qemu_args[@]}" "file=$VM_SWAP,if=virtio$CACHE")
@@ -1542,8 +1542,8 @@ for SPECFILE in "${SPECFILES[@]}" ; do
                else
                    qemu_args=(-hda "$VM_IMAGE")
                    if [ -n "$VM_SWAP" ]; then
-                       qemu_args=("${qemu_args[@]}" "-hdb")
-                       qemu_args=("${qemu_args[@]}" "$VM_SWAP")
+                       qemu_args=("${qemu_args[@]}" "-drive")
+                       qemu_args=("${qemu_args[@]}" "file=$VM_SWAP,if=ide,index=1$CACHE")
                    fi
                fi
                if [ -n "$BUILD_JOBS" -a "$icecream" = 0 ]; then