block.c (0152bf400fe3ca7facb382683bfcccda70ebf51a) | block.c (d736f119dae6d292e8d60f2e02fa51a79524113e) |
---|---|
1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 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 --- 808 unchanged lines hidden (view full) --- 817} 818 819static void bdrv_child_cb_drained_end(BdrvChild *child) 820{ 821 BlockDriverState *bs = child->opaque; 822 bdrv_drained_end(bs); 823} 824 | 1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 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 --- 808 unchanged lines hidden (view full) --- 817} 818 819static void bdrv_child_cb_drained_end(BdrvChild *child) 820{ 821 BlockDriverState *bs = child->opaque; 822 bdrv_drained_end(bs); 823} 824 |
825static void bdrv_child_cb_attach(BdrvChild *child) 826{ 827 BlockDriverState *bs = child->opaque; 828 bdrv_apply_subtree_drain(child, bs); 829} 830 831static void bdrv_child_cb_detach(BdrvChild *child) 832{ 833 BlockDriverState *bs = child->opaque; 834 bdrv_unapply_subtree_drain(child, bs); 835} 836 |
|
825static int bdrv_child_cb_inactivate(BdrvChild *child) 826{ 827 BlockDriverState *bs = child->opaque; 828 assert(bs->open_flags & BDRV_O_INACTIVE); 829 return 0; 830} 831 832/* --- 51 unchanged lines hidden (view full) --- 884 *child_flags = flags; 885} 886 887const BdrvChildRole child_file = { 888 .get_parent_desc = bdrv_child_get_parent_desc, 889 .inherit_options = bdrv_inherited_options, 890 .drained_begin = bdrv_child_cb_drained_begin, 891 .drained_end = bdrv_child_cb_drained_end, | 837static int bdrv_child_cb_inactivate(BdrvChild *child) 838{ 839 BlockDriverState *bs = child->opaque; 840 assert(bs->open_flags & BDRV_O_INACTIVE); 841 return 0; 842} 843 844/* --- 51 unchanged lines hidden (view full) --- 896 *child_flags = flags; 897} 898 899const BdrvChildRole child_file = { 900 .get_parent_desc = bdrv_child_get_parent_desc, 901 .inherit_options = bdrv_inherited_options, 902 .drained_begin = bdrv_child_cb_drained_begin, 903 .drained_end = bdrv_child_cb_drained_end, |
904 .attach = bdrv_child_cb_attach, 905 .detach = bdrv_child_cb_detach, |
|
892 .inactivate = bdrv_child_cb_inactivate, 893}; 894 895/* 896 * Returns the options and flags that bs->file should get if the use of formats 897 * (and not only protocols) is permitted for it, based on the given options and 898 * flags for the parent BDS 899 */ --- 6 unchanged lines hidden (view full) --- 906 *child_flags &= ~(BDRV_O_PROTOCOL | BDRV_O_NO_IO); 907} 908 909const BdrvChildRole child_format = { 910 .get_parent_desc = bdrv_child_get_parent_desc, 911 .inherit_options = bdrv_inherited_fmt_options, 912 .drained_begin = bdrv_child_cb_drained_begin, 913 .drained_end = bdrv_child_cb_drained_end, | 906 .inactivate = bdrv_child_cb_inactivate, 907}; 908 909/* 910 * Returns the options and flags that bs->file should get if the use of formats 911 * (and not only protocols) is permitted for it, based on the given options and 912 * flags for the parent BDS 913 */ --- 6 unchanged lines hidden (view full) --- 920 *child_flags &= ~(BDRV_O_PROTOCOL | BDRV_O_NO_IO); 921} 922 923const BdrvChildRole child_format = { 924 .get_parent_desc = bdrv_child_get_parent_desc, 925 .inherit_options = bdrv_inherited_fmt_options, 926 .drained_begin = bdrv_child_cb_drained_begin, 927 .drained_end = bdrv_child_cb_drained_end, |
928 .attach = bdrv_child_cb_attach, 929 .detach = bdrv_child_cb_detach, |
|
914 .inactivate = bdrv_child_cb_inactivate, 915}; 916 917static void bdrv_backing_attach(BdrvChild *c) 918{ 919 BlockDriverState *parent = c->opaque; 920 BlockDriverState *backing_hd = c->bs; 921 --- 26 unchanged lines hidden (view full) --- 948 * In case 1 and 2, neither the source nor the target is the backing file. 949 * In case 3, we will block the top BDS, so there is only one block job 950 * for the top BDS and its backing chain. 951 */ 952 bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_SOURCE, 953 parent->backing_blocker); 954 bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_TARGET, 955 parent->backing_blocker); | 930 .inactivate = bdrv_child_cb_inactivate, 931}; 932 933static void bdrv_backing_attach(BdrvChild *c) 934{ 935 BlockDriverState *parent = c->opaque; 936 BlockDriverState *backing_hd = c->bs; 937 --- 26 unchanged lines hidden (view full) --- 964 * In case 1 and 2, neither the source nor the target is the backing file. 965 * In case 3, we will block the top BDS, so there is only one block job 966 * for the top BDS and its backing chain. 967 */ 968 bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_SOURCE, 969 parent->backing_blocker); 970 bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_TARGET, 971 parent->backing_blocker); |
972 973 bdrv_child_cb_attach(c); |
|
956} 957 958static void bdrv_backing_detach(BdrvChild *c) 959{ 960 BlockDriverState *parent = c->opaque; 961 962 assert(parent->backing_blocker); 963 bdrv_op_unblock_all(c->bs, parent->backing_blocker); 964 error_free(parent->backing_blocker); 965 parent->backing_blocker = NULL; | 974} 975 976static void bdrv_backing_detach(BdrvChild *c) 977{ 978 BlockDriverState *parent = c->opaque; 979 980 assert(parent->backing_blocker); 981 bdrv_op_unblock_all(c->bs, parent->backing_blocker); 982 error_free(parent->backing_blocker); 983 parent->backing_blocker = NULL; |
984 985 bdrv_child_cb_detach(c); |
|
966} 967 968/* 969 * Returns the options and flags that bs->backing should get, based on the 970 * given options and flags for the parent BDS 971 */ 972static void bdrv_backing_options(int *child_flags, QDict *child_options, 973 int parent_flags, QDict *parent_options) --- 999 unchanged lines hidden (view full) --- 1973{ 1974 BlockDriverState *old_bs = child->bs; 1975 int i; 1976 1977 if (old_bs && new_bs) { 1978 assert(bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs)); 1979 } 1980 if (old_bs) { | 986} 987 988/* 989 * Returns the options and flags that bs->backing should get, based on the 990 * given options and flags for the parent BDS 991 */ 992static void bdrv_backing_options(int *child_flags, QDict *child_options, 993 int parent_flags, QDict *parent_options) --- 999 unchanged lines hidden (view full) --- 1993{ 1994 BlockDriverState *old_bs = child->bs; 1995 int i; 1996 1997 if (old_bs && new_bs) { 1998 assert(bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs)); 1999 } 2000 if (old_bs) { |
2001 /* Detach first so that the recursive drain sections coming from @child 2002 * are already gone and we only end the drain sections that came from 2003 * elsewhere. */ 2004 if (child->role->detach) { 2005 child->role->detach(child); 2006 } |
|
1981 if (old_bs->quiesce_counter && child->role->drained_end) { 1982 for (i = 0; i < old_bs->quiesce_counter; i++) { 1983 child->role->drained_end(child); 1984 } 1985 } | 2007 if (old_bs->quiesce_counter && child->role->drained_end) { 2008 for (i = 0; i < old_bs->quiesce_counter; i++) { 2009 child->role->drained_end(child); 2010 } 2011 } |
1986 if (child->role->detach) { 1987 child->role->detach(child); 1988 } | |
1989 QLIST_REMOVE(child, next_parent); 1990 } 1991 1992 child->bs = new_bs; 1993 1994 if (new_bs) { 1995 QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent); 1996 if (new_bs->quiesce_counter && child->role->drained_begin) { 1997 for (i = 0; i < new_bs->quiesce_counter; i++) { 1998 child->role->drained_begin(child); 1999 } 2000 } 2001 | 2012 QLIST_REMOVE(child, next_parent); 2013 } 2014 2015 child->bs = new_bs; 2016 2017 if (new_bs) { 2018 QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent); 2019 if (new_bs->quiesce_counter && child->role->drained_begin) { 2020 for (i = 0; i < new_bs->quiesce_counter; i++) { 2021 child->role->drained_begin(child); 2022 } 2023 } 2024 |
2025 /* Attach only after starting new drained sections, so that recursive 2026 * drain sections coming from @child don't get an extra .drained_begin 2027 * callback. */ |
|
2002 if (child->role->attach) { 2003 child->role->attach(child); 2004 } 2005 } 2006} 2007 2008/* 2009 * Updates @child to change its reference to point to @new_bs, including --- 3141 unchanged lines hidden --- | 2028 if (child->role->attach) { 2029 child->role->attach(child); 2030 } 2031 } 2032} 2033 2034/* 2035 * Updates @child to change its reference to point to @new_bs, including --- 3141 unchanged lines hidden --- |