Skip to content

Commit 0df750e

Browse files
elmarcomstsirkin
authored andcommitted
libvhost-user: make it a meson subproject
By making libvhost-user a subproject, check it builds standalone (without the global QEMU cflags etc). Note that the library still relies on QEMU include/qemu/atomic.h and linux_headers/. Signed-off-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 3d22bd2 commit 0df750e

21 files changed

+40
-27
lines changed

block/export/vhost-user-blk-server.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
#include "qemu/osdep.h"
1313
#include "block/block.h"
14-
#include "contrib/libvhost-user/libvhost-user.h"
14+
#include "subprojects/libvhost-user/libvhost-user.h" /* only for the type definitions */
1515
#include "standard-headers/linux/virtio_blk.h"
1616
#include "qemu/vhost-user-server.h"
1717
#include "vhost-user-blk-server.h"

contrib/libvhost-user/meson.build

-4
This file was deleted.

contrib/vhost-user-blk/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# FIXME: broken on 32-bit architectures
22
executable('vhost-user-blk', files('vhost-user-blk.c'),
3-
link_with: libvhost_user,
4-
dependencies: qemuutil,
3+
dependencies: [qemuutil, vhost_user],
54
build_by_default: false,
65
install: false)

contrib/vhost-user-blk/vhost-user-blk.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
#include "qemu/osdep.h"
1919
#include "standard-headers/linux/virtio_blk.h"
20-
#include "contrib/libvhost-user/libvhost-user-glib.h"
21-
#include "contrib/libvhost-user/libvhost-user.h"
20+
#include "libvhost-user-glib.h"
2221

2322
#if defined(__linux__)
2423
#include <linux/fs.h>

contrib/vhost-user-gpu/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ if 'CONFIG_TOOLS' in config_host and 'CONFIG_VIRGL' in config_host \
22
and 'CONFIG_GBM' in config_host and 'CONFIG_LINUX' in config_host \
33
and pixman.found()
44
executable('vhost-user-gpu', files('vhost-user-gpu.c', 'virgl.c', 'vugbm.c'),
5-
link_with: libvhost_user,
6-
dependencies: [qemuutil, pixman, gbm, virgl],
5+
dependencies: [qemuutil, pixman, gbm, virgl, vhost_user],
76
install: true,
87
install_dir: get_option('libexecdir'))
98

contrib/vhost-user-gpu/vugpu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "qemu/osdep.h"
1919

20-
#include "contrib/libvhost-user/libvhost-user-glib.h"
20+
#include "libvhost-user-glib.h"
2121
#include "standard-headers/linux/virtio_gpu.h"
2222

2323
#include "qemu/queue.h"

contrib/vhost-user-input/main.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include "qemu/iov.h"
1313
#include "qemu/bswap.h"
1414
#include "qemu/sockets.h"
15-
#include "contrib/libvhost-user/libvhost-user.h"
16-
#include "contrib/libvhost-user/libvhost-user-glib.h"
15+
#include "libvhost-user-glib.h"
1716
#include "standard-headers/linux/virtio_input.h"
1817
#include "qapi/error.h"
1918

contrib/vhost-user-input/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
executable('vhost-user-input', files('main.c'),
2-
link_with: libvhost_user,
3-
dependencies: qemuutil,
2+
dependencies: [qemuutil, vhost_user],
43
build_by_default: targetos == 'linux',
54
install: false)

contrib/vhost-user-scsi/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
if 'CONFIG_LIBISCSI' in config_host
22
executable('vhost-user-scsi', files('vhost-user-scsi.c'),
3-
link_with: libvhost_user,
4-
dependencies: [qemuutil, libiscsi],
3+
dependencies: [qemuutil, libiscsi, vhost_user],
54
build_by_default: targetos == 'linux',
65
install: false)
76
endif

contrib/vhost-user-scsi/vhost-user-scsi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define inline __attribute__((gnu_inline)) /* required for libiscsi v1.9.0 */
1616
#include <iscsi/scsi-lowlevel.h>
1717
#undef inline
18-
#include "contrib/libvhost-user/libvhost-user-glib.h"
18+
#include "libvhost-user-glib.h"
1919
#include "standard-headers/linux/virtio_scsi.h"
2020

2121

include/qemu/vhost-user-server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef VHOST_USER_SERVER_H
1212
#define VHOST_USER_SERVER_H
1313

14-
#include "contrib/libvhost-user/libvhost-user.h"
14+
#include "subprojects/libvhost-user/libvhost-user.h" /* only for the type definitions */
1515
#include "io/channel-socket.h"
1616
#include "io/channel-file.h"
1717
#include "io/net-listener.h"

meson.build

+6-1
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,12 @@ trace_events_subdirs += [
14751475
'util',
14761476
]
14771477

1478-
subdir('contrib/libvhost-user')
1478+
vhost_user = not_found
1479+
if 'CONFIG_VHOST_USER' in config_host
1480+
libvhost_user = subproject('libvhost-user')
1481+
vhost_user = libvhost_user.get_variable('vhost_user_dep')
1482+
endif
1483+
14791484
subdir('qapi')
14801485
subdir('qobject')
14811486
subdir('stubs')

subprojects/libvhost-user/meson.build

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
project('libvhost-user', 'c',
2+
license: 'GPL-2.0-or-later',
3+
default_options: ['c_std=gnu99'])
4+
5+
glib = dependency('glib-2.0')
6+
inc = include_directories('../../include', '../../linux-headers')
7+
8+
vhost_user = static_library('vhost-user',
9+
files('libvhost-user.c'),
10+
include_directories: inc,
11+
c_args: '-D_GNU_SOURCE')
12+
13+
vhost_user_glib = static_library('vhost-user-glib',
14+
files('libvhost-user-glib.c'),
15+
include_directories: inc,
16+
link_with: vhost_user,
17+
dependencies: glib)
18+
19+
vhost_user_dep = declare_dependency(link_with: vhost_user_glib,
20+
include_directories: include_directories('.'))

tests/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ endforeach
264264
if have_tools and 'CONFIG_VHOST_USER' in config_host and 'CONFIG_LINUX' in config_host
265265
executable('vhost-user-bridge',
266266
sources: files('vhost-user-bridge.c'),
267-
link_with: [libvhost_user],
268-
dependencies: [qemuutil])
267+
dependencies: [qemuutil, vhost_user])
269268
endif
270269

271270
if have_system and 'CONFIG_POSIX' in config_host

tests/vhost-user-bridge.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "qemu/ctype.h"
3535
#include "qemu/iov.h"
3636
#include "standard-headers/linux/virtio_net.h"
37-
#include "contrib/libvhost-user/libvhost-user.h"
37+
#include "libvhost-user.h"
3838

3939
#define VHOST_USER_BRIDGE_DEBUG 1
4040

tools/virtiofsd/fuse_virtio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <grp.h>
3636
#include <unistd.h>
3737

38-
#include "contrib/libvhost-user/libvhost-user.h"
38+
#include "libvhost-user.h"
3939

4040
struct fv_VuDev;
4141
struct fv_QueueInfo {

tools/virtiofsd/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ executable('virtiofsd', files(
88
'helper.c',
99
'passthrough_ll.c',
1010
'passthrough_seccomp.c'),
11-
link_with: libvhost_user,
12-
dependencies: [seccomp, qemuutil, libcap_ng],
11+
dependencies: [seccomp, qemuutil, libcap_ng, vhost_user],
1312
install: true,
1413
install_dir: get_option('libexecdir'))
1514

0 commit comments

Comments
 (0)