[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 6/8] libvhost-user: check memfd API
From: |
marcandre . lureau |
Subject: |
[PATCH v2 6/8] libvhost-user: check memfd API |
Date: |
Wed, 25 Nov 2020 14:06:38 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Do not compile potentially panicking code, instead check memfd API is
present during configure time.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
subprojects/libvhost-user/libvhost-user.c | 6 ------
subprojects/libvhost-user/meson.build | 12 ++++++++++++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/subprojects/libvhost-user/libvhost-user.c
b/subprojects/libvhost-user/libvhost-user.c
index fab7ca17ee..09741a7b49 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -1616,7 +1616,6 @@ vu_inflight_queue_size(uint16_t queue_size)
sizeof(uint16_t), INFLIGHT_ALIGNMENT);
}
-#ifdef MFD_ALLOW_SEALING
static void *
memfd_alloc(const char *name, size_t size, unsigned int flags, int *fd)
{
@@ -1648,7 +1647,6 @@ memfd_alloc(const char *name, size_t size, unsigned int
flags, int *fd)
return ptr;
}
-#endif
static bool
vu_get_inflight_fd(VuDev *dev, VhostUserMsg *vmsg)
@@ -1672,13 +1670,9 @@ vu_get_inflight_fd(VuDev *dev, VhostUserMsg *vmsg)
mmap_size = vu_inflight_queue_size(queue_size) * num_queues;
-#ifdef MFD_ALLOW_SEALING
addr = memfd_alloc("vhost-inflight", mmap_size,
F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL,
&fd);
-#else
- vu_panic(dev, "Not implemented: memfd support is missing");
-#endif
if (!addr) {
vu_panic(dev, "Failed to alloc vhost inflight area");
diff --git a/subprojects/libvhost-user/meson.build
b/subprojects/libvhost-user/meson.build
index f9ecc534cf..ac228b5ba6 100644
--- a/subprojects/libvhost-user/meson.build
+++ b/subprojects/libvhost-user/meson.build
@@ -2,7 +2,19 @@ project('libvhost-user', 'c',
license: 'GPL-2.0-or-later',
default_options: ['c_std=gnu99'])
+cc = meson.get_compiler('c')
+
glib = dependency('glib-2.0')
+foreach h, syms: {
+ 'sys/mman.h': ['memfd_create', 'MFD_ALLOW_SEALING'],
+ 'sys/fcntl.h': ['F_SEAL_GROW', 'F_SEAL_SHRINK', 'F_SEAL_SEAL'] }
+ foreach sym: syms
+ cc.has_header_symbol(h, sym,
+ args: ['-D_GNU_SOURCE'],
+ required: true)
+ endforeach
+endforeach
+
inc = include_directories('../../include', '../../linux-headers')
vhost_user = static_library('vhost-user',
--
2.29.0
- [PATCH v2 0/8] libvhost-user: make it a subproject (was: "lower dependency on QEMU headers"), marcandre . lureau, 2020/11/25
- [PATCH v2 1/8] libvhost-user: replace qemu/bswap.h with glibc endian.h, marcandre . lureau, 2020/11/25
- [PATCH v2 2/8] libvhost-user: replace qemu/memfd.h usage, marcandre . lureau, 2020/11/25
- [PATCH v2 3/8] libvhost-user: remove qemu/compiler.h usage, marcandre . lureau, 2020/11/25
- [PATCH v2 4/8] libvhost-user: drop qemu/osdep.h dependency, marcandre . lureau, 2020/11/25
- [PATCH v2 5/8] libvhost-user: make it a meson subproject, marcandre . lureau, 2020/11/25
- [PATCH v2 6/8] libvhost-user: check memfd API,
marcandre . lureau <=
- [PATCH v2 7/8] libvhost-user: add a simple link test without glib, marcandre . lureau, 2020/11/25
- [PATCH v2 8/8] .gitlab-ci: add build-libvhost-user, marcandre . lureau, 2020/11/25