[libvirt] [PATCH 1/3] qemu: monitor: return block stats data as a hash to avoid disk mixup

Peter Krempa pkrempa at redhat.com
Tue Sep 30 09:04:53 UTC 2014


On 09/29/14 20:17, Eric Blake wrote:
> On 09/25/2014 06:06 AM, Peter Krempa wrote:
>> The current block stats code matched up the disk name with the actual
>> stats by the order in the data returned from qemu. This unfortunately
>> isn't right as qemu may return the disks in any order. Fix this by
>> returning a hash of stats and index them by the disk alias.
>> ---
>>  src/qemu/qemu_driver.c       |  44 ++++++++---------
>>  src/qemu/qemu_monitor.c      |  14 ++----
>>  src/qemu/qemu_monitor.h      |   6 +--
>>  src/qemu/qemu_monitor_json.c | 112 ++++++++++++++++++++-----------------------
>>  src/qemu/qemu_monitor_json.h |   4 +-
>>  5 files changed, 82 insertions(+), 98 deletions(-)
>>
> 
>> @@ -1749,56 +1750,62 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
>>      if (flush_total_times)
>>          *flush_total_times = -1;
>>
>> -    if (qemuMonitorJSONGetAllBlockStatsInfo(mon, dev_name, &stats, 1) != 1)
>> +    if (qemuMonitorJSONGetAllBlockStatsInfo(mon, &blockstats) < 0)
>>          goto cleanup;
>>
>> -    *rd_req = stats.rd_req;
>> -    *rd_bytes = stats.rd_bytes;
>> -    *wr_req = stats.wr_req;
>> -    *wr_bytes = stats.wr_bytes;
>> +    if (!(stats = virHashLookup(blockstats, dev_name))) {
> 
> Maybe slightly less efficient (we now malloc stats for all members, only
> to throw away everything but the one we want), but I can live with it.
> 
> ACK; worth having in 1.2.9
>
I've pushed this one and I'll hold off the rest until the release.

Peter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140930/9bc4c0e4/attachment-0001.sig>


More information about the libvir-list mailing list