render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0226-block-reinitialize-across-bdrv_close-bdrv_open.patch

cd9d16
From 2432c8cf0a61be64094dae724638a9a081ee4bf9 Mon Sep 17 00:00:00 2001
cd9d16
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
cd9d16
Date: Thu, 27 Oct 2011 10:54:28 +0100
cd9d16
Subject: [PATCH] block: reinitialize across bdrv_close()/bdrv_open()
cd9d16
MIME-Version: 1.0
cd9d16
Content-Type: text/plain; charset=UTF-8
cd9d16
Content-Transfer-Encoding: 8bit
cd9d16
cd9d16
Several BlockDriverState fields are not being reinitialized across
cd9d16
bdrv_close()/bdrv_open().  Make sure they are reset to their default
cd9d16
values.
cd9d16
cd9d16
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
cd9d16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
cd9d16
(cherry picked from commit 03f541bd6eacdc6c2893f72b975257c89cab2b74)
cd9d16
cd9d16
Signed-off-by: Bruce Rogers <brogers@suse.com>
cd9d16
[AF: backported]
cd9d16
Signed-off-by: Andreas Färber <afaerber@suse.de>
cd9d16
---
cd9d16
 block.c | 6 ++++--
cd9d16
 1 file changed, 4 insertions(+), 2 deletions(-)
cd9d16
cd9d16
diff --git a/block.c b/block.c
cd9d16
index 8d77746..1d6d26b 100644
cd9d16
--- a/block.c
cd9d16
+++ b/block.c
cd9d16
@@ -426,11 +426,14 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
cd9d16
     bs->total_sectors = 0;
cd9d16
     bs->encrypted = 0;
cd9d16
     bs->valid_key = 0;
cd9d16
+    bs->sg = 0;
cd9d16
     bs->open_flags = flags;
cd9d16
+    bs->growable = 0;
cd9d16
     /* buffer_alignment defaulted to 512, drivers can change this value */
cd9d16
     bs->buffer_alignment = 512;
cd9d16
 
cd9d16
     pstrcpy(bs->filename, sizeof(bs->filename), filename);
cd9d16
+    bs->backing_file[0] = '\0';
cd9d16
 
cd9d16
     if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
cd9d16
         return -ENOTSUP;
cd9d16
@@ -439,8 +442,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
cd9d16
     bs->drv = drv;
cd9d16
     bs->opaque = qemu_mallocz(drv->instance_size);
cd9d16
 
cd9d16
-    if (flags & BDRV_O_CACHE_WB)
cd9d16
-        bs->enable_write_cache = 1;
cd9d16
+    bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
cd9d16
 
cd9d16
     /*
cd9d16
      * Clear flags that are internal to the block layer before opening the
cd9d16
-- 
cd9d16
1.7.11.2
cd9d16