]> 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)
commitf2c3e32065e16f84f23a7c05a87ba8f0212bb0a0
treeb7b20b56f97bc95c9199992a07314da02e335b7e
parentfb1cd0f7d9a09a2da727c150aa71b32ee91d34c5
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