]> git.ipfire.org Git - thirdparty/qemu.git/commit - block.c
block: Remove children options from bs->{options,explicit_options}
authorAlberto Garcia <berto@igalia.com>
Fri, 29 Jun 2018 11:37:00 +0000 (14:37 +0300)
committerKevin Wolf <kwolf@redhat.com>
Wed, 15 Aug 2018 10:50:39 +0000 (12:50 +0200)
commit2f624b80ba67f19edb3f7c5bc27cddc3c844e443
tree57ef8b503eef29aa29b470f4f4ff96b641ded414
parent655b4b67e380891ee3996349213c62088d71395d
block: Remove children options from bs->{options,explicit_options}

When bdrv_open_inherit() opens a BlockDriverState the options QDict
can contain options for some of its children, passed in the form of
child-name.option=value

So while each child is opened with that subset of options, those same
options remain stored in the parent BDS, leaving (at least) two copies
of each one of them ("child-name.option=value" in the parent and
"option=value" in the child).

Having the children options stored in the parent is unnecessary and it
can easily lead to an inconsistent state:

  $ qemu-img create -f qcow2 hd0.qcow2 10M
  $ qemu-img create -f qcow2 -b hd0.qcow2 hd1.qcow2
  $ qemu-img create -f qcow2 -b hd1.qcow2 hd2.qcow2

  $ $QEMU -drive file=hd2.qcow2,node-name=hd2,backing.node-name=hd1

This opens a chain of images hd0 <- hd1 <- hd2. Now let's remove hd1
using block_stream:

  (qemu) block_stream hd2 0 hd0.qcow2

After this hd2 contains backing.node-name=hd1, which is no longer
correct because hd1 doesn't exist anymore.

This patch removes all children options from the parent dictionaries
at the end of bdrv_open_inherit() and bdrv_reopen_queue_child().

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c