[PATCH] block/io_uring: improve error message when init fails

Fiona Ebner posted 1 patch 10 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240123135044.204985-1-f.ebner@proxmox.com
Maintainers: Aarushi Mehta <mehta.aaru20@gmail.com>, Julia Suvorova <jusual@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
block/io_uring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] block/io_uring: improve error message when init fails
Posted by Fiona Ebner 10 months, 1 week ago
The man page for io_uring_queue_init states:

> io_uring_queue_init(3) returns 0 on success and -errno on failure.

and the man page for io_uring_setup (which is one of the functions
where the return value of io_uring_queue_init() can come from) states:

> On error, a negative error code is returned. The caller should not
> rely on errno variable.

Tested using 'sysctl kernel.io_uring_disabled=2'. Output before this
change:

> failed to init linux io_uring ring

Output after this change:

> failed to init linux io_uring ring: Operation not permitted

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 block/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/io_uring.c b/block/io_uring.c
index d77ae55745..d11b2051ab 100644
--- a/block/io_uring.c
+++ b/block/io_uring.c
@@ -432,7 +432,7 @@ LuringState *luring_init(Error **errp)
 
     rc = io_uring_queue_init(MAX_ENTRIES, ring, 0);
     if (rc < 0) {
-        error_setg_errno(errp, errno, "failed to init linux io_uring ring");
+        error_setg_errno(errp, -rc, "failed to init linux io_uring ring");
         g_free(s);
         return NULL;
     }
-- 
2.39.2
Re: [PATCH] block/io_uring: improve error message when init fails
Posted by Stefan Hajnoczi 10 months, 1 week ago
On Tue, Jan 23, 2024 at 02:50:44PM +0100, Fiona Ebner wrote:
> The man page for io_uring_queue_init states:
> 
> > io_uring_queue_init(3) returns 0 on success and -errno on failure.
> 
> and the man page for io_uring_setup (which is one of the functions
> where the return value of io_uring_queue_init() can come from) states:
> 
> > On error, a negative error code is returned. The caller should not
> > rely on errno variable.
> 
> Tested using 'sysctl kernel.io_uring_disabled=2'. Output before this
> change:
> 
> > failed to init linux io_uring ring
> 
> Output after this change:
> 
> > failed to init linux io_uring ring: Operation not permitted
> 
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
>  block/io_uring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied to my master tree:
https://gitlab.com/stefanha/qemu/commits/master

Stefan