[libvirt] [PATCH 1/3] qemu: monitor: return block stats data as a hash to avoid disk mixup
Eric Blake
eblake at redhat.com
Mon Sep 29 18:17:48 UTC 2014
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
-------------- 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/20140929/b18eaa4b/attachment-0001.sig>
More information about the libvir-list
mailing list