[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 11/39] block: Assert that flags are in range
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 11/39] block: Assert that flags are in range |
Date: |
Thu, 16 Jun 2016 16:08:00 +0200 |
From: Eric Blake <address@hidden>
Add a new BDRV_REQ_MASK constant, and use it to make sure that
caller flags are always valid.
Tested with 'make check' and with qemu-iotests on both '-raw'
and '-qcow2'; the only failure turned up was fixed in the
previous commit.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/io.c | 6 ++++++
include/block/block.h | 3 +++
2 files changed, 9 insertions(+)
diff --git a/block/io.c b/block/io.c
index fb99a71..5b2017f 100644
--- a/block/io.c
+++ b/block/io.c
@@ -776,6 +776,8 @@ static int coroutine_fn bdrv_driver_preadv(BlockDriverState
*bs,
int64_t sector_num;
unsigned int nb_sectors;
+ assert(!(flags & ~BDRV_REQ_MASK));
+
if (drv->bdrv_co_preadv) {
return drv->bdrv_co_preadv(bs, offset, bytes, qiov, flags);
}
@@ -815,6 +817,8 @@ static int coroutine_fn
bdrv_driver_pwritev(BlockDriverState *bs,
unsigned int nb_sectors;
int ret;
+ assert(!(flags & ~BDRV_REQ_MASK));
+
if (drv->bdrv_co_pwritev) {
ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov,
flags & bs->supported_write_flags);
@@ -953,6 +957,7 @@ static int coroutine_fn
bdrv_aligned_preadv(BlockDriverState *bs,
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
assert(!qiov || bytes == qiov->size);
assert((bs->open_flags & BDRV_O_NO_IO) == 0);
+ assert(!(flags & ~BDRV_REQ_MASK));
/* Handle Copy on Read and associated serialisation */
if (flags & BDRV_REQ_COPY_ON_READ) {
@@ -1242,6 +1247,7 @@ static int coroutine_fn
bdrv_aligned_pwritev(BlockDriverState *bs,
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
assert(!qiov || bytes == qiov->size);
assert((bs->open_flags & BDRV_O_NO_IO) == 0);
+ assert(!(flags & ~BDRV_REQ_MASK));
waited = wait_serialising_requests(req);
assert(!waited || !req->serialising);
diff --git a/include/block/block.h b/include/block/block.h
index 54cca28..8cabcdd 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -65,6 +65,9 @@ typedef enum {
BDRV_REQ_MAY_UNMAP = 0x4,
BDRV_REQ_NO_SERIALISING = 0x8,
BDRV_REQ_FUA = 0x10,
+
+ /* Mask of valid flags */
+ BDRV_REQ_MASK = 0x1f,
} BdrvRequestFlags;
typedef struct BlockSizes {
--
1.8.3.1
- [Qemu-block] [PULL 14/39] block: Prepare bdrv_aligned_preadv() for byte-aligned requests, (continued)
- [Qemu-block] [PULL 14/39] block: Prepare bdrv_aligned_preadv() for byte-aligned requests, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 13/39] block: Byte-based bdrv_co_do_copy_on_readv(), Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 12/39] block: drop support for using qcow[2] encryption with system emulators, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 16/39] raw-posix: Switch to bdrv_co_* interfaces, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 23/39] block: Allow .bdrv_load/save_vmstate() to return 0/-errno, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 19/39] linux-aio: Cancel BH if not needed, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 21/39] block: Introduce bdrv_preadv(), Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 17/39] raw-posix: Implement .bdrv_co_preadv/pwritev, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 15/39] block: Prepare bdrv_aligned_pwritev() for byte-aligned requests, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 10/39] block: Avoid bogus flags during mirroring, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 11/39] block: Assert that flags are in range,
Kevin Wolf <=
- [Qemu-block] [PULL 20/39] doc: Fix mailing list address in tests/qemu-iotests/README, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 24/39] block: Make bdrv_load/save_vmstate coroutine_fns, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 18/39] block: Don't enforce 512 byte minimum alignment, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 29/39] block: use the block job list in qmp_query_block_jobs(), Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 30/39] block: Prevent sleeping jobs from resuming if they have been paused, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 27/39] block: Fix snapshot=on with aio=native, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 25/39] qcow2: Let vmstate call qcow2_co_preadv/pwrite directly, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 22/39] block: Make .bdrv_load_vmstate() vectored, Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 28/39] block: use the block job list in bdrv_drain_all(), Kevin Wolf, 2016/06/16
- [Qemu-block] [PULL 32/39] iotests: 095: Clean up QEMU before showing image info, Kevin Wolf, 2016/06/16