[libvirt] [PATCH] virPerfEventIsEnabled: Accept NULL @perf

Michal Privoznik mprivozn at redhat.com
Thu May 4 14:32:50 UTC 2017

After bdcf6e481 there is a crasher in libvirt. The commit assumes
that priv->perf is always set. That is not true. For inactive
domains, the priv->perf is not allocated as it is set in
qemuProcessLaunch(). Now, usually we differentiate between
accesses to inactive and active definition and it works just
fine. Except for 'domstats'. There priv->perf is accessed without
prior check for domain inactivity. While we could check for that,
more robust solution is to make virPerfEventIsEnabled() accept

How to reproduce:
1) ensure you have at least one inactive domain
2) virsh domstats

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
 src/util/virperf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virperf.c b/src/util/virperf.c
index fa5b6cc..2c832b3 100644
--- a/src/util/virperf.c
+++ b/src/util/virperf.c
@@ -297,7 +297,7 @@ virPerfEventDisable(virPerfPtr perf,
 bool virPerfEventIsEnabled(virPerfPtr perf,
                            virPerfEventType type)
-    return perf->events[type].enabled;
+    return perf && perf->events[type].enabled;

More information about the libvir-list mailing list