target/arm: Expand vector registers for SVE
[qemu/ar7.git] / tests / test-bdrv-drain.c
blobd760e2b24356476d4beadf553ea717972c7e0073
1 /*
2 * Block node draining tests
4 * Copyright (c) 2017 Kevin Wolf <kwolf@redhat.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #include "qemu/osdep.h"
26 #include "block/block.h"
27 #include "block/blockjob_int.h"
28 #include "sysemu/block-backend.h"
29 #include "qapi/error.h"
31 typedef struct BDRVTestState {
32 int drain_count;
33 } BDRVTestState;
35 static void coroutine_fn bdrv_test_co_drain_begin(BlockDriverState *bs)
37 BDRVTestState *s = bs->opaque;
38 s->drain_count++;
41 static void coroutine_fn bdrv_test_co_drain_end(BlockDriverState *bs)
43 BDRVTestState *s = bs->opaque;
44 s->drain_count--;
47 static void bdrv_test_close(BlockDriverState *bs)
49 BDRVTestState *s = bs->opaque;
50 g_assert_cmpint(s->drain_count, >, 0);
53 static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs,
54 uint64_t offset, uint64_t bytes,
55 QEMUIOVector *qiov, int flags)
57 /* We want this request to stay until the polling loop in drain waits for
58 * it to complete. We need to sleep a while as bdrv_drain_invoke() comes
59 * first and polls its result, too, but it shouldn't accidentally complete
60 * this request yet. */
61 qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000);
63 return 0;
66 static BlockDriver bdrv_test = {
67 .format_name = "test",
68 .instance_size = sizeof(BDRVTestState),
70 .bdrv_close = bdrv_test_close,
71 .bdrv_co_preadv = bdrv_test_co_preadv,
73 .bdrv_co_drain_begin = bdrv_test_co_drain_begin,
74 .bdrv_co_drain_end = bdrv_test_co_drain_end,
76 .bdrv_child_perm = bdrv_format_default_perms,
79 static void aio_ret_cb(void *opaque, int ret)
81 int *aio_ret = opaque;
82 *aio_ret = ret;
85 typedef struct CallInCoroutineData {
86 void (*entry)(void);
87 bool done;
88 } CallInCoroutineData;
90 static coroutine_fn void call_in_coroutine_entry(void *opaque)
92 CallInCoroutineData *data = opaque;
94 data->entry();
95 data->done = true;
98 static void call_in_coroutine(void (*entry)(void))
100 Coroutine *co;
101 CallInCoroutineData data = {
102 .entry = entry,
103 .done = false,
106 co = qemu_coroutine_create(call_in_coroutine_entry, &data);
107 qemu_coroutine_enter(co);
108 while (!data.done) {
109 aio_poll(qemu_get_aio_context(), true);
113 enum drain_type {
114 BDRV_DRAIN_ALL,
115 BDRV_DRAIN,
116 BDRV_SUBTREE_DRAIN,
117 DRAIN_TYPE_MAX,
120 static void do_drain_begin(enum drain_type drain_type, BlockDriverState *bs)
122 switch (drain_type) {
123 case BDRV_DRAIN_ALL: bdrv_drain_all_begin(); break;
124 case BDRV_DRAIN: bdrv_drained_begin(bs); break;
125 case BDRV_SUBTREE_DRAIN: bdrv_subtree_drained_begin(bs); break;
126 default: g_assert_not_reached();
130 static void do_drain_end(enum drain_type drain_type, BlockDriverState *bs)
132 switch (drain_type) {
133 case BDRV_DRAIN_ALL: bdrv_drain_all_end(); break;
134 case BDRV_DRAIN: bdrv_drained_end(bs); break;
135 case BDRV_SUBTREE_DRAIN: bdrv_subtree_drained_end(bs); break;
136 default: g_assert_not_reached();
140 static void test_drv_cb_common(enum drain_type drain_type, bool recursive)
142 BlockBackend *blk;
143 BlockDriverState *bs, *backing;
144 BDRVTestState *s, *backing_s;
145 BlockAIOCB *acb;
146 int aio_ret;
148 QEMUIOVector qiov;
149 struct iovec iov = {
150 .iov_base = NULL,
151 .iov_len = 0,
153 qemu_iovec_init_external(&qiov, &iov, 1);
155 blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
156 bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
157 &error_abort);
158 s = bs->opaque;
159 blk_insert_bs(blk, bs, &error_abort);
161 backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
162 backing_s = backing->opaque;
163 bdrv_set_backing_hd(bs, backing, &error_abort);
165 /* Simple bdrv_drain_all_begin/end pair, check that CBs are called */
166 g_assert_cmpint(s->drain_count, ==, 0);
167 g_assert_cmpint(backing_s->drain_count, ==, 0);
169 do_drain_begin(drain_type, bs);
171 g_assert_cmpint(s->drain_count, ==, 1);
172 g_assert_cmpint(backing_s->drain_count, ==, !!recursive);
174 do_drain_end(drain_type, bs);
176 g_assert_cmpint(s->drain_count, ==, 0);
177 g_assert_cmpint(backing_s->drain_count, ==, 0);
179 /* Now do the same while a request is pending */
180 aio_ret = -EINPROGRESS;
181 acb = blk_aio_preadv(blk, 0, &qiov, 0, aio_ret_cb, &aio_ret);
182 g_assert(acb != NULL);
183 g_assert_cmpint(aio_ret, ==, -EINPROGRESS);
185 g_assert_cmpint(s->drain_count, ==, 0);
186 g_assert_cmpint(backing_s->drain_count, ==, 0);
188 do_drain_begin(drain_type, bs);
190 g_assert_cmpint(aio_ret, ==, 0);
191 g_assert_cmpint(s->drain_count, ==, 1);
192 g_assert_cmpint(backing_s->drain_count, ==, !!recursive);
194 do_drain_end(drain_type, bs);
196 g_assert_cmpint(s->drain_count, ==, 0);
197 g_assert_cmpint(backing_s->drain_count, ==, 0);
199 bdrv_unref(backing);
200 bdrv_unref(bs);
201 blk_unref(blk);
204 static void test_drv_cb_drain_all(void)
206 test_drv_cb_common(BDRV_DRAIN_ALL, true);
209 static void test_drv_cb_drain(void)
211 test_drv_cb_common(BDRV_DRAIN, false);
214 static void test_drv_cb_drain_subtree(void)
216 test_drv_cb_common(BDRV_SUBTREE_DRAIN, true);
219 static void test_drv_cb_co_drain(void)
221 call_in_coroutine(test_drv_cb_drain);
224 static void test_drv_cb_co_drain_subtree(void)
226 call_in_coroutine(test_drv_cb_drain_subtree);
229 static void test_quiesce_common(enum drain_type drain_type, bool recursive)
231 BlockBackend *blk;
232 BlockDriverState *bs, *backing;
234 blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
235 bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
236 &error_abort);
237 blk_insert_bs(blk, bs, &error_abort);
239 backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
240 bdrv_set_backing_hd(bs, backing, &error_abort);
242 g_assert_cmpint(bs->quiesce_counter, ==, 0);
243 g_assert_cmpint(backing->quiesce_counter, ==, 0);
245 do_drain_begin(drain_type, bs);
247 g_assert_cmpint(bs->quiesce_counter, ==, 1);
248 g_assert_cmpint(backing->quiesce_counter, ==, !!recursive);
250 do_drain_end(drain_type, bs);
252 g_assert_cmpint(bs->quiesce_counter, ==, 0);
253 g_assert_cmpint(backing->quiesce_counter, ==, 0);
255 bdrv_unref(backing);
256 bdrv_unref(bs);
257 blk_unref(blk);
260 static void test_quiesce_drain_all(void)
262 // XXX drain_all doesn't quiesce
263 //test_quiesce_common(BDRV_DRAIN_ALL, true);
266 static void test_quiesce_drain(void)
268 test_quiesce_common(BDRV_DRAIN, false);
271 static void test_quiesce_drain_subtree(void)
273 test_quiesce_common(BDRV_SUBTREE_DRAIN, true);
276 static void test_quiesce_co_drain(void)
278 call_in_coroutine(test_quiesce_drain);
281 static void test_quiesce_co_drain_subtree(void)
283 call_in_coroutine(test_quiesce_drain_subtree);
286 static void test_nested(void)
288 BlockBackend *blk;
289 BlockDriverState *bs, *backing;
290 BDRVTestState *s, *backing_s;
291 enum drain_type outer, inner;
293 blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
294 bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
295 &error_abort);
296 s = bs->opaque;
297 blk_insert_bs(blk, bs, &error_abort);
299 backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
300 backing_s = backing->opaque;
301 bdrv_set_backing_hd(bs, backing, &error_abort);
303 for (outer = 0; outer < DRAIN_TYPE_MAX; outer++) {
304 for (inner = 0; inner < DRAIN_TYPE_MAX; inner++) {
305 /* XXX bdrv_drain_all() doesn't increase the quiesce_counter */
306 int bs_quiesce = (outer != BDRV_DRAIN_ALL) +
307 (inner != BDRV_DRAIN_ALL);
308 int backing_quiesce = (outer == BDRV_SUBTREE_DRAIN) +
309 (inner == BDRV_SUBTREE_DRAIN);
310 int backing_cb_cnt = (outer != BDRV_DRAIN) +
311 (inner != BDRV_DRAIN);
313 g_assert_cmpint(bs->quiesce_counter, ==, 0);
314 g_assert_cmpint(backing->quiesce_counter, ==, 0);
315 g_assert_cmpint(s->drain_count, ==, 0);
316 g_assert_cmpint(backing_s->drain_count, ==, 0);
318 do_drain_begin(outer, bs);
319 do_drain_begin(inner, bs);
321 g_assert_cmpint(bs->quiesce_counter, ==, bs_quiesce);
322 g_assert_cmpint(backing->quiesce_counter, ==, backing_quiesce);
323 g_assert_cmpint(s->drain_count, ==, 2);
324 g_assert_cmpint(backing_s->drain_count, ==, backing_cb_cnt);
326 do_drain_end(inner, bs);
327 do_drain_end(outer, bs);
329 g_assert_cmpint(bs->quiesce_counter, ==, 0);
330 g_assert_cmpint(backing->quiesce_counter, ==, 0);
331 g_assert_cmpint(s->drain_count, ==, 0);
332 g_assert_cmpint(backing_s->drain_count, ==, 0);
336 bdrv_unref(backing);
337 bdrv_unref(bs);
338 blk_unref(blk);
341 static void test_multiparent(void)
343 BlockBackend *blk_a, *blk_b;
344 BlockDriverState *bs_a, *bs_b, *backing;
345 BDRVTestState *a_s, *b_s, *backing_s;
347 blk_a = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
348 bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
349 &error_abort);
350 a_s = bs_a->opaque;
351 blk_insert_bs(blk_a, bs_a, &error_abort);
353 blk_b = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
354 bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
355 &error_abort);
356 b_s = bs_b->opaque;
357 blk_insert_bs(blk_b, bs_b, &error_abort);
359 backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
360 backing_s = backing->opaque;
361 bdrv_set_backing_hd(bs_a, backing, &error_abort);
362 bdrv_set_backing_hd(bs_b, backing, &error_abort);
364 g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
365 g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
366 g_assert_cmpint(backing->quiesce_counter, ==, 0);
367 g_assert_cmpint(a_s->drain_count, ==, 0);
368 g_assert_cmpint(b_s->drain_count, ==, 0);
369 g_assert_cmpint(backing_s->drain_count, ==, 0);
371 do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
373 g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
374 g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
375 g_assert_cmpint(backing->quiesce_counter, ==, 1);
376 g_assert_cmpint(a_s->drain_count, ==, 1);
377 g_assert_cmpint(b_s->drain_count, ==, 1);
378 g_assert_cmpint(backing_s->drain_count, ==, 1);
380 do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
382 g_assert_cmpint(bs_a->quiesce_counter, ==, 2);
383 g_assert_cmpint(bs_b->quiesce_counter, ==, 2);
384 g_assert_cmpint(backing->quiesce_counter, ==, 2);
385 g_assert_cmpint(a_s->drain_count, ==, 2);
386 g_assert_cmpint(b_s->drain_count, ==, 2);
387 g_assert_cmpint(backing_s->drain_count, ==, 2);
389 do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
391 g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
392 g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
393 g_assert_cmpint(backing->quiesce_counter, ==, 1);
394 g_assert_cmpint(a_s->drain_count, ==, 1);
395 g_assert_cmpint(b_s->drain_count, ==, 1);
396 g_assert_cmpint(backing_s->drain_count, ==, 1);
398 do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
400 g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
401 g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
402 g_assert_cmpint(backing->quiesce_counter, ==, 0);
403 g_assert_cmpint(a_s->drain_count, ==, 0);
404 g_assert_cmpint(b_s->drain_count, ==, 0);
405 g_assert_cmpint(backing_s->drain_count, ==, 0);
407 bdrv_unref(backing);
408 bdrv_unref(bs_a);
409 bdrv_unref(bs_b);
410 blk_unref(blk_a);
411 blk_unref(blk_b);
414 static void test_graph_change(void)
416 BlockBackend *blk_a, *blk_b;
417 BlockDriverState *bs_a, *bs_b, *backing;
418 BDRVTestState *a_s, *b_s, *backing_s;
420 blk_a = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
421 bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
422 &error_abort);
423 a_s = bs_a->opaque;
424 blk_insert_bs(blk_a, bs_a, &error_abort);
426 blk_b = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
427 bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
428 &error_abort);
429 b_s = bs_b->opaque;
430 blk_insert_bs(blk_b, bs_b, &error_abort);
432 backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
433 backing_s = backing->opaque;
434 bdrv_set_backing_hd(bs_a, backing, &error_abort);
436 g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
437 g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
438 g_assert_cmpint(backing->quiesce_counter, ==, 0);
439 g_assert_cmpint(a_s->drain_count, ==, 0);
440 g_assert_cmpint(b_s->drain_count, ==, 0);
441 g_assert_cmpint(backing_s->drain_count, ==, 0);
443 do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
444 do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
445 do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
446 do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
447 do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
449 bdrv_set_backing_hd(bs_b, backing, &error_abort);
450 g_assert_cmpint(bs_a->quiesce_counter, ==, 5);
451 g_assert_cmpint(bs_b->quiesce_counter, ==, 5);
452 g_assert_cmpint(backing->quiesce_counter, ==, 5);
453 g_assert_cmpint(a_s->drain_count, ==, 5);
454 g_assert_cmpint(b_s->drain_count, ==, 5);
455 g_assert_cmpint(backing_s->drain_count, ==, 5);
457 bdrv_set_backing_hd(bs_b, NULL, &error_abort);
458 g_assert_cmpint(bs_a->quiesce_counter, ==, 3);
459 g_assert_cmpint(bs_b->quiesce_counter, ==, 2);
460 g_assert_cmpint(backing->quiesce_counter, ==, 3);
461 g_assert_cmpint(a_s->drain_count, ==, 3);
462 g_assert_cmpint(b_s->drain_count, ==, 2);
463 g_assert_cmpint(backing_s->drain_count, ==, 3);
465 bdrv_set_backing_hd(bs_b, backing, &error_abort);
466 g_assert_cmpint(bs_a->quiesce_counter, ==, 5);
467 g_assert_cmpint(bs_b->quiesce_counter, ==, 5);
468 g_assert_cmpint(backing->quiesce_counter, ==, 5);
469 g_assert_cmpint(a_s->drain_count, ==, 5);
470 g_assert_cmpint(b_s->drain_count, ==, 5);
471 g_assert_cmpint(backing_s->drain_count, ==, 5);
473 do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
474 do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
475 do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
476 do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
477 do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
479 g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
480 g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
481 g_assert_cmpint(backing->quiesce_counter, ==, 0);
482 g_assert_cmpint(a_s->drain_count, ==, 0);
483 g_assert_cmpint(b_s->drain_count, ==, 0);
484 g_assert_cmpint(backing_s->drain_count, ==, 0);
486 bdrv_unref(backing);
487 bdrv_unref(bs_a);
488 bdrv_unref(bs_b);
489 blk_unref(blk_a);
490 blk_unref(blk_b);
494 typedef struct TestBlockJob {
495 BlockJob common;
496 bool should_complete;
497 } TestBlockJob;
499 static void test_job_completed(BlockJob *job, void *opaque)
501 block_job_completed(job, 0);
504 static void coroutine_fn test_job_start(void *opaque)
506 TestBlockJob *s = opaque;
508 while (!s->should_complete) {
509 block_job_sleep_ns(&s->common, 100000);
512 block_job_defer_to_main_loop(&s->common, test_job_completed, NULL);
515 static void test_job_complete(BlockJob *job, Error **errp)
517 TestBlockJob *s = container_of(job, TestBlockJob, common);
518 s->should_complete = true;
521 BlockJobDriver test_job_driver = {
522 .instance_size = sizeof(TestBlockJob),
523 .start = test_job_start,
524 .complete = test_job_complete,
527 static void test_blockjob_common(enum drain_type drain_type)
529 BlockBackend *blk_src, *blk_target;
530 BlockDriverState *src, *target;
531 BlockJob *job;
532 int ret;
534 src = bdrv_new_open_driver(&bdrv_test, "source", BDRV_O_RDWR,
535 &error_abort);
536 blk_src = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
537 blk_insert_bs(blk_src, src, &error_abort);
539 target = bdrv_new_open_driver(&bdrv_test, "target", BDRV_O_RDWR,
540 &error_abort);
541 blk_target = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
542 blk_insert_bs(blk_target, target, &error_abort);
544 job = block_job_create("job0", &test_job_driver, src, 0, BLK_PERM_ALL, 0,
545 0, NULL, NULL, &error_abort);
546 block_job_add_bdrv(job, "target", target, 0, BLK_PERM_ALL, &error_abort);
547 block_job_start(job);
549 g_assert_cmpint(job->pause_count, ==, 0);
550 g_assert_false(job->paused);
551 g_assert_false(job->busy); /* We're in block_job_sleep_ns() */
553 do_drain_begin(drain_type, src);
555 if (drain_type == BDRV_DRAIN_ALL) {
556 /* bdrv_drain_all() drains both src and target */
557 g_assert_cmpint(job->pause_count, ==, 2);
558 } else {
559 g_assert_cmpint(job->pause_count, ==, 1);
561 /* XXX We don't wait until the job is actually paused. Is this okay? */
562 /* g_assert_true(job->paused); */
563 g_assert_false(job->busy); /* The job is paused */
565 do_drain_end(drain_type, src);
567 g_assert_cmpint(job->pause_count, ==, 0);
568 g_assert_false(job->paused);
569 g_assert_false(job->busy); /* We're in block_job_sleep_ns() */
571 do_drain_begin(drain_type, target);
573 if (drain_type == BDRV_DRAIN_ALL) {
574 /* bdrv_drain_all() drains both src and target */
575 g_assert_cmpint(job->pause_count, ==, 2);
576 } else {
577 g_assert_cmpint(job->pause_count, ==, 1);
579 /* XXX We don't wait until the job is actually paused. Is this okay? */
580 /* g_assert_true(job->paused); */
581 g_assert_false(job->busy); /* The job is paused */
583 do_drain_end(drain_type, target);
585 g_assert_cmpint(job->pause_count, ==, 0);
586 g_assert_false(job->paused);
587 g_assert_false(job->busy); /* We're in block_job_sleep_ns() */
589 ret = block_job_complete_sync(job, &error_abort);
590 g_assert_cmpint(ret, ==, 0);
592 blk_unref(blk_src);
593 blk_unref(blk_target);
594 bdrv_unref(src);
595 bdrv_unref(target);
598 static void test_blockjob_drain_all(void)
600 test_blockjob_common(BDRV_DRAIN_ALL);
603 static void test_blockjob_drain(void)
605 test_blockjob_common(BDRV_DRAIN);
608 static void test_blockjob_drain_subtree(void)
610 test_blockjob_common(BDRV_SUBTREE_DRAIN);
613 int main(int argc, char **argv)
615 bdrv_init();
616 qemu_init_main_loop(&error_abort);
618 g_test_init(&argc, &argv, NULL);
620 g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_all);
621 g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain);
622 g_test_add_func("/bdrv-drain/driver-cb/drain_subtree",
623 test_drv_cb_drain_subtree);
625 // XXX bdrv_drain_all() doesn't work in coroutine context
626 g_test_add_func("/bdrv-drain/driver-cb/co/drain", test_drv_cb_co_drain);
627 g_test_add_func("/bdrv-drain/driver-cb/co/drain_subtree",
628 test_drv_cb_co_drain_subtree);
631 g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_all);
632 g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain);
633 g_test_add_func("/bdrv-drain/quiesce/drain_subtree",
634 test_quiesce_drain_subtree);
636 // XXX bdrv_drain_all() doesn't work in coroutine context
637 g_test_add_func("/bdrv-drain/quiesce/co/drain", test_quiesce_co_drain);
638 g_test_add_func("/bdrv-drain/quiesce/co/drain_subtree",
639 test_quiesce_co_drain_subtree);
641 g_test_add_func("/bdrv-drain/nested", test_nested);
642 g_test_add_func("/bdrv-drain/multiparent", test_multiparent);
643 g_test_add_func("/bdrv-drain/graph-change", test_graph_change);
645 g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_all);
646 g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain);
647 g_test_add_func("/bdrv-drain/blockjob/drain_subtree",
648 test_blockjob_drain_subtree);
650 return g_test_run();