]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Adjust qemuDomainGetBlockInfo data for sparse backed files
authorJohn Ferlan <jferlan@redhat.com>
Mon, 12 Dec 2016 22:12:09 +0000 (17:12 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 20 Dec 2016 17:56:44 +0000 (12:56 -0500)
commitb9b1aa6392e058b9c3814ea391943bc3be18ccba
tree574802841c88701db583ac8c21963d39445402a7
parent3b67fc9f9ff076d2e4d6ed1d8faf548b250c9a31
qemu: Adjust qemuDomainGetBlockInfo data for sparse backed files

According to commit id '0282ca45a' the 'physical' value should
essentially be the last offset of the image or the host physical
size in bytes of the image container. However, commit id '15fa84ac'
refactored the GetBlockInfo to use the same returned data as the
GetStatsBlock API for an active domain. For the 'entry->physical'
that would end up being the "actual-size" as set through the
qemuMonitorJSONBlockStatsUpdateCapacityOne (commit '7b11f5e5').
Digging deeper into QEMU code one finds that actual_size is
filled in using the same algorithm as GetBlockInfo has used for
setting the 'allocation' field when the domain is inactive.

The difference in values is seen primarily in sparse raw files
and other container type files (such as qcow2), which will return
a smaller value via the stat API for 'st_blocks'. Additionally
for container files, the 'capacity' field (populated via the
QEMU "virtual-size" value) may be slightly different (smaller)
in order to accomodate the overhead for the container. For
sparse files, the state 'st_size' field is returned.

This patch thus alters the allocation and physical values for
sparse backed storage files to be more appropriate to the API
contract. The result for GetBlockInfo is the following:

 capacity: logical size in bytes of the image (how much storage
           the guest will see)
 allocation: host storage in bytes occupied by the image (such
             as highest allocated extent if there are no holes,
             similar to 'du')
 physical: host physical size in bytes of the image container
           (last offset, similar to 'ls')

NB: The GetStatsBlock API allows a different contract for the
values:

 "block.<num>.allocation" - offset of the highest written sector
                            as unsigned long long.
 "block.<num>.capacity" - logical size in bytes of the block device
                          backing image as unsigned long long.
 "block.<num>.physical" - physical size in bytes of the container
                          of the backing image as unsigned long long.
src/qemu/qemu_driver.c