Forbid adding children to a Quorum in blkverify mode
cover Forbid adding children to a Quorum in blkverify mode
Hi,
as pointed out by Kevin, the Quorum driver should not allow adding new children when running in blkverify mode.
This series fixes that and also adds a couple of basic iotests for the x-blockdev-change QMP command.
Berto
Alberto Garcia (2):
quorum: Forbid adding children in blkverify mode
iotest: Test x-blockdev-change on a Quorum
block/quorum.c | 8 +++++ tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/081.out | 54 +++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+)
Signature · 1 line
2.11.0
PATCH 1/2 quorum: Forbid adding children in blkverify mode
The blkverify mode of Quorum only works when the number of children is exactly two, so any attempt to add a new one must return an error.
quorum_del_child() on the other hand doesn't need any additional check because decreasing the number of children would make it go under the vote threshold.
--- block/quorum.c | 8 ++++++++ 1 file changed, 8 insertions(+)
block/quorum.c +8 -0
@@ -992,6 +992,11 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,char indexstr[32 ];int ret; +if (s->is_blkverify) { +error_setg (errp,"Cannot add a child to a quorum in blkverify mode" ); +return ; + } +assert (s->num_children <=INT_MAX /sizeof (BdrvChild *));if (s->num_children ==INT_MAX /sizeof (BdrvChild *) || s->next_child_index ==UINT_MAX ) {
@@ -1046,6 +1051,9 @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child,return ; } +/* We know now that num_children > threshold, so blkverify must be false */ +assert (!s->is_blkverify); +bdrv_drained_begin (bs);/* We can safely remove this child now */
Signature · 1 line
2.11.0
PATCH 2/2 iotest: Test x-blockdev-change on a Quorum
In reply to Alberto GarciaThis patch tests that you can add and remove drives from a Quorum using the x-blockdev-change command.
--- tests/qemu-iotests/081 | 86 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/081.out | 54 +++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+)
tests/qemu-iotests/081 +86 -0
@@ -198,6 +198,92 @@ quorum="$quorum,file.children.2.driver=raw" $QEMU_IO -c "open -o $quorum" | _filter_qemu_io +echo +echo "== dinamically adding a child to a quorum ==" + +for verify in false true; do + run_qemu <<EOF + { "execute": "qmp_capabilities" } + { "execute": "blockdev-add", + "arguments": { + "driver": "quorum", + "node-name": "drive0-quorum", + "vote-threshold": 2, + "blkverify": ${verify}, + "children": [ + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/1.raw" + } + }, + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/2.raw" + } + } + ] + } + } + { "execute": "blockdev-add", + "arguments": { + "node-name": "drive3", + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/2.raw" + } + } + } + { "execute": "x-blockdev-change", + "arguments": { "parent": "drive0-quorum", + "node": "drive3" } } + { "execute": "quit" } +EOF +done + +echo +echo "== dinamically removing a child from a quorum ==" + +for verify in false true; do + for vote_threshold in 1 2; do + run_qemu <<EOF + { "execute": "qmp_capabilities" } + { "execute": "blockdev-add", + "arguments": { + "driver": "quorum", + "node-name": "drive0-quorum", + "vote-threshold": ${vote_threshold}, + "blkverify": ${verify}, + "children": [ + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/1.raw" + } + }, + { + "driver": "$IMGFMT", + "file": { + "driver": "file", + "filename": "$TEST_DIR/2.raw" + } + } + ] + } + } + { "execute": "x-blockdev-change", + "arguments": { "parent": "drive0-quorum", + "child": "children.1" } } + { "execute": "quit" } +EOF + done +done + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/081.out +54 -0
58 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH 2/2] iotest: Test x-blockdev-change on a Quorum
Am 18.10.2018 um 10:59 hat Alberto Garcia geschrieben:
tests/qemu-iotests/081 quorum="$quorum,file.children.2.driver=raw" · line 202
Quoted 13 lines
This patch tests that you can add and remove drives from a Quorum using the x-blockdev-change command.
Signed-off-by Alberto Garcia <[email protected]>tests/qemu-iotests/081 +2
-0@@ -198,6 +198,92 @@ quorum="$quorum,file.children.2.driver=raw" $QEMU_IO -c "open -o $quorum" | _filter_qemu_io +echo +echo "== dinamically adding a child to a quorum =="
s/dinamically/dynamically/ (and in three more instances)
Thanks, fixed the typo and applied the series to the block branch.
Kevin