Fix check for default backing files in bdrv_reopen_prepare()
cover Fix check for default backing files in bdrv_reopen_prepare()
Hi,
Patch 1 is the fix for the bug reported by Max here:
https://lists.gnu.org/archive/html/qemu-block/2019-04/msg00293.html
Patch 2 fixes a different (but slightly related) issue that I found while preparing the first patch.
Regards,
Berto
Alberto Garcia (2):
block: Fix check for default backing files in bdrv_reopen_prepare()
block: Clear the backing_file fields on detach
block.c | 6 +++++- tests/qemu-iotests/245 | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/2 block: Fix check for default backing files in bdrv_reopen_prepare()
x-blockdev-reopen requires that the 'backing' parameter is specified when an image has a backing file attached or when there is a default backing file in the image metadata.
The latter can be checked by reading bs->auto_backing_file, but bdrv_reopen_prepare() is using bs->backing_file.
This bug should be detected by iotest 245, but unfortunately the test expectation is wrong so it must be corrected as well.
--- block.c | 3 ++- tests/qemu-iotests/245 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
block.c +2 -1
@@ -3634,7 +3634,8 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,* its metadata. Otherwise the 'backing' option can be omitted. */ if (drv->supports_backing && reopen_state->backing_missing && - (backing_bs (reopen_state->bs) || reopen_state->bs->backing_file[0 ])) { + (backing_bs (reopen_state->bs) || + reopen_state->bs->auto_backing_file[0 ])) {error_setg (errp,"backing is missing for '%s'" , reopen_state->bs->node_name); ret = -EINVAL ;
tests/qemu-iotests/245 +1 -1
@@ -716,7 +716,7 @@ class TestBlockdevReopen(iotests.QMPTestCase): # Detach hd2 from hd0. self.reopen(opts, {'backing': None}) - self.reopen(opts, {}, "backing is missing for 'hd0'") + self.reopen(opts) # Remove both hd0 and hd2 result = self.vm.qmp('blockdev-del', conv_keys = True, node_name = 'hd0')
Signature · 1 line
2.11.0
PATCH 2/2 block: Clear the backing_file fields on detach
In reply to Alberto Garcia--- block.c | 3 +++ 1 file changed, 3 insertions(+)
block.c +3 -0
@@ -1085,6 +1085,9 @@ static void bdrv_backing_detach(BdrvChild *c)error_free (parent->backing_blocker); parent->backing_blocker =NULL ; + parent->backing_file[0 ] ='\0' ; + parent->backing_format[0 ] ='\0' ; +bdrv_child_cb_detach (c); }
Signature · 1 line
2.11.0
Quoted 8 lines · Alberto Garcia
Hi,
Patch 1 is the fix for the bug reported by Max here:
https://lists.gnu.org/archive/html/qemu-block/2019-04/msg00293.htmlPatch 2 fixes a different (but slightly related) issue that I found while preparing the first patch.
I think the real problem is that bs->backing_file is not a cache for bs->backing->bs->filename.
In fact, every user of bs->backing_file expects it to be something different. Some expect it to be a cache for bs->backing->bs->filename, some expect it to be what the image header says (i.e., it if’s a relative path, it’s relative to the overlay), some expect it to be what the image header says, but relative paths to be translated so they are relative to qemu’s CWD.
All of this should be cleaned up and this is what patch 7 in my "block:
Deal with filters" series does:
http://lists.nongnu.org/archive/html/qemu-block/2019-04/msg00308.html
Max
Quoted 13 lines · Max Reitz
Quoted 2 lines
Patch 2 fixes a different (but slightly related) issue that I found while preparing the first patch.
I think the real problem is that
bs->backing_fileis not a cache forbs->backing->bs->filename.In fact, every user of
bs->backing_fileexpects it to be something different. Some expect it to be a cache forbs->backing->bs->filename, some expect it to be what the image header says (i.e., it if’s a relative path, it’s relative to the overlay), some expect it to be what the image header says, but relative paths to be translated so they are relative to qemu’s CWD.
Quoted 4 lines
All of this should be cleaned up and this is what patch 7 in my "block:
Deal with filters" series does:http://lists.nongnu.org/archive/html/qemu-block/2019-04/msg00308.html
Ok, you can leave out the second patch then. The first one should still be correct, right?
Berto
Quoted 14 lines · Alberto Garcia
Quoted 13 lines · Max Reitz
Quoted 2 lines
Patch 2 fixes a different (but slightly related) issue that I found while preparing the first patch.
I think the real problem is that
bs->backing_fileis not a cache forbs->backing->bs->filename.In fact, every user of
bs->backing_fileexpects it to be something different. Some expect it to be a cache forbs->backing->bs->filename, some expect it to be what the image header says (i.e., it if’s a relative path, it’s relative to the overlay), some expect it to be what the image header says, but relative paths to be translated so they are relative to qemu’s CWD.
Quoted 7 lines
Quoted 4 lines
All of this should be cleaned up and this is what patch 7 in my "block:
Deal with filters" series does:http://lists.nongnu.org/archive/html/qemu-block/2019-04/msg00308.html
Ok, you can leave out the second patch then. The first one should still be correct, right?
I just think it’s unnecessary because as of my series both backing_file and auto_backing_file serve the purpose.
Max
Quoted 5 lines · Max Reitz
Quoted 2 lines
Ok, you can leave out the second patch then. The first one should still be correct, right?
I just think it’s unnecessary because as of my series both
backing_fileandauto_backing_fileserve the purpose.
Ok then!
Berto