kvm: selftest: add dirty logging test
authorPeter Xu <peterx@redhat.com>
Wed, 22 Aug 2018 07:20:00 +0000 (15:20 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 22 Aug 2018 14:48:39 +0000 (16:48 +0200)
commit3b4cd0ff5407c14900bcda7ea4aeb43a65620deb
tree5d7368ac31741a2c026ba5e17cea582630795507
parentaee41be5933fdd1cd6fbd80b31954585e3520d98
kvm: selftest: add dirty logging test

Test KVM dirty logging functionality.

The test creates a standalone memory slot to test tracking the dirty
pages since we can't really write to the default memory slot which still
contains the guest ELF image.

We have two threads running during the test:

(1) the vcpu thread continuously dirties random guest pages by writting
    a iteration number to the first 8 bytes of the page

(2) the host thread continuously fetches dirty logs for the testing
    memory region and verify each single bit of the dirty bitmap by
    checking against the values written onto the page

Note that since the guest cannot calls the general userspace APIs like
random(), it depends on the host to provide random numbers for the
page indexes to dirty.

Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/dirty_log_test.c [new file with mode: 0644]
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/lib/kvm_util.c