diff options
author | Kevin Wolf <kwolf@redhat.com> | 2012-11-12 17:05:39 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-12-11 11:04:25 +0100 |
commit | 7b272452398135e4f8e48341239705d03c82dae3 (patch) | |
tree | 7dd08fda7fb30b8c1c77aa95c44becc3fc29bca1 /block.c | |
parent | c57b6656c3168bccca7f78b3f740e9149893b3da (diff) | |
download | qemu-7b272452398135e4f8e48341239705d03c82dae3.tar.gz qemu-7b272452398135e4f8e48341239705d03c82dae3.tar.bz2 qemu-7b272452398135e4f8e48341239705d03c82dae3.zip |
block: Factor out bdrv_open_flags
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 35 |
1 files changed, 21 insertions, 14 deletions
@@ -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); |