All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] Forbid adding children to a Quorum in blkverify mode
@ 2018-10-18  8:59 Alberto Garcia
  2018-10-18  8:59 ` [Qemu-devel] [PATCH 1/2] quorum: Forbid adding children " Alberto Garcia
  2018-10-18  8:59 ` [Qemu-devel] [PATCH 2/2] iotest: Test x-blockdev-change on a Quorum Alberto Garcia
  0 siblings, 2 replies; 4+ messages in thread
From: Alberto Garcia @ 2018-10-18  8:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alberto Garcia, qemu-block, Kevin Wolf, Max Reitz

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(+)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 1/2] quorum: Forbid adding children in blkverify mode
  2018-10-18  8:59 [Qemu-devel] [PATCH 0/2] Forbid adding children to a Quorum in blkverify mode Alberto Garcia
@ 2018-10-18  8:59 ` Alberto Garcia
  2018-10-18  8:59 ` [Qemu-devel] [PATCH 2/2] iotest: Test x-blockdev-change on a Quorum Alberto Garcia
  1 sibling, 0 replies; 4+ messages in thread
From: Alberto Garcia @ 2018-10-18  8:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alberto Garcia, qemu-block, Kevin Wolf, Max Reitz

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.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reported-by: Kevin Wolf <kwolf@redhat.com>
---
 block/quorum.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/block/quorum.c b/block/quorum.c
index 6188ff6666..16b3c8067c 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -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 */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 2/2] iotest: Test x-blockdev-change on a Quorum
  2018-10-18  8:59 [Qemu-devel] [PATCH 0/2] Forbid adding children to a Quorum in blkverify mode Alberto Garcia
  2018-10-18  8:59 ` [Qemu-devel] [PATCH 1/2] quorum: Forbid adding children " Alberto Garcia
@ 2018-10-18  8:59 ` Alberto Garcia
  2018-10-18 13:07   ` Kevin Wolf
  1 sibling, 1 reply; 4+ messages in thread
From: Alberto Garcia @ 2018-10-18  8:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alberto Garcia, qemu-block, Kevin Wolf, Max Reitz

This patch tests that you can add and remove drives from a Quorum
using the x-blockdev-change command.

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 tests/qemu-iotests/081     | 86 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/081.out | 54 +++++++++++++++++++++++++++++
 2 files changed, 140 insertions(+)

diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
index 0ea010afbf..7a441f9300 100755
--- a/tests/qemu-iotests/081
+++ b/tests/qemu-iotests/081
@@ -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
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
index 2f12c890e9..909f3fba3b 100644
--- a/tests/qemu-iotests/081.out
+++ b/tests/qemu-iotests/081.out
@@ -71,4 +71,58 @@ read 10485760/10485760 bytes at offset 0
 
 == checking the blkverify mode with invalid settings ==
 can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2
+
+== dinamically adding a child to a quorum ==
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "Cannot add a child to a quorum in blkverify mode"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+
+
+== dinamically removing a child from a quorum ==
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "blkverify=on can only be set if there are exactly two files and vote-threshold is 2"}}
+{"error": {"class": "GenericError", "desc": "Cannot find device=drive0-quorum nor node_name=drive0-quorum"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "The number of children cannot be lower than the vote threshold 2"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
+
 *** done
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] iotest: Test x-blockdev-change on a Quorum
  2018-10-18  8:59 ` [Qemu-devel] [PATCH 2/2] iotest: Test x-blockdev-change on a Quorum Alberto Garcia
@ 2018-10-18 13:07   ` Kevin Wolf
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2018-10-18 13:07 UTC (permalink / raw)
  To: Alberto Garcia; +Cc: qemu-devel, qemu-block, Max Reitz

Am 18.10.2018 um 10:59 hat Alberto Garcia geschrieben:
> This patch tests that you can add and remove drives from a Quorum
> using the x-blockdev-change command.
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>

> --- a/tests/qemu-iotests/081
> +++ b/tests/qemu-iotests/081
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-18 13:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18  8:59 [Qemu-devel] [PATCH 0/2] Forbid adding children to a Quorum in blkverify mode Alberto Garcia
2018-10-18  8:59 ` [Qemu-devel] [PATCH 1/2] quorum: Forbid adding children " Alberto Garcia
2018-10-18  8:59 ` [Qemu-devel] [PATCH 2/2] iotest: Test x-blockdev-change on a Quorum Alberto Garcia
2018-10-18 13:07   ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.