block: warn about aio=native if libaio is unavailable
v3 cover block: warn about aio=native if libaio is unavailable
v3:
* Fix Patch 2 commit description because the mention of raw-posix.c ignored Windows [Markus]
* Drop #ifdef CONFIG_LINUX_AIO from qemu-nbd.c
v2:
* Banish CONFIG_LINUX_AIO from blockdev.c, that is raw-posix.c's business [Kevin]
* Print the warning in the same way as the aio=native,cache.direct=off deprecation warning [Kevin]
Stefan Hajnoczi (3):
raw-posix: warn about BDRV_O_NATIVE_AIO if libaio is unavailable
blockdev: always compile in -drive aio= parsing
qemu-nbd: always compile in --aio=MODE option
block/raw-posix.c | 11 ++++++++++- blockdev.c | 2 -- qemu-nbd.c | 8 -------- 3 files changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.4.3
PATCH v3 1/3 raw-posix: warn about BDRV_O_NATIVE_AIO if libaio is unavailable
raw-posix.c silently ignores BDRV_O_NATIVE_AIO if libaio is unavailable. It is confusing when aio=native performance is identical to aio=threads because the binary was accidentally built without libaio.
Print a deprecation warning if -drive aio=native is used with a binary that does not support libaio. There are probably users using aio=native who would be inconvenienced if QEMU suddenly refused to start their guests. In the future this will become an error.
--- block/raw-posix.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
block/raw-posix.c +10 -1
@@ -519,7 +519,16 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,"future QEMU versions.\n" , bs->filename); } -#endif +#else +if (bdrv_flags &BDRV_O_NATIVE_AIO ) { +error_printf ("WARNING: aio=native was specified for '%s', but " +"is not supported in this build. Falling back to " +"aio=threads.\n" +" This will become an error condition in " +"future QEMU versions.\n" , + bs->filename); + } +#endif /* !defined(CONFIG_LINUX_AIO) */ s->has_discard = true; s->has_write_zeroes = true;
Signature · 1 line
2.4.3
PATCH v3 2/3 blockdev: always compile in -drive aio= parsing
In reply to Stefan HajnocziCONFIG_LINUX_AIO is an implementation detail of raw-posix.c. Don't mention CONFIG_LINUX_AIO in blockdev.c. Let block drivers decide what to do with BDRV_O_NATIVE_AIO. They may print an error if it is unsupported.
--- blockdev.c | 2 -- 1 file changed, 2 deletions(-)
blockdev.c +0 -2
@@ -405,7 +405,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, bdrv_flags |=BDRV_O_NO_FLUSH ; } -#ifdef CONFIG_LINUX_AIO if ((buf =qemu_opt_get (opts,"aio" )) !=NULL ) {if (!strcmp (buf,"native" )) { bdrv_flags |=BDRV_O_NATIVE_AIO ;
@@ -416,7 +415,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, goto early_err; } } -#endif if ((buf =qemu_opt_get (opts,"format" )) !=NULL ) {if (is_help_option (buf)) {
Signature · 1 line
2.4.3
PATCH v3 3/3 qemu-nbd: always compile in --aio=MODE option
In reply to Stefan HajnocziThe --aio=MODE option enables Linux AIO or Windows overlapped I/O.
The #ifdef CONFIG_LINUX_AIO was a layering violation that also prevented Windows overlapped I/O from being used.
Now that raw-posix.c prints an error when Linux AIO has not been compiled in, we can unconditionally compile the option into qemu-nbd.
After this patch qemu-nbd --aio=native works on Windows.
--- qemu-nbd.c | 8 -------- 1 file changed, 8 deletions(-)
qemu-nbd.c +0 -8
@@ -98,9 +98,7 @@ static void usage(const char *name)" '[ID_OR_NAME]'\n" " -n, --nocache disable host cache\n" " --cache=MODE set cache mode (none, writeback, ...)\n" -#ifdef CONFIG_LINUX_AIO" --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, discard)\n" "\n"
@@ -429,9 +427,7 @@ int main(int argc, char **argv) { "load-snapshot", 1, NULL, 'l' }, { "nocache", 0, NULL, 'n' }, { "cache", 1, NULL, QEMU_NBD_OPT_CACHE }, -#ifdef CONFIG_LINUX_AIO { "aio", 1, NULL, QEMU_NBD_OPT_AIO }, -#endif { "discard", 1, NULL, QEMU_NBD_OPT_DISCARD }, { "detect-zeroes", 1, NULL, QEMU_NBD_OPT_DETECT_ZEROES }, { "shared", 1, NULL, 'e' },
@@ -450,9 +446,7 @@ int main(int argc, char **argv)int fd;bool seen_cache = false;bool seen_discard = false; -#ifdef CONFIG_LINUX_AIO bool seen_aio = false; -#endif pthread_t client_thread;const char *fmt =NULL ;Error *local_err =NULL ;
@@ -485,7 +479,6 @@ int main(int argc, char **argv)errx (EXIT_FAILURE ,"Invalid cache mode `%s'" , optarg); }break ; -#ifdef CONFIG_LINUX_AIO case QEMU_NBD_OPT_AIO :if (seen_aio) {errx (EXIT_FAILURE ,"--aio can only be specified once" );
@@ -499,7 +492,6 @@ int main(int argc, char **argv)errx (EXIT_FAILURE ,"invalid aio mode `%s'" , optarg); }break ; -#endif case QEMU_NBD_OPT_DISCARD :if (seen_discard) {errx (EXIT_FAILURE ,"--discard can only be specified once" );
Signature · 1 line
2.4.3
Quoted 4 lines · Stefan Hajnoczi
v3:
* Fix Patch 2 commit description because the mention ofraw-posix.cignored Windows [Markus]
* Drop #ifdefCONFIG_LINUX_AIOfromqemu-nbd.c
No fishy uses of CONFIG_LINUX_AIO left.
Series
Kevin Wolf
AppliedAm 23.07.2015 um 14:48 hat Stefan Hajnoczi geschrieben:
Quoted 10 lines
v3:
* Fix Patch 2 commit description because the mention ofraw-posix.cignored Windows [Markus]
* Drop #ifdefCONFIG_LINUX_AIOfromqemu-nbd.cv2:
* BanishCONFIG_LINUX_AIOfromblockdev.c, that is raw-posix.c's business [Kevin]
* Print the warning in the same way as the aio=native,cache.direct=off deprecation warning [Kevin]
Thanks, applied to my block-next branch for 2.5.
Kevin