* [Qemu-devel] [PATCH 0/2] block: fix backing file overriding
@ 2013-09-22 12:05 Fam Zheng
2013-09-22 12:05 ` [Qemu-devel] [PATCH 1/2] " Fam Zheng
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fam Zheng @ 2013-09-22 12:05 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha
The backing.file.filename option is not working as expected: if there's also a
backing file name from the format driver, adding this option fails bdrv_open;
if there's no backing file name info in the image, "info block" doesn't show
the overrided file name.
A test case is updated to catch these issues.
Fam Zheng (2):
block: fix backing file overriding
qemu-iotests: add test for backing file overriding
block.c | 7 +++++--
tests/qemu-iotests/051 | 17 ++++++++++++++++-
tests/qemu-iotests/051.out | 11 +++++++++++
3 files changed, 32 insertions(+), 3 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/2] block: fix backing file overriding
2013-09-22 12:05 [Qemu-devel] [PATCH 0/2] block: fix backing file overriding Fam Zheng
@ 2013-09-22 12:05 ` Fam Zheng
2013-09-22 12:05 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add test for " Fam Zheng
2013-09-23 9:11 ` [Qemu-devel] [PATCH 0/2] block: fix " Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Fam Zheng @ 2013-09-22 12:05 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha
Providing backing.file.filename doesn't override backing file as expected:
$ x86_64-softmmu/qemu-system-x86_64 -drive \
file=/tmp/child.qcow2,backing.file.filename=/tmp/fake.qcow2
qemu-system-x86_64: -drive \
file=/tmp/child.qcow2,backing.file.filename=/tmp/fake.qcow2: could not
open disk image /tmp/child.qcow2: Can't specify 'file' and 'filename'
options at the same time
With
$ qemu-img info /tmp/child.qcow2
image: /tmp/child.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 196K
cluster_size: 65536
backing file: /tmp/fake.qcow2
This fixes it by calling bdrv_get_full_backing_filename only if
backing.file.filename is not provided. Also save the backing file name
to bs->backing_file so the information is correct with HMP "info block".
Signed-off-by: Fam Zheng <famz@redhat.com>
---
block.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index e176c6f..a2ea39a 100644
--- a/block.c
+++ b/block.c
@@ -978,11 +978,12 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
} else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) {
QDECREF(options);
return 0;
+ } else {
+ bdrv_get_full_backing_filename(bs, backing_filename,
+ sizeof(backing_filename));
}
bs->backing_hd = bdrv_new("");
- bdrv_get_full_backing_filename(bs, backing_filename,
- sizeof(backing_filename));
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
@@ -994,6 +995,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
ret = bdrv_open(bs->backing_hd,
*backing_filename ? backing_filename : NULL, options,
back_flags, back_drv, &local_err);
+ pstrcpy(bs->backing_file, sizeof(bs->backing_file),
+ bs->backing_hd->file->filename);
if (ret < 0) {
bdrv_unref(bs->backing_hd);
bs->backing_hd = NULL;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] qemu-iotests: add test for backing file overriding
2013-09-22 12:05 [Qemu-devel] [PATCH 0/2] block: fix backing file overriding Fam Zheng
2013-09-22 12:05 ` [Qemu-devel] [PATCH 1/2] " Fam Zheng
@ 2013-09-22 12:05 ` Fam Zheng
2013-09-23 9:11 ` [Qemu-devel] [PATCH 0/2] block: fix " Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Fam Zheng @ 2013-09-22 12:05 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha
Test that backing.file.filename option can be parsed and override the
backing file from image (backing file reflected with "info block").
Signed-off-by: Fam Zheng <famz@redhat.com>
---
tests/qemu-iotests/051 | 17 ++++++++++++++++-
tests/qemu-iotests/051.out | 11 +++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
index 1f39c6a..78e1182 100755
--- a/tests/qemu-iotests/051
+++ b/tests/qemu-iotests/051
@@ -45,7 +45,14 @@ _supported_os Linux
function do_run_qemu()
{
echo Testing: "$@"
- echo quit | $QEMU -nographic -monitor stdio -serial none "$@"
+ (
+ if ! test -t 0; then
+ while read cmd; do
+ echo $cmd
+ done
+ fi
+ echo quit
+ ) | $QEMU -nographic -monitor stdio -serial none "$@"
echo
}
@@ -57,6 +64,9 @@ function run_qemu()
size=128M
_make_test_img $size
+cp $TEST_IMG $TEST_IMG.orig
+mv $TEST_IMG $TEST_IMG.base
+_make_test_img -b $TEST_IMG.base $size
echo
echo === Unknown option ===
@@ -67,6 +77,11 @@ run_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=on
run_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=1234
run_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=foo
+echo
+echo === Overriding backing file ===
+echo
+
+echo "info block" | run_qemu -drive file=$TEST_IMG,driver=qcow2,backing.file.filename=$TEST_IMG.orig -nodefaults
echo
echo === Enable and disable lazy refcounting on the command line, plus some invalid values ===
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index 88e8fa7..335fbe3 100644
--- a/tests/qemu-iotests/051.out
+++ b/tests/qemu-iotests/051.out
@@ -1,5 +1,6 @@
QA output created by 051
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/t.IMGFMT.base'
=== Unknown option ===
@@ -16,6 +17,16 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo: could not open disk image TEST_DIR/t.qcow2: Block format 'qcow2' used by device 'ide0-hd0' doesn't support the option 'unknown_opt'
+=== Overriding backing file ===
+
+Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,backing.file.filename=TEST_DIR/t.qcow2.orig -nodefaults
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) i^[[K^[[Din^[[K^[[D^[[Dinf^[[K^[[D^[[D^[[Dinfo^[[K^[[D^[[D^[[D^[[Dinfo ^[[K^[[D^[[D^[[D^[[D^[[Dinfo b^[[K^[[D^[[D^[[D^[[D^[[D^[[Dinfo bl^[[K^[[D^[[D^[[D^[[D^[[D^[[D^[[Dinfo blo^[[K^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[Dinfo bloc^[[K^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[Dinfo block^[[K
+ide0-hd0: TEST_DIR/t.qcow2 (qcow2)
+ Backing file: TEST_DIR/t.qcow2.orig (chain depth: 1)
+ [not inserted](qemu) q^[[K^[[Dqu^[[K^[[D^[[Dqui^[[K^[[D^[[D^[[Dquit^[[K
+
+
=== Enable and disable lazy refcounting on the command line, plus some invalid values ===
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,lazy-refcounts=on
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] block: fix backing file overriding
2013-09-22 12:05 [Qemu-devel] [PATCH 0/2] block: fix backing file overriding Fam Zheng
2013-09-22 12:05 ` [Qemu-devel] [PATCH 1/2] " Fam Zheng
2013-09-22 12:05 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add test for " Fam Zheng
@ 2013-09-23 9:11 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2013-09-23 9:11 UTC (permalink / raw)
To: Fam Zheng; +Cc: qemu-devel, stefanha
Am 22.09.2013 um 14:05 hat Fam Zheng geschrieben:
> The backing.file.filename option is not working as expected: if there's also a
> backing file name from the format driver, adding this option fails bdrv_open;
> if there's no backing file name info in the image, "info block" doesn't show
> the overrided file name.
>
> A test case is updated to catch these issues.
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-23 9:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-22 12:05 [Qemu-devel] [PATCH 0/2] block: fix backing file overriding Fam Zheng
2013-09-22 12:05 ` [Qemu-devel] [PATCH 1/2] " Fam Zheng
2013-09-22 12:05 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add test for " Fam Zheng
2013-09-23 9:11 ` [Qemu-devel] [PATCH 0/2] block: fix " Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).