]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virPerfEventIsEnabled: Accept NULL @perf
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 4 May 2017 14:27:45 +0000 (16:27 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 4 May 2017 14:42:25 +0000 (16:42 +0200)
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
NULL.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
src/util/virperf.c

index fa5b6cca64977dfa3a69616bab26da1bd3c3eb66..2c832b34eb116e551d10d1c019092db077f8c377 100644 (file)
@@ -297,7 +297,7 @@ virPerfEventDisable(virPerfPtr perf,
 bool virPerfEventIsEnabled(virPerfPtr perf,
                            virPerfEventType type)
 {
-    return perf->events[type].enabled;
+    return perf && perf->events[type].enabled;
 }
 
 int