[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/43] block: Factor out bdrv_open_flags
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 05/43] block: Factor out bdrv_open_flags |
Date: |
Thu, 13 Dec 2012 16:10:12 +0100 |
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/block.c b/block.c
index c7a1a3c..c4f5566 100644
--- a/block.c
+++ b/block.c
@@ -634,6 +634,26 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs)
bs->copy_on_read--;
}
+static int bdrv_open_flags(BlockDriverState *bs, int flags)
+{
+ int open_flags = flags | BDRV_O_CACHE_WB;
+
+ /*
+ * Clear flags that are internal to the block layer before opening the
+ * image.
+ */
+ open_flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
+
+ /*
+ * Snapshots should be writable.
+ */
+ if (bs->is_temporary) {
+ open_flags |= BDRV_O_RDWR;
+ }
+
+ return open_flags;
+}
+
/*
* Common part for opening disk images and files
*/
@@ -665,20 +685,7 @@ static int bdrv_open_common(BlockDriverState *bs, const
char *filename,
bs->opaque = g_malloc0(drv->instance_size);
bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
- open_flags = flags | BDRV_O_CACHE_WB;
-
- /*
- * Clear flags that are internal to the block layer before opening the
- * image.
- */
- open_flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
-
- /*
- * Snapshots should be writable.
- */
- if (bs->is_temporary) {
- open_flags |= BDRV_O_RDWR;
- }
+ open_flags = bdrv_open_flags(bs, flags);
bs->read_only = !(open_flags & BDRV_O_RDWR);
--
1.7.6.5
- [Qemu-devel] [PULL 00/43] Block patches, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 01/43] tests: use aio_poll() instead of aio_flush() in test-aio.c, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 04/43] aio: Get rid of qemu_aio_flush(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 03/43] block: Improve bdrv_aio_co_cancel_em, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 02/43] tests: avoid qemu_aio_flush() in test-thread-pool.c, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 06/43] block: Avoid second open for format probing, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 09/43] block: vpc support for ~2 TB disks, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 12/43] block: simplify default_drive, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 07/43] virtio-blk: Remove duplicate property definition, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 05/43] block: Factor out bdrv_open_flags,
Kevin Wolf <=
- [Qemu-devel] [PATCH 10/43] raw-posix: inline paio_ioctl into hdev_aio_ioctl, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 16/43] qmp: qmp_transaction(): pass Error object to bdrv_img_create(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 13/43] block: bdrv_img_create(): add Error ** argument, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 14/43] qemu-img: img_create(): pass Error object to bdrv_img_create(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 08/43] block: vpc initialize the uuid footer field, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 17/43] qmp: qmp_drive_mirror(): pass Error object to bdrv_img_create(), Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 11/43] Support default block interfaces per QEMUMachine, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 22/43] Fix error code checking for SetFilePointer() call, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 35/43] atapi: reset cdrom tray statuses on ide_reset, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 27/43] use qemu_opts_create_nofail, Kevin Wolf, 2012/12/13