thebeanogamer / rpms / qemu-kvm

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