
On 12/16/14 09:04, Eric Blake wrote:
Create a helper function that can be reused for gathering block info from virDomainListGetStats.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Split guts... (qemuStorageLimitsRefresh): ...into new helper function.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/qemu/qemu_driver.c | 207 ++++++++++++++++++++++++++----------------------- 1 file changed, 110 insertions(+), 97 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5e9c133..13ec903 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10992,65 +10992,23 @@ qemuDomainMemoryPeek(virDomainPtr dom, }
+/* Refresh the capacity and allocation limits of a given storage + * source. Assumes that the caller has already obtained a domain + * job. */ static int -qemuDomainGetBlockInfo(virDomainPtr dom, - const char *path, - virDomainBlockInfoPtr info, - unsigned int flags) +qemuStorageLimitsRefresh(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg, + virDomainObjPtr vm, virDomainDiskDefPtr disk, + virStorageSourcePtr src)
One argument per line please.
{ - virQEMUDriverPtr driver = dom->conn->privateData; - virDomainObjPtr vm; int ret = -1; int fd = -1; off_t end; virStorageSourcePtr meta = NULL; - virDomainDiskDefPtr disk = NULL;
[...]
@@ -11071,51 +11029,51 @@ qemuDomainGetBlockInfo(virDomainPtr dom, * punching holes), and physical size of a non-raw file can * change. */ - if (virStorageSourceIsLocalStorage(disk->src)) { + if (virStorageSourceIsLocalStorage(src)) { /* Yes, this is a mild TOCTTOU race, but if someone is * changing files in the background behind libvirt's back, * they deserve bogus information. */ - if (stat(disk->src->path, &sb) < 0) { + if (stat(src->path, &sb) < 0) {
Here you'll get a context conflict after fixing earlier patch.
virReportSystemError(errno, - _("cannot stat file '%s'"), disk->src->path); - goto endjob; + _("cannot stat file '%s'"), src->path); + goto cleanup; }
[...] ACK, Peter