qemu/block.c
/*
 * Sets the backing file link of a BDS. A new reference is created; callers
 * which don't need their own reference any more must call bdrv_unref().
 */
Sets the backing file link of a BDS. A new reference is created; callers
which don't need their own reference any more must call bdrv_unref().
Sets the backing file link of a BDS . A new reference is created ; callers which don ' t need their own reference any more must call bdrv_unref () .
void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
                         Error **errp)
{
    bool update_inherits_from = bdrv_chain_contains(bs, backing_hd) &&
        bdrv_inherits_from_recursive(backing_hd, bs);
    if (backing_hd) {
        bdrv_ref(backing_hd);
    }
    if (bs->backing) {
        bdrv_unref_child(bs, bs->backing);
    }
    if (!backing_hd) {
        bs->backing = NULL;
        goto out;
    }
    bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_backing,
                                    errp);
    if (update_inherits_from) {
        backing_hd->inherits_from = bs;
    }
    if (!bs->backing) {
        bdrv_unref(backing_hd);
    }
    bdrv_refresh_filename(bs);
out:
    bdrv_refresh_limits(bs, NULL);
}
void bdrv_set_backing_hd ( BlockDriverState * bs , BlockDriverState * backing_hd , Error * * errp ) { bool update_inherits_from = bdrv_chain_contains ( bs , backing_hd ) && bdrv_inherits_from_recursive ( backing_hd , bs ) ; if ( backing_hd ) { bdrv_ref ( backing_hd ) ; } if ( bs -> backing ) { bdrv_unref_child ( bs , bs -> backing ) ; } if ( ! backing_hd ) { bs -> backing = NULL ; goto out ; } bs -> backing = bdrv_attach_child ( bs , backing_hd , " " , & child_backing , errp ) ; if ( update_inherits_from ) { backing_hd -> inherits_from = bs ; } if ( ! bs -> backing ) { bdrv_unref ( backing_hd ) ; } bdrv_refresh_filename ( bs ) ; out : bdrv_refresh_limits ( bs , NULL ) ; }
Sets the backing file link of a BDS.
Sets the backing file link of a BDS .
/* If backing_hd was already part of bs's backing chain, and
     * inherits_from pointed recursively to bs then let's update it to
     * point directly to bs (else it will become NULL). */