[PULL for-7.0 1/2] aio-posix: fix build failure io_uring 2.2

Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>
There is a newer version of this series
[PULL for-7.0 1/2] aio-posix: fix build failure io_uring 2.2
Posted by Stefan Hajnoczi 3 years ago
From: Haiyue Wang <haiyue.wang@intel.com>

The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

This leads to build failure:
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]
  182 |     io_uring_prep_poll_remove(sqe, node);
      |                                    ^~~~
      |                                    |
      |                                    AioHandler *
In file included from /root/io/qemu/include/block/aio.h:18,
                 from ../util/aio-posix.h:20,
                 from ../util/fdmon-io_uring.c:49:
/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
  415 |           __u64 user_data)
      |           ~~~~~~^~~~~~~~~
cc1: all warnings being treated as errors

Use LIBURING_HAVE_DATA64 to check whether the io_uring supports 64-bit
variants of the get/set userdata, to convert the paramter to the right
data type.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Message-Id: <20220221162401.45415-1-haiyue.wang@intel.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 util/fdmon-io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
index 1461dfa407..ab43052dd7 100644
--- a/util/fdmon-io_uring.c
+++ b/util/fdmon-io_uring.c
@@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
 {
     struct io_uring_sqe *sqe = get_sqe(ctx);
 
+#ifdef LIBURING_HAVE_DATA64
+    io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);
+#else
     io_uring_prep_poll_remove(sqe, node);
+#endif
 }
 
 /* Add a timeout that self-cancels when another cqe becomes ready */
-- 
2.35.1


Re: [PULL for-7.0 1/2] aio-posix: fix build failure io_uring 2.2
Posted by Daniel P. Berrangé 3 years ago
On Thu, Mar 17, 2022 at 04:57:42PM +0000, Stefan Hajnoczi wrote:
> From: Haiyue Wang <haiyue.wang@intel.com>
> 
> The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
> https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

Ewww, that changes the public ABI of the library on 32-bit
platforms, but failed to bump the soname version, except....

...investigating this I noticed a further change that happend
a few weeks earlier in liburing that actually dropped the
version from the soname entirely making it an unversioned
library.

This is the current shipping 2.1 version:

$ eu-readelf -a liburing.so.2.0.0  | grep SONAME
  SONAME            Library soname: [liburing.so.2]

and in git master:

$ eu-readelf -a src/liburing.so.2.2 | grep SONA
  SONAME            Library soname: [liburing.so]

Surely that's a mistake.

After the ABI incompatibility above, I would have expected
it to bump to liburing.so.3 


> 
> This leads to build failure:
> ../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
> ../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]
>   182 |     io_uring_prep_poll_remove(sqe, node);
>       |                                    ^~~~
>       |                                    |
>       |                                    AioHandler *
> In file included from /root/io/qemu/include/block/aio.h:18,
>                  from ../util/aio-posix.h:20,
>                  from ../util/fdmon-io_uring.c:49:
> /usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
>   415 |           __u64 user_data)
>       |           ~~~~~~^~~~~~~~~
> cc1: all warnings being treated as errors
> 
> Use LIBURING_HAVE_DATA64 to check whether the io_uring supports 64-bit
> variants of the get/set userdata, to convert the paramter to the right
> data type.
> 
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> Message-Id: <20220221162401.45415-1-haiyue.wang@intel.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  util/fdmon-io_uring.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
> index 1461dfa407..ab43052dd7 100644
> --- a/util/fdmon-io_uring.c
> +++ b/util/fdmon-io_uring.c
> @@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
>  {
>      struct io_uring_sqe *sqe = get_sqe(ctx);
>  
> +#ifdef LIBURING_HAVE_DATA64
> +    io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);
> +#else
>      io_uring_prep_poll_remove(sqe, node);
> +#endif
>  }
>  
>  /* Add a timeout that self-cancels when another cqe becomes ready */
> -- 
> 2.35.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 :|


Re: [PULL for-7.0 1/2] aio-posix: fix build failure io_uring 2.2
Posted by Stefan Hajnoczi 3 years ago
On Thu, Mar 17, 2022 at 05:14:20PM +0000, Daniel P. Berrangé wrote:
> On Thu, Mar 17, 2022 at 04:57:42PM +0000, Stefan Hajnoczi wrote:
> > From: Haiyue Wang <haiyue.wang@intel.com>
> > 
> > The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
> > https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b
> 
> Ewww, that changes the public ABI of the library on 32-bit
> platforms, but failed to bump the soname version, except....
> 
> ...investigating this I noticed a further change that happend
> a few weeks earlier in liburing that actually dropped the
> version from the soname entirely making it an unversioned
> library.
> 
> This is the current shipping 2.1 version:
> 
> $ eu-readelf -a liburing.so.2.0.0  | grep SONAME
>   SONAME            Library soname: [liburing.so.2]
> 
> and in git master:
> 
> $ eu-readelf -a src/liburing.so.2.2 | grep SONA
>   SONAME            Library soname: [liburing.so]
> 
> Surely that's a mistake.
> 
> After the ABI incompatibility above, I would have expected
> it to bump to liburing.so.3 

