summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmilio G. Cota <cota@braap.org>2016-07-22 12:36:30 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2016-08-02 12:03:58 +0200
commit7266ae91a111001abda65c79299c9b7e365456b6 (patch)
tree9bbd8547070f5f5429a081f539ea85ddb5dcb38b /tests
parent767db021bc45affa7a7c20ea21730d2867a0c37f (diff)
downloadqemu-7266ae91a111001abda65c79299c9b7e365456b6.zip
qht: do not segfault when gathering stats from an uninitialized qht
So far, QHT functions assume that the passed qht has previously been initialized--otherwise they segfault. This patch makes an exception for qht_statistics_init, with the goal of simplifying calling code. For instance, qht_statistics_init is called from the 'info jit' dump, and given that under KVM the TB qht is never initialized, we get a segfault. Thus, instead of complicating the 'info jit' code with additional checks, let's allow passing an uninitialized qht to qht_statistics_init. While at it, add a test for this to test-qht. Before the patch (for $ qemu -enable-kvm [...]): (qemu) info jit [...] direct jump count 0 (0%) (2 jumps=0 0%) Program received signal SIGSEGV, Segmentation fault. After the patch the "TB hash buckets", "TB hash occupancy" and "TB hash avg chain" lines are omitted. (qemu) info jit [...] direct jump count 0 (0%) (2 jumps=0 0%) TB hash buckets 0/0 (-nan% head buckets used) TB hash occupancy nan% avg chain occ. Histogram: (null) TB hash avg chain nan buckets. Histogram: (null) [...] Reported by: Changlong Xie <xiecl.fnst@cn.fujitsu.com> Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <1469205390-14369-1-git-send-email-cota@braap.org> [Extract printing statistics to an entirely separate function. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-qht.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/test-qht.c b/tests/test-qht.c
index f1d628371d..46a64b6731 100644
--- a/tests/test-qht.c
+++ b/tests/test-qht.c
@@ -95,8 +95,12 @@ static void iter_check(unsigned int count)
static void qht_do_test(unsigned int mode, size_t init_entries)
{
+ /* under KVM we might fetch stats from an uninitialized qht */
+ check_n(0);
+
qht_init(&ht, 0, mode);
+ check_n(0);
insert(0, N);
check(0, N, true);
check_n(N);