[libvirt] [PATCH 09/12] getstats: prepare for dynamic block.count stat
Eric Blake
eblake at redhat.com
Mon Dec 8 17:22:37 UTC 2014
On 12/08/2014 07:26 AM, Peter Krempa wrote:
> On 12/08/14 15:19, Peter Krempa wrote:
>> On 12/06/14 09:14, Eric Blake wrote:
>>> A coming patch will make it optionally possible to list backing
>>> chain block stats; in this mode of operation, block.counts is no
>>> longer the number of <disks> in the domain, but the number of
>>> blocks in the array being reported. We still want block.count
>>> listed first, but rather than iterate the tree twice (once to
>>> count, and once to list stats), it's easier to just touch things
>>> up after the fact.
>>>
>>> * src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Compute count
>>> after the fact.
>>>
>>> Signed-off-by: Eric Blake <eblake at redhat.com>
>>> ---
>>> src/qemu/qemu_driver.c | 9 ++++++++-
>>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>>
>
> Compiler complains:
>
> qemu/qemu_driver.c: In function 'qemuDomainGetStatsBlock':
> qemu/qemu_driver.c:18630:46: error: 'i' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> record->params[count_index].value.ui = i;
> ^
You must be compiling at -O2 while I was not :)
Found the culprit: the QEMU_ADD_COUNT_PARAM macro has a hidden goto,
that can bypass the initialization of i=0 in the for loop; the solution
is trivial.
>>
>> ACK,
>>
>
> if you fix the issue above.
I'll be pushing the acked patches that can be reshuffled without
dependencies, and reposting the rest of the series with fixes
incorporated...
diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c
index bb516af..78d1bdd 100644
--- i/src/qemu/qemu_driver.c
+++ w/src/qemu/qemu_driver.c
@@ -18539,7 +18539,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
int *maxparams,
unsigned int privflags)
{
- size_t i;
+ size_t i = 0;
int ret = -1;
int rc;
virHashTablePtr stats = NULL;
@@ -18568,7 +18568,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
count_index = record->nparams;
QEMU_ADD_COUNT_PARAM(record, maxparams, "block", 0);
- for (i = 0; i < dom->def->ndisks; i++) {
+ for (i; i < dom->def->ndisks; i++) {
qemuBlockStats *entry;
virDomainDiskDefPtr disk = dom->def->disks[i];
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141208/9a9debf7/attachment-0001.sig>
More information about the libvir-list
mailing list