Thanks, I have sent a liburing patch to fix the soname.

Stefan
RE: [PULL for-7.0 1/2] aio-posix: fix build failure io_uring 2.2
Posted by Wang, Haiyue 3 years ago
> -----Original Message-----
> From: Daniel P. Berrangé <berrange@redhat.com>
> Sent: Friday, March 18, 2022 01:14
> To: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: qemu-devel@nongnu.org; Peter Maydell <peter.maydell@linaro.org>; Fam Zheng <fam@euphon.net>; Paolo
> Bonzini <pbonzini@redhat.com>; Wang, Haiyue <haiyue.wang@intel.com>; qemu-block@nongnu.org
> Subject: Re: [PULL for-7.0 1/2] aio-posix: fix build failure io_uring 2.2
> 
> On Thu, Mar 17, 2022 at 04:57:42PM +0000, Stefan Hajnoczi wrote:
> > From: Haiyue Wang <haiyue.wang@intel.com>
> >
> > The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
> > https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b
> 
> Ewww, that changes the public ABI of the library on 32-bit
> platforms, but failed to bump the soname version, except....
> 
> ...investigating this I noticed a further change that happend
> a few weeks earlier in liburing that actually dropped the
> version from the soname entirely making it an unversioned
> library.
> 
> This is the current shipping 2.1 version:
> 
> $ eu-readelf -a liburing.so.2.0.0  | grep SONAME
>   SONAME            Library soname: [liburing.so.2]
> 
> and in git master:
> 
> $ eu-readelf -a src/liburing.so.2.2 | grep SONA
>   SONAME            Library soname: [liburing.so]
> 
> Surely that's a mistake.
> 
> After the ABI incompatibility above, I would have expected
> it to bump to liburing.so.3
> 

It's not ABI issue:

https://github.com/axboe/liburing/issues/490

rbernon commented on Dec 5, 2021
Well the documentation says that, io_uring_prep_timeout_update, io_uring_prep_timeout_remove,
io_uring_prep_poll_update, io_uring_prep_poll_remove, io_uring_prep_cancel, all target a previously
submitted sqe with a matching user_data, but they all take a void * to match it, which isn't correct
as the match is going to happen on the 64bit value.

The previously submitted sqe user_data may be any 64bit value, including on 32bit as the submitter
may have set the value itself, without going through the io_uring_sqe_set_data helpers. For instance
if you only need an index (or fd) and operation type, which fit well on 64bits, you don't really want
to use a pointer there.

> 
> >
> > This leads to build failure:
> > ../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
> > ../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes
> integer from pointer without a cast [-Werror=int-conversion]
> >   182 |     io_uring_prep_poll_remove(sqe, node);
> >       |                                    ^~~~
> >       |                                    |
> >       |                                    AioHandler *
> > In file included from /root/io/qemu/include/block/aio.h:18,
> >                  from ../util/aio-posix.h:20,
> >                  from ../util/fdmon-io_uring.c:49:
> > /usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument
> is of type ‘AioHandler *’
> >   415 |           __u64 user_data)
> >       |           ~~~~~~^~~~~~~~~
> > cc1: all warnings being treated as errors
> >
> > Use LIBURING_HAVE_DATA64 to check whether the io_uring supports 64-bit
> > variants of the get/set userdata, to convert the paramter to the right
> > data type.
> >
> > Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> > Message-Id: <20220221162401.45415-1-haiyue.wang@intel.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  util/fdmon-io_uring.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
> > index 1461dfa407..ab43052dd7 100644
> > --- a/util/fdmon-io_uring.c
> > +++ b/util/fdmon-io_uring.c
> > @@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
> >  {
> >      struct io_uring_sqe *sqe = get_sqe(ctx);
> >
> > +#ifdef LIBURING_HAVE_DATA64
> > +    io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);
> > +#else
> >      io_uring_prep_poll_remove(sqe, node);
> > +#endif
> >  }
> >
> >  /* Add a timeout that self-cancels when another cqe becomes ready */
> > --
> > 2.35.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 :|