0a122b
From 39fd66a311ade8aa330c6c32f1b2a3669e6db44f Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Wed, 11 Dec 2013 20:14:09 +0100
0a122b
Subject: [PATCH 05/37] block: Update BlockLimits when they might have changed
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
Message-id: <1392117622-28812-6-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: 57170
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 05/37] block: Update BlockLimits when they might have changed
0a122b
Bugzilla: 748906
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
0a122b
0a122b
When reopening with different flags, or when backing files disappear
0a122b
from the chain, the limits may change. Make sure they get updated in
0a122b
these cases.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
0a122b
Reviewed-by: Max Reitz <mreitz@redhat.com>
0a122b
Reviewed-by: BenoƮt Canet <benoit@irqsave.net>
0a122b
(cherry picked from commit 355ef4ac95a7a47d5c7201ccd910056a100d2fdf)
0a122b
0a122b
Conflicts:
0a122b
	block/stream.c
0a122b
0a122b
Trivial context-only conflict.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 block.c               | 5 ++++-
0a122b
 block/stream.c        | 2 ++
0a122b
 include/block/block.h | 1 +
0a122b
 3 files changed, 7 insertions(+), 1 deletion(-)
0a122b
---
0a122b
 block.c               |    5 ++++-
0a122b
 block/stream.c        |    2 ++
0a122b
 include/block/block.h |    1 +
0a122b
 3 files changed, 7 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/block.c b/block.c
0a122b
index 8b36d05..f62acbd 100644
0a122b
--- a/block.c
0a122b
+++ b/block.c
0a122b
@@ -446,7 +446,7 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options,
0a122b
     return ret;
0a122b
 }
0a122b
 
0a122b
-static int bdrv_refresh_limits(BlockDriverState *bs)
0a122b
+int bdrv_refresh_limits(BlockDriverState *bs)
0a122b
 {
0a122b
     BlockDriver *drv = bs->drv;
0a122b
 
0a122b
@@ -1452,6 +1452,8 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
0a122b
     reopen_state->bs->enable_write_cache = !!(reopen_state->flags &
0a122b
                                               BDRV_O_CACHE_WB);
0a122b
     reopen_state->bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
0a122b
+
0a122b
+    bdrv_refresh_limits(reopen_state->bs);
0a122b
 }
0a122b
 
0a122b
 /*
0a122b
@@ -2284,6 +2286,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,
0a122b
     }
0a122b
     new_top_bs->backing_hd = base_bs;
0a122b
 
0a122b
+    bdrv_refresh_limits(new_top_bs);
0a122b
 
0a122b
     QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) {
0a122b
         /* so that bdrv_close() does not recursively close the chain */
0a122b
diff --git a/block/stream.c b/block/stream.c
0a122b
index 1420d09..3a7d8f3 100644
0a122b
--- a/block/stream.c
0a122b
+++ b/block/stream.c
0a122b
@@ -71,6 +71,8 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base,
0a122b
         bdrv_unref(unused);
0a122b
     }
0a122b
     top->backing_hd = base;
0a122b
+
0a122b
+    bdrv_refresh_limits(top);
0a122b
 }
0a122b
 
0a122b
 static void coroutine_fn stream_run(void *opaque)
0a122b
diff --git a/include/block/block.h b/include/block/block.h
0a122b
index d20d63e..3e22fc2 100644
0a122b
--- a/include/block/block.h
0a122b
+++ b/include/block/block.h
0a122b
@@ -250,6 +250,7 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset);
0a122b
 int64_t bdrv_getlength(BlockDriverState *bs);
0a122b
 int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
0a122b
 void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
0a122b
+int bdrv_refresh_limits(BlockDriverState *bs);
0a122b
 int bdrv_commit(BlockDriverState *bs);
0a122b
 int bdrv_commit_all(void);
0a122b
 int bdrv_change_backing_file(BlockDriverState *bs,
0a122b
-- 
0a122b
1.7.1
0a122b