If we remove the child with the highest index from the quorum,
decrement s->next_child_index. This way we get stable children
names as long as we only remove the last child.

Signed-off-by: Lukas Straub <lukasstra...@web.de>
---
 block/quorum.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/block/quorum.c b/block/quorum.c
index df68adcfaa..6100d4108a 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1054,6 +1054,12 @@ static void quorum_del_child(BlockDriverState *bs, 
BdrvChild *child,
     /* We know now that num_children > threshold, so blkverify must be false */
     assert(!s->is_blkverify);

+    unsigned child_id;
+    sscanf(child->name, "children.%u", &child_id);
+    if (child_id == s->next_child_index - 1) {
+        s->next_child_index--;
+    }
+
     bdrv_drained_begin(bs);

     /* We can safely remove this child now */
--
2.20.1


Reply via email to