package/qemu: add libfuse3 optional dependency
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Mon, 9 Aug 2021 08:54:26 +0000 (10:54 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Thu, 12 Aug 2021 21:51:19 +0000 (23:51 +0200)
libfuse3 is an optional dependency which is enabled by default since
version 6.0.0 and
https://gitlab.com/qemu-project/qemu/-/commit/0c9b70d5900a5108e899edfdd6f3790f8cb6bdc2

So add this dependency and fix the following build failures on musl
raised since bump to version 6.0.0 in commit
6b86c9335fc3ff381878156c6243454d4b688df9:

../block/export/fuse.c: In function 'fuse_fallocate':
../block/export/fuse.c:563:23: error: 'FALLOC_FL_ZERO_RANGE' undeclared (first use in this function)
  563 |     } else if (mode & FALLOC_FL_ZERO_RANGE) {
      |                       ^~~~~~~~~~~~~~~~~~~~
../block/export/fuse.c:563:23: note: each undeclared identifier is reported only once for each function it appears in
../block/export/fuse.c: In function 'fuse_lseek':
../block/export/fuse.c:639:19: error: 'SEEK_HOLE' undeclared (first use in this function)
  639 |     if (whence != SEEK_HOLE && whence != SEEK_DATA) {
      |                   ^~~~~~~~~
../block/export/fuse.c:639:42: error: 'SEEK_DATA' undeclared (first use in this function); did you mean 'SEEK_SET'?
  639 |     if (whence != SEEK_HOLE && whence != SEEK_DATA) {
      |                                          ^~~~~~~~~
      |                                          SEEK_SET

Fixes:
 - http://autobuild.buildroot.org/results/0196609043bd37543e6a0d17ffc2254302ea7ba3

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/qemu/0005-block-export-fuse.c-fix-musl-build.patch [new file with mode: 0644]
package/qemu/qemu.mk

diff --git a/package/qemu/0005-block-export-fuse.c-fix-musl-build.patch b/package/qemu/0005-block-export-fuse.c-fix-musl-build.patch
new file mode 100644 (file)
index 0000000..0da6b3f
--- /dev/null
@@ -0,0 +1,46 @@
+From 4d5280c066eb46a31556044fb52c2618928b0019 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Mon, 9 Aug 2021 10:04:07 +0200
+Subject: [PATCH] block/export/fuse.c: fix musl build
+
+Fix the following build failure on musl raised since version 6.0.0 and
+https://gitlab.com/qemu-project/qemu/-/commit/4ca37a96a75aafe7a37ba51ab1912b09b7190a6b
+because musl does not define FALLOC_FL_ZERO_RANGE:
+
+../block/export/fuse.c: In function 'fuse_fallocate':
+../block/export/fuse.c:563:23: error: 'FALLOC_FL_ZERO_RANGE' undeclared (first use in this function)
+  563 |     } else if (mode & FALLOC_FL_ZERO_RANGE) {
+      |                       ^~~~~~~~~~~~~~~~~~~~
+
+Fixes:
+ - http://autobuild.buildroot.org/results/b96e3d364fd1f8bbfb18904a742e73327d308f64
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status: sent to qemu-devel@nongnu.org]
+---
+ block/export/fuse.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/block/export/fuse.c b/block/export/fuse.c
+index ada9e263eb..07e31129a6 100644
+--- a/block/export/fuse.c
++++ b/block/export/fuse.c
+@@ -635,6 +635,7 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
+             offset += size;
+             length -= size;
+         } while (ret == 0 && length > 0);
++#ifdef FALLOC_FL_ZERO_RANGE
+     } else if (mode & FALLOC_FL_ZERO_RANGE) {
+         if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + length > blk_len) {
+             /* No need for zeroes, we are going to write them ourselves */
+@@ -654,6 +655,7 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
+             offset += size;
+             length -= size;
+         } while (ret == 0 && length > 0);
++#endif
+     } else if (!mode) {
+         /* We can only fallocate at the EOF with a truncate */
+         if (offset < blk_len) {
+-- 
+2.30.2
+
index 50ace104ceeeda098c03a822544170b5818cbd18..88516678d1262a523fbb5b948b77e1c64936001f 100644 (file)
@@ -90,6 +90,19 @@ else
 QEMU_OPTS += --disable-tools
 endif
 
+ifeq ($(BR2_PACKAGE_LIBFUSE3),y)
+QEMU_OPTS += --enable-fuse
+QEMU_DEPENDENCIES += libfuse3
+# musl does not support SEEK_HOLE/SEEK_DATA
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+QEMU_OPTS += --disable-fuse-lseek
+else
+QEMU_OPTS += --enable-fuse-lseek
+endif
+else
+QEMU_OPTS += --disable-fuse --disable-fuse-lseek
+endif
+
 ifeq ($(BR2_PACKAGE_LIBSECCOMP),y)
 QEMU_OPTS += --enable-seccomp
 QEMU_DEPENDENCIES += libseccomp