On Sat 09 Jan 2021 01:57:58 PM CET, Vladimir Sementsov-Ogievskiy wrote: > -void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, > +int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, > Error **errp)
The indentation of the second line should be adjusted, shouldn't it? > { > + int ret; > bool update_inherits_from = bdrv_chain_contains(bs, backing_hd) && > bdrv_inherits_from_recursive(backing_hd, bs); > > if (bdrv_is_backing_chain_frozen(bs, child_bs(bs->backing), errp)) { > - return; > + return -EPERM; > } > > if (backing_hd) { > @@ -2853,15 +2854,24 @@ void bdrv_set_backing_hd(BlockDriverState *bs, > BlockDriverState *backing_hd, > > bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_of_bds, > bdrv_backing_role(bs), errp); > + if (!bs->backing) { > + ret = -EPERM; > + goto out; > + } This is not visible in the patch, but before the bdrv_attach_child() call there's this: if (!backing_hd) { goto out; } But in this case 'ret' is still uninitialized. > out: > bdrv_refresh_limits(bs, NULL); > + > + return ret; > } > -static void bdrv_replace_node_common(BlockDriverState *from, > - BlockDriverState *to, > - bool auto_skip, Error **errp) > +static int bdrv_replace_node_common(BlockDriverState *from, > + BlockDriverState *to, > + bool auto_skip, Error **errp) > { > BdrvChild *c, *next; > GSList *list = NULL, *p; > @@ -4562,6 +4572,7 @@ static void bdrv_replace_node_common(BlockDriverState > *from, > goto out; > } > if (c->frozen) { > + ret = -EPERM; > error_setg(errp, "Cannot change '%s' link to '%s'", > c->name, from->node_name); > goto out; Same here, you set 'ret' in the second 'goto out' but not in the first. Berto