[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 49/66] libvhost-user: check memfd API
From: |
Michael S. Tsirkin |
Subject: |
[PULL 49/66] libvhost-user: check memfd API |
Date: |
Tue, 8 Dec 2020 14:36:40 -0500 |
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>
Message-Id: <20201125100640.366523-7-marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@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',
--
MST
- [PULL 42/66] failover: Remove primary_dev member, (continued)
- [PULL 42/66] failover: Remove primary_dev member, Michael S. Tsirkin, 2020/12/08
- [PULL 43/66] hw: add compat machines for 6.0, Michael S. Tsirkin, 2020/12/08
- [PULL 44/66] libvhost-user: replace qemu/bswap.h with glibc endian.h, Michael S. Tsirkin, 2020/12/08
- [PULL 47/66] libvhost-user: drop qemu/osdep.h dependency, Michael S. Tsirkin, 2020/12/08
- [PULL 45/66] libvhost-user: replace qemu/memfd.h usage, Michael S. Tsirkin, 2020/12/08
- [PULL 46/66] libvhost-user: remove qemu/compiler.h usage, Michael S. Tsirkin, 2020/12/08
- [PULL 48/66] libvhost-user: make it a meson subproject, Michael S. Tsirkin, 2020/12/08
- [PULL 50/66] libvhost-user: add a simple link test without glib, Michael S. Tsirkin, 2020/12/08
- [PULL 51/66] .gitlab-ci: add build-libvhost-user, Michael S. Tsirkin, 2020/12/08
- [PULL 52/66] contrib/vhost-user-blk: avoid g_return_val_if() input validation, Michael S. Tsirkin, 2020/12/08
- [PULL 49/66] libvhost-user: check memfd API,
Michael S. Tsirkin <=
- [PULL 53/66] contrib/vhost-user-gpu: avoid g_return_val_if() input validation, Michael S. Tsirkin, 2020/12/08
- [PULL 54/66] contrib/vhost-user-input: avoid g_return_val_if() input validation, Michael S. Tsirkin, 2020/12/08
- [PULL 55/66] block/export: avoid g_return_val_if() input validation, Michael S. Tsirkin, 2020/12/08
- [PULL 58/66] x86: acpi: introduce AcpiPmInfo::smi_on_cpu_unplug, Michael S. Tsirkin, 2020/12/08
- [PULL 56/66] hw/i386/pc: add max combined fw size as machine configuration option, Michael S. Tsirkin, 2020/12/08
- [PULL 59/66] tests/acpi: allow expected files change, Michael S. Tsirkin, 2020/12/08
- [PULL 62/66] x86: ich9: factor out "guest_cpu_hotplug_features", Michael S. Tsirkin, 2020/12/08
- [PULL 61/66] tests/acpi: update expected files, Michael S. Tsirkin, 2020/12/08
- [PULL 63/66] x86: ich9: let firmware negotiate 'CPU hot-unplug with SMI' feature, Michael S. Tsirkin, 2020/12/08
- [PULL 64/66] pcie_aer: Fix help message of pcie_aer_inject_error command, Michael S. Tsirkin, 2020/12/08