[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/31] block: Create bdrv_inherited_flags()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 11/31] block: Create bdrv_inherited_flags() |
Date: |
Wed, 30 Apr 2014 20:23:43 +0200 |
Instead of having bdrv_open_flags() as a function that creates flags for
several unrelated places and then adding open-coded flags on top, create
a new function that derives the flags for bs->file from the flags for bs.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index 100fa86..01282c2 100644
--- a/block.c
+++ b/block.c
@@ -774,6 +774,30 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs)
bs->copy_on_read--;
}
+/*
+ * Returns the flags that bs->file should get, based on the given flags for
+ * the parent BDS
+ */
+static int bdrv_inherited_flags(int flags)
+{
+ /* Enable protocol handling, disable format probing for bs->file */
+ flags |= BDRV_O_PROTOCOL;
+
+ /* Our block drivers take care to send flushes and respect unmap policy,
+ * so we can enable both unconditionally on lower layers. */
+ flags |= BDRV_O_CACHE_WB | BDRV_O_UNMAP;
+
+ /* The backing file of a temporary snapshot is read-only */
+ if (flags & BDRV_O_SNAPSHOT) {
+ flags &= ~BDRV_O_RDWR;
+ }
+
+ /* Clear flags that only apply to the top layer */
+ flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
+
+ return flags;
+}
+
static int bdrv_open_flags(BlockDriverState *bs, int flags)
{
int open_flags = flags | BDRV_O_CACHE_WB;
@@ -1333,8 +1357,8 @@ int bdrv_open(BlockDriverState **pbs, const char
*filename,
assert(file == NULL);
ret = bdrv_open_image(&file, filename, options, "file",
- bdrv_open_flags(bs, flags | BDRV_O_UNMAP) |
- BDRV_O_PROTOCOL, true, &local_err);
+ bdrv_inherited_flags(flags),
+ true, &local_err);
if (ret < 0) {
goto unlink_and_fail;
}
--
1.8.3.1
- [Qemu-devel] [PULL 01/31] block: fix qemu-img --help invocation, (continued)
- [Qemu-devel] [PULL 01/31] block: fix qemu-img --help invocation, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 02/31] mirror: Use DIV_ROUND_UP, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 03/31] block: Add '--version' option to qemu-img, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 04/31] block: Ignore duplicate or NULL format_name in bdrv_iterate_format, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 07/31] block: qemu-iotests - fix image cleanup when using spaced pathnames, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 06/31] mirror: Check for bdrv_get_info result, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 08/31] block: qemu-iotests: make test 019 and 086 work with spaced pathnames, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 05/31] mirror: Fix resource leak when bdrv_getlength fails, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 10/31] iotests: Discarding compressed clusters on qcow2, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 09/31] qcow2: Fix discard, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 11/31] block: Create bdrv_inherited_flags(),
Kevin Wolf <=
- [Qemu-devel] [PULL 12/31] block: Create bdrv_backing_flags(), Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 13/31] block: Remove BDRV_O_COPY_ON_READ for bs->file, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 14/31] block: Unlink temporary files in raw-posix/win32, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 15/31] Revert "block: another bdrv_append fix", Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 16/31] block: Fix open_flags in bdrv_reopen(), Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 17/31] block: Use error_abort in bdrv_image_info_specific_dump(), Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 19/31] block: Use correct width in format strings, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 18/31] qcow2: Avoid overflow in alloc_clusters_noref(), Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 20/31] qcow2: Catch bdrv_getlength() error, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 23/31] block/vdi: Error out immediately in vdi_create(), Kevin Wolf, 2014/04/30