]> xenbits.xensource.com Git - libvirt.git/commit
util: Introduce virStorageSourceUpdatePhysicalSize
authorJohn Ferlan <jferlan@redhat.com>
Thu, 1 Dec 2016 21:19:26 +0000 (16:19 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 12 Dec 2016 21:04:17 +0000 (16:04 -0500)
commitc5f6151390ff0a8e65014172bb8c0a8d312c3353
treef82eeeab4922afc59bf79fd950c539c2cbfd16a9
parenta7fea19fcd0f4923cca21345c811e9eae96589d6
util: Introduce virStorageSourceUpdatePhysicalSize

Commit id '8dc27259' introduced virStorageSourceUpdateBlockPhysicalSize
in order to retrieve the physical size for a block backed source device
for an active domain since commit id '15fa84ac' changed to use the
qemuMonitorGetAllBlockStatsInfo and qemuMonitorBlockStatsUpdateCapacity
API's to (essentially) retrieve the "actual-size" from a 'query-block'
operation for the source device.

However, the code only was made functional for a BLOCK backing type
and it neglected to use qemuOpenFile, instead using just open. After
the open the block lseek would find the end of the block and set the
physical value, close the fd and return.

Since the code would return 0 immediately if the source device wasn't
a BLOCK backed device, the physical would be displayed incorrectly,
such as follows in domblkinfo for a file backed source device:

Capacity:       1073741824
Allocation:     0
Physical:       0

This patch will modify the algorithm to get the physical size for other
backing types and it will make use of the qemuDomainStorageOpenStat
helper in order to open/stat the source file depending on its type.
The qemuDomainGetStatsOneBlock will no longer inhibit printing errors,
but it will still ignore them leaving the physical value set to 0.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/libvirt_private.syms
src/qemu/qemu_driver.c
src/util/virstoragefile.c
src/util/virstoragefile.h