KVM: sefltests: Add explicit synchronization to move mem region test
authorSean Christopherson <sean.j.christopherson@intel.com>
Fri, 10 Apr 2020 23:17:02 +0000 (16:17 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 15 Apr 2020 16:08:43 +0000 (12:08 -0400)
commit8a0639fe9201ed7af73dd40fc4b6f9a4f7b16a42
tree8f01c90f708c8b8de0f46ad6d10b84549847b1f4
parent3e6b94126784fd5b0e781f2e8e980948ee945195
KVM: sefltests: Add explicit synchronization to move mem region test

Use sem_post() and sem_timedwait() to synchronize test stages between
the vCPU thread and the main thread instead of using usleep() to wait
for the vCPU thread and hoping for the best.

Opportunistically refactor the code to make it suck less in general,
and to prepare for adding more testcases.

Suggested-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20200410231707.7128-6-sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/x86_64/set_memory_region_test.c