[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v8 03/15] block: Add functions for inheriting a BBRS
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v8 03/15] block: Add functions for inheriting a BBRS |
Date: |
Mon, 26 Oct 2015 21:39:07 +0100 |
In order to open a BDS which inherits a BB's root state,
blk_get_open_flags_from_root_state() is used to inquire the flags to be
passed to bdrv_open(), and blk_apply_root_state() is used to apply the
remaining state after the BDS has been opened.
Signed-off-by: Max Reitz <address@hidden>
---
block/block-backend.c | 27 +++++++++++++++++++++++++++
include/sysemu/block-backend.h | 2 ++
2 files changed, 29 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 878c448..7d49539 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1239,6 +1239,33 @@ void blk_update_root_state(BlockBackend *blk)
}
}
+/*
+ * Applies the information in the root state to the given BlockDriverState.
This
+ * does not include the flags which have to be specified for bdrv_open(), use
+ * blk_get_open_flags_from_root_state() to inquire them.
+ */
+void blk_apply_root_state(BlockBackend *blk, BlockDriverState *bs)
+{
+ bs->detect_zeroes = blk->root_state.detect_zeroes;
+ if (blk->root_state.throttle_group) {
+ bdrv_io_limits_enable(bs, blk->root_state.throttle_group);
+ }
+}
+
+/*
+ * Returns the flags to be used for bdrv_open() of a BlockDriverState which is
+ * supposed to inherit the root state.
+ */
+int blk_get_open_flags_from_root_state(BlockBackend *blk)
+{
+ int bs_flags;
+
+ bs_flags = blk->root_state.read_only ? 0 : BDRV_O_RDWR;
+ bs_flags |= blk->root_state.open_flags & ~BDRV_O_RDWR;
+
+ return bs_flags;
+}
+
BlockBackendRootState *blk_get_root_state(BlockBackend *blk)
{
return &blk->root_state;
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 14a6d32..40e315b 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -167,6 +167,8 @@ void blk_io_unplug(BlockBackend *blk);
BlockAcctStats *blk_get_stats(BlockBackend *blk);
BlockBackendRootState *blk_get_root_state(BlockBackend *blk);
void blk_update_root_state(BlockBackend *blk);
+void blk_apply_root_state(BlockBackend *blk, BlockDriverState *bs);
+int blk_get_open_flags_from_root_state(BlockBackend *blk);
void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
BlockCompletionFunc *cb, void *opaque);
--
2.6.2
- [Qemu-block] [PATCH v8 00/15] blockdev: BlockBackend and media, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 01/15] block: Add blk_remove_bs(), Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 02/15] block: Make bdrv_states public, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 03/15] block: Add functions for inheriting a BBRS,
Max Reitz <=
- [Qemu-block] [PATCH v8 04/15] blockdev: Add blockdev-open-tray, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 05/15] blockdev: Add blockdev-close-tray, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 06/15] blockdev: Add blockdev-remove-medium, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 07/15] blockdev: Add blockdev-insert-medium, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 08/15] blockdev: Implement eject with basic operations, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 09/15] blockdev: Implement change with basic operations, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 10/15] block: Inquire tray state before tray-moved events, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 11/15] qmp: Introduce blockdev-change-medium, Max Reitz, 2015/10/26
- [Qemu-block] [PATCH v8 12/15] hmp: Use blockdev-change-medium for change command, Max Reitz, 2015/10/26