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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]