]> git.proxmox.com Git - mirror_qemu.git/commit - block.c
block: Improve get_allocated_file_size's default
authorMax Reitz <mreitz@redhat.com>
Wed, 12 Jun 2019 16:14:13 +0000 (18:14 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 7 Sep 2020 10:31:31 +0000 (12:31 +0200)
commit081e465026769a24b86ba2e6a77709cfea33f16a
tree7fcf59220af674ee450618289de6cb8e609061d9
parentf706a92f249b573c624fa5a8067fa1c6636a6ae0
block: Improve get_allocated_file_size's default

There are two practical problems with bdrv_get_allocated_file_size()'s
default right now:
(1) For drivers with children, we should generally sum all their sizes
    instead of just passing the request through to bs->file.  The latter
    is good for filters, but not so much for format drivers.

(2) Filters need not have bs->file, so we should actually go to the
    filtered child instead of hard-coding bs->file.

Fix this by splitting the default implementation into three branches:
(1) For filter drivers: Return the size of the filtered child
(2) For protocol drivers: Return -ENOTSUP, because the default
    implementation cannot make a guess
(3) For other drivers: Sum all data-bearing children's sizes

Signed-off-by: Max Reitz <mreitz@redhat.com>
block.c