[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 02/16] block-backend: Add blk_request_perm
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH RFC 02/16] block-backend: Add blk_request_perm |
Date: |
Tue, 21 Mar 2017 11:16:21 +0800 |
This function tries to request, if not granted yet, for the given
permissions.
Signed-off-by: Fam Zheng <address@hidden>
---
block/block-backend.c | 12 ++++++++++++
include/sysemu/block-backend.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 5742c09..5d17404 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -595,6 +595,18 @@ void blk_get_perm(BlockBackend *blk, uint64_t *perm,
uint64_t *shared_perm)
*shared_perm = blk->shared_perm;
}
+int blk_request_perm(BlockBackend *blk, uint64_t perm, Error **errp)
+{
+ uint64_t blk_perm, shared_perm;
+
+ blk_get_perm(blk, &blk_perm, &shared_perm);
+ if ((blk_perm & perm) == perm) {
+ return 0;
+ }
+ blk_perm |= perm;
+ return blk_set_perm(blk, blk_perm, shared_perm, errp);
+}
+
static int blk_do_attach_dev(BlockBackend *blk, void *dev)
{
if (blk->dev) {
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 096c17f..016632e 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -108,6 +108,7 @@ bool bdrv_is_root_node(BlockDriverState *bs);
int blk_set_perm(BlockBackend *blk, uint64_t perm, uint64_t shared_perm,
Error **errp);
void blk_get_perm(BlockBackend *blk, uint64_t *perm, uint64_t *shared_perm);
+int blk_request_perm(BlockBackend *blk, uint64_t perm, Error **errp);
void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
void blk_iostatus_enable(BlockBackend *blk);
--
2.9.3
- [Qemu-devel] [PATCH RFC 00/16] block: Protect AIO context change with perm API, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 01/16] block: Define BLK_PERM_AIO_CONTEXT_CHANGE, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 02/16] block-backend: Add blk_request_perm,
Fam Zheng <=
- [Qemu-devel] [PATCH RFC 03/16] blockjob: Add BLK_PERM_AIO_CONTEXT_CHANGE shared perm on bs, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 04/16] block: Propagate BLK_PERM_AIO_CONTEXT_CHANGE down the graph, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 05/16] backup: Request BLK_PERM_AIO_CONTEXT_CHANGE on target, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 06/16] backup: Do initial aio context move of target via BB interface, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 07/16] mirror: Request aio context change permission on target, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 08/16] commit: Allow aio context change on s->base, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 09/16] mirror: Do initial aio context move of target via BB interface, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 10/16] virtio-scsi: Request BLK_PERM_AIO_CONTEXT_CHANGE for dataplane, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 11/16] virtio-blk: Request BLK_PERM_AIO_CONTEXT_CHANGE for dataplane, Fam Zheng, 2017/03/20
- [Qemu-devel] [PATCH RFC 12/16] blk: fix aio context loss on media change, Fam Zheng, 2017/03/20