Re: [PATCH v2 27/33] tests: Use child_of_bds instead of child_file

2020-02-11 Thread Eric Blake

On 2/4/20 11:08 AM, Max Reitz wrote:

Signed-off-by: Max Reitz 
---


Another sparse commit message.


  tests/test-bdrv-drain.c | 29 +
  tests/test-bdrv-graph-mod.c |  6 --
  2 files changed, 21 insertions(+), 14 deletions(-)



Just touches the tests - so if the testsuite passes, the patch must be 
correct ;)


Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




[PATCH v2 27/33] tests: Use child_of_bds instead of child_file

2020-02-04 Thread Max Reitz
Signed-off-by: Max Reitz 
---
 tests/test-bdrv-drain.c | 29 +
 tests/test-bdrv-graph-mod.c |  6 --
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
index 15393a0140..91567ca97d 100644
--- a/tests/test-bdrv-drain.c
+++ b/tests/test-bdrv-drain.c
@@ -97,7 +97,7 @@ static void bdrv_test_child_perm(BlockDriverState *bs, 
BdrvChild *c,
  * detach_by_driver_cb_parent as one of them.
  */
 if (child_class != _file && child_class != _of_bds) {
-child_class = _file;
+child_class = _of_bds;
 }
 
 bdrv_format_default_perms(bs, c, child_class, role, reopen_queue,
@@ -1203,7 +1203,8 @@ static void do_test_delete_by_drain(bool 
detach_instead_of_delete,
 
 null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | 
BDRV_O_PROTOCOL,
 _abort);
-bdrv_attach_child(bs, null_bs, "null-child", _file, 0, _abort);
+bdrv_attach_child(bs, null_bs, "null-child", _of_bds,
+  BDRV_CHILD_DATA, _abort);
 
 /* This child will be the one to pass to requests through to, and
  * it will stall until a drain occurs */
@@ -1211,14 +1212,17 @@ static void do_test_delete_by_drain(bool 
detach_instead_of_delete,
 _abort);
 child_bs->total_sectors = 65536 >> BDRV_SECTOR_BITS;
 /* Takes our reference to child_bs */
-tts->wait_child = bdrv_attach_child(bs, child_bs, "wait-child", 
_file,
-0, _abort);
+tts->wait_child = bdrv_attach_child(bs, child_bs, "wait-child",
+_of_bds,
+BDRV_CHILD_DATA | BDRV_CHILD_PRIMARY,
+_abort);
 
 /* This child is just there to be deleted
  * (for detach_instead_of_delete == true) */
 null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | 
BDRV_O_PROTOCOL,
 _abort);
-bdrv_attach_child(bs, null_bs, "null-child", _file, 0, _abort);
+bdrv_attach_child(bs, null_bs, "null-child", _of_bds, 
BDRV_CHILD_DATA,
+  _abort);
 
 blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
 blk_insert_bs(blk, bs, _abort);
@@ -1315,7 +1319,8 @@ static void detach_indirect_bh(void *opaque)
 
 bdrv_ref(data->c);
 data->child_c = bdrv_attach_child(data->parent_b, data->c, "PB-C",
-  _file, 0, _abort);
+  _of_bds, BDRV_CHILD_DATA,
+  _abort);
 }
 
 static void detach_by_parent_aio_cb(void *opaque, int ret)
@@ -1332,7 +1337,7 @@ static void detach_by_driver_cb_drained_begin(BdrvChild 
*child)
 {
 aio_bh_schedule_oneshot(qemu_get_current_aio_context(),
 detach_indirect_bh, _by_parent_data);
-child_file.drained_begin(child);
+child_of_bds.drained_begin(child);
 }
 
 static BdrvChildClass detach_by_driver_cb_class;
@@ -1367,7 +1372,7 @@ static void test_detach_indirect(bool by_parent_cb)
 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, 0);
 
 if (!by_parent_cb) {
-detach_by_driver_cb_class = child_file;
+detach_by_driver_cb_class = child_of_bds;
 detach_by_driver_cb_class.drained_begin =
 detach_by_driver_cb_drained_begin;
 }
@@ -1397,15 +1402,15 @@ static void test_detach_indirect(bool by_parent_cb)
 /* Set child relationships */
 bdrv_ref(b);
 bdrv_ref(a);
-child_b = bdrv_attach_child(parent_b, b, "PB-B", _file, 0,
-_abort);
+child_b = bdrv_attach_child(parent_b, b, "PB-B", _of_bds,
+BDRV_CHILD_DATA, _abort);
 child_a = bdrv_attach_child(parent_b, a, "PB-A", _of_bds,
 BDRV_CHILD_COW, _abort);
 
 bdrv_ref(a);
 bdrv_attach_child(parent_a, a, "PA-A",
-  by_parent_cb ? _file : _by_driver_cb_class,
-  0, _abort);
+  by_parent_cb ? _of_bds : 
_by_driver_cb_class,
+  BDRV_CHILD_DATA, _abort);
 
 g_assert_cmpint(parent_a->refcnt, ==, 1);
 g_assert_cmpint(parent_b->refcnt, ==, 1);
diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c
index 3707e2533c..6ae91ff171 100644
--- a/tests/test-bdrv-graph-mod.c
+++ b/tests/test-bdrv-graph-mod.c
@@ -112,7 +112,8 @@ static void test_update_perm_tree(void)
 
 blk_insert_bs(root, bs, _abort);
 
-bdrv_attach_child(filter, bs, "child", _file, 0, _abort);
+bdrv_attach_child(filter, bs, "child", _of_bds,
+  BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, _abort);
 
 bdrv_append(filter, bs, _err);
 
@@ -178,7 +179,8 @@ static void test_should_update_child(void)
 bdrv_set_backing_hd(target, bs, _abort);
 
 g_assert(target->backing->bs == bs);
-