Only advertise aio=io_uring if support is actually available
PATCH v2 1/1 Only advertise aio=io_uring if support is actually available
Change --help output for aio option to only list the aio backend options that are actually available. io_uring is an optional, linux only backend option so hide it for cases where it isn't there.
--- block/file-posix.c | 4 ++++ qemu-nbd.c | 4 ++++ qemu-options.hx | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-)
block/file-posix.c +4 -0
@@ -544,7 +544,11 @@ static QemuOptsList raw_runtime_opts = { { .name = "aio", .type =QEMU_OPT_STRING , +#ifdef CONFIG_LINUX_IO_URING .help = "host AIO implementation (threads, native, io_uring)", +#else + .help = "host AIO implementation (threads, native)", +#endif }, { .name = "aio-max-batch",
qemu-nbd.c +4 -0
@@ -147,7 +147,11 @@ static void usage(const char *name) " --cache=MODE set cache mode used to access the disk image, the\n" " valid options are: 'none', 'writeback' (default),\n" " 'writethrough', 'directsync' and 'unsafe'\n" +#ifdef CONFIG_LINUX_IO_URING " --aio=MODE set AIO mode (native, io_uring or threads)\n" +#else +" --aio=MODE set AIO mode (native or threads)\n" +#endif" --discard=MODE set discard mode (ignore, unmap)\n" " --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n" " --image-opts treat FILE as a full set of image options\n"
qemu-options.hx +5 -1
@@ -1338,7 +1338,11 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive, " [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n" " [,snapshot=on|off][,rerror=ignore|stop|report]\n" " [,werror=ignore|stop|report|enospc][,id=name]\n" - " [,aio=threads|native|io_uring]\n" + " [,aio=threads|native" +#if defined(CONFIG_LINUX_IO_URING) + "|io_uring" +#endif + "]\n" " [,readonly=on|off][,copy-on-read=on|off]\n" " [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n" " [[,bps=b]|[[,bps_rd=r][,bps_wr=w]]]\n"
Signature · 1 line
2.35.3
Quoted 3 lines · Dirk Müller
Change --help output for aio option to only list the aio backend options that are actually available.
io_uringis an optional, linux only backend option so hide it for cases where it isn't there.
As pointed out by Dan, this commit message is not quite accurate. It hides only one of the two conditional options, but 'native' is also a Linux-only optional backend (CONFIG_LINUX_AIO).
Quoted 9 lines
Reviewed-by Eric Blake <[email protected]>Signed-off-by Dirk Müller <[email protected]>--- block/file-posix.c | 4 ++++ qemu-nbd.c | 4 ++++ qemu-options.hx | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 8 lines · Eric Blake
Quoted 3 lines · Dirk Müller
Change --help output for aio option to only list the aio backend options that are actually available.
io_uringis an optional, linux only backend option so hide it for cases where it isn't there.As pointed out by Dan, this commit message is not quite accurate. It hides only one of the two conditional options, but 'native' is also a Linux-only optional backend (
CONFIG_LINUX_AIO).
Stepping back a bit - we already said that making --help machine-parseable is a non-goal, and so the intent of this patch is for human readers. But adding an #ifdef ladder to show all 4 possible combinations gets hairy; adding another option turns it into 8 combinations. Is there a better way?
What if we just document ALL strings possible in at least one build (no #ifdef ladder in the help text), but add --aio=help as a way to do a runtime list of which aio modes are understood by THIS build? It would match how we have --device=help for qemu proper, and may even be able to reuse some of that framework code (for parsing out when help is requested).
Yes, that would be a bigger patch, but it may also be easier to maintain down the road. And even though there is an #ifdef ladder at runtime, it only has O(n) growth rather than O(n^2) for each possible combination of which options are enabled, and would appear only once in the runtime rather than duplicated across each place which documents similar help text across multiple utilities.
Quoted 10 lines
Quoted 10 lines
Reviewed-by Eric Blake <[email protected]>Signed-off-by Dirk Müller <[email protected]>--- block/file-posix.c | 4 ++++ qemu-nbd.c | 4 ++++ qemu-options.hx | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 16 lines · Eric Blake
Quoted 8 lines · Eric Blake
Quoted 3 lines · Dirk Müller
Change --help output for aio option to only list the aio backend options that are actually available.
io_uringis an optional, linux only backend option so hide it for cases where it isn't there.As pointed out by Dan, this commit message is not quite accurate. It hides only one of the two conditional options, but 'native' is also a Linux-only optional backend (
CONFIG_LINUX_AIO).Stepping back a bit - we already said that making --help machine-parseable is a non-goal, and so the intent of this patch is for human readers. But adding an #ifdef ladder to show all 4 possible combinations gets hairy; adding another option turns it into 8 combinations. Is there a better way
Quoted 6 lines
What if we just document ALL strings possible in at least one build (no #ifdef ladder in the help text), but add --aio=help as a way to do a runtime list of which aio modes are understood by THIS build? It would match how we have --device=help for qemu proper, and may even be able to reuse some of that framework code (for parsing out when help is requested).
Did you literally mean '--aio=help' ? 'aio' is just an option for disks, and I don't think we want new top levelk options. So would have to be '-drive ....,aio=help', or '--blockdev ....aio=help' the latter gets tricky with nested json syntax though, so not sure it is nicer.
With regards,
Daniel
Signature · 3 lines
|: 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 :|
Quoted 24 lines · Daniel P. Berrangé
Quoted 16 lines · Eric Blake
Quoted 8 lines · Eric Blake
Quoted 3 lines · Dirk Müller
Change --help output for aio option to only list the aio backend options that are actually available.
io_uringis an optional, linux only backend option so hide it for cases where it isn't there.As pointed out by Dan, this commit message is not quite accurate. It hides only one of the two conditional options, but 'native' is also a Linux-only optional backend (
CONFIG_LINUX_AIO).Stepping back a bit - we already said that making --help machine-parseable is a non-goal, and so the intent of this patch is for human readers. But adding an #ifdef ladder to show all 4 possible combinations gets hairy; adding another option turns it into 8 combinations. Is there a better way
Quoted 6 lines
What if we just document ALL strings possible in at least one build (no #ifdef ladder in the help text), but add --aio=help as a way to do a runtime list of which aio modes are understood by THIS build? It would match how we have --device=help for qemu proper, and may even be able to reuse some of that framework code (for parsing out when help is requested).
Quoted 5 lines
Did you literally mean '--aio=help' ? 'aio' is just an option for disks, and I don't think we want new top levelk options. So would have to be '-drive ....,aio=help', or '--blockdev ....aio=help' the latter gets tricky with nested json syntax though, so not sure it is nicer.
For qemu-nbd, it literally is:
--aio=MODE set AIO mode (native, io_uring or threads)
so adding --aio=help is already a top-level option there. But for other utilities, you are right that it is a per-device option, and not a top-level thing (qemu-nbd is weird because it exposes exactly one device).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org