qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH for 7.1] linux-user: fix compat with glibc >= 2.36 sys/mount.h
Date: Wed, 10 Aug 2022 10:32:46 +0100	[thread overview]
Message-ID: <YvN7Phdaw6b8D7ky@redhat.com> (raw)
In-Reply-To: <20220802164134.1851910-1-berrange@redhat.com>

Laurent: ping,

Can you consider queuing this so 7.1 isn't broken with latest glibc
releases.

On Tue, Aug 02, 2022 at 12:41:34PM -0400, Daniel P. Berrangé wrote:
> The latest glibc 2.36 has extended sys/mount.h so that it
> defines the FSCONFIG_* enum constants. These are historically
> defined in linux/mount.h, and thus if you include both headers
> the compiler complains:
> 
> In file included from /usr/include/linux/fs.h:19,
>                  from ../linux-user/syscall.c:98:
> /usr/include/linux/mount.h:95:6: error: redeclaration of 'enum fsconfig_command'
>    95 | enum fsconfig_command {
>       |      ^~~~~~~~~~~~~~~~
> In file included from ../linux-user/syscall.c:31:
> /usr/include/sys/mount.h:189:6: note: originally defined here
>   189 | enum fsconfig_command
>       |      ^~~~~~~~~~~~~~~~
> /usr/include/linux/mount.h:96:9: error: redeclaration of enumerator 'FSCONFIG_SET_FLAG'
>    96 |         FSCONFIG_SET_FLAG       = 0,    /* Set parameter, supplying no value */
>       |         ^~~~~~~~~~~~~~~~~
> /usr/include/sys/mount.h:191:3: note: previous definition of 'FSCONFIG_SET_FLAG' with type 'enum fsconfig_command'
>   191 |   FSCONFIG_SET_FLAG       = 0,    /* Set parameter, supplying no value */
>       |   ^~~~~~~~~~~~~~~~~
> ...snip...
> 
> QEMU doesn't include linux/mount.h, but it does use
> linux/fs.h and thus gets linux/mount.h indirectly.
> 
> glibc acknowledges this problem but does not appear to
> be intending to fix it in the forseeable future, simply
> documenting it as a known incompatibility with no
> workaround:
> 
>   https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
>   https://sourceware.org/glibc/wiki/Synchronizing_Headers
> 
> To address this requires either removing use of sys/mount.h
> or linux/fs.h, despite QEMU needing declarations from
> both.
> 
> This patch removes linux/fs.h, meaning we have to define
> various FS_IOC constants that are now unavailable.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  linux-user/syscall.c | 18 ++++++++++++++++++
>  meson.build          |  2 ++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index b27a6552aa..52d178afe7 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -95,7 +95,25 @@
>  #include <linux/soundcard.h>
>  #include <linux/kd.h>
>  #include <linux/mtio.h>
> +
> +#ifdef HAVE_SYS_MOUNT_FSCONFIG
> +/*
> + * glibc >= 2.36 linux/mount.h conflicts with sys/mount.h,
> + * which in turn prevents use of linux/fs.h. So we have to
> + * define the constants ourselves for now.
> + */
> +#define FS_IOC_GETFLAGS                _IOR('f', 1, long)
> +#define FS_IOC_SETFLAGS                _IOW('f', 2, long)
> +#define FS_IOC_GETVERSION              _IOR('v', 1, long)
> +#define FS_IOC_SETVERSION              _IOW('v', 2, long)
> +#define FS_IOC_FIEMAP                  _IOWR('f', 11, struct fiemap)
> +#define FS_IOC32_GETFLAGS              _IOR('f', 1, int)
> +#define FS_IOC32_SETFLAGS              _IOW('f', 2, int)
> +#define FS_IOC32_GETVERSION            _IOR('v', 1, int)
> +#define FS_IOC32_SETVERSION            _IOW('v', 2, int)
> +#else
>  #include <linux/fs.h>
> +#endif
>  #include <linux/fd.h>
>  #if defined(CONFIG_FIEMAP)
>  #include <linux/fiemap.h>
> diff --git a/meson.build b/meson.build
> index 294e9a8f32..30a380752c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1963,6 +1963,8 @@ config_host_data.set('HAVE_OPTRESET',
>                       cc.has_header_symbol('getopt.h', 'optreset'))
>  config_host_data.set('HAVE_IPPROTO_MPTCP',
>                       cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
> +config_host_data.set('HAVE_SYS_MOUNT_FSCONFIG',
> +                     cc.has_header_symbol('sys/mount.h', 'FSCONFIG_SET_FLAG'))
>  
>  # has_member
>  config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
> -- 
> 2.37.1
> 

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 :|



  parent reply	other threads:[~2022-08-10  9:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 16:41 [PATCH for 7.1] linux-user: fix compat with glibc >= 2.36 sys/mount.h Daniel P. Berrangé
2022-08-02 18:29 ` Richard W.M. Jones
2022-08-02 18:34   ` Richard W.M. Jones
2022-08-02 19:01 ` Peter Maydell
2022-08-03  9:27 ` Daniel P. Berrangé
2022-08-05  7:33   ` Florian Weimer
2022-08-10  9:32 ` Daniel P. Berrangé [this message]
2022-08-10 16:37 ` Laurent Vivier
2022-10-01 21:34 ` Andreas Schwab
2022-10-03  8:31   ` Daniel P. Berrangé
2022-10-04  9:46     ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YvN7Phdaw6b8D7ky@redhat.com \
    --to=berrange@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).