arm_gicv3_kvm: increase clroffset accordingly
[qemu/ar7.git] / tests / test-bdrv-drain.c
bloba11c4cfbf294df96f86c846512adddb4004dc322
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(Job *job, void *opaque)
501 job_completed(job, 0, NULL);
504 static void coroutine_fn test_job_start(void *opaque)
506 TestBlockJob *s = opaque;
508 job_transition_to_ready(&s->common.job);
509 while (!s->should_complete) {
510 job_sleep_ns(&s->common.job, 100000);
513 job_defer_to_main_loop(&s->common.job, test_job_completed, NULL);
516 static void test_job_complete(Job *job, Error **errp)
518 TestBlockJob *s = container_of(job, TestBlockJob, common.job);
519 s->should_complete = true;
522 BlockJobDriver test_job_driver = {
523 .job_driver = {
524 .instance_size = sizeof(TestBlockJob),
525 .free = block_job_free,
526 .user_resume = block_job_user_resume,
527 .drain = block_job_drain,
528 .start = test_job_start,
529 .complete = test_job_complete,
533 static void test_blockjob_common(enum drain_type drain_type)
535 BlockBackend *blk_src, *blk_target;
536 BlockDriverState *src, *target;
537 BlockJob *job;
538 int ret;
540 src = bdrv_new_open_driver(&bdrv_test, "source", BDRV_O_RDWR,
541 &error_abort);
542 blk_src = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
543 blk_insert_bs(blk_src, src, &error_abort);
545 target = bdrv_new_open_driver(&bdrv_test, "target", BDRV_O_RDWR,
546 &error_abort);
547 blk_target = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
548 blk_insert_bs(blk_target, target, &error_abort);
550 job = block_job_create("job0", &test_job_driver, NULL, src, 0, BLK_PERM_ALL,
551 0, 0, NULL, NULL, &error_abort);
552 block_job_add_bdrv(job, "target", target, 0, BLK_PERM_ALL, &error_abort);
553 job_start(&job->job);
555 g_assert_cmpint(job->job.pause_count, ==, 0);
556 g_assert_false(job->job.paused);
557 g_assert_false(job->job.busy); /* We're in job_sleep_ns() */
559 do_drain_begin(drain_type, src);
561 if (drain_type == BDRV_DRAIN_ALL) {
562 /* bdrv_drain_all() drains both src and target */
563 g_assert_cmpint(job->job.pause_count, ==, 2);
564 } else {
565 g_assert_cmpint(job->job.pause_count, ==, 1);
567 /* XXX We don't wait until the job is actually paused. Is this okay? */
568 /* g_assert_true(job->job.paused); */
569 g_assert_false(job->job.busy); /* The job is paused */
571 do_drain_end(drain_type, src);
573 g_assert_cmpint(job->job.pause_count, ==, 0);
574 g_assert_false(job->job.paused);
575 g_assert_false(job->job.busy); /* We're in job_sleep_ns() */
577 do_drain_begin(drain_type, target);
579 if (drain_type == BDRV_DRAIN_ALL) {
580 /* bdrv_drain_all() drains both src and target */
581 g_assert_cmpint(job->job.pause_count, ==, 2);
582 } else {
583 g_assert_cmpint(job->job.pause_count, ==, 1);
585 /* XXX We don't wait until the job is actually paused. Is this okay? */
586 /* g_assert_true(job->job.paused); */
587 g_assert_false(job->job.busy); /* The job is paused */
589 do_drain_end(drain_type, target);
591 g_assert_cmpint(job->job.pause_count, ==, 0);
592 g_assert_false(job->job.paused);
593 g_assert_false(job->job.busy); /* We're in job_sleep_ns() */
595 ret = job_complete_sync(&job->job, &error_abort);
596 g_assert_cmpint(ret, ==, 0);
598 blk_unref(blk_src);
599 blk_unref(blk_target);
600 bdrv_unref(src);
601 bdrv_unref(target);
604 static void test_blockjob_drain_all(void)
606 test_blockjob_common(BDRV_DRAIN_ALL);
609 static void test_blockjob_drain(void)
611 test_blockjob_common(BDRV_DRAIN);
614 static void test_blockjob_drain_subtree(void)
616 test_blockjob_common(BDRV_SUBTREE_DRAIN);
619 int main(int argc, char **argv)
621 bdrv_init();
622 qemu_init_main_loop(&error_abort);
624 g_test_init(&argc, &argv, NULL);
626 g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_all);
627 g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain);
628 g_test_add_func("/bdrv-drain/driver-cb/drain_subtree",
629 test_drv_cb_drain_subtree);
631 // XXX bdrv_drain_all() doesn't work in coroutine context
632 g_test_add_func("/bdrv-drain/driver-cb/co/drain", test_drv_cb_co_drain);
633 g_test_add_func("/bdrv-drain/driver-cb/co/drain_subtree",
634 test_drv_cb_co_drain_subtree);
637 g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_all);
638 g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain);
639 g_test_add_func("/bdrv-drain/quiesce/drain_subtree",
640 test_quiesce_drain_subtree);
642 // XXX bdrv_drain_all() doesn't work in coroutine context
643 g_test_add_func("/bdrv-drain/quiesce/co/drain", test_quiesce_co_drain);
644 g_test_add_func("/bdrv-drain/quiesce/co/drain_subtree",
645 test_quiesce_co_drain_subtree);
647 g_test_add_func("/bdrv-drain/nested", test_nested);
648 g_test_add_func("/bdrv-drain/multiparent", test_multiparent);
649 g_test_add_func("/bdrv-drain/graph-change", test_graph_change);
651 g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_all);
652 g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain);
653 g_test_add_func("/bdrv-drain/blockjob/drain_subtree",
654 test_blockjob_drain_subtree);
656 return g_test_run();