[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 06/17] vfio-user: build library
From: |
Jagannathan Raman |
Subject: |
[PATCH v8 06/17] vfio-user: build library |
Date: |
Tue, 19 Apr 2022 16:44:11 -0400 |
add the libvfio-user library as a submodule. build it as a cmake
subproject.
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
configure | 20 +++++++++-
meson.build | 44 +++++++++++++++++++++-
.gitlab-ci.d/buildtest.yml | 2 +
.gitmodules | 3 ++
Kconfig.host | 4 ++
MAINTAINERS | 1 +
hw/remote/Kconfig | 4 ++
hw/remote/meson.build | 2 +
meson_options.txt | 3 ++
subprojects/libvfio-user | 1 +
tests/docker/dockerfiles/centos8.docker | 2 +
tests/docker/dockerfiles/ubuntu2004.docker | 2 +
12 files changed, 86 insertions(+), 2 deletions(-)
create mode 160000 subprojects/libvfio-user
diff --git a/configure b/configure
index 7a1a98bddf..c4fd7a42d4 100755
--- a/configure
+++ b/configure
@@ -333,6 +333,7 @@ meson_args=""
ninja=""
gio="$default_feature"
skip_meson=no
+vfio_user_server="disabled"
# The following Meson options are handled manually (still they
# are included in the automatically generated help message)
@@ -1044,6 +1045,11 @@ for opt do
;;
--disable-blobs) meson_option_parse --disable-install-blobs ""
;;
+ --enable-vfio-user-server) vfio_user_server="enabled"
+ cmake_required="yes"
+ ;;
+ --disable-vfio-user-server) vfio_user_server="disabled"
+ ;;
--enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
;;
--enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
@@ -1267,6 +1273,7 @@ cat << EOF
vhost-vdpa vhost-vdpa kernel backend support
opengl opengl support
gio libgio support
+ vfio-user-server vfio-user server support
NOTE: The object files are built at the place where configure is launched
EOF
@@ -2622,6 +2629,17 @@ but not implemented on your system"
fi
fi
+##########################################
+# check for vfio_user_server
+
+case "$vfio_user_server" in
+ auto | enabled )
+ if test "$git_submodules_action" != "ignore"; then
+ git_submodules="${git_submodules} subprojects/libvfio-user"
+ fi
+ ;;
+esac
+
##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -3185,7 +3203,7 @@ if test "$skip_meson" = no; then
-Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false;
fi) \
-Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
- -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
+ -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp
-Dvfio_user_server=$vfio_user_server \
$(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo
"-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
$(if test "$default_feature" = no; then echo
"-Dauto_features=disabled"; fi) \
"$@" $cross_arg "$PWD" "$source_path"
diff --git a/meson.build b/meson.build
index 861de93c4f..84bc3a1c4f 100644
--- a/meson.build
+++ b/meson.build
@@ -298,6 +298,11 @@ have_tpm = get_option('tpm') \
.require(targetos != 'windows', error_message: 'TPM emulation only available
on POSIX systems') \
.allowed()
+if targetos != 'linux' and get_option('vfio_user_server').enabled()
+ error('vfio-user server is supported only on Linux')
+endif
+vfio_user_server_allowed = targetos == 'linux' and not
get_option('vfio_user_server').disabled()
+
# Target-specific libraries and flags
libm = cc.find_library('m', required: false)
threads = dependency('threads')
@@ -2111,7 +2116,8 @@ host_kconfig = \
(have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
- (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : [])
+ (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \
+ (vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : [])
ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
@@ -2500,6 +2506,41 @@ if get_option('cfi') and slirp_opt == 'system'
+ ' Please configure with --enable-slirp=git')
endif
+vfiouser = not_found
+if have_system and vfio_user_server_allowed
+ have_internal = fs.exists(meson.current_source_dir() /
'subprojects/libvfio-user/Makefile')
+
+ if not have_internal
+ error('libvfio-user source not found - please pull git submodule')
+ endif
+
+ json_c = dependency('json-c', required: false)
+ if not json_c.found()
+ json_c = dependency('libjson-c', required: false)
+ endif
+ if not json_c.found()
+ json_c = dependency('libjson-c-dev', required: false)
+ endif
+
+ if not json_c.found()
+ error('Unable to find json-c package')
+ endif
+
+ cmake = import('cmake')
+
+ vfiouser_subproj = cmake.subproject('libvfio-user')
+
+ vfiouser_sl = vfiouser_subproj.dependency('vfio-user-static')
+
+ # Although cmake links the json-c library with vfio-user-static
+ # target, that info is not available to meson via cmake.subproject.
+ # As such, we have to separately declare the json-c dependency here.
+ # This appears to be a current limitation of using cmake inside meson.
+ # libvfio-user is planning a switch to meson in the future, which
+ # would address this item automatically.
+ vfiouser = declare_dependency(dependencies: [vfiouser_sl, json_c])
+endif
+
fdt = not_found
if have_system
fdt_opt = get_option('fdt')
@@ -3612,6 +3653,7 @@ summary_info += {'target list': '
'.join(target_dirs)}
if have_system
summary_info += {'default devices': get_option('default_devices')}
summary_info += {'out of process emulation': multiprocess_allowed}
+ summary_info += {'vfio-user server': vfio_user_server_allowed}
endif
summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index 0aea7ab84c..671a5d8fa4 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -42,6 +42,7 @@ build-system-ubuntu:
variables:
IMAGE: ubuntu2004
CONFIGURE_ARGS: --enable-docs --enable-fdt=system --enable-slirp=system
+ --enable-vfio-user-server
TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
microblazeel-softmmu mips64el-softmmu
MAKE_CHECK_ARGS: check-build
@@ -165,6 +166,7 @@ build-system-centos:
IMAGE: centos8
CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-fdt=system
--enable-modules --enable-trace-backends=dtrace --enable-docs
+ --enable-vfio-user-server
TARGETS: ppc64-softmmu or1k-softmmu s390x-softmmu
x86_64-softmmu rx-softmmu sh4-softmmu nios2-softmmu
MAKE_CHECK_ARGS: check-build
diff --git a/.gitmodules b/.gitmodules
index f4b6a9b401..d66af96dc9 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -67,3 +67,6 @@
[submodule "tests/lcitool/libvirt-ci"]
path = tests/lcitool/libvirt-ci
url = https://gitlab.com/libvirt/libvirt-ci.git
+[submodule "subprojects/libvfio-user"]
+ path = subprojects/libvfio-user
+ url = https://github.com/nutanix/libvfio-user.git
diff --git a/Kconfig.host b/Kconfig.host
index 60b9c07b5e..f2da8bcf8a 100644
--- a/Kconfig.host
+++ b/Kconfig.host
@@ -45,3 +45,7 @@ config MULTIPROCESS_ALLOWED
config FUZZ
bool
select SPARSE_MEM
+
+config VFIO_USER_SERVER_ALLOWED
+ bool
+ imply VFIO_USER_SERVER
diff --git a/MAINTAINERS b/MAINTAINERS
index 4ad2451e03..dca81a2d22 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3597,6 +3597,7 @@ F: hw/remote/proxy-memory-listener.c
F: include/hw/remote/proxy-memory-listener.h
F: hw/remote/iohub.c
F: include/hw/remote/iohub.h
+F: subprojects/libvfio-user
EBPF:
M: Jason Wang <jasowang@redhat.com>
diff --git a/hw/remote/Kconfig b/hw/remote/Kconfig
index 08c16e235f..2d6b4f4cf4 100644
--- a/hw/remote/Kconfig
+++ b/hw/remote/Kconfig
@@ -2,3 +2,7 @@ config MULTIPROCESS
bool
depends on PCI && PCI_EXPRESS && KVM
select REMOTE_PCIHOST
+
+config VFIO_USER_SERVER
+ bool
+ depends on MULTIPROCESS
diff --git a/hw/remote/meson.build b/hw/remote/meson.build
index e6a5574242..dfea6b533b 100644
--- a/hw/remote/meson.build
+++ b/hw/remote/meson.build
@@ -7,6 +7,8 @@ remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true:
files('remote-obj.c'))
remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('proxy.c'))
remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('iohub.c'))
+remote_ss.add(when: 'CONFIG_VFIO_USER_SERVER', if_true: vfiouser)
+
specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('memory.c'))
specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true:
files('proxy-memory-listener.c'))
diff --git a/meson_options.txt b/meson_options.txt
index 52b11cead4..bd531fd545 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -91,6 +91,9 @@ option('avx2', type: 'feature', value: 'auto',
option('avx512f', type: 'feature', value: 'disabled',
description: 'AVX512F optimizations')
+option('vfio_user_server', type: 'feature', value: 'auto',
+ description: 'vfio-user server support')
+
option('attr', type : 'feature', value : 'auto',
description: 'attr/xattr support')
option('auth_pam', type : 'feature', value : 'auto',
diff --git a/subprojects/libvfio-user b/subprojects/libvfio-user
new file mode 160000
index 0000000000..030d2f6e79
--- /dev/null
+++ b/subprojects/libvfio-user
@@ -0,0 +1 @@
+Subproject commit 030d2f6e7978b8ca7577b81d4f48e2771bcd8f47
diff --git a/tests/docker/dockerfiles/centos8.docker
b/tests/docker/dockerfiles/centos8.docker
index 3ede55d09b..b6b4aa9626 100644
--- a/tests/docker/dockerfiles/centos8.docker
+++ b/tests/docker/dockerfiles/centos8.docker
@@ -23,6 +23,7 @@ RUN dnf update -y && \
capstone-devel \
ccache \
clang \
+ cmake \
ctags \
cyrus-sasl-devel \
daxctl-devel \
@@ -45,6 +46,7 @@ RUN dnf update -y && \
gtk3-devel \
hostname \
jemalloc-devel \
+ json-c-devel \
libaio-devel \
libasan \
libattr-devel \
diff --git a/tests/docker/dockerfiles/ubuntu2004.docker
b/tests/docker/dockerfiles/ubuntu2004.docker
index b9d06cb040..2422cc5574 100644
--- a/tests/docker/dockerfiles/ubuntu2004.docker
+++ b/tests/docker/dockerfiles/ubuntu2004.docker
@@ -18,6 +18,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
ca-certificates \
ccache \
clang \
+ cmake \
dbus \
debianutils \
diffutils \
@@ -58,6 +59,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
libiscsi-dev \
libjemalloc-dev \
libjpeg-turbo8-dev \
+ libjson-c-dev \
liblttng-ust-dev \
liblzo2-dev \
libncursesw5-dev \
--
2.20.1
- Re: [PATCH v8 10/17] vfio-user: run vfio-user context, (continued)
[PATCH v8 13/17] vfio-user: handle DMA mappings, Jagannathan Raman, 2022/04/19
[PATCH v8 14/17] vfio-user: handle PCI BAR accesses, Jagannathan Raman, 2022/04/19
[PATCH v8 15/17] vfio-user: handle device interrupts, Jagannathan Raman, 2022/04/19
[PATCH v8 16/17] vfio-user: handle reset of remote device, Jagannathan Raman, 2022/04/19
[PATCH v8 17/17] vfio-user: avocado tests for vfio-user, Jagannathan Raman, 2022/04/19
[PATCH v8 11/17] vfio-user: handle PCI config space accesses, Jagannathan Raman, 2022/04/19
[PATCH v8 08/17] vfio-user: instantiate vfio-user context, Jagannathan Raman, 2022/04/19
[PATCH v8 05/17] configure: require cmake 3.19 or newer, Jagannathan Raman, 2022/04/19
[PATCH v8 06/17] vfio-user: build library,
Jagannathan Raman <=
[PATCH v8 02/17] qdev: unplug blocker for devices, Jagannathan Raman, 2022/04/19
[PATCH v8 07/17] vfio-user: define vfio-user-server object, Jagannathan Raman, 2022/04/19
[PATCH v8 03/17] remote/machine: add HotplugHandler for remote machine, Jagannathan Raman, 2022/04/19
[PATCH v8 01/17] tests/avocado: Specify target VM argument to helper routines, Jagannathan Raman, 2022/04/19