summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlberto Garcia2019-03-12 17:48:47 +0100
committerKevin Wolf2019-03-12 20:30:14 +0100
commitcb828c31de125d8c88ba1c3510b11343cbd211b3 (patch)
tree859dad1e58d716ff7a37d17b2f5688551664e0c2 /include
parentblock: Allow omitting the 'backing' option in certain cases (diff)
downloadqemu-cb828c31de125d8c88ba1c3510b11343cbd211b3.tar.gz
qemu-cb828c31de125d8c88ba1c3510b11343cbd211b3.tar.xz
qemu-cb828c31de125d8c88ba1c3510b11343cbd211b3.zip
block: Allow changing the backing file on reopen
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: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/block/block.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/block/block.h b/include/block/block.h
index fcc61a3a19..68a3efbb43 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -188,6 +188,8 @@ typedef struct BDRVReopenState {
int flags;
BlockdevDetectZeroesOptions detect_zeroes;
bool backing_missing;
+ bool replace_backing_bs; /* new_backing_bs is ignored if this is false */
+ BlockDriverState *new_backing_bs; /* If NULL then detach the current bs */
uint64_t perm, shared_perm;
QDict *options;
QDict *explicit_options;