block: fix backing file overriding
commitdbecebddfa4932d1c83915bcb9b5ba5984eb91be
authorFam Zheng <famz@redhat.com>
Sun, 22 Sep 2013 12:05:06 +0000 (22 20:05 +0800)
committerKevin Wolf <kwolf@redhat.com>
Wed, 25 Sep 2013 08:08:56 +0000 (25 10:08 +0200)
tree65e9d7177b76cdb9a0192ce7bc13e09d66597e9c
parentf828a4c8faa118e0ebab3e353ac6840f3b2a0318
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>
block.c