linux-user: fix regression with some ioctls with newest glibc
cover linux-user: fix regression with some ioctls with newest glibc
This fixes a problem where some ioctls lost their definition when we build with latest glibc that prevents use using linux/fs.h It further does some cleanup of conditionals to mitigate against such problems in future.
Daniel P. Berrangé (4):
linux-user: add more compat ioctl definitions
linux-user: remove conditionals for many fs.h ioctls
meson: enforce a minimum Linux kernel headers version >= 4.18
linux-user: drop conditionals for obsolete kernel header versions
linux-user/ioctls.h | 24 ----------------------- linux-user/linux_loop.h | 4 ---- linux-user/syscall.c | 39 ++++++++++++++++++++++++++------------ meson.build | 12 ++++++++++++ tests/tcg/i386/test-i386.c | 10 +++------- 5 files changed, 42 insertions(+), 47 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/4 linux-user: add more compat ioctl definitions
GLibc changes prevent us from including linux/fs.h anymore, and we previously adjusted to this in
commit 3cd3df2a9584e6f753bb62a0028bd67124ab5532
Author: Daniel P. Berrangé <[email protected]>
Date: Tue Aug 2 12:41:34 2022 -0400
linux-user: fix compat with glibc >= 2.36 sys/mount.h
That change required adding compat ioctl definitions on the QEMU side for any ioctls that we would otherwise obtain from linux/fs.h. This commit adds more that were initially missed, due to their usage being conditionalized in QEMU.
--- linux-user/syscall.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
linux-user/syscall.c +25 -0
@@ -111,6 +111,31 @@#define FS_IOC32_SETFLAGS _IOW('f', 2, int)#define FS_IOC32_GETVERSION _IOR('v', 1, int)#define FS_IOC32_SETVERSION _IOW('v', 2, int) + +#define BLKGETSIZE64 _IOR(0x12,114,size_t) +#define BLKDISCARD _IO(0x12,119) +#define BLKIOMIN _IO(0x12,120) +#define BLKIOOPT _IO(0x12,121) +#define BLKALIGNOFF _IO(0x12,122) +#define BLKPBSZGET _IO(0x12,123) +#define BLKDISCARDZEROES _IO(0x12,124) +#define BLKSECDISCARD _IO(0x12,125) +#define BLKROTATIONAL _IO(0x12,126) +#define BLKZEROOUT _IO(0x12,127) + +#define FIBMAP _IO(0x00,1) +#define FIGETBSZ _IO(0x00,2) + +struct file_clone_range { +__s64 src_fd; +__u64 src_offset; +__u64 src_length; +__u64 dest_offset; +}; + +#define FICLONE _IOW(0x94, 9, int) +#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range) +#else #include <linux/fs.h> #endif
Signature · 1 line
2.37.3
Re: [PATCH 1/4] linux-user: add more compat ioctl definitions
Le 04/10/2022 à 11:32, Daniel P. Berrangé a écrit :
Quoted 45 lines
GLibc changes prevent us from including
linux/fs.hanymore, and we previously adjusted to this incommit
3cd3df2a9584e6f753bb62a0028bd67124ab5532
Author: Daniel P. Berrangé <[email protected]>
Date: Tue Aug 2 12:41:34 2022 -0400linux-user: fix compat with glibc >= 2.36
sys/mount.hThat change required adding compat ioctl definitions on the QEMU side for any ioctls that we would otherwise obtain from
linux/fs.h. This commit adds more that were initially missed, due to their usage being conditionalized in QEMU.Signed-off-by Daniel P. Berrangé <[email protected]>--- linux-user/syscall.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)linux-user/syscall.c +18
-0@@ -111,6 +111,31 @@#define FS_IOC32_SETFLAGS _IOW('f', 2, int)#define FS_IOC32_GETVERSION _IOR('v', 1, int)#define FS_IOC32_SETVERSION _IOW('v', 2, int) + +#define BLKGETSIZE64 _IOR(0x12,114,size_t) +#define BLKDISCARD _IO(0x12,119) +#define BLKIOMIN _IO(0x12,120) +#define BLKIOOPT _IO(0x12,121) +#define BLKALIGNOFF _IO(0x12,122) +#define BLKPBSZGET _IO(0x12,123) +#define BLKDISCARDZEROES _IO(0x12,124) +#define BLKSECDISCARD _IO(0x12,125) +#define BLKROTATIONAL _IO(0x12,126) +#define BLKZEROOUT _IO(0x12,127) + +#define FIBMAP _IO(0x00,1) +#define FIGETBSZ _IO(0x00,2) + +struct file_clone_range { +__s64 src_fd; +__u64 src_offset;
linux-user/syscall.c line 141
Quoted 10 lines
linux-user/syscall.c +7
-0+__u64 src_length; + __u64 dest_offset; +}; + +#define FICLONE _IOW(0x94, 9, int) +#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range) +#else #include <linux/fs.h> #endif
Laurent Vivier
AppliedRe: [PATCH 1/4] linux-user: add more compat ioctl definitions
In reply to Daniel P. BerrangéLe 04/10/2022 à 11:32, Daniel P. Berrangé a écrit :
Quoted 45 lines
GLibc changes prevent us from including
linux/fs.hanymore, and we previously adjusted to this incommit
3cd3df2a9584e6f753bb62a0028bd67124ab5532
Author: Daniel P. Berrangé <[email protected]>
Date: Tue Aug 2 12:41:34 2022 -0400linux-user: fix compat with glibc >= 2.36
sys/mount.hThat change required adding compat ioctl definitions on the QEMU side for any ioctls that we would otherwise obtain from
linux/fs.h. This commit adds more that were initially missed, due to their usage being conditionalized in QEMU.Signed-off-by Daniel P. Berrangé <[email protected]>--- linux-user/syscall.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)linux-user/syscall.c +18
-0@@ -111,6 +111,31 @@#define FS_IOC32_SETFLAGS _IOW('f', 2, int)#define FS_IOC32_GETVERSION _IOR('v', 1, int)#define FS_IOC32_SETVERSION _IOW('v', 2, int) + +#define BLKGETSIZE64 _IOR(0x12,114,size_t) +#define BLKDISCARD _IO(0x12,119) +#define BLKIOMIN _IO(0x12,120) +#define BLKIOOPT _IO(0x12,121) +#define BLKALIGNOFF _IO(0x12,122) +#define BLKPBSZGET _IO(0x12,123) +#define BLKDISCARDZEROES _IO(0x12,124) +#define BLKSECDISCARD _IO(0x12,125) +#define BLKROTATIONAL _IO(0x12,126) +#define BLKZEROOUT _IO(0x12,127) + +#define FIBMAP _IO(0x00,1) +#define FIGETBSZ _IO(0x00,2) + +struct file_clone_range { +__s64 src_fd; +__u64 src_offset;
linux-user/syscall.c line 141
Quoted 10 lines
linux-user/syscall.c +7
-0+__u64 src_length; + __u64 dest_offset; +}; + +#define FICLONE _IOW(0x94, 9, int) +#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range) +#else #include <linux/fs.h> #endif
Applied to my linux-user-for-7.2 branch.
Thanks,
Laurent
PATCH 2/4 linux-user: remove conditionals for many fs.h ioctls
In reply to Daniel P. BerrangéThese ioctls have been defined in linux/fs.h for a long time
* BLKGETSIZE64 - <2.6.12 (linux.git epoch)
* BLKDISCARD - 2.6.28 (d30a2605be9d5132d95944916e8f578fcfe4f976)
* BLKIOMIN - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKIOOPT - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKALIGNOFF - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKPBSZGET - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKDISCARDZEROES - 2.6.32 (98262f2762f0067375f83824d81ea929e37e6bfe)
* BLKSECDISCARD - 2.6.36 (8d57a98ccd0b4489003473979da8f5a1363ba7a3)
* BLKROTATIONAL - 3.2 (ef00f59c95fe6e002e7c6e3663cdea65e253f4cc)
* BLKZEROOUT - 3.6 (66ba32dc167202c3cf8c86806581a9393ec7f488)
* FIBMAP - <2.6.12 (linux.git epoch)
* FIGETBSZ - <2.6.12 (linux.git epoch)
and when building with latest glibc, we'll see compat definitions in syscall.c anyway thanks to the previous patch. Thus we can assume they always exist and remove the conditional checks.
--- linux-user/ioctls.h | 24 ------------------------ 1 file changed, 24 deletions(-)
linux-user/ioctls.h +0 -24
@@ -96,9 +96,7 @@ IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) IOCTL(BLKRRPART, 0, TYPE_NULL) IOCTL(BLKGETSIZE, IOC_R, MK_PTR(TYPE_ULONG)) -#ifdef BLKGETSIZE64 IOCTL(BLKGETSIZE64, IOC_R, MK_PTR(TYPE_ULONGLONG)) -#endif IOCTL(BLKFLSBUF, 0, TYPE_NULL) IOCTL(BLKRASET, 0, TYPE_INT)IOCTL (BLKRAGET ,IOC_R ,MK_PTR (TYPE_LONG ))
@@ -107,33 +105,15 @@IOCTL_SPECIAL (BLKPG ,IOC_W , do_ioctl_blkpg, MK_PTR(MK_STRUCT(STRUCT_blkpg_ioctl_arg))) -#ifdef BLKDISCARD IOCTL(BLKDISCARD, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif -#ifdef BLKIOMIN IOCTL(BLKIOMIN, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKIOOPT IOCTL(BLKIOOPT, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKALIGNOFF IOCTL(BLKALIGNOFF, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKPBSZGET IOCTL(BLKPBSZGET, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKDISCARDZEROES IOCTL(BLKDISCARDZEROES, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKSECDISCARD IOCTL(BLKSECDISCARD, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif -#ifdef BLKROTATIONAL IOCTL(BLKROTATIONAL, IOC_R, MK_PTR(TYPE_SHORT)) -#endif -#ifdef BLKZEROOUT IOCTL(BLKZEROOUT, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif IOCTL(FDMSGON, 0, TYPE_NULL)IOCTL (FDMSGOFF ,0 ,TYPE_NULL )
@@ -149,17 +129,13 @@ IOCTL(FDTWADDLE, 0, TYPE_NULL) IOCTL(FDEJECT, 0, TYPE_NULL) -#ifdef FIBMAP IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG)) -#endif #ifdef FICLONE IOCTL(FICLONE, IOC_W, TYPE_INT) IOCTL(FICLONERANGE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_file_clone_range)))#endif -#ifdef FIGETBSZ IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG)) -#endif #ifdef CONFIG_FIEMAP IOCTL_SPECIAL (FS_IOC_FIEMAP ,IOC_W |IOC_R , do_ioctl_fs_ioc_fiemap,MK_PTR (MK_STRUCT (STRUCT_fiemap)))
Signature · 1 line
2.37.3
Re: [PATCH 2/4] linux-user: remove conditionals for many fs.h ioctls
Le 04/10/2022 à 11:32, Daniel P. Berrangé a écrit :
Quoted 80 lines
These ioctls have been defined in
linux/fs.hfor a long time* BLKGETSIZE64 - <2.6.12 (linux.git epoch)
* BLKDISCARD - 2.6.28 (d30a2605be9d5132d95944916e8f578fcfe4f976)
* BLKIOMIN - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKIOOPT - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKALIGNOFF - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKPBSZGET - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKDISCARDZEROES - 2.6.32 (98262f2762f0067375f83824d81ea929e37e6bfe)
* BLKSECDISCARD - 2.6.36 (8d57a98ccd0b4489003473979da8f5a1363ba7a3)
* BLKROTATIONAL - 3.2 (ef00f59c95fe6e002e7c6e3663cdea65e253f4cc)
* BLKZEROOUT - 3.6 (66ba32dc167202c3cf8c86806581a9393ec7f488)
* FIBMAP - <2.6.12 (linux.git epoch)
* FIGETBSZ - <2.6.12 (linux.git epoch)and when building with latest glibc, we'll see compat definitions in
syscall.canyway thanks to the previous patch. Thus we can assume they always exist and remove the conditional checks.Signed-off-by Daniel P. Berrangé <[email protected]>--- linux-user/ioctls.h | 24 ------------------------ 1 file changed, 24 deletions(-)linux-user/ioctls.h +0
-22@@ -96,9 +96,7 @@ IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) IOCTL(BLKRRPART, 0, TYPE_NULL) IOCTL(BLKGETSIZE, IOC_R, MK_PTR(TYPE_ULONG)) -#ifdef BLKGETSIZE64 IOCTL(BLKGETSIZE64, IOC_R, MK_PTR(TYPE_ULONGLONG)) -#endif IOCTL(BLKFLSBUF, 0, TYPE_NULL) IOCTL(BLKRASET, 0, TYPE_INT)IOCTL (BLKRAGET ,IOC_R ,MK_PTR (TYPE_LONG ))@@ -107,33 +105,15 @@IOCTL_SPECIAL (BLKPG ,IOC_W , do_ioctl_blkpg, MK_PTR(MK_STRUCT(STRUCT_blkpg_ioctl_arg))) -#ifdef BLKDISCARD IOCTL(BLKDISCARD, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif -#ifdef BLKIOMIN IOCTL(BLKIOMIN, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKIOOPT IOCTL(BLKIOOPT, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKALIGNOFF IOCTL(BLKALIGNOFF, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKPBSZGET IOCTL(BLKPBSZGET, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKDISCARDZEROES IOCTL(BLKDISCARDZEROES, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKSECDISCARD IOCTL(BLKSECDISCARD, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif -#ifdef BLKROTATIONAL IOCTL(BLKROTATIONAL, IOC_R, MK_PTR(TYPE_SHORT)) -#endif -#ifdef BLKZEROOUT IOCTL(BLKZEROOUT, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif IOCTL(FDMSGON, 0, TYPE_NULL)IOCTL (FDMSGOFF ,0 ,TYPE_NULL )@@ -149,17 +129,13 @@ IOCTL(FDTWADDLE, 0, TYPE_NULL) IOCTL(FDEJECT, 0, TYPE_NULL) -#ifdef FIBMAP IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG)) -#endif #ifdef FICLONE
linux-user/ioctls.h line 141
Quoted 10 lines
linux-user/ioctls.h +0
-2IOCTL(FICLONE, IOC_W, TYPE_INT) IOCTL(FICLONERANGE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_file_clone_range)))#endif -#ifdef FIGETBSZ IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG)) -#endif #ifdef CONFIG_FIEMAP IOCTL_SPECIAL (FS_IOC_FIEMAP ,IOC_W |IOC_R , do_ioctl_fs_ioc_fiemap,MK_PTR (MK_STRUCT (STRUCT_fiemap)))
Laurent Vivier
AppliedRe: [PATCH 2/4] linux-user: remove conditionals for many fs.h ioctls
In reply to Daniel P. BerrangéLe 04/10/2022 à 11:32, Daniel P. Berrangé a écrit :
Quoted 80 lines
These ioctls have been defined in
linux/fs.hfor a long time* BLKGETSIZE64 - <2.6.12 (linux.git epoch)
* BLKDISCARD - 2.6.28 (d30a2605be9d5132d95944916e8f578fcfe4f976)
* BLKIOMIN - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKIOOPT - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKALIGNOFF - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKPBSZGET - 2.6.32 (ac481c20ef8f6c6f2be75d581863f40c43874ef7)
* BLKDISCARDZEROES - 2.6.32 (98262f2762f0067375f83824d81ea929e37e6bfe)
* BLKSECDISCARD - 2.6.36 (8d57a98ccd0b4489003473979da8f5a1363ba7a3)
* BLKROTATIONAL - 3.2 (ef00f59c95fe6e002e7c6e3663cdea65e253f4cc)
* BLKZEROOUT - 3.6 (66ba32dc167202c3cf8c86806581a9393ec7f488)
* FIBMAP - <2.6.12 (linux.git epoch)
* FIGETBSZ - <2.6.12 (linux.git epoch)and when building with latest glibc, we'll see compat definitions in
syscall.canyway thanks to the previous patch. Thus we can assume they always exist and remove the conditional checks.Signed-off-by Daniel P. Berrangé <[email protected]>--- linux-user/ioctls.h | 24 ------------------------ 1 file changed, 24 deletions(-)linux-user/ioctls.h +0
-22@@ -96,9 +96,7 @@ IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) IOCTL(BLKRRPART, 0, TYPE_NULL) IOCTL(BLKGETSIZE, IOC_R, MK_PTR(TYPE_ULONG)) -#ifdef BLKGETSIZE64 IOCTL(BLKGETSIZE64, IOC_R, MK_PTR(TYPE_ULONGLONG)) -#endif IOCTL(BLKFLSBUF, 0, TYPE_NULL) IOCTL(BLKRASET, 0, TYPE_INT)IOCTL (BLKRAGET ,IOC_R ,MK_PTR (TYPE_LONG ))@@ -107,33 +105,15 @@IOCTL_SPECIAL (BLKPG ,IOC_W , do_ioctl_blkpg, MK_PTR(MK_STRUCT(STRUCT_blkpg_ioctl_arg))) -#ifdef BLKDISCARD IOCTL(BLKDISCARD, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif -#ifdef BLKIOMIN IOCTL(BLKIOMIN, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKIOOPT IOCTL(BLKIOOPT, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKALIGNOFF IOCTL(BLKALIGNOFF, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKPBSZGET IOCTL(BLKPBSZGET, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKDISCARDZEROES IOCTL(BLKDISCARDZEROES, IOC_R, MK_PTR(TYPE_INT)) -#endif -#ifdef BLKSECDISCARD IOCTL(BLKSECDISCARD, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif -#ifdef BLKROTATIONAL IOCTL(BLKROTATIONAL, IOC_R, MK_PTR(TYPE_SHORT)) -#endif -#ifdef BLKZEROOUT IOCTL(BLKZEROOUT, IOC_W, MK_PTR(MK_ARRAY(TYPE_ULONGLONG, 2))) -#endif IOCTL(FDMSGON, 0, TYPE_NULL)IOCTL (FDMSGOFF ,0 ,TYPE_NULL )@@ -149,17 +129,13 @@ IOCTL(FDTWADDLE, 0, TYPE_NULL) IOCTL(FDEJECT, 0, TYPE_NULL) -#ifdef FIBMAP IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG)) -#endif #ifdef FICLONE
linux-user/ioctls.h line 141
Quoted 10 lines
linux-user/ioctls.h +0
-2IOCTL(FICLONE, IOC_W, TYPE_INT) IOCTL(FICLONERANGE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_file_clone_range)))#endif -#ifdef FIGETBSZ IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG)) -#endif #ifdef CONFIG_FIEMAP IOCTL_SPECIAL (FS_IOC_FIEMAP ,IOC_W |IOC_R , do_ioctl_fs_ioc_fiemap,MK_PTR (MK_STRUCT (STRUCT_fiemap)))
Applied to my linux-user-for-7.2 branch.
Thanks,
Laurent
PATCH 3/4 meson: enforce a minimum Linux kernel headers version >= 4.18
In reply to Daniel P. BerrangéVarious areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15
The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Overall, we can set the baseline to 4.18 currently.
--- meson.build | 12 ++++++++++++ 1 file changed, 12 insertions(+)
meson.build +12 -0
@@ -248,6 +248,18 @@ if targetos == 'linux' add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers', '-isystem', 'linux-headers', language: ['c', 'cpp']) + + if not cc.compiles(''' + #include <linux/version.h> + int main(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) +#error "QEMU requires Linux kernel headers version >= 4.18.0" +#endif + return 0; + }''') + error('QEMU requires Linux kernel headers version >= 4.18.0') +endif + endif add_project_arguments('-iquote', '.',
Signature · 1 line
2.37.3
Re: [PATCH 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
Quoted 18 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15
Quoted 5 lines
The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Overall, we can set the baseline to 4.18 currently.
I wonder if we want to be a bit more conservative about this than we would for other library-type dependency setting ? At the moment, even if you don't meet our minimum distro baseline, you can still build by, for instance, building local copies of newer versions of our dependencies and using those. That seems harder to do for the system header files.
-- PMM
Re: [PATCH 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
Quoted 23 lines · Peter Maydell
Quoted 22 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Quoted 8 lines
Quoted 1 line
Overall, we can set the baseline to 4.18 currently.
I wonder if we want to be a bit more conservative about this than we would for other library-type dependency setting ? At the moment, even if you don't meet our minimum distro baseline, you can still build by, for instance, building local copies of newer versions of our dependencies and using those. That seems harder to do for the system header files.
In theory it ought to be possible to install a newer version of the linux kernel headers too, as there's no need for them to actually match the kernel being run. Depending on the age difference of distro vs newer kernel headers though, I guess there's a small risk of incompatibility between the new kernel headers and original glibc.
Personally I think we're already pretty generous though in terms of backcompat though, and at least for the user emulators, people can do a static build on a newer install and run it on an older install.
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 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
In reply to Daniel P. BerrangéLe 04/10/2022 à 11:32, Daniel P. Berrangé a écrit :
Quoted 17 lines
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15
Quoted 5 lines
The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Overall, we can set the baseline to 4.18 currently.
As this change affects entire QEMU build, I'd prefer to have some "Acked-by" before merging it via linux-user branch.
Thanks,
Laurent
Re: [PATCH 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
Quoted 19 lines · Laurent Vivier
Quoted 17 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15
Quoted 8 lines
Quoted 5 lines
The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Overall, we can set the baseline to 4.18 currently.
As this change affects entire QEMU build, I'd prefer to have some "Acked-by" before merging it via linux-user branch.
I still think we should be more conservative about kernel header requirements than we are for other dependencies.
thanks
-- PMM
Re: [PATCH 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
Quoted 24 lines · Peter Maydell
Quoted 23 lines · Laurent Vivier
Quoted 21 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Overall, we can set the baseline to 4.18 currently.
As this change affects entire QEMU build, I'd prefer to have some "Acked-by" before merging it via linux-user branch.
I still think we should be more conservative about kernel header requirements than we are for other dependencies.
How much more though ? What other distros do we want to target that we don't already cover with our targetted platforms ?
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 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
Quoted 28 lines · Daniel P. Berrangé
Quoted 26 lines · Peter Maydell
Quoted 25 lines · Laurent Vivier
Quoted 22 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Overall, we can set the baseline to 4.18 currently.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As this change affects entire QEMU build, I'd prefer to have some "Acked-by" before merging it via linux-user branch.
I still think we should be more conservative about kernel header requirements than we are for other dependencies.
How much more though ? What other distros do we want to target that we don't already cover with our targetted platforms ?
I don't want to target them. I just don't want to leave them completely stuck. I think system headers are significantly different from just needing to build a local version of some dependency library.
Alternatively if we really need recent kernel headers to build linux-user then we should come up with some scheme for using a local copy of the relevant headers, as we do for KVM...
-- PMM
Re: [PATCH 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
Quoted 46 lines · Peter Maydell
Quoted 28 lines · Daniel P. Berrangé
Quoted 26 lines · Peter Maydell
Quoted 25 lines · Laurent Vivier
Quoted 22 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Overall, we can set the baseline to 4.18 currently.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As this change affects entire QEMU build, I'd prefer to have some "Acked-by" before merging it via linux-user branch.
I still think we should be more conservative about kernel header requirements than we are for other dependencies.
How much more though ? What other distros do we want to target that we don't already cover with our targetted platforms ?
I don't want to target them. I just don't want to leave them completely stuck. I think system headers are significantly different from just needing to build a local version of some dependency library.
Quoted 3 lines
Alternatively if we really need recent kernel headers to build linux-user then we should come up with some scheme for using a local copy of the relevant headers, as we do for KVM...
This wasn't so much about needing recent headers, rather it was about removing conditionals that are not likely to be needed by anyone. I wanted to set a min kernel version to make it clearer to future authors how far back they need to care about compat for.
The next patch removed conditions for:
2.5.66 (??)
2.6.0 (Dec 2003) 4.2 (Aug 2015) 4.12 (Jul 2017)
I can't imagine anyone needs 2.6.x support. Perhaps 4.x if someone is still using RHEL-7 though
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 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
In reply to Daniel P. BerrangéQuoted 27 lines · Daniel P. Berrangé
Quoted 26 lines · Peter Maydell
Quoted 25 lines · Laurent Vivier
Quoted 22 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Overall, we can set the baseline to 4.18 currently.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
As this change affects entire QEMU build, I'd prefer to have some "Acked-by" before merging it via linux-user branch.
I still think we should be more conservative about kernel header requirements than we are for other dependencies.
How much more though ? What other distros do we want to target that we don't already cover with our targetted platforms ?
Well purely selfishly the big build box I have access to is still on 18.04 which is currently running 4.15.0-191-generic. It will hopefully get upgraded before 18.04 goes out of support from Canonical. From a practical point of view it will be a pain if I can't bisect on it in the meantime.
Quoted 4 lines
With regards,
Daniel
Signature · 1 line
Alex Bennée
Re: [PATCH 3/4] meson: enforce a minimum Linux kernel headers version >= 4.18
In reply to Daniel P. BerrangéQuoted 21 lines · Daniel P. Berrangé
Various areas of QEMU have a dependency on Linux kernel header definitions. This falls under the scope of our supported platforms matrix, but historically we've not checked for a minimum kernel headers version. This has made it unclear when we can drop support for older kernel headers.
* Alpine 3.14: 5.10
* CentOS 8: 4.18
* CentOS 9: 5.14
* Debian 10: 4.19
* Debian 11: 5.10
* Fedora 35: 5.19
* Fedora 36: 5.19
* OpenSUSE 15.3: 5.3.0
* Ubuntu 20.04: 5.4
* Ubuntu 22.04: 5.15The above ignores the 3rd version digit since distros update their packages periodically and such updates don't generally affect public APIs to the extent that it matters for our build time check.
Quoted 6 lines
Overall, we can set the baseline to 4.18 currently.
Signed-off-by Daniel P. Berrangé <[email protected]>--- meson.build | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Since there's no agreement, I'll just consider this patch discarded, along with the next one. I won't repost since Laurent has already queued the first two patches.
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 :|
PATCH 4/4 linux-user: drop conditionals for obsolete kernel header versions
In reply to Daniel P. BerrangéGiven our newly enforced 4.18 baseline for the kernel headers version, we can drop any conditional checks for older versions.
--- linux-user/linux_loop.h | 4 ---- linux-user/syscall.c | 14 ++------------ tests/tcg/i386/test-i386.c | 10 +++------- 3 files changed, 5 insertions(+), 23 deletions(-)
linux-user/linux_loop.h +0 -4
@@ -31,10 +31,6 @@ enum {#include <asm/posix_types.h> /* for __kernel_old_dev_t */ #include <asm/types.h> /* for __u64 */ -#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,0 )/* This is a guess. */ -#define __kernel_old_dev_t __kernel_dev_t -#endif -/* Backwards compatibility version */ struct loop_info {int lo_number;/* ioctl r/o */
linux-user/syscall.c +2 -12
@@ -2540,16 +2540,12 @@ set_timeout:case NETLINK_DROP_MEMBERSHIP :case NETLINK_BROADCAST_ERROR :case NETLINK_NO_ENOBUFS : -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,2 ,0 )case NETLINK_LISTEN_ALL_NSID :case NETLINK_CAP_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) */ -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,12 ,0 )case NETLINK_EXT_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ #if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,20 ,0 )case NETLINK_GET_STRICT_CHK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0) */ break ;default : goto unimplemented;
@@ -2918,16 +2914,12 @@ get_timeout:case NETLINK_PKTINFO :case NETLINK_BROADCAST_ERROR :case NETLINK_NO_ENOBUFS : -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,2 ,0 )case NETLINK_LISTEN_ALL_NSID :case NETLINK_CAP_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) */ -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,12 ,0 )case NETLINK_EXT_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ #if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,20 ,0 )case NETLINK_GET_STRICT_CHK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0) */ if (get_user_u32 (len, optlen)) {return -TARGET_EFAULT ; }
@@ -2944,7 +2936,6 @@ get_timeout:return -TARGET_EFAULT ; }break ; -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,2 ,0 )case NETLINK_LIST_MEMBERSHIPS : {uint32_t *results;
@@ -2975,7 +2966,6 @@ get_timeout:unlock_user (results, optval_addr,0 );break ; } -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) */ default : goto unimplemented; }
tests/tcg/i386/test-i386.c +3 -7
@@ -1224,10 +1224,6 @@ static inline int modify_ldt(int func, void * ptr, unsigned long bytecount)return syscall (__NR_modify_ldt, func, ptr, bytecount); } -#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,5 ,66 ) -#define modify_ldt_ldt_s user_desc -#endif -#define MK_SEL (n) (((n) << 3) | 7)uint8_t seg_data1[4096 ];
@@ -1265,7 +1261,7 @@ uint8_t seg_data2[4096];/* NOTE: we use Linux modify_ldt syscall */ void test_segs (void ) { -struct modify_ldt_ldt_s ldt; +struct user_desc ldt;long long ldt_table[3 ];int res, res2;char tmp;
@@ -1367,7 +1363,7 @@ extern char code16_func3;void test_code16 (void ) { -struct modify_ldt_ldt_s ldt; +struct user_desc ldt;int res, res2;/* build a code segment */
@@ -1774,7 +1770,7 @@ void test_exceptions(void) } { -struct modify_ldt_ldt_s ldt; +struct user_desc ldt; ldt.entry_number =1 ; ldt.base_addr = (unsigned long )&seg_data1; ldt.limit = (sizeof (seg_data1) +0xfff ) >>12 ;
Signature · 1 line
2.37.3
Re: [PATCH 4/4] linux-user: drop conditionals for obsolete kernel header versions
Le 04/10/2022 à 11:32, Daniel P. Berrangé a écrit :
Quoted 115 lines
Given our newly enforced 4.18 baseline for the kernel headers version, we can drop any conditional checks for older versions.
Signed-off-by Daniel P. Berrangé <[email protected]>--- linux-user/linux_loop.h | 4 ---- linux-user/syscall.c | 14 ++------------ tests/tcg/i386/test-i386.c | 10 +++------- 3 files changed, 5 insertions(+), 23 deletions(-)linux-user/linux_loop.h +0
-4@@ -31,10 +31,6 @@ enum {#include <asm/posix_types.h> /* for __kernel_old_dev_t */ #include <asm/types.h> /* for __u64 */ -#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,0 )/* This is a guess. */ -#define __kernel_old_dev_t __kernel_dev_t -#endif -/* Backwards compatibility version */ struct loop_info {int lo_number;/* ioctl r/o */ linux-user/syscall.c +2
-12@@ -2540,16 +2540,12 @@ set_timeout:case NETLINK_DROP_MEMBERSHIP :case NETLINK_BROADCAST_ERROR :case NETLINK_NO_ENOBUFS : -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,2 ,0 )case NETLINK_LISTEN_ALL_NSID :case NETLINK_CAP_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) */ -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,12 ,0 )case NETLINK_EXT_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ #if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,20 ,0 )case NETLINK_GET_STRICT_CHK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0) */ break ;default : goto unimplemented;@@ -2918,16 +2914,12 @@ get_timeout:case NETLINK_PKTINFO :case NETLINK_BROADCAST_ERROR :case NETLINK_NO_ENOBUFS : -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,2 ,0 )case NETLINK_LISTEN_ALL_NSID :case NETLINK_CAP_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) */ -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,12 ,0 )case NETLINK_EXT_ACK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ #if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,20 ,0 )case NETLINK_GET_STRICT_CHK : -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) */ +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0) */ if (get_user_u32 (len, optlen)) {return -TARGET_EFAULT ; }@@ -2944,7 +2936,6 @@ get_timeout:return -TARGET_EFAULT ; }break ; -#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,2 ,0 )case NETLINK_LIST_MEMBERSHIPS : {uint32_t *results;@@ -2975,7 +2966,6 @@ get_timeout:unlock_user (results, optval_addr,0 );break ; } -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) */ default : goto unimplemented; }tests/tcg/i386/test-i386.c +2
-6@@ -1224,10 +1224,6 @@ static inline int modify_ldt(int func, void * ptr, unsigned long bytecount)return syscall (__NR_modify_ldt, func, ptr, bytecount); } -#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,5 ,66 ) -#define modify_ldt_ldt_s user_desc -#endif -#define MK_SEL (n) (((n) << 3) | 7)uint8_t seg_data1[4096 ];@@ -1265,7 +1261,7 @@ uint8_t seg_data2[4096];/* NOTE: we use Linux modify_ldt syscall */ void test_segs (void ) { -struct modify_ldt_ldt_s ldt; +struct user_desc ldt;long long ldt_table[3 ];int res, res2;char tmp;@@ -1367,7 +1363,7 @@ extern char code16_func3;void test_code16 (void ) { -struct modify_ldt_ldt_s ldt; +struct user_desc ldt;int res, res2;/* build a code segment */
tests/tcg/i386/test-i386.c void test_exceptions(void) · line 1776
Quoted 8 lines
tests/tcg/i386/test-i386.c +1
-1@@ -1774,7 +1770,7 @@ void test_exceptions(void) } { -struct modify_ldt_ldt_s ldt; +struct user_desc ldt; ldt.entry_number =1 ; ldt.base_addr = (unsigned long )&seg_data1; ldt.limit = (sizeof (seg_data1) +0xfff ) >>12 ;