This patch adds histograms to the stats which were previously ignored due to them not being a virTypedParameterType earlier. Signed-off-by: Amneesh Singh <natto@xxxxxxxxxxxxx> --- src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 52e1f88568..bc6f484d88 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17989,13 +17989,50 @@ qemuDomainAddStatsFromHashTable(GHashTable *stats, case QEMU_MONITOR_QUERY_STATS_TYPE_INSTANT: type = "cur"; break; - case QEMU_MONITOR_QUERY_STATS_TYPE_PEAK: type = "max"; break; - case QEMU_MONITOR_QUERY_STATS_TYPE_LOG2_HISTOGRAM: case QEMU_MONITOR_QUERY_STATS_TYPE_LINEAR_HISTOGRAM: + case QEMU_MONITOR_QUERY_STATS_TYPE_LOG2_HISTOGRAM: { + virHistogram *histogram; + size_t size; + size_t i; + int flag = 0; + + if (!virJSONValueIsArray(value)) + continue; + + if (data->type == QEMU_MONITOR_QUERY_STATS_TYPE_LINEAR_HISTOGRAM && + data->bucket_size == 0) + continue; + + size = virJSONValueArraySize(value); + histogram = virHistogramNew(size); + + for (i = 0; i < size; i++) { + virHistogramBucket *bucket = histogram->buckets + i; + virJSONValue *current = virJSONValueArrayGet(value, i); + + bucket->x = (data->type == QEMU_MONITOR_QUERY_STATS_TYPE_LINEAR_HISTOGRAM ? + (i + 1) * data->bucket_size : + 1LL << i); + + if (virJSONValueGetNumberLong(current, &(bucket->y)) < 0) { + flag = 1; + break; + } + } + + if (flag) { + virHistogramFree(histogram); + continue; + } + + ignore_value(virTypedParamListAddHistogram(params, histogram, "%s.%s", + prefix, key)); + } + case QEMU_MONITOR_QUERY_STATS_TYPE_LAST: default: continue; -- 2.37.1