[12/15] libvirt: Fix build against glibc 2.36

Message ID 20220815171753.1858688-12-michael.tremer@ipfire.org
State Accepted
Commit 34097d0bd3f6d1106e830e2c3b1d74ab9fbb13cf
Headers
Series [01/15] sysvinit: Fix build against glibc 2.36 |

Commit Message

Michael Tremer Aug. 15, 2022, 5:17 p.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/libvirt                                   |  1 +
 .../libvirt-7.10.0-fix-glibc-headers.patch    | 42 +++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 src/patches/libvirt-7.10.0-fix-glibc-headers.patch
  

Patch

diff --git a/lfs/libvirt b/lfs/libvirt
index 77f75e1d3..d07f19b03 100644
--- a/lfs/libvirt
+++ b/lfs/libvirt
@@ -83,6 +83,7 @@  $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar Jxf $(DIR_DL)/$(DL_FILE)
 
 	cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/libvirt/0001-Change-default-behavior-of-libvirt-guests.sh-for-IPF.patch
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/libvirt-7.10.0-fix-glibc-headers.patch
 
 	cd $(DIR_APP) && meson \
 		--prefix=/usr \
diff --git a/src/patches/libvirt-7.10.0-fix-glibc-headers.patch b/src/patches/libvirt-7.10.0-fix-glibc-headers.patch
new file mode 100644
index 000000000..cfe71d4bd
--- /dev/null
+++ b/src/patches/libvirt-7.10.0-fix-glibc-headers.patch
@@ -0,0 +1,42 @@ 
+From c0d9adf220dc0d223330a7bac37b174132d330ba Mon Sep 17 00:00:00 2001
+From: Cole Robinson <crobinso@redhat.com>
+Date: Mon, 1 Aug 2022 15:24:01 -0400
+Subject: [PATCH] virfile: Fix build with glibc 2.36
+
+With glibc 2.36, sys/mount.h and linux/mount.h conflict:
+https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
+
+virfile.c imports sys/mount.h and linux/fs.h, which pulls in
+linux/mount.h.
+
+Manually define the constants we need from linux/fs.h, like was
+done in llvm:
+
+https://reviews.llvm.org/rGb379129c4beb3f26223288627a1291739f33af02
+
+Reviewed-by: Erik Skultety <eskultet@redhat.com>
+Signed-off-by: Cole Robinson <crobinso@redhat.com>
+---
+ src/util/virfile.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/util/virfile.c b/src/util/virfile.c
+index 99da058db3..ce541b8946 100644
+--- a/src/util/virfile.c
++++ b/src/util/virfile.c
+@@ -71,7 +71,11 @@
+ # endif
+ # include <sys/ioctl.h>
+ # include <linux/cdrom.h>
+-# include <linux/fs.h>
++/* These come from linux/fs.h, but that header conflicts with
++ * sys/mount.h on glibc 2.36+ */
++# define FS_IOC_GETFLAGS _IOR('f', 1, long)
++# define FS_IOC_SETFLAGS _IOW('f', 2, long)
++# define FS_NOCOW_FL 0x00800000
+ #endif
+ 
+ #if WITH_LIBATTR
+-- 
+GitLab
+