block: Fix deadlocks in bdrv_graph_wrunlock()
[qemu/kevin.git] / block / replication.c
blob5ded5f1ca94ba7e893c30d7d525931028f65b816
1 /*
2 * Replication Block filter
4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
5 * Copyright (c) 2016 Intel Corporation
6 * Copyright (c) 2016 FUJITSU LIMITED
8 * Author:
9 * Wen Congyang <wency@cn.fujitsu.com>
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include "qemu/module.h"
17 #include "qemu/option.h"
18 #include "block/nbd.h"
19 #include "block/blockjob.h"
20 #include "block/block_int.h"
21 #include "block/block_backup.h"
22 #include "sysemu/block-backend.h"
23 #include "qapi/error.h"
24 #include "qapi/qmp/qdict.h"
25 #include "block/replication.h"
27 typedef enum {
28 BLOCK_REPLICATION_NONE, /* block replication is not started */
29 BLOCK_REPLICATION_RUNNING, /* block replication is running */
30 BLOCK_REPLICATION_FAILOVER, /* failover is running in background */
31 BLOCK_REPLICATION_FAILOVER_FAILED, /* failover failed */
32 BLOCK_REPLICATION_DONE, /* block replication is done */
33 } ReplicationStage;
35 typedef struct BDRVReplicationState {
36 ReplicationMode mode;
37 ReplicationStage stage;
38 BlockJob *commit_job;
39 BdrvChild *hidden_disk;
40 BdrvChild *secondary_disk;
41 BlockJob *backup_job;
42 char *top_id;
43 ReplicationState *rs;
44 Error *blocker;
45 bool orig_hidden_read_only;
46 bool orig_secondary_read_only;
47 int error;
48 } BDRVReplicationState;
50 static void replication_start(ReplicationState *rs, ReplicationMode mode,
51 Error **errp);
52 static void replication_do_checkpoint(ReplicationState *rs, Error **errp);
53 static void replication_get_error(ReplicationState *rs, Error **errp);
54 static void replication_stop(ReplicationState *rs, bool failover,
55 Error **errp);
57 #define REPLICATION_MODE "mode"
58 #define REPLICATION_TOP_ID "top-id"
59 static QemuOptsList replication_runtime_opts = {
60 .name = "replication",
61 .head = QTAILQ_HEAD_INITIALIZER(replication_runtime_opts.head),
62 .desc = {
64 .name = REPLICATION_MODE,
65 .type = QEMU_OPT_STRING,
68 .name = REPLICATION_TOP_ID,
69 .type = QEMU_OPT_STRING,
71 { /* end of list */ }
75 static ReplicationOps replication_ops = {
76 .start = replication_start,
77 .checkpoint = replication_do_checkpoint,
78 .get_error = replication_get_error,
79 .stop = replication_stop,
82 static int replication_open(BlockDriverState *bs, QDict *options,
83 int flags, Error **errp)
85 int ret;
86 BDRVReplicationState *s = bs->opaque;
87 QemuOpts *opts = NULL;
88 const char *mode;
89 const char *top_id;
91 ret = bdrv_open_file_child(NULL, options, "file", bs, errp);
92 if (ret < 0) {
93 return ret;
96 ret = -EINVAL;
97 opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort);
98 if (!qemu_opts_absorb_qdict(opts, options, errp)) {
99 goto fail;
102 mode = qemu_opt_get(opts, REPLICATION_MODE);
103 if (!mode) {
104 error_setg(errp, "Missing the option mode");
105 goto fail;
108 if (!strcmp(mode, "primary")) {
109 s->mode = REPLICATION_MODE_PRIMARY;
110 top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
111 if (top_id) {
112 error_setg(errp,
113 "The primary side does not support option top-id");
114 goto fail;
116 } else if (!strcmp(mode, "secondary")) {
117 s->mode = REPLICATION_MODE_SECONDARY;
118 top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
119 s->top_id = g_strdup(top_id);
120 if (!s->top_id) {
121 error_setg(errp, "Missing the option top-id");
122 goto fail;
124 } else {
125 error_setg(errp,
126 "The option mode's value should be primary or secondary");
127 goto fail;
130 s->rs = replication_new(bs, &replication_ops);
132 ret = 0;
134 fail:
135 qemu_opts_del(opts);
136 return ret;
139 static void replication_close(BlockDriverState *bs)
141 BDRVReplicationState *s = bs->opaque;
142 Job *commit_job;
143 GLOBAL_STATE_CODE();
145 if (s->stage == BLOCK_REPLICATION_RUNNING) {
146 replication_stop(s->rs, false, NULL);
148 if (s->stage == BLOCK_REPLICATION_FAILOVER) {
149 commit_job = &s->commit_job->job;
150 assert(commit_job->aio_context == qemu_get_current_aio_context());
151 job_cancel_sync(commit_job, false);
154 if (s->mode == REPLICATION_MODE_SECONDARY) {
155 g_free(s->top_id);
158 replication_remove(s->rs);
161 static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,
162 BdrvChildRole role,
163 BlockReopenQueue *reopen_queue,
164 uint64_t perm, uint64_t shared,
165 uint64_t *nperm, uint64_t *nshared)
167 if (role & BDRV_CHILD_PRIMARY) {
168 *nperm = BLK_PERM_CONSISTENT_READ;
169 } else {
170 *nperm = 0;
173 if ((bs->open_flags & (BDRV_O_INACTIVE | BDRV_O_RDWR)) == BDRV_O_RDWR) {
174 *nperm |= BLK_PERM_WRITE;
176 *nshared = BLK_PERM_CONSISTENT_READ
177 | BLK_PERM_WRITE
178 | BLK_PERM_WRITE_UNCHANGED;
179 return;
182 static int64_t coroutine_fn GRAPH_RDLOCK
183 replication_co_getlength(BlockDriverState *bs)
185 return bdrv_co_getlength(bs->file->bs);
188 static int replication_get_io_status(BDRVReplicationState *s)
190 switch (s->stage) {
191 case BLOCK_REPLICATION_NONE:
192 return -EIO;
193 case BLOCK_REPLICATION_RUNNING:
194 return 0;
195 case BLOCK_REPLICATION_FAILOVER:
196 return s->mode == REPLICATION_MODE_PRIMARY ? -EIO : 0;
197 case BLOCK_REPLICATION_FAILOVER_FAILED:
198 return s->mode == REPLICATION_MODE_PRIMARY ? -EIO : 1;
199 case BLOCK_REPLICATION_DONE:
201 * active commit job completes, and active disk and secondary_disk
202 * is swapped, so we can operate bs->file directly
204 return s->mode == REPLICATION_MODE_PRIMARY ? -EIO : 0;
205 default:
206 abort();
210 static int replication_return_value(BDRVReplicationState *s, int ret)
212 if (s->mode == REPLICATION_MODE_SECONDARY) {
213 return ret;
216 if (ret < 0) {
217 s->error = ret;
218 ret = 0;
221 return ret;
224 static int coroutine_fn GRAPH_RDLOCK
225 replication_co_readv(BlockDriverState *bs, int64_t sector_num,
226 int remaining_sectors, QEMUIOVector *qiov)
228 BDRVReplicationState *s = bs->opaque;
229 int ret;
231 if (s->mode == REPLICATION_MODE_PRIMARY) {
232 /* We only use it to forward primary write requests */
233 return -EIO;
236 ret = replication_get_io_status(s);
237 if (ret < 0) {
238 return ret;
241 ret = bdrv_co_preadv(bs->file, sector_num * BDRV_SECTOR_SIZE,
242 remaining_sectors * BDRV_SECTOR_SIZE, qiov, 0);
244 return replication_return_value(s, ret);
247 static int coroutine_fn GRAPH_RDLOCK
248 replication_co_writev(BlockDriverState *bs, int64_t sector_num,
249 int remaining_sectors, QEMUIOVector *qiov, int flags)
251 BDRVReplicationState *s = bs->opaque;
252 QEMUIOVector hd_qiov;
253 uint64_t bytes_done = 0;
254 BdrvChild *top = bs->file;
255 BdrvChild *base = s->secondary_disk;
256 BdrvChild *target;
257 int ret;
258 int64_t n;
260 ret = replication_get_io_status(s);
261 if (ret < 0) {
262 goto out;
265 if (ret == 0) {
266 ret = bdrv_co_pwritev(top, sector_num * BDRV_SECTOR_SIZE,
267 remaining_sectors * BDRV_SECTOR_SIZE, qiov, 0);
268 return replication_return_value(s, ret);
272 * Failover failed, only write to active disk if the sectors
273 * have already been allocated in active disk/hidden disk.
275 qemu_iovec_init(&hd_qiov, qiov->niov);
276 while (remaining_sectors > 0) {
277 int64_t count;
279 ret = bdrv_co_is_allocated_above(top->bs, base->bs, false,
280 sector_num * BDRV_SECTOR_SIZE,
281 remaining_sectors * BDRV_SECTOR_SIZE,
282 &count);
283 if (ret < 0) {
284 goto out1;
287 assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE));
288 n = count >> BDRV_SECTOR_BITS;
289 qemu_iovec_reset(&hd_qiov);
290 qemu_iovec_concat(&hd_qiov, qiov, bytes_done, count);
292 target = ret ? top : base;
293 ret = bdrv_co_pwritev(target, sector_num * BDRV_SECTOR_SIZE,
294 n * BDRV_SECTOR_SIZE, &hd_qiov, 0);
295 if (ret < 0) {
296 goto out1;
299 remaining_sectors -= n;
300 sector_num += n;
301 bytes_done += count;
304 out1:
305 qemu_iovec_destroy(&hd_qiov);
306 out:
307 return ret;
310 static void GRAPH_UNLOCKED
311 secondary_do_checkpoint(BlockDriverState *bs, Error **errp)
313 BDRVReplicationState *s = bs->opaque;
314 BdrvChild *active_disk;
315 Error *local_err = NULL;
316 int ret;
318 GRAPH_RDLOCK_GUARD_MAINLOOP();
320 if (!s->backup_job) {
321 error_setg(errp, "Backup job was cancelled unexpectedly");
322 return;
325 backup_do_checkpoint(s->backup_job, &local_err);
326 if (local_err) {
327 error_propagate(errp, local_err);
328 return;
331 active_disk = bs->file;
332 if (!active_disk->bs->drv) {
333 error_setg(errp, "Active disk %s is ejected",
334 active_disk->bs->node_name);
335 return;
338 ret = bdrv_make_empty(active_disk, errp);
339 if (ret < 0) {
340 return;
343 if (!s->hidden_disk->bs->drv) {
344 error_setg(errp, "Hidden disk %s is ejected",
345 s->hidden_disk->bs->node_name);
346 return;
349 ret = bdrv_make_empty(s->hidden_disk, errp);
350 if (ret < 0) {
351 return;
355 /* This function is supposed to be called twice:
356 * first with writable = true, then with writable = false.
357 * The first call puts s->hidden_disk and s->secondary_disk in
358 * r/w mode, and the second puts them back in their original state.
360 static void reopen_backing_file(BlockDriverState *bs, bool writable,
361 Error **errp)
363 BDRVReplicationState *s = bs->opaque;
364 BdrvChild *hidden_disk, *secondary_disk;
365 BlockReopenQueue *reopen_queue = NULL;
367 GLOBAL_STATE_CODE();
368 GRAPH_RDLOCK_GUARD_MAINLOOP();
371 * s->hidden_disk and s->secondary_disk may not be set yet, as they will
372 * only be set after the children are writable.
374 hidden_disk = bs->file->bs->backing;
375 secondary_disk = hidden_disk->bs->backing;
377 if (writable) {
378 s->orig_hidden_read_only = bdrv_is_read_only(hidden_disk->bs);
379 s->orig_secondary_read_only = bdrv_is_read_only(secondary_disk->bs);
382 if (s->orig_hidden_read_only) {
383 QDict *opts = qdict_new();
384 qdict_put_bool(opts, BDRV_OPT_READ_ONLY, !writable);
385 reopen_queue = bdrv_reopen_queue(reopen_queue, hidden_disk->bs,
386 opts, true);
389 if (s->orig_secondary_read_only) {
390 QDict *opts = qdict_new();
391 qdict_put_bool(opts, BDRV_OPT_READ_ONLY, !writable);
392 reopen_queue = bdrv_reopen_queue(reopen_queue, secondary_disk->bs,
393 opts, true);
396 if (reopen_queue) {
397 AioContext *ctx = bdrv_get_aio_context(bs);
398 if (ctx != qemu_get_aio_context()) {
399 aio_context_release(ctx);
401 bdrv_reopen_multiple(reopen_queue, errp);
402 if (ctx != qemu_get_aio_context()) {
403 aio_context_acquire(ctx);
408 static void backup_job_cleanup(BlockDriverState *bs)
410 BDRVReplicationState *s = bs->opaque;
411 BlockDriverState *top_bs;
413 s->backup_job = NULL;
415 top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
416 if (!top_bs) {
417 return;
419 bdrv_op_unblock_all(top_bs, s->blocker);
420 error_free(s->blocker);
421 reopen_backing_file(bs, false, NULL);
424 static void backup_job_completed(void *opaque, int ret)
426 BlockDriverState *bs = opaque;
427 BDRVReplicationState *s = bs->opaque;
429 if (s->stage != BLOCK_REPLICATION_FAILOVER) {
430 /* The backup job is cancelled unexpectedly */
431 s->error = -EIO;
434 backup_job_cleanup(bs);
437 static bool GRAPH_RDLOCK
438 check_top_bs(BlockDriverState *top_bs, BlockDriverState *bs)
440 BdrvChild *child;
442 /* The bs itself is the top_bs */
443 if (top_bs == bs) {
444 return true;
447 /* Iterate over top_bs's children */
448 QLIST_FOREACH(child, &top_bs->children, next) {
449 if (child->bs == bs || check_top_bs(child->bs, bs)) {
450 return true;
454 return false;
457 static void replication_start(ReplicationState *rs, ReplicationMode mode,
458 Error **errp)
460 BlockDriverState *bs = rs->opaque;
461 BDRVReplicationState *s;
462 BlockDriverState *top_bs;
463 BdrvChild *active_disk, *hidden_disk, *secondary_disk;
464 int64_t active_length, hidden_length, disk_length;
465 AioContext *aio_context;
466 Error *local_err = NULL;
467 BackupPerf perf = { .use_copy_range = true, .max_workers = 1 };
469 GLOBAL_STATE_CODE();
471 aio_context = bdrv_get_aio_context(bs);
472 aio_context_acquire(aio_context);
473 s = bs->opaque;
475 if (s->stage == BLOCK_REPLICATION_DONE ||
476 s->stage == BLOCK_REPLICATION_FAILOVER) {
478 * This case happens when a secondary is promoted to primary.
479 * Ignore the request because the secondary side of replication
480 * doesn't have to do anything anymore.
482 aio_context_release(aio_context);
483 return;
486 if (s->stage != BLOCK_REPLICATION_NONE) {
487 error_setg(errp, "Block replication is running or done");
488 aio_context_release(aio_context);
489 return;
492 if (s->mode != mode) {
493 error_setg(errp, "The parameter mode's value is invalid, needs %d,"
494 " but got %d", s->mode, mode);
495 aio_context_release(aio_context);
496 return;
499 switch (s->mode) {
500 case REPLICATION_MODE_PRIMARY:
501 break;
502 case REPLICATION_MODE_SECONDARY:
503 bdrv_graph_rdlock_main_loop();
504 active_disk = bs->file;
505 if (!active_disk || !active_disk->bs || !active_disk->bs->backing) {
506 error_setg(errp, "Active disk doesn't have backing file");
507 bdrv_graph_rdunlock_main_loop();
508 aio_context_release(aio_context);
509 return;
512 hidden_disk = active_disk->bs->backing;
513 if (!hidden_disk->bs || !hidden_disk->bs->backing) {
514 error_setg(errp, "Hidden disk doesn't have backing file");
515 bdrv_graph_rdunlock_main_loop();
516 aio_context_release(aio_context);
517 return;
520 secondary_disk = hidden_disk->bs->backing;
521 if (!secondary_disk->bs || !bdrv_has_blk(secondary_disk->bs)) {
522 error_setg(errp, "The secondary disk doesn't have block backend");
523 bdrv_graph_rdunlock_main_loop();
524 aio_context_release(aio_context);
525 return;
527 bdrv_graph_rdunlock_main_loop();
529 /* verify the length */
530 active_length = bdrv_getlength(active_disk->bs);
531 hidden_length = bdrv_getlength(hidden_disk->bs);
532 disk_length = bdrv_getlength(secondary_disk->bs);
533 if (active_length < 0 || hidden_length < 0 || disk_length < 0 ||
534 active_length != hidden_length || hidden_length != disk_length) {
535 error_setg(errp, "Active disk, hidden disk, secondary disk's length"
536 " are not the same");
537 aio_context_release(aio_context);
538 return;
541 /* Must be true, or the bdrv_getlength() calls would have failed */
542 assert(active_disk->bs->drv && hidden_disk->bs->drv);
544 bdrv_graph_rdlock_main_loop();
545 if (!active_disk->bs->drv->bdrv_make_empty ||
546 !hidden_disk->bs->drv->bdrv_make_empty) {
547 error_setg(errp,
548 "Active disk or hidden disk doesn't support make_empty");
549 aio_context_release(aio_context);
550 bdrv_graph_rdunlock_main_loop();
551 return;
553 bdrv_graph_rdunlock_main_loop();
555 /* reopen the backing file in r/w mode */
556 reopen_backing_file(bs, true, &local_err);
557 if (local_err) {
558 error_propagate(errp, local_err);
559 aio_context_release(aio_context);
560 return;
563 bdrv_graph_wrlock(bs);
565 bdrv_ref(hidden_disk->bs);
566 s->hidden_disk = bdrv_attach_child(bs, hidden_disk->bs, "hidden disk",
567 &child_of_bds, BDRV_CHILD_DATA,
568 &local_err);
569 if (local_err) {
570 error_propagate(errp, local_err);
571 bdrv_graph_wrunlock(bs);
572 aio_context_release(aio_context);
573 return;
576 bdrv_ref(secondary_disk->bs);
577 s->secondary_disk = bdrv_attach_child(bs, secondary_disk->bs,
578 "secondary disk", &child_of_bds,
579 BDRV_CHILD_DATA, &local_err);
580 if (local_err) {
581 error_propagate(errp, local_err);
582 bdrv_graph_wrunlock(bs);
583 aio_context_release(aio_context);
584 return;
587 /* start backup job now */
588 error_setg(&s->blocker,
589 "Block device is in use by internal backup job");
591 top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
592 if (!top_bs || !bdrv_is_root_node(top_bs) ||
593 !check_top_bs(top_bs, bs)) {
594 error_setg(errp, "No top_bs or it is invalid");
595 bdrv_graph_wrunlock(bs);
596 reopen_backing_file(bs, false, NULL);
597 aio_context_release(aio_context);
598 return;
600 bdrv_op_block_all(top_bs, s->blocker);
601 bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker);
603 bdrv_graph_wrunlock(bs);
605 s->backup_job = backup_job_create(
606 NULL, s->secondary_disk->bs, s->hidden_disk->bs,
607 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL,
608 &perf,
609 BLOCKDEV_ON_ERROR_REPORT,
610 BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
611 backup_job_completed, bs, NULL, &local_err);
612 if (local_err) {
613 error_propagate(errp, local_err);
614 backup_job_cleanup(bs);
615 aio_context_release(aio_context);
616 return;
618 job_start(&s->backup_job->job);
619 break;
620 default:
621 aio_context_release(aio_context);
622 abort();
625 s->stage = BLOCK_REPLICATION_RUNNING;
627 if (s->mode == REPLICATION_MODE_SECONDARY) {
628 secondary_do_checkpoint(bs, errp);
631 s->error = 0;
632 aio_context_release(aio_context);
635 static void replication_do_checkpoint(ReplicationState *rs, Error **errp)
637 BlockDriverState *bs = rs->opaque;
638 BDRVReplicationState *s;
639 AioContext *aio_context;
641 aio_context = bdrv_get_aio_context(bs);
642 aio_context_acquire(aio_context);
643 s = bs->opaque;
645 if (s->stage == BLOCK_REPLICATION_DONE ||
646 s->stage == BLOCK_REPLICATION_FAILOVER) {
648 * This case happens when a secondary was promoted to primary.
649 * Ignore the request because the secondary side of replication
650 * doesn't have to do anything anymore.
652 aio_context_release(aio_context);
653 return;
656 if (s->mode == REPLICATION_MODE_SECONDARY) {
657 secondary_do_checkpoint(bs, errp);
659 aio_context_release(aio_context);
662 static void replication_get_error(ReplicationState *rs, Error **errp)
664 BlockDriverState *bs = rs->opaque;
665 BDRVReplicationState *s;
666 AioContext *aio_context;
668 aio_context = bdrv_get_aio_context(bs);
669 aio_context_acquire(aio_context);
670 s = bs->opaque;
672 if (s->stage == BLOCK_REPLICATION_NONE) {
673 error_setg(errp, "Block replication is not running");
674 aio_context_release(aio_context);
675 return;
678 if (s->error) {
679 error_setg(errp, "I/O error occurred");
680 aio_context_release(aio_context);
681 return;
683 aio_context_release(aio_context);
686 static void replication_done(void *opaque, int ret)
688 BlockDriverState *bs = opaque;
689 BDRVReplicationState *s = bs->opaque;
691 if (ret == 0) {
692 s->stage = BLOCK_REPLICATION_DONE;
694 bdrv_graph_wrlock(NULL);
695 bdrv_unref_child(bs, s->secondary_disk);
696 s->secondary_disk = NULL;
697 bdrv_unref_child(bs, s->hidden_disk);
698 s->hidden_disk = NULL;
699 bdrv_graph_wrunlock(NULL);
701 s->error = 0;
702 } else {
703 s->stage = BLOCK_REPLICATION_FAILOVER_FAILED;
704 s->error = -EIO;
708 static void replication_stop(ReplicationState *rs, bool failover, Error **errp)
710 BlockDriverState *bs = rs->opaque;
711 BDRVReplicationState *s;
712 AioContext *aio_context;
714 aio_context = bdrv_get_aio_context(bs);
715 aio_context_acquire(aio_context);
716 s = bs->opaque;
718 if (s->stage == BLOCK_REPLICATION_DONE ||
719 s->stage == BLOCK_REPLICATION_FAILOVER) {
721 * This case happens when a secondary was promoted to primary.
722 * Ignore the request because the secondary side of replication
723 * doesn't have to do anything anymore.
725 aio_context_release(aio_context);
726 return;
729 if (s->stage != BLOCK_REPLICATION_RUNNING) {
730 error_setg(errp, "Block replication is not running");
731 aio_context_release(aio_context);
732 return;
735 switch (s->mode) {
736 case REPLICATION_MODE_PRIMARY:
737 s->stage = BLOCK_REPLICATION_DONE;
738 s->error = 0;
739 break;
740 case REPLICATION_MODE_SECONDARY:
742 * This BDS will be closed, and the job should be completed
743 * before the BDS is closed, because we will access hidden
744 * disk, secondary disk in backup_job_completed().
746 if (s->backup_job) {
747 aio_context_release(aio_context);
748 job_cancel_sync(&s->backup_job->job, true);
749 aio_context_acquire(aio_context);
752 if (!failover) {
753 secondary_do_checkpoint(bs, errp);
754 s->stage = BLOCK_REPLICATION_DONE;
755 aio_context_release(aio_context);
756 return;
759 bdrv_graph_rdlock_main_loop();
760 s->stage = BLOCK_REPLICATION_FAILOVER;
761 s->commit_job = commit_active_start(
762 NULL, bs->file->bs, s->secondary_disk->bs,
763 JOB_INTERNAL, 0, BLOCKDEV_ON_ERROR_REPORT,
764 NULL, replication_done, bs, true, errp);
765 bdrv_graph_rdunlock_main_loop();
766 break;
767 default:
768 aio_context_release(aio_context);
769 abort();
771 aio_context_release(aio_context);
774 static const char *const replication_strong_runtime_opts[] = {
775 REPLICATION_MODE,
776 REPLICATION_TOP_ID,
778 NULL
781 static BlockDriver bdrv_replication = {
782 .format_name = "replication",
783 .instance_size = sizeof(BDRVReplicationState),
785 .bdrv_open = replication_open,
786 .bdrv_close = replication_close,
787 .bdrv_child_perm = replication_child_perm,
789 .bdrv_co_getlength = replication_co_getlength,
790 .bdrv_co_readv = replication_co_readv,
791 .bdrv_co_writev = replication_co_writev,
793 .is_filter = true,
795 .strong_runtime_opts = replication_strong_runtime_opts,
798 static void bdrv_replication_init(void)
800 bdrv_register(&bdrv_replication);
803 block_init(bdrv_replication_init);