Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit b1d7161

Browse files
committed
optionally build with vsock support
If we cannot find /usr/include/linux/vm_sockets.h locally, do not build with vsock support. Signed-off-by: Peng Tao <bergwolf@gmail.com>
1 parent d27d5ba commit b1d7161

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

configure.ac

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ AC_SUBST(SYSTEMD_SYSTEMUNIT)
7474
AM_CONDITIONAL(SYSTEMD, test "x${SYSTEMD_SYSTEMUNIT}" != "xno" )
7575

7676
AC_CHECK_FILE([/usr/include/linux/vm_sockets.h],
77-
[], [AC_MSG_ERROR(Cannot find linux/vm_sockets.h)])
77+
[have_vsock=yes], [have_vsock=no])
78+
if test "x$have_vsock" == "xyes"; then
79+
AC_DEFINE_UNQUOTED([HAVE_VSOCK], 1, [enable vm socket support])
80+
fi
81+
AM_CONDITIONAL([HAVE_VSOCK], [test "x$have_vsock" == "xyes"])
7882

7983
AC_CONFIG_FILES([
8084
Makefile
@@ -91,6 +95,8 @@ AC_MSG_RESULT([
9195
with-vbox: ${with_vbox}
9296
with-aarch64: ${with_aarch64}
9397
98+
vsock-support: ${have_vsock}
99+
94100
compiler: ${CC}
95101
cflags: ${CFLAGS}
96102
suid cflags: ${SUID_CFLAGS}

src/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
AM_CFLAGS = -Wall -Werror
22
bin_PROGRAMS=hyperstart
3-
hyperstart_SOURCES=init.c jsmn.c net.c util.c parse.c parson.c container.c exec.c event.c portmapping.c vsock.c
3+
hyperstart_SOURCES=init.c jsmn.c net.c util.c parse.c parson.c container.c exec.c event.c portmapping.c
4+
if HAVE_VSOCK
5+
hyperstart_SOURCES+=vsock.c
6+
endif

src/vsock.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22
#define _VSOCK_H_
33

44
#include "event.h"
5+
#include "../config.h"
56

7+
#ifdef HAVE_VSOCK
68
int probe_vsock_device(void);
79
int hyper_create_vsock_listener(unsigned short port);
810
int hyper_vsock_accept(struct hyper_event *he, int efd,
911
struct hyper_event *ne, struct hyper_event_ops *ops);
12+
#else /*HAVE_VSOCK*/
13+
static int probe_vsock_device(void)
14+
{
15+
return -1;
16+
}
17+
static int hyper_create_vsock_listener(unsigned short port)
18+
{
19+
return -1;
20+
}
21+
static int hyper_vsock_accept(struct hyper_event *he, int efd,
22+
struct hyper_event *ne, struct hyper_event_ops *ops)
23+
{
24+
return -1;
25+
}
26+
27+
#endif /*HAVE_VSOCK*/
1028

1129
#endif

0 commit comments

Comments
 (0)