Currently when virDomainListGetStats is called, the stats for those disabled perf events won't be showed in result. This will produce some problems for applications based on libvirt sometime, e.g. the OpenStack bug https://bugs.launchpad.net/ceilometer/+bug/1670948 This patch just show '0' in result for disabled events for virDomainListGetStats API. I guess this should be also rational to show all stats even though the events are not enabled. Signed-off-by: Qiaowei Ren <qiaowei.ren@xxxxxxxxx> --- src/qemu/qemu_driver.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2032fac..237bf57 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19355,8 +19355,10 @@ qemuDomainGetStatsPerfOneEvent(virPerfPtr perf, char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; uint64_t value = 0; - if (virPerfReadEvent(perf, type, &value) < 0) - return -1; + if (virPerfEventIsEnabled(perf, type)) { + if (virPerfReadEvent(perf, type, &value) < 0) + return -1; + } snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "perf.%s", virPerfEventTypeToString(type)); @@ -19383,9 +19385,6 @@ qemuDomainGetStatsPerf(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, int ret = -1; for (i = 0; i < VIR_PERF_EVENT_LAST; i++) { - if (!virPerfEventIsEnabled(priv->perf, i)) - continue; - if (qemuDomainGetStatsPerfOneEvent(priv->perf, i, record, maxparams) < 0) goto cleanup; -- 1.9.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list