[libvirt] [PATCH] fix key error for qemuMonitorGetBlockStatsInfo

Osier Yang jyang at redhat.com
Mon Jul 2 09:53:41 UTC 2012


On 2012年06月21日 15:58, Osier Yang wrote:
> On 2012年06月21日 15:37, lvroyce at linux.vnet.ibm.com wrote:
>> From: lvroyce<lvroyce at linux.vnet.ibm.com>
>>
>> virDomainBlockStatsFlags can't collect total_time_ns for read/write/flush
>> because of key typo when retriveing from qemu cmd result
>>
>> Signed-off-by: lvroyce<lvroyce at linux.vnet.ibm.com>
>> ---
>> src/qemu/qemu_monitor_json.c | 24 ++++++++++++------------
>> src/qemu/qemu_monitor_text.c | 18 +++++++++---------
>> 2 files changed, 21 insertions(+), 21 deletions(-)
>>
>> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
>> index 7d2da21..7eb9529 100644
>> --- a/src/qemu/qemu_monitor_json.c
>> +++ b/src/qemu/qemu_monitor_json.c
>> @@ -1710,12 +1710,12 @@ int
>> qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
>> goto cleanup;
>> }
>> if (rd_total_times&&
>> - virJSONValueObjectHasKey(stats, "rd_total_times_ns")&&
>> - (virJSONValueObjectGetNumberLong(stats, "rd_total_times_ns",
>> + virJSONValueObjectHasKey(stats, "rd_total_time_ns")&&
>> + (virJSONValueObjectGetNumberLong(stats, "rd_total_time_ns",
>> rd_total_times)< 0)) {
>> qemuReportError(VIR_ERR_INTERNAL_ERROR,
>> _("cannot read %s statistic"),
>> - "rd_total_times_ns");
>> + "rd_total_time_ns");
>> goto cleanup;
>> }
>> if (virJSONValueObjectGetNumberLong(stats, "wr_bytes", wr_bytes)< 0) {
>> @@ -1731,12 +1731,12 @@ int
>> qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
>> goto cleanup;
>> }
>> if (wr_total_times&&
>> - virJSONValueObjectHasKey(stats, "wr_total_times_ns")&&
>> - (virJSONValueObjectGetNumberLong(stats, "wr_total_times_ns",
>> + virJSONValueObjectHasKey(stats, "wr_total_time_ns")&&
>> + (virJSONValueObjectGetNumberLong(stats, "wr_total_time_ns",
>> wr_total_times)< 0)) {
>> qemuReportError(VIR_ERR_INTERNAL_ERROR,
>> _("cannot read %s statistic"),
>> - "wr_total_times_ns");
>> + "wr_total_time_ns");
>> goto cleanup;
>> }
>> if (flush_req&&
>> @@ -1749,12 +1749,12 @@ int
>> qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
>> goto cleanup;
>> }
>> if (flush_total_times&&
>> - virJSONValueObjectHasKey(stats, "flush_total_times_ns")&&
>> - (virJSONValueObjectGetNumberLong(stats, "flush_total_times_ns",
>> + virJSONValueObjectHasKey(stats, "flush_total_time_ns")&&
>> + (virJSONValueObjectGetNumberLong(stats, "flush_total_time_ns",
>> flush_total_times)< 0)) {
>> qemuReportError(VIR_ERR_INTERNAL_ERROR,
>> _("cannot read %s statistic"),
>> - "flush_total_times_ns");
>> + "flush_total_time_ns");
>> goto cleanup;
>> }
>> }
>> @@ -1822,12 +1822,12 @@ int
>> qemuMonitorJSONGetBlockStatsParamsNumber(qemuMonitorPtr mon,
>>
>> if (STREQ(key, "rd_bytes") ||
>> STREQ(key, "rd_operations") ||
>> - STREQ(key, "rd_total_times_ns") ||
>> + STREQ(key, "rd_total_time_ns") ||
>> STREQ(key, "wr_bytes") ||
>> STREQ(key, "wr_operations") ||
>> - STREQ(key, "wr_total_times_ns") ||
>> + STREQ(key, "wr_total_time_ns") ||
>> STREQ(key, "flush_operations") ||
>> - STREQ(key, "flush_total_times_ns")) {
>> + STREQ(key, "flush_total_time_ns")) {
>> num++;
>> } else {
>> /* wr_highest_offset is parsed by qemuMonitorJSONGetBlockExtent. */
>> diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
>> index edb5dfd..086b06b 100644
>> --- a/src/qemu/qemu_monitor_text.c
>> +++ b/src/qemu/qemu_monitor_text.c
>> @@ -977,13 +977,13 @@ int
>> qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
>> if (virStrToLong_ll (p,&dummy, 10, wr_req) == -1)
>> VIR_DEBUG ("error reading wr_req: %s", p);
>> } else if (rd_total_times&&
>> - STRPREFIX (p, "rd_total_times_ns=")) {
>> - p += strlen("rd_total_times_ns=");
>> + STRPREFIX (p, "rd_total_time_ns=")) {
>> + p += strlen("rd_total_time_ns=");
>> if (virStrToLong_ll (p,&dummy, 10, rd_total_times) == -1)
>> VIR_DEBUG ("error reading rd_total_times: %s", p);
>> } else if (wr_total_times&&
>> - STRPREFIX (p, "wr_total_times_ns=")) {
>> - p += strlen("wr_total_times_ns=");
>> + STRPREFIX (p, "wr_total_time_ns=")) {
>> + p += strlen("wr_total_time_ns=");
>> if (virStrToLong_ll (p,&dummy, 10, wr_total_times) == -1)
>> VIR_DEBUG ("error reading wr_total_times: %s", p);
>> } else if (flush_req&&
>> @@ -992,8 +992,8 @@ int
>> qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
>> if (virStrToLong_ll (p,&dummy, 10, flush_req) == -1)
>> VIR_DEBUG ("error reading flush_req: %s", p);
>> } else if (flush_total_times&&
>> - STRPREFIX (p, "flush_total_times_ns=")) {
>> - p += strlen("flush_total_times_ns=");
>> + STRPREFIX (p, "flush_total_time_ns=")) {
>> + p += strlen("flush_total_time_ns=");
>> if (virStrToLong_ll (p,&dummy, 10, flush_total_times) == -1)
>> VIR_DEBUG ("error reading flush_total_times: %s", p);
>> } else {
>> @@ -1071,10 +1071,10 @@ int
>> qemuMonitorTextGetBlockStatsParamsNumber(qemuMonitorPtr mon,
>> STRPREFIX (p, " wr_bytes=") ||
>> STRPREFIX (p, " rd_operations=") ||
>> STRPREFIX (p, " wr_operations=") ||
>> - STRPREFIX (p, " rd_total_times_ns=") ||
>> - STRPREFIX (p, " wr_total_times_ns=") ||
>> + STRPREFIX (p, " rd_total_time_ns=") ||
>> + STRPREFIX (p, " wr_total_time_ns=") ||
>> STRPREFIX (p, " flush_operations=") ||
>> - STRPREFIX (p, " flush_total_times_ns=")) {
>> + STRPREFIX (p, " flush_total_time_ns=")) {
>> num++;
>> } else {
>> VIR_DEBUG ("unknown block stat near %s", p);
>
>
> ACK, interesting, QEMU doc has bug to fix too then. E.g.
>
> {
> "device":"sd0",
> "stats":{
> "wr_highest_offset":0,
> "wr_bytes":0,
> "wr_operations":0,
> "rd_bytes":0,
> "rd_operations":0
> "flush_operations":0,
> "wr_total_times_ns":0
> "rd_total_times_ns":0
> "flush_total_times_ns":0
> }
>

Hi, lvroyce.

Sorry for the late, and not see your message on IRC. Pushed now.

Regards,
Osier




More information about the libvir-list mailing list