summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2013-09-22 20:05:06 +0800
committerKevin Wolf <kwolf@redhat.com>2013-09-25 10:08:56 +0200
commitdbecebddfa4932d1c83915bcb9b5ba5984eb91be (patch)
tree65e9d7177b76cdb9a0192ce7bc13e09d66597e9c /block.c
parentf828a4c8faa118e0ebab3e353ac6840f3b2a0318 (diff)
downloadqemu-dbecebddfa4932d1c83915bcb9b5ba5984eb91be.tar.gz
block: fix backing file overriding
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> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/block.c b/block.c
index ea4956d6c7..b383b721d2 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;