Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3df33a0f authored by Stefan Raspl's avatar Stefan Raspl Committed by Paolo Bonzini
Browse files

tools/kvm_stat: fix crash when filtering out all non-child trace events



When we apply a filter that will only leave child trace events, we
receive a ZeroDivisionError when calculating the percentages.
In that case, provide percentages based on child events only.
To reproduce, run 'kvm_stat -f .*[\(].*'.

Signed-off-by: default avatarStefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 369d5a85
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1084,9 +1084,15 @@ class Tui(object):
        self.screen.clrtobot()
        stats = self.stats.get(self._display_guests)
        total = 0.
        ctotal = 0.
        for key, values in stats.items():
            if key.find('(') == -1:
                total += values.value
            else:
                ctotal += values.value
        if total == 0.:
            # we don't have any fields, or all non-child events are filtered
            total = ctotal

        if self._sorting == SORT_DEFAULT:
            def sortkey((_k, v)):