@@ -1,3 +1,2 @@
client
server
-check_vsock
@@ -1,4 +1,4 @@
-TARGETS=client server check_vsock
+TARGETS=client server
LDLIBS+= -lselinux
deleted file mode 100644
@@ -1,47 +0,0 @@
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-// Must be included after sys/socket.h
-#include <linux/vm_sockets.h>
-
-int main(int argc, char **argv)
-{
- int sock;
- struct sockaddr_vm svm;
-
- sock = socket(AF_VSOCK, SOCK_STREAM, 0);
- if (sock < 0) {
- if (errno == EAFNOSUPPORT) {
- // AF_VSOCK not supported
- exit(2);
- } else {
- perror("socket");
- exit(1);
- }
- }
-
- bzero(&svm, sizeof(svm));
- svm.svm_family = AF_VSOCK;
- svm.svm_port = VMADDR_PORT_ANY;
- svm.svm_cid = VMADDR_CID_LOCAL;
-
- if (bind(sock, (struct sockaddr *)&svm, sizeof(svm)) < 0) {
- if (errno == EADDRNOTAVAIL) {
- // vsock_loopback not supported
- close(sock);
- exit(3);
- } else {
- perror("bind");
- close(sock);
- exit(1);
- }
- }
-
- close(sock);
- exit(0);
-}
@@ -6,19 +6,14 @@ BEGIN {
$basedir =~ s|(.*)/[^/]*|$1|;
# check if vsock and vsock_loopback are available
- $rc = system("$basedir/check_vsock");
-
- if ( $rc eq 0 ) {
- plan tests => 12;
- }
- elsif ( $rc eq 2 << 8 ) {
+ if ( system("modprobe vsock 2>/dev/null") ne 0 ) {
plan skip_all => "vsock socket family not supported";
}
- elsif ( $rc eq 3 << 8 ) {
+ elsif ( system("modprobe vsock_loopback 2>/dev/null") ne 0 ) {
plan skip_all => "vsock_loopback transport not supported";
}
else {
- plan skip_all => "unexpected error when checking vsock support";
+ plan tests => 12;
}
}
On Fedora sysadm_t is not allowed to create vsock sockets, so the check would fail. Since modprobing the relevant kernel modules is also a reliable way to check the general vsock support, use that instead of the more direct check. Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> --- tests/vsock_socket/.gitignore | 1 - tests/vsock_socket/Makefile | 2 +- tests/vsock_socket/check_vsock.c | 47 -------------------------------- tests/vsock_socket/test | 11 ++------ 4 files changed, 4 insertions(+), 57 deletions(-) delete mode 100644 tests/vsock_socket/check_vsock.c