> -----Original Message----- > From: Stefan Hajnoczi <stefa...@redhat.com> > Sent: Monday, February 21, 2022 22:54 > To: Wang, Haiyue <haiyue.w...@intel.com> > Cc: qemu-de...@nongnu.org; Fam Zheng <f...@euphon.net>; open list:Block I/O > path <qemu-block@nongnu.org> > Subject: Re: [PATCH v1] aio-posix: fix build failure io_uring 2.2 > > On Fri, Feb 18, 2022 at 12:16:27AM +0800, Haiyue Wang wrote: > > 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 > > > > So convert the paramter to right type according to the io_uring define. > > > > Signed-off-by: Haiyue Wang <haiyue.w...@intel.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..e7febbf11f 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)node); > > +#else > > io_uring_prep_poll_remove(sqe, node); > > +#endif > > } > > Thanks for the patch. I suggest using the same approach as the liburing > commit to avoid the #ifdef:
Old version is "void *user_data", so need to use ' LIBURING_HAVE_DATA64', also, as the comment said: /* * Tell the app the have the 64-bit variants of the get/set userdata */ #define LIBURING_HAVE_DATA64 And yes, two casts seems be more safe: (__u64)(uintptr_t)node > > diff --git a/test/poll-cancel-ton.c b/test/poll-cancel-ton.c > index f0875cd..05bf565 100644 > --- a/test/poll-cancel-ton.c > +++ b/test/poll-cancel-ton.c > @@ -55,7 +55,7 @@ static int del_polls(struct io_uring *ring, int fd, int nr) > > sqe = io_uring_get_sqe(ring); > data = sqe_index[lrand48() % nr]; > - io_uring_prep_poll_remove(sqe, data); > + io_uring_prep_poll_remove(sqe, > (__u64)(uintptr_t)data); > > So the QEMU add_poll_remove_sqe() function would do: > > io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node); > > Was there a reason why you chose an #ifdef instead? > > Thanks, > Stefan