diff options
author | Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> | 2017-04-05 11:19:09 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2017-04-11 15:33:00 +0200 |
commit | 7a9e51198c24a576275cf509a110d24d7c6ca664 (patch) | |
tree | babdbdcd2c8a486836005c78066c3fc3b8e8ed48 /qemu-options.h | |
parent | aa388ddc36e8032f41cd17bef88cc3ebaeba77c9 (diff) |
block: pass the right options for BlockDriver.bdrv_open()
raw_open() expects the caller always passing in the right actual
@options parameter. But when trying to applying snapshot on a RBD
image, bdrv_snapshot_goto() calls raw_open() (by calling the
bdrv_open callback on the BlockDriver) with a NULL @options, and
that will result in a Segmentation fault.
For the other non-raw format drivers, it also makes sense to passing
in the actual options, althought they don't trigger the problem so
far.
Let's prepare a @options by adding the "file" key-value pair to a
copy of the actual options that were given for the node (i.e.
bs->options), and pass it to the callback.
BlockDriver.bdrv_open() expects bs->file to be NULL and just
overwrites it with the result from bdrv_open_child(). That means we
should actually make sure it's NULL because otherwise the child BDS
will have a reference count that is 1 too high. So we unconditionally
invoke bdrv_unref_child() before calling BlockDriver.bdrv_open(), and
we wrap everything in bdrv_ref()/bdrv_unref() so the BDS isn't
deleted in the meantime.
Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Message-id: 20170405091909.36357-2-bjsdjshi@linux.vnet.ibm.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'qemu-options.h')
0 files changed, 0 insertions, 0 deletions