]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: selftests: Fix hang in hardware_disable_test
authorDavid Matlack <dmatlack@google.com>
Fri, 14 May 2021 23:05:21 +0000 (23:05 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 27 May 2021 11:45:55 +0000 (07:45 -0400)
commit86a34dd08df882552409aedbb0c90a61d81f35d9
treeb7b20b56f97bc95c9199992a07314da02e335b7e
parentae1b3a495724b06e15ff7c291b2dfa981c913f1f
KVM: selftests: Fix hang in hardware_disable_test

If /dev/kvm is not available then hardware_disable_test will hang
indefinitely because the child process exits before posting to the
semaphore for which the parent is waiting.

Fix this by making the parent periodically check if the child has
exited. We have to be careful to forward the child's exit status to
preserve a KSFT_SKIP status.

I considered just checking for /dev/kvm before creating the child
process, but there are so many other reasons why the child could exit
early that it seemed better to handle that as general case.

Tested:

$ ./hardware_disable_test
/dev/kvm not available, skipping test
$ echo $?
4
$ modprobe kvm_intel
$ ./hardware_disable_test
$ echo $?
0

Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20210514230521.2608768-1-dmatlack@google.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/hardware_disable_test.c