mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
block: Factor out bdrv_replace_child_noperm()
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
d0ac038025
commit
8ee039951d
40
block.c
40
block.c
@ -1713,11 +1713,10 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
|
|||||||
*nshared = shared;
|
*nshared = shared;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
|
static void bdrv_replace_child_noperm(BdrvChild *child,
|
||||||
bool check_new_perm)
|
BlockDriverState *new_bs)
|
||||||
{
|
{
|
||||||
BlockDriverState *old_bs = child->bs;
|
BlockDriverState *old_bs = child->bs;
|
||||||
uint64_t perm, shared_perm;
|
|
||||||
|
|
||||||
if (old_bs) {
|
if (old_bs) {
|
||||||
if (old_bs->quiesce_counter && child->role->drained_end) {
|
if (old_bs->quiesce_counter && child->role->drained_end) {
|
||||||
@ -1727,13 +1726,6 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
|
|||||||
child->role->detach(child);
|
child->role->detach(child);
|
||||||
}
|
}
|
||||||
QLIST_REMOVE(child, next_parent);
|
QLIST_REMOVE(child, next_parent);
|
||||||
|
|
||||||
/* Update permissions for old node. This is guaranteed to succeed
|
|
||||||
* because we're just taking a parent away, so we're loosening
|
|
||||||
* restrictions. */
|
|
||||||
bdrv_get_cumulative_perm(old_bs, &perm, &shared_perm);
|
|
||||||
bdrv_check_perm(old_bs, perm, shared_perm, &error_abort);
|
|
||||||
bdrv_set_perm(old_bs, perm, shared_perm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
child->bs = new_bs;
|
child->bs = new_bs;
|
||||||
@ -1744,15 +1736,35 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
|
|||||||
child->role->drained_begin(child);
|
child->role->drained_begin(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (child->role->attach) {
|
||||||
|
child->role->attach(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
|
||||||
|
bool check_new_perm)
|
||||||
|
{
|
||||||
|
BlockDriverState *old_bs = child->bs;
|
||||||
|
uint64_t perm, shared_perm;
|
||||||
|
|
||||||
|
if (old_bs) {
|
||||||
|
/* Update permissions for old node. This is guaranteed to succeed
|
||||||
|
* because we're just taking a parent away, so we're loosening
|
||||||
|
* restrictions. */
|
||||||
|
bdrv_get_cumulative_perm(old_bs, &perm, &shared_perm);
|
||||||
|
bdrv_check_perm(old_bs, perm, shared_perm, &error_abort);
|
||||||
|
bdrv_set_perm(old_bs, perm, shared_perm);
|
||||||
|
}
|
||||||
|
|
||||||
|
bdrv_replace_child_noperm(child, new_bs);
|
||||||
|
|
||||||
|
if (new_bs) {
|
||||||
bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
|
bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
|
||||||
if (check_new_perm) {
|
if (check_new_perm) {
|
||||||
bdrv_check_perm(new_bs, perm, shared_perm, &error_abort);
|
bdrv_check_perm(new_bs, perm, shared_perm, &error_abort);
|
||||||
}
|
}
|
||||||
bdrv_set_perm(new_bs, perm, shared_perm);
|
bdrv_set_perm(new_bs, perm, shared_perm);
|
||||||
|
|
||||||
if (child->role->attach) {
|
|
||||||
child->role->attach(child);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user