On 12/06/14 09:14, 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(a)redhat.com>
---
src/qemu/qemu_driver.c | 196 ++++++++++++++++++++++++++-----------------------
1 file changed, 105 insertions(+), 91 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e873362..1e254bc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10981,59 +10981,25 @@ qemuDomainMemoryPeek(virDomainPtr dom,
}
+/* Refresh the capacity and allocation limits of a given storage
+ * source. Assumes that the caller has already obtained a domain job.
+ * Set *activeFail to true if data cannot be obtained because a
+ * transient guest is no longer active. */
static int
-qemuDomainGetBlockInfo(virDomainPtr dom,
- const char *path,
- virDomainBlockInfoPtr info,
- unsigned int flags)
+qemuStorageLimitsRefresh(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg,
One argument per line looks better.
+ virDomainObjPtr vm, virDomainDiskDefPtr
disk,
+ virStorageSourcePtr src, const char *path,
disk, src and path together? That doesn't seem to make much sense.
While 'path' is used for error messages only, and I don't think it's
entirely necessary to use the user-provided string in error messages we
will be good of with just using src->path.
The 'disk' argument is used to gather the allocation stat in case of
block devices for an active domain. That is really strange. If you want
to make this function usable for any disk source, the disk alias won't
be the right way to get that.
I think a better approach will be to split the code into two helpers,
one being called on offline domains that gathers data from images on
disk and doesn't ever touch the monitor (basically the existing code in
qemuDomainGetBlockInfo minus the monitor call) and a second helper that
will gather the data from monitor calls and never touch files used for
online VMs. This is partially available in the existing helper to gather
domain block stats.
Peter