• A
    block: Allow changing the backing file on reopen · cb828c31
    Alberto Garcia 提交于
    This patch allows the user to change the backing file of an image that
    is being reopened. Here's what it does:
    
     - In bdrv_reopen_prepare(): check that the value of 'backing' points
       to an existing node or is null. If it points to an existing node it
       also needs to make sure that replacing the backing file will not
       create a cycle in the node graph (i.e. you cannot reach the parent
       from the new backing file).
    
     - In bdrv_reopen_commit(): perform the actual node replacement by
       calling bdrv_set_backing_hd().
    
    There may be temporary implicit nodes between a BDS and its backing
    file (e.g. a commit filter node). In these cases bdrv_reopen_prepare()
    looks for the real (non-implicit) backing file and requires that the
    'backing' option points to it. Replacing or detaching a backing file
    is forbidden if there are implicit nodes in the middle.
    
    Although x-blockdev-reopen is meant to be used like blockdev-add,
    there's an important thing that must be taken into account: the only
    way to set a new backing file is by using a reference to an existing
    node (previously added with e.g. blockdev-add).  If 'backing' contains
    a dictionary with a new set of options ({"driver": "qcow2", "file": {
    ... }}) then it is interpreted that the _existing_ backing file must
    be reopened with those options.
    Signed-off-by: NAlberto Garcia <berto@igalia.com>
    Signed-off-by: NKevin Wolf <kwolf@redhat.com>
    cb828c31
block.c 184.8 KB