block: BDRV_O_NO_IO for backing file on creation
PATCH 1/1 block: BDRV_O_NO_IO for backing file on creation
When creating an image file with a backing file, we generally try to open the backing file (unless -u was specified), mostly to verify that it is there, but also to get the file size if none was specified for the new image.
For neither of these things do we need data I/O, and so we can pass BDRV_O_NO_IO when opening the backing file. This allows us to open even encrypted backing images without requiring the user to provide a secret.
This makes the -u switch in iotests 189 and 198 unnecessary (and the $size parameter), so drop it, because this way we get regression tests for this patch here.
--- block.c | 6 +++++- tests/qemu-iotests/189 | 2 +- tests/qemu-iotests/198 | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-)
block.c +5 -1
@@ -6553,9 +6553,13 @@ void bdrv_img_create(const char *filename, const char *fmt, }assert (full_backing); -/* backing files always opened read-only */ +/* +* No need to do I/O here, which allows us to open encrypted +* backing images without needing the secret +*/ back_flags = flags; back_flags &= ~(BDRV_O_RDWR |BDRV_O_SNAPSHOT |BDRV_O_NO_BACKING ); + back_flags |=BDRV_O_NO_IO ; backing_options =qdict_new ();if (backing_fmt) {
tests/qemu-iotests/189 +1 -1
@@ -67,7 +67,7 @@ echo "== verify pattern ==" $QEMU_IO --object $SECRET0 -c "read -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir echo "== create overlay ==" -_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -u -b "$TEST_IMG_BASE" -F $IMGFMT $size +_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -b "$TEST_IMG_BASE" -F $IMGFMT echo echo "== writing part of a cluster =="
tests/qemu-iotests/198 +1 -1
@@ -64,7 +64,7 @@ echo "== writing whole image base ==" $QEMU_IO --object $SECRET0 -c "write -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir echo "== create overlay ==" -_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -u -b "$TEST_IMG_BASE" -F $IMGFMT $size +_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -b "$TEST_IMG_BASE" -F $IMGFMT echo echo "== writing whole image layer =="
Signature · 1 line
2.31.1
Kevin Wolf
AppliedAm 22.06.2021 um 16:00 hat Max Reitz geschrieben:
Quoted 9 lines
When creating an image file with a backing file, we generally try to open the backing file (unless -u was specified), mostly to verify that it is there, but also to get the file size if none was specified for the new image.
For neither of these things do we need data I/O, and so we can pass
BDRV_O_NO_IOwhen opening the backing file. This allows us to open even encrypted backing images without requiring the user to provide a secret.
Quoted 6 lines
This makes the -u switch in iotests 189 and 198 unnecessary (and the $size parameter), so drop it, because this way we get regression tests for this patch here.
Signed-off-by Max Reitz <[email protected]>
Thanks, applied to the block branch.
Kevin