[Libguestfs] [PATCH nbdkit] tests: Skip vsock tests unless the vsock_loopback module is loaded

Richard W.M. Jones rjones at redhat.com
Fri Apr 1 10:46:24 UTC 2022


It's unfortunate that vsock in Linux can be broken if some but not all
vsock modules needed are loaded.  As we are testing loopback
(VMADDR_CID_LOCAL), require that vsock_loopback is loaded.

Linux is able to autoload the correct module(s) if vsock.ko is _not_
loaded.  We could in theory enhance the test to check this, but that
leaves us with uncertainty about whether the test could work (eg. Is
vsock available as a module in this kernel?  Is this even Linux?)

Reported-by: Ming Xie
Thanks: Stefano Garzarella
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2069558
---
 tests/functions.sh.in | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 6d41f683..7877c84d 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -240,11 +240,13 @@ requires_non_root ()
 }
 
 # Tests that use the vsock interface will fail if vsock is not
-# supported.  On Linux you have to load the kernel modules: vsockmon
-# and vsock_loopback.
+# supported.  On Linux you have to load the kernel module
+# vsock_loopback.  See also
+# https://bugzilla.redhat.com/show_bug.cgi?id=2069558
 requires_vsock_support ()
 {
-    if ! grep -q ^AF_VSOCK /proc/net/protocols; then
+    if ! grep -q ^AF_VSOCK /proc/net/protocols ||
+       ! lsmod | grep ^vsock_loopback; then
         echo "$0: test skipped because AF_VSOCK is not supported."
         exit 77
     fi
-- 
2.35.1



More information about the Libguestfs mailing list