Lines Matching refs:bs
82 static int replication_open(BlockDriverState *bs, QDict *options, in replication_open() argument
86 BDRVReplicationState *s = bs->opaque; in replication_open()
91 ret = bdrv_open_file_child(NULL, options, "file", bs, errp); in replication_open()
130 s->rs = replication_new(bs, &replication_ops); in replication_open()
139 static void replication_close(BlockDriverState *bs) in replication_close() argument
141 BDRVReplicationState *s = bs->opaque; in replication_close()
161 static void replication_child_perm(BlockDriverState *bs, BdrvChild *c, in replication_child_perm() argument
173 if ((bs->open_flags & (BDRV_O_INACTIVE | BDRV_O_RDWR)) == BDRV_O_RDWR) { in replication_child_perm()
183 replication_co_getlength(BlockDriverState *bs) in replication_co_getlength() argument
185 return bdrv_co_getlength(bs->file->bs); in replication_co_getlength()
225 replication_co_readv(BlockDriverState *bs, int64_t sector_num, in replication_co_readv() argument
228 BDRVReplicationState *s = bs->opaque; in replication_co_readv()
241 ret = bdrv_co_preadv(bs->file, sector_num * BDRV_SECTOR_SIZE, in replication_co_readv()
248 replication_co_writev(BlockDriverState *bs, int64_t sector_num, in replication_co_writev() argument
251 BDRVReplicationState *s = bs->opaque; in replication_co_writev()
254 BdrvChild *top = bs->file; in replication_co_writev()
279 ret = bdrv_co_is_allocated_above(top->bs, base->bs, false, in replication_co_writev()
311 secondary_do_checkpoint(BlockDriverState *bs, Error **errp) in secondary_do_checkpoint() argument
313 BDRVReplicationState *s = bs->opaque; in secondary_do_checkpoint()
331 active_disk = bs->file; in secondary_do_checkpoint()
332 if (!active_disk->bs->drv) { in secondary_do_checkpoint()
334 active_disk->bs->node_name); in secondary_do_checkpoint()
343 if (!s->hidden_disk->bs->drv) { in secondary_do_checkpoint()
345 s->hidden_disk->bs->node_name); in secondary_do_checkpoint()
360 static void reopen_backing_file(BlockDriverState *bs, bool writable, in reopen_backing_file() argument
363 BDRVReplicationState *s = bs->opaque; in reopen_backing_file()
374 hidden_disk = bs->file->bs->backing; in reopen_backing_file()
375 secondary_disk = hidden_disk->bs->backing; in reopen_backing_file()
378 s->orig_hidden_read_only = bdrv_is_read_only(hidden_disk->bs); in reopen_backing_file()
379 s->orig_secondary_read_only = bdrv_is_read_only(secondary_disk->bs); in reopen_backing_file()
385 reopen_queue = bdrv_reopen_queue(reopen_queue, hidden_disk->bs, in reopen_backing_file()
392 reopen_queue = bdrv_reopen_queue(reopen_queue, secondary_disk->bs, in reopen_backing_file()
401 static void backup_job_cleanup(BlockDriverState *bs) in backup_job_cleanup() argument
403 BDRVReplicationState *s = bs->opaque; in backup_job_cleanup()
414 reopen_backing_file(bs, false, NULL); in backup_job_cleanup()
419 BlockDriverState *bs = opaque; in backup_job_completed() local
420 BDRVReplicationState *s = bs->opaque; in backup_job_completed()
427 backup_job_cleanup(bs); in backup_job_completed()
431 check_top_bs(BlockDriverState *top_bs, BlockDriverState *bs) in check_top_bs() argument
436 if (top_bs == bs) { in check_top_bs()
442 if (child->bs == bs || check_top_bs(child->bs, bs)) { in check_top_bs()
453 BlockDriverState *bs = rs->opaque; in replication_start() local
463 s = bs->opaque; in replication_start()
491 active_disk = bs->file; in replication_start()
492 if (!active_disk || !active_disk->bs || !active_disk->bs->backing) { in replication_start()
498 hidden_disk = active_disk->bs->backing; in replication_start()
499 if (!hidden_disk->bs || !hidden_disk->bs->backing) { in replication_start()
505 secondary_disk = hidden_disk->bs->backing; in replication_start()
506 if (!secondary_disk->bs || !bdrv_has_blk(secondary_disk->bs)) { in replication_start()
514 active_length = bdrv_getlength(active_disk->bs); in replication_start()
515 hidden_length = bdrv_getlength(hidden_disk->bs); in replication_start()
516 disk_length = bdrv_getlength(secondary_disk->bs); in replication_start()
525 assert(active_disk->bs->drv && hidden_disk->bs->drv); in replication_start()
528 if (!active_disk->bs->drv->bdrv_make_empty || in replication_start()
529 !hidden_disk->bs->drv->bdrv_make_empty) { in replication_start()
538 reopen_backing_file(bs, true, &local_err); in replication_start()
546 bdrv_ref(hidden_disk->bs); in replication_start()
547 s->hidden_disk = bdrv_attach_child(bs, hidden_disk->bs, "hidden disk", in replication_start()
556 bdrv_ref(secondary_disk->bs); in replication_start()
557 s->secondary_disk = bdrv_attach_child(bs, secondary_disk->bs, in replication_start()
572 !check_top_bs(top_bs, bs)) { in replication_start()
575 reopen_backing_file(bs, false, NULL); in replication_start()
584 NULL, s->secondary_disk->bs, s->hidden_disk->bs, in replication_start()
589 backup_job_completed, bs, NULL, &local_err); in replication_start()
592 backup_job_cleanup(bs); in replication_start()
604 secondary_do_checkpoint(bs, errp); in replication_start()
612 BlockDriverState *bs = rs->opaque; in replication_do_checkpoint() local
613 BDRVReplicationState *s = bs->opaque; in replication_do_checkpoint()
626 secondary_do_checkpoint(bs, errp); in replication_do_checkpoint()
632 BlockDriverState *bs = rs->opaque; in replication_get_error() local
633 BDRVReplicationState *s = bs->opaque; in replication_get_error()
648 BlockDriverState *bs = opaque; in replication_done() local
649 BDRVReplicationState *s = bs->opaque; in replication_done()
655 bdrv_unref_child(bs, s->secondary_disk); in replication_done()
657 bdrv_unref_child(bs, s->hidden_disk); in replication_done()
670 BlockDriverState *bs = rs->opaque; in replication_stop() local
671 BDRVReplicationState *s = bs->opaque; in replication_stop()
704 secondary_do_checkpoint(bs, errp); in replication_stop()
712 NULL, bs->file->bs, s->secondary_disk->bs, in replication_stop()
714 NULL, replication_done, bs, true, errp); in replication_stop()