diff mbox series

[v6,13/14] qemu-nbd: adds option for aio engines

Message ID 20190719133530.28688-14-mehta.aaru20@gmail.com
State New
Headers show
Series Add support for io_uring | expand

Commit Message

Aarushi Mehta July 19, 2019, 1:35 p.m. UTC
Signed-off-by: Aarushi Mehta <mehta.aaru20@gmail.com>
---
 qemu-nbd.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Stefan Hajnoczi July 19, 2019, 3:43 p.m. UTC | #1
On Fri, Jul 19, 2019 at 07:05:29PM +0530, Aarushi Mehta wrote:
> Signed-off-by: Aarushi Mehta <mehta.aaru20@gmail.com>
> ---
>  qemu-nbd.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Eric Blake July 19, 2019, 3:55 p.m. UTC | #2
On 7/19/19 8:35 AM, Aarushi Mehta wrote:
> Signed-off-by: Aarushi Mehta <mehta.aaru20@gmail.com>
> ---
>  qemu-nbd.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 

Missing a patch to qemu-nbd.texi to document this.

> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index a8cb39e510..e5a71b3501 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -135,7 +135,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"
> -"      --aio=MODE            set AIO mode (native or threads)\n"
> +"      --aio=MODE            set AIO mode (native, io_uring or threads)\n"
>  "      --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"
> @@ -718,13 +718,9 @@ int main(int argc, char **argv)
>                  exit(EXIT_FAILURE);
>              }
>              seen_aio = true;
> -            if (!strcmp(optarg, "native")) {
> -                flags |= BDRV_O_NATIVE_AIO;
> -            } else if (!strcmp(optarg, "threads")) {
> -                /* this is the default */
> -            } else {
> -               error_report("invalid aio mode `%s'", optarg);
> -               exit(EXIT_FAILURE);
> +            if (bdrv_parse_aio(optarg, &flags) < 0) {
> +                error_report("Invalid aio mode `%s'", optarg);
> +                exit(EXIT_FAILURE);

Nice - you're also fixing an indentation error.  We aren't consistent on
whether error messages start with upper or lowercase, so I will overlook
that change.

But as long as you're touching the line, could you also change `' to be
''?  The former form looks awkward in modern type, and while it was
popular 20 years ago, nowadays it makes programs look dated (or
identifies you as a user of m4...).
diff mbox series

Patch

diff --git a/qemu-nbd.c b/qemu-nbd.c
index a8cb39e510..e5a71b3501 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -135,7 +135,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"
-"      --aio=MODE            set AIO mode (native or threads)\n"
+"      --aio=MODE            set AIO mode (native, io_uring or threads)\n"
 "      --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"
@@ -718,13 +718,9 @@  int main(int argc, char **argv)
                 exit(EXIT_FAILURE);
             }
             seen_aio = true;
-            if (!strcmp(optarg, "native")) {
-                flags |= BDRV_O_NATIVE_AIO;
-            } else if (!strcmp(optarg, "threads")) {
-                /* this is the default */
-            } else {
-               error_report("invalid aio mode `%s'", optarg);
-               exit(EXIT_FAILURE);
+            if (bdrv_parse_aio(optarg, &flags) < 0) {
+                error_report("Invalid aio mode `%s'", optarg);
+                exit(EXIT_FAILURE);
             }
             break;
         case QEMU_NBD_OPT_DISCARD: