]> xenbits.xensource.com Git - qemu-xen.git/commit
virtio-blk: do not relay a previous driver's WCE configuration to the current
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 20 Sep 2013 15:31:55 +0000 (17:31 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 25 Sep 2013 04:03:09 +0000 (23:03 -0500)
commitc8adc0db7e76e804692372a06ca02cc5a80b67d5
tree376ab12a8440542d5ac0722eac228874a2ef2a79
parentaeab582580fa057dbe646fc3277570af6a8d5ce8
virtio-blk: do not relay a previous driver's WCE configuration to the current

The following sequence happens:
- the SeaBIOS virtio-blk driver does not support the WCE feature, which
causes QEMU to disable writeback caching

- the Linux virtio-blk driver resets the device, finds WCE is available
but writeback caching is disabled; tells block layer to not send cache
flush commands

- the Linux virtio-blk driver sets the DRIVER_OK bit, which causes
writeback caching to be re-enabled, but the Linux virtio-blk driver does
not know of this side effect and cache flushes remain disabled

The bug is at the third step.  If the guest does know about CONFIG_WCE,
QEMU should ignore the WCE feature's state.  The guest will control the
cache mode solely using configuration space.  This change makes Linux
do flushes correctly, but Linux will keep SeaBIOS's writethrough mode.

Hence, whenever the guest is reset, the cache mode of the disk should
be reset to whatever was specified in the "-drive" option.  With this
change, the Linux virtio-blk driver finds that writeback caching is
enabled, and tells the block layer to send cache flush commands
appropriately.

Reported-by: Rusty Russell <rusty@au1.ibm.com
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit ef5bc96268ceec64769617dc53b0ac3a20ff351c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/block/virtio-blk.c
include/hw/virtio/virtio-blk.h