Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 3160499aacb81f6735941eb4c372d87a > files > 521

kvm-83-164.el5_5.30.src.rpm

From 9ccca9df16290d64d49abfad3529019c4b3a1485 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Fri, 30 Apr 2010 11:34:51 -0300
Subject: [PATCH] qcow2: Export synchronous qcow_read/write to avoid broken emulation

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <patch-8925-clone-for-rhel55-rhel55>
Patchwork-id: 9916
O-Subject: [RHEL-5.6 KVM PATCH] qcow2: Export synchronous qcow_read/write to
	avoid broken emulation
Bugzilla: 604188
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Christoph Hellwig <chellwig@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>

Bugzilla: 542954
Upstream status: Has different fix

Without the AsyncContext that upstream and RHEL 6 have, the generic emulation
of bdrv_read/write is broken: While callers expect that no other code that
the requested read/write is run, the emulation allows callbacks of other AIO
requests to run in between. This can make caches and other in-memory data used
by the caller of bdrv_read/write inconsistent and lead to corruption.

This corruption is observed when using a backing file format that does not
implement a synchronous bdrv_read/write callback itself.

There are four block drivers that support bdrv_aio_read/write:
raw-posix/raw-win32 additionally implement a synchronous version as
bdrv_pread/pwrite, so they are not affected. qcow2 lacks a synchronous version,
which is fixed by this patch. qcow is affected, too, but it's disabled in RHEL
except for qemu-img (which doesn't use AIO), so it's not worth fixing.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu/block-qcow2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/block-qcow2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c
index 514c4ad..7276959 100644
--- a/qemu/block-qcow2.c
+++ b/qemu/block-qcow2.c
@@ -3358,8 +3358,8 @@ BlockDriver bdrv_qcow2 = {
     sizeof(BDRVQcowState),
     qcow_probe,
     qcow_open,
-    NULL,
-    NULL,
+    qcow_read,
+    qcow_write,
     qcow_close,
     qcow_create,
     qcow_flush,
-- 
1.7.0.3