Fix QEMU compilation on Debian 10
PATCH 3/3 Update linux headers to v6.3rc5
In reply to David 'Digit' Turnercommit 7e364e56293bb98cae1b55fd835f5991c4e96e7d
--- include/standard-headers/drm/drm_fourcc.h | 12 ++ include/standard-headers/linux/ethtool.h | 48 +++++++- include/standard-headers/linux/fuse.h | 45 +++++++- include/standard-headers/linux/pci_regs.h | 1 + include/standard-headers/linux/vhost_types.h | 2 + include/standard-headers/linux/virtio_blk.h | 105 +++++++++++++++++ linux-headers/asm-arm64/kvm.h | 1 + linux-headers/asm-x86/kvm.h | 34 +++++- linux-headers/linux/const.h | 36 ++++++ linux-headers/linux/kvm.h | 9 ++ linux-headers/linux/memfd.h | 39 +++++++ linux-headers/linux/nvme_ioctl.h | 114 +++++++++++++++++++ linux-headers/linux/vfio.h | 15 ++- linux-headers/linux/vhost.h | 8 ++ 14 files changed, 459 insertions(+), 10 deletions(-) create mode 100644 linux-headers/linux/const.h create mode 100644 linux-headers/linux/memfd.h create mode 100644 linux-headers/linux/nvme_ioctl.h
include/standard-headers/drm/drm_fourcc.h +12 -0
@@ -87,6 +87,18 @@ extern "C" {* * The authoritative list of format modifier codes is found in * `include/uapi/drm/drm_fourcc.h` +* +* Open Source User Waiver +* ----------------------- +* +* Because this is the authoritative source for pixel formats and modifiers +* referenced by GL, Vulkan extensions and other standards and hence used both +* by open source and closed source driver stacks, the usual requirement for an +* upstream in-kernel or open source userspace user does not apply. +* +* To ensure, as much as feasible, compatibility across stacks and avoid +* confusion with incompatible enumerations stakeholders for all relevant driver +* stacks should approve additions. */ #define fourcc_code (a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
include/standard-headers/linux/ethtool.h +47 -1
72 lines not on this page · raw message
include/standard-headers/linux/fuse.h +44 -1
79 lines not on this page · raw message
include/standard-headers/linux/pci_regs.h +1 -0
@@ -693,6 +693,7 @@#define PCI_EXP_LNKCTL2_TX_MARGIN 0x0380/* Transmit Margin */ #define PCI_EXP_LNKCTL2_HASD 0x0020/* HW Autonomous Speed Disable */ #define PCI_EXP_LNKSTA2 0x32/* Link Status 2 */ +#define PCI_EXP_LNKSTA2_FLIT 0x0400/* Flit Mode Status */ #define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 0x32/* end of v2 EPs w/ link */ #define PCI_EXP_SLTCAP2 0x34/* Slot Capabilities 2 */ #define PCI_EXP_SLTCAP2_IBPD 0x00000001/* In-band PD Disable Supported */
include/standard-headers/linux/vhost_types.h +2 -0
@@ -163,5 +163,7 @@ struct vhost_vdpa_iova_range {#define VHOST_BACKEND_F_IOTLB_ASID 0x3/* Device can be suspended */ #define VHOST_BACKEND_F_SUSPEND 0x4 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME 0x5#endif
include/standard-headers/linux/virtio_blk.h +105 -0
133 lines not on this page · raw message
linux-headers/asm-arm64/kvm.h +1 -0
@@ -109,6 +109,7 @@ struct kvm_regs {#define KVM_ARM_VCPU_SVE 4/* enable SVE for this CPU */ #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5/* VCPU uses address authentication */ #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6/* VCPU uses generic authentication */ +#define KVM_ARM_VCPU_HAS_EL2 7/* Support nested virtualization */ struct kvm_vcpu_init {__u32 target;
linux-headers/asm-x86/kvm.h +32 -2
@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/ioctl.h> +#include <linux/stddef.h> #define KVM_PIO_PAGE_OFFSET 1#define KVM_COALESCED_MMIO_PAGE_OFFSET 2
@@ -505,8 +506,8 @@ struct kvm_nested_state {* KVM_{GET,PUT}_NESTED_STATE ioctl values. */ union { -struct kvm_vmx_nested_state_data vmx[0 ]; -struct kvm_svm_nested_state_data svm[0 ]; + __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx); + __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm); } data; };
@@ -523,6 +524,35 @@ struct kvm_pmu_event_filter {#define KVM_PMU_EVENT_ALLOW 0#define KVM_PMU_EVENT_DENY 1 +#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0) +#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS) + +/* +* Masked event layout. +* Bits Description +* ---- ----------- +* 7:0 event select (low bits) +* 15:8 umask match +* 31:16 unused +* 35:32 event select (high bits) +* 36:54 unused +* 55 exclude bit +* 63:56 umask mask +*/ + +#define KVM_PMU_ENCODE_MASKED_ENTRY (event_select, mask, match, exclude) \ + (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | \ + (((mask) & 0xFFULL) << 56) | \ + (((match) & 0xFFULL) << 8) | \ + ((__u64)(!!(exclude)) << 55)) + +#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT \ + (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8)) +#define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56) +/* for KVM_{GET,SET,HAS}_DEVICE_ATTR */ #define KVM_VCPU_TSC_CTRL 0/* control group for the timestamp counter (TSC) */ #define KVM_VCPU_TSC_OFFSET 0/* attribute for the TSC offset */
linux-headers/linux/const.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* const.h: Macros for dealing with constants. */ + +#ifndef _LINUX_CONST_H +#define _LINUX_CONST_H + +/* Some constant macros are used in both assembler and +* C code. Therefore we cannot annotate them always with +* 'UL' and other type specifiers unilaterally. We +* use the following macros to deal with this. +* +* Similarly, _AT() will cast an expression with a type in C, but +* leave it unchanged in asm. +*/ + +#ifdef __ASSEMBLY__ +#define _AC (X ,Y ) X +#define _AT (T ,X ) X +#else +#define __AC (X ,Y ) (X##Y) +#define _AC (X ,Y ) __AC(X,Y) +#define _AT (T ,X ) ((T)(X)) +#endif + +#define _UL (x) (_AC(x, UL)) +#define _ULL (x) (_AC(x, ULL)) + +#define _BITUL (x) (_UL(1) << (x)) +#define _BITULL (x) (_ULL(1) << (x)) + +#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask)) + +#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) + +#endif /* _LINUX_CONST_H */
linux-headers/linux/kvm.h +9 -0
@@ -581,6 +581,8 @@ struct kvm_s390_mem_op {struct {__u8 ar;/* the access register number */ __u8 key;/* access key, ignored if flag unset */ +__u8 pad1[6 ];/* ignored */ +__u64 old_addr;/* ignored if cmpxchg flag unset */ };__u32 sida_offset;/* offset into the sida */ __u8 reserved[32 ];/* ignored */
@@ -593,11 +595,17 @@ struct kvm_s390_mem_op {#define KVM_S390_MEMOP_SIDA_WRITE 3#define KVM_S390_MEMOP_ABSOLUTE_READ 4#define KVM_S390_MEMOP_ABSOLUTE_WRITE 5 +#define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6 +/* flags for kvm_s390_mem_op->flags */ #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)#define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)#define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2) +/* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */ +#define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0) +#define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1) +/* for KVM_INTERRUPT */ struct kvm_interrupt {/* in */
@@ -1173,6 +1181,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 +#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226#ifdef KVM_CAP_IRQ_ROUTING
linux-headers/linux/memfd.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_MEMFD_H +#define _LINUX_MEMFD_H + +#include <asm-generic/hugetlb_encode.h> + +/* flags for memfd_create(2) (unsigned int) */ +#define MFD_CLOEXEC 0x0001U +#define MFD_ALLOW_SEALING 0x0002U +#define MFD_HUGETLB 0x0004U +/* not executable and sealed to prevent changing to executable. */ +#define MFD_NOEXEC_SEAL 0x0008U +/* executable */ +#define MFD_EXEC 0x0010U + +/* +* Huge page size encoding when MFD_HUGETLB is specified, and a huge page +* size other than the default is desired. See hugetlb_encode.h. +* All known huge page size encodings are provided here. It is the +* responsibility of the application to know which sizes are supported on +* the running system. See mmap(2) man page for details. +*/ +#define MFD_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT +#define MFD_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK + +#define MFD_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB +#define MFD_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB +#define MFD_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB +#define MFD_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB +#define MFD_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB +#define MFD_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB +#define MFD_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB +#define MFD_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB +#define MFD_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB +#define MFD_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB +#define MFD_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB +#define MFD_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB + +#endif /* _LINUX_MEMFD_H */
linux-headers/linux/nvme_ioctl.h new file +114 -0
114 lines not on this page · raw message
linux-headers/linux/vfio.h +9 -6
@@ -49,7 +49,11 @@/* Supports VFIO_DMA_UNMAP_FLAG_ALL */ #define VFIO_UNMAP_ALL 9 -/* Supports the vaddr flag for DMA map and unmap */ +/* +* Supports the vaddr flag for DMA map and unmap. Not supported for mediated +* devices, so this capability is subject to change as groups are added or +* removed. +*/ #define VFIO_UPDATE_VADDR 10/*
@@ -1343,8 +1347,7 @@ struct vfio_iommu_type1_info_dma_avail {* Map process virtual addresses to IO virtual addresses using the * provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required. * -* If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova, and -* unblock translation of host virtual addresses in the iova range. The vaddr +* If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova. The vaddr * must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR. To * maintain memory consistency within the user application, the updated vaddr * must address the same memory object as originally mapped. Failure to do so
@@ -1395,9 +1398,9 @@ struct vfio_bitmap {* must be 0. This cannot be combined with the get-dirty-bitmap flag. * * If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host -* virtual addresses in the iova range. Tasks that attempt to translate an -* iova's vaddr will block. DMA to already-mapped pages continues. This -* cannot be combined with the get-dirty-bitmap flag. +* virtual addresses in the iova range. DMA to already-mapped pages continues. +* Groups may not be added to the container while any addresses are invalid. +* This cannot be combined with the get-dirty-bitmap flag. */ struct vfio_iommu_type1_dma_unmap {__u32 argsz;
linux-headers/linux/vhost.h +8 -0
@@ -180,4 +180,12 @@*/ #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) +/* Resume a device so it can resume processing virtqueue requests +* +* After the return of this ioctl the device will have restored all the +* necessary states and it is fully operational to continue processing the +* virtqueue descriptors. +*/ +#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) +#endif
Signature · 1 line
2.40.0.348.gf938b09366-goog
PATCH v2 1/1 Fix QEMU compilation on Debian 10
QEMU does not compile on an old Debian 10 system for the following reasons:
- Several sources include recent kernel headers that are not provided by this system, and not listed in linux-headers/
- The libvhost-user.c source file ends up including a system kernel header, instead of the up-to-date standard-headers/ version that contains the right macro definition.
David 'Digit' Turner (3):
Fix libvhost-user.c compilation. update-linux-headers.sh: Add missing kernel headers. Update linux headers to v6.3rc5
include/standard-headers/drm/drm_fourcc.h | 12 ++ include/standard-headers/linux/ethtool.h | 48 +++++++- include/standard-headers/linux/fuse.h | 45 +++++++- include/standard-headers/linux/pci_regs.h | 1 + include/standard-headers/linux/vhost_types.h | 2 + include/standard-headers/linux/virtio_blk.h | 105 +++++++++++++++++ linux-headers/asm-arm64/kvm.h | 1 + linux-headers/asm-x86/kvm.h | 34 +++++- linux-headers/linux/const.h | 36 ++++++ linux-headers/linux/kvm.h | 9 ++ linux-headers/linux/memfd.h | 39 +++++++ linux-headers/linux/nvme_ioctl.h | 114 +++++++++++++++++++ linux-headers/linux/vfio.h | 15 ++- linux-headers/linux/vhost.h | 8 ++ scripts/update-linux-headers.sh | 4 +- subprojects/libvhost-user/libvhost-user.c | 6 + 16 files changed, 467 insertions(+), 12 deletions(-) create mode 100644 linux-headers/linux/const.h create mode 100644 linux-headers/linux/memfd.h create mode 100644 linux-headers/linux/nvme_ioctl.h
Signature · 1 line
2.40.0.348.gf938b09366-goog
PATCH 1/3 Fix libvhost-user.c compilation.
The source file uses VIRTIO_F_VERSION_1 which is not defined by <linux/virtio_config.h> on Debian 10.
The system-provided <linux/virtio_config.h> which does not include the macro definition is included through <linux/vhost.h>, so fix the issue by including the standard-headers version before that.
--- subprojects/libvhost-user/libvhost-user.c | 6 ++++++ 1 file changed, 6 insertions(+)
subprojects/libvhost-user/libvhost-user.c +6 -0
@@ -32,6 +32,12 @@#include <sys/mman.h> #include <endian.h> +/* Necessary to provide VIRTIO_F_VERSION_1 on system +* with older linux headers. Must appear before +* <linux/vhost.h> below. +*/ +#include "standard-headers/linux/virtio_config.h" +#if defined(__linux__)#include <sys/syscall.h> #include <fcntl.h>
Signature · 1 line
2.40.0.348.gf938b09366-goog
PATCH 2/3 update-linux-headers.sh: Add missing kernel headers.
In reply to David 'Digit' TurnerAdd <linux/memfd.h>, used by hw/display/virtio-gpu-udmabuf.c Add <linux/nvme_ioctl.h>, used by qga/commands-posix.c Add <linux/const.h> used by kvm-all.c, which requires the _BITUL() macro definition to be available.
Without these, QEMU will not compile on Debian 10 systems.
--- scripts/update-linux-headers.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/update-linux-headers.sh +2 -2
@@ -160,8 +160,8 @@ done rm -rf "$output/linux-headers/linux" mkdir -p "$output/linux-headers/linux" -for header in kvm.h vfio.h vfio_ccw.h vfio_zdev.h vhost.h \ - psci.h psp-sev.h userfaultfd.h mman.h vduse.h; do +for header in const.h kvm.h vfio.h vfio_ccw.h vfio_zdev.h vhost.h \ + psci.h psp-sev.h userfaultfd.h memfd.h mman.h nvme_ioctl.h vduse.h; do cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux" done
Signature · 1 line
2.40.0.348.gf938b09366-goog
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
In reply to David 'Digit' TurnerIf you are reposting, please version patchsets, E.g. -v2 flag for git format-patch will enerate [PATCH v2] for you.
Repeating what I said on previous version:
Quoted 9 lines · David 'Digit' Turner
The source file uses
VIRTIO_F_VERSION_1which is not defined by <linux/virtio_config.h> on Debian 10.The system-provided <
linux/virtio_config.h> which does not include the macro definition is included through <linux/vhost.h>, so fix the issue by including the standard-headers version before that.Signed-off-by David 'Digit' Turner <[email protected]>
This happens to work usually but there's no guarantee "standard-headers/linux/virtio_config.h"
and <linux/virtio_config.h> are interchangeable or even do not conflict.
But where is <linux/vhost.h> using <linux/virtio_config.h>? Everyone should be using "standard-headers/linux/virtio_config.h".
Quoted 23 lines
--- subprojects/libvhost-user/libvhost-user.c | 6 ++++++ 1 file changed, 6 insertions(+)subprojects/libvhost-user/libvhost-user.c +6
-0@@ -32,6 +32,12 @@#include <sys/mman.h> #include <endian.h> +/* Necessary to provide VIRTIO_F_VERSION_1 on system +* with older linux headers. Must appear before +* <linux/vhost.h> below. +*/ +#include "standard-headers/linux/virtio_config.h" +#if defined(__linux__)#include <sys/syscall.h> #include <fcntl.h> Signature · 1 line
2.40.0.348.gf938b09366-goog
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
The <linux/vhost.h> of glib-2.17 begins with:
#ifndef _LINUX_VHOST_H
#define _LINUX_VHOST_H
/* Userspace interface for in-kernel virtio accelerators. */ /* vhost is used to reduce the number of system calls involved in virtio.
*
* Existing virtio net code is used in the guest without modification. *
* This header includes interface used by userspace hypervisor for
* device configuration.
*/
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/virtio_config.h>
#include <linux/virtio_ring.h>
Here's the compilation error I get in this case:
FAILED: subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o
/src/prebuilts/clang/clang-r487747/bin/clang --sysroot=/out/sysroot -m64 -mcx16 -Isubprojects/libvhost-user/libvhost-user.a.p -Isubprojects/libvhost-user -I../../ src/third_party/qemu/subprojects/libvhost-user -I/out/dest-install/usr/include -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu99 -O2 -g -Wsign-compare -Wdeclarat ion-after-statement -Wstrict-aliasing -fno-pie -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -Wundef -Wwrite-strings -Wmissi
ng-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-b
ody -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wmissing-format-attribute -Wthread-safety -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-sh
ift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -Wno-gnu-variable-sized-type-not-at-end -fstack- protector-strong -pthread -D_GNU_SOURCE -MD -MQ subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o -MF subprojects/libvhost-user/libvhost-user.a.p/libv host-user.c.o.d -o subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o -c ../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:529:17:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'
1ULL << VIRTIO_F_VERSION_1 |
^../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:563:30:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'
if (!vu_has_feature(dev, VIRTIO_F_VERSION_1)) {
^../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:632:22:
warning: unused variable 'dev_region' [-Wunused-variable]
VuDevRegion *dev_region = &dev->regions[i];
^../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:633:13:
warning: unused variable 'ret' [-Wunused-variable]
int ret;
^2 warnings and 2 errors generated.
Quoted 51 lines · Michael S. Tsirkin
If you are reposting, please version patchsets, E.g. -v2 flag for git format-patch will enerate [PATCH v2] for you.
Repeating what I said on previous version:
Quoted 9 lines · David 'Digit' Turner
The source file uses
VIRTIO_F_VERSION_1which is not defined by <linux/virtio_config.h> on Debian 10.The system-provided <
linux/virtio_config.h> which does not include the macro definition is included through <linux/vhost.h>, so fix the issue by including the standard-headers version before that.Signed-off-by David 'Digit' Turner <[email protected]>This happens to work usually but there's no guarantee "
standard-headers/linux/virtio_config.h"
and <linux/virtio_config.h> are interchangeable or even do not conflict.But where is <
linux/vhost.h> using <linux/virtio_config.h>? Everyone should be using "standard-headers/linux/virtio_config.h".Review
Quoted 5 lines
--- subprojects/libvhost-user/libvhost-user.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/subprojects/libvhost-user/libvhost-user.cQuoted 18 lines
index
0200b78e8e..0a5768cb55100644subprojects/libvhost-user/libvhost-user.c +6
-1@@ -32,6 +32,12 @@#include <sys/mman.h> #include <endian.h> +/* Necessary to provide VIRTIO_F_VERSION_1 on system +* with older linux headers. Must appear before +* <linux/vhost.h> below. +*/ +#include "standard-headers/linux/virtio_config.h" +#if defined(__linux__)#include <sys/syscall.h> #include <fcntl.h> --2.40.0.348.gf938b09366-goog
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
I meant glibc-2.17, I am using a sysroot to ensure the generated binaries run on older Linux distributions.
Quoted 130 lines · David Turner
The <
linux/vhost.h> of glib-2.17 begins with:#ifndef
_LINUX_VHOST_H
#define_LINUX_VHOST_H
/* Userspace interface for in-kernel virtio accelerators. */ /* vhost is used to reduce the number of system calls involved in virtio.
*
* Existing virtio net code is used in the guest without modification. *
* This header includes interface used by userspace hypervisor for
* device configuration.
*/
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/virtio_config.h>
#include <linux/virtio_ring.h>Here's the compilation error I get in this case:
FAILED:
subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o/src/prebuilts/clang/clang-r487747/bin/clang --sysroot=/out/sysroot -m64
(quoted diff) +0
-2-mcx16 -Isubprojects/libvhost-user/libvhost-user.a.p -Isubprojects/libvhost-user -I../../src/third_party/qemu/subprojects/libvhost-user
(quoted diff) +0
-2-I/out/dest-install/usr/include -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu99 -O2 -g -Wsign-compare -Wdeclaration-after-statement -Wstrict-aliasing -fno-pie -D_FILE_OFFSET_BITS=64
(quoted diff) +0
-2-D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-definition
(quoted diff) +0
-2-Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
(quoted diff) +0
-2-Wmissing-format-attribute -Wthread-safety -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition
(quoted diff) +0
-2-Wno-tautological-type-limit-compare -Wno-psabi -Wno-gnu-variable-sized-type-not-at-end -fstack-protector-strong -pthread -D_GNU_SOURCE -MD -MQ
subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o-MF subprojects/libvhost-user/libvhost-user.a.p/libv host-user.c.o.d -osubprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o-c../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:529:17:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'1ULL << VIRTIO_F_VERSION_1 | ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:563:30:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'if (!vu_has_feature(dev, VIRTIO_F_VERSION_1)) { ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:632:22:
warning: unused variable 'dev_region' [-Wunused-variable]VuDevRegion *dev_region = &dev->regions[i]; ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:633:13:
warning: unused variable 'ret' [-Wunused-variable]int ret; ^2 warnings and 2 errors generated.
Quoted 51 lines · Michael S. Tsirkin
If you are reposting, please version patchsets, E.g. -v2 flag for git format-patch will enerate [PATCH v2] for you.
Repeating what I said on previous version:
Quoted 9 lines · David 'Digit' Turner
The source file uses
VIRTIO_F_VERSION_1which is not defined by <linux/virtio_config.h> on Debian 10.The system-provided <
linux/virtio_config.h> which does not include the macro definition is included through <linux/vhost.h>, so fix the issue by including the standard-headers version before that.Signed-off-by David 'Digit' Turner <[email protected]>This happens to work usually but there's no guarantee "
standard-headers/linux/virtio_config.h"
and <linux/virtio_config.h> are interchangeable or even do not conflict.But where is <
linux/vhost.h> using <linux/virtio_config.h>? Everyone should be using "standard-headers/linux/virtio_config.h".Review
Quoted 5 lines
--- subprojects/libvhost-user/libvhost-user.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/subprojects/libvhost-user/libvhost-user.cQuoted 18 lines
index
0200b78e8e..0a5768cb55100644subprojects/libvhost-user/libvhost-user.c +6
-1@@ -32,6 +32,12 @@#include <sys/mman.h> #include <endian.h> +/* Necessary to provide VIRTIO_F_VERSION_1 on system +* with older linux headers. Must appear before +* <linux/vhost.h> below. +*/ +#include "standard-headers/linux/virtio_config.h" +#if defined(__linux__)#include <sys/syscall.h> #include <fcntl.h> --2.40.0.348.gf938b09366-goog
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
So it looks like that for some reason, the QEMU linux-headers directory is not in the include search path for this compilation command, and that the system-or-sysroot provided <linux/vhost.h> is picked instead. Fixing this might be a better long-term fix than what I am proposing in this patch. I am not sure how to do that yet though. Do you have any recommendations?
Quoted 136 lines · David Turner
I meant glibc-2.17, I am using a sysroot to ensure the generated binaries run on older Linux distributions.
Quoted 131 lines · David Turner
The <
linux/vhost.h> of glib-2.17 begins with:#ifndef
_LINUX_VHOST_H
#define_LINUX_VHOST_H
/* Userspace interface for in-kernel virtio accelerators. */ /* vhost is used to reduce the number of system calls involved in virtio.
*
* Existing virtio net code is used in the guest without modification. *
* This header includes interface used by userspace hypervisor for
* device configuration.
*/
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/virtio_config.h>
#include <linux/virtio_ring.h>Here's the compilation error I get in this case:
FAILED:
subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o/src/prebuilts/clang/clang-r487747/bin/clang --sysroot=/out/sysroot -m64
(quoted diff) +0
-2-mcx16 -Isubprojects/libvhost-user/libvhost-user.a.p -Isubprojects/libvhost-user -I../../src/third_party/qemu/subprojects/libvhost-user
(quoted diff) +0
-2-I/out/dest-install/usr/include -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu99 -O2 -g -Wsign-compare -Wdeclaration-after-statement -Wstrict-aliasing -fno-pie -D_FILE_OFFSET_BITS=64
(quoted diff) +0
-2-D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls
(quoted diff) +0
-2-Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
(quoted diff) +0
-2-Wmissing-format-attribute -Wthread-safety -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition
(quoted diff) +0
-2-Wno-tautological-type-limit-compare -Wno-psabi -Wno-gnu-variable-sized-type-not-at-end -fstack-protector-strong -pthread -D_GNU_SOURCE -MD -MQ
subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o-MF subprojects/libvhost-user/libvhost-user.a.p/libv host-user.c.o.d -osubprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o-c../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:529:17:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'1ULL << VIRTIO_F_VERSION_1 | ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:563:30:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'if (!vu_has_feature(dev, VIRTIO_F_VERSION_1)) { ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:632:22:
warning: unused variable 'dev_region' [-Wunused-variable]VuDevRegion *dev_region = &dev->regions[i]; ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:633:13:
warning: unused variable 'ret' [-Wunused-variable]int ret; ^2 warnings and 2 errors generated.
Quoted 51 lines · Michael S. Tsirkin
If you are reposting, please version patchsets, E.g. -v2 flag for git format-patch will enerate [PATCH v2] for you.
Repeating what I said on previous version:
Quoted 9 lines · David 'Digit' Turner
The source file uses
VIRTIO_F_VERSION_1which is not defined by <linux/virtio_config.h> on Debian 10.The system-provided <
linux/virtio_config.h> which does not include the macro definition is included through <linux/vhost.h>, so fix the issue by including the standard-headers version before that.Signed-off-by David 'Digit' Turner <[email protected]>This happens to work usually but there's no guarantee "
standard-headers/linux/virtio_config.h"
and <linux/virtio_config.h> are interchangeable or even do not conflict.But where is <
linux/vhost.h> using <linux/virtio_config.h>? Everyone should be using "standard-headers/linux/virtio_config.h".Review
Quoted 5 lines
--- subprojects/libvhost-user/libvhost-user.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/subprojects/libvhost-user/libvhost-user.cQuoted 18 lines
index
0200b78e8e..0a5768cb55100644subprojects/libvhost-user/libvhost-user.c +6
-1@@ -32,6 +32,12 @@#include <sys/mman.h> #include <endian.h> +/* Necessary to provide VIRTIO_F_VERSION_1 on system +* with older linux headers. Must appear before +* <linux/vhost.h> below. +*/ +#include "standard-headers/linux/virtio_config.h" +#if defined(__linux__)#include <sys/syscall.h> #include <fcntl.h> --2.40.0.348.gf938b09366-goog
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
Quoted 5 lines · David Turner
So it looks like that for some reason, the QEMU linux-headers directory is not in the include search path for this compilation command, and that the system-or-sysroot provided <
linux/vhost.h> is picked instead. Fixing this might be a better long-term fix than what I am proposing in this patch. I am not sure how to do that yet though. Do you have any recommendations?
Check what flags are passed to the compiler :)
meson.build has:
if targetos == 'linux'
add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
'-isystem', 'linux-headers',
language: all_languages)endif
Signature · 1 line
MST
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
In reply to David TurnerDigging a little further, the top-level meson.build for qemu has the following:
if targetos == 'linux'
add_project_arguments('-isystem', meson.current_source_dir() /
'linux-headers',
'-isystem', 'linux-headers',
language: all_languages)endif
But this does not carry to the subprojects (and there is nothing equivalent in subprojects/libvhost-user/meson.build)/
If I change the above to use add_global_arguments() instead, compilation succeeds.
I don´t know if this is going to break other things though, but I'd be happy to change the patch to do that instead.
Quoted 145 lines · David Turner
So it looks like that for some reason, the QEMU linux-headers directory is not in the include search path for this compilation command, and that the system-or-sysroot provided <
linux/vhost.h> is picked instead. Fixing this might be a better long-term fix than what I am proposing in this patch. I am not sure how to do that yet though. Do you have any recommendations?Quoted 136 lines · David Turner
I meant glibc-2.17, I am using a sysroot to ensure the generated binaries run on older Linux distributions.
Quoted 131 lines · David Turner
The <
linux/vhost.h> of glib-2.17 begins with:#ifndef
_LINUX_VHOST_H
#define_LINUX_VHOST_H
/* Userspace interface for in-kernel virtio accelerators. */ /* vhost is used to reduce the number of system calls involved in virtio.
*
* Existing virtio net code is used in the guest without modification. *
* This header includes interface used by userspace hypervisor for
* device configuration.
*/
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/virtio_config.h>
#include <linux/virtio_ring.h>Here's the compilation error I get in this case:
FAILED:
subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o/src/prebuilts/clang/clang-r487747/bin/clang --sysroot=/out/sysroot -m64
(quoted diff) +0
-2-mcx16 -Isubprojects/libvhost-user/libvhost-user.a.p -Isubprojects/libvhost-user -I../../src/third_party/qemu/subprojects/libvhost-user
(quoted diff) +0
-2-I/out/dest-install/usr/include -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu99 -O2 -g -Wsign-compare -Wdeclaration-after-statement -Wstrict-aliasing -fno-pie -D_FILE_OFFSET_BITS=64
(quoted diff) +0
-2-D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls
(quoted diff) +0
-2-Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
(quoted diff) +0
-2-Wmissing-format-attribute -Wthread-safety -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition
(quoted diff) +0
-2-Wno-tautological-type-limit-compare -Wno-psabi -Wno-gnu-variable-sized-type-not-at-end -fstack-protector-strong -pthread -D_GNU_SOURCE -MD -MQ
subprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o-MF subprojects/libvhost-user/libvhost-user.a.p/libv host-user.c.o.d -osubprojects/libvhost-user/libvhost-user.a.p/libvhost-user.c.o-c../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:529:17:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'1ULL << VIRTIO_F_VERSION_1 | ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:563:30:
error: use of undeclared identifier 'VIRTIO_F_VERSION_1'if (!vu_has_feature(dev, VIRTIO_F_VERSION_1)) { ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:632:22:
warning: unused variable 'dev_region' [-Wunused-variable]VuDevRegion *dev_region = &dev->regions[i]; ^
../../src/third_party/qemu/subprojects/libvhost-user/libvhost-user.c:633:13:
warning: unused variable 'ret' [-Wunused-variable]int ret; ^2 warnings and 2 errors generated.
Quoted 51 lines · Michael S. Tsirkin
If you are reposting, please version patchsets, E.g. -v2 flag for git format-patch will enerate [PATCH v2] for you.
Repeating what I said on previous version:
Quoted 9 lines · David 'Digit' Turner
The source file uses
VIRTIO_F_VERSION_1which is not defined by <linux/virtio_config.h> on Debian 10.The system-provided <
linux/virtio_config.h> which does not include the macro definition is included through <linux/vhost.h>, so fix the issue by including the standard-headers version before that.Signed-off-by David 'Digit' Turner <[email protected]>This happens to work usually but there's no guarantee "
standard-headers/linux/virtio_config.h"
and <linux/virtio_config.h> are interchangeable or even do not conflict.But where is <
linux/vhost.h> using <linux/virtio_config.h>? Everyone should be using "standard-headers/linux/virtio_config.h".Review
Quoted 5 lines
--- subprojects/libvhost-user/libvhost-user.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/subprojects/libvhost-user/libvhost-user.cQuoted 18 lines
index
0200b78e8e..0a5768cb55100644subprojects/libvhost-user/libvhost-user.c +6
-1@@ -32,6 +32,12 @@#include <sys/mman.h> #include <endian.h> +/* Necessary to provide VIRTIO_F_VERSION_1 on system +* with older linux headers. Must appear before +* <linux/vhost.h> below. +*/ +#include "standard-headers/linux/virtio_config.h" +#if defined(__linux__)#include <sys/syscall.h> #include <fcntl.h> --2.40.0.348.gf938b09366-goog
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
In reply to Michael S. TsirkinQuoted 12 lines · Michael S. Tsirkin
Quoted 1 line · David Turner
So it looks like that for some reason, the QEMU linux-headers directory
is not
Quoted 2 lines
in the include search path for this compilation command, and that the system-or-sysroot provided <
linux/vhost.h> is picked instead. Fixingthis might
Quoted 1 line
be a better long-term fix than what I am proposing in this patch. I am
not sure
Quoted 1 line
how to do that yet though. Do you have any recommendations?
Check what flags are passed to the compiler :)
That's what I did :-)
meson.build has:
Quoted 9 lines
if targetos == 'linux'
add_project_arguments('-isystem',meson.current_source_dir()/
'linux-headers','-isystem', 'linux-headers', language: all_languages)endif
add_project_arguments()does not apply the arguments to subprojects, hence
why this fails for subprojects/libvhost-user /
Quoted 4 lines
--
MST
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
In reply to David TurnerQuoted 11 lines · David Turner
Digging a little further, the top-level meson.build for qemu has the following:
if targetos == 'linux' add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers', '-isystem', 'linux-headers', language: all_languages) endif
Quoted 7 lines
But this does not carry to the subprojects (and there is nothing equivalent in subprojects/libvhost-user/meson.build)/
If I change the above to useadd_global_arguments()instead, compilation succeeds.I don´t know if this is going to break other things though, but I'd be happy to change the patch to do that instead.
Or just add above lines to libvhost-user. That's probably safer.
Signature · 1 line
MST
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
In reply to David TurnerQuoted 2 lines · David Turner
I meant glibc-2.17, I am using a sysroot to ensure the generated binaries run on older Linux distributions.
I think that would be considered an unsupported buld configuration from QEMU's POV. Our platform policy is declared here:
https://www.qemu.org/docs/master/about/build-platforms.html
and from this policy we decide the minimum versions of libraries we intend to build against.
Our two oldest build targets are Debian 10 / RHEL 8, both of which ship with GLibC 2.28.
IOW, trying to build with a sysroot contanining ancient glibc 2.17 is well outside what QEMU intends to support. 2.17 is from circa 2012.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
Quoted 12 lines · Daniel P. Berrangé
Quoted 2 lines · David Turner
I meant glibc-2.17, I am using a sysroot to ensure the generated binaries run on older Linux distributions.
I think that would be considered an unsupported buld configuration from QEMU's POV. Our platform policy is declared here:
https://www.qemu.org/docs/master/about/build-platforms.html
and from this policy we decide the minimum versions of libraries we intend to build against.
Quoted 8 lines
Our two oldest build targets are Debian 10 / RHEL 8, both of which ship with GLibC 2.28.
IOW, trying to build with a sysroot contanining ancient glibc 2.17 is well outside what QEMU intends to support. 2.17 is from circa 2012.
Thank you for the clarification. My use of 2.17 is purely accidental at
that point (just reusing this Android prebuilt sysroot
<https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/>
which is quite dated).
I will try with a Debian 10 based sysroot first and will let you know. Maybe these patches are not needed after all.
Quoted 12 lines
With regards,
Daniel
--
|: https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-
https://fstop138.berrange.com :|
|: https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|
Re: [PATCH 1/3] Fix libvhost-user.c compilation.
In reply to David 'Digit' TurnerQuoted 9 lines · David 'Digit' Turner
The source file uses
VIRTIO_F_VERSION_1which is not defined by <linux/virtio_config.h> on Debian 10.The system-provided <
linux/virtio_config.h> which does not include the macro definition is included through <linux/vhost.h>, so fix the issue by including the standard-headers version before that.Signed-off-by David 'Digit' Turner <[email protected]>
And maybe we want to use linux-headers on Linux then?
Quoted 23 lines
--- subprojects/libvhost-user/libvhost-user.c | 6 ++++++ 1 file changed, 6 insertions(+)subprojects/libvhost-user/libvhost-user.c +6
-0@@ -32,6 +32,12 @@#include <sys/mman.h> #include <endian.h> +/* Necessary to provide VIRTIO_F_VERSION_1 on system +* with older linux headers. Must appear before +* <linux/vhost.h> below. +*/ +#include "standard-headers/linux/virtio_config.h" +#if defined(__linux__)#include <sys/syscall.h> #include <fcntl.h> Signature · 1 line
2.40.0.348.gf938b09366-goog