From patchwork Thu Aug 1 23:40:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 11071599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73E4E746 for ; Thu, 1 Aug 2019 23:48:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 622F728701 for ; Thu, 1 Aug 2019 23:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5464D28756; Thu, 1 Aug 2019 23:48:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E1D7A28701 for ; Thu, 1 Aug 2019 23:48:21 +0000 (UTC) Received: from localhost ([::1]:59808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htKo1-0000eZ-As for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Aug 2019 19:48:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60875) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htKiI-0007Fc-2S for qemu-devel@nongnu.org; Thu, 01 Aug 2019 19:42:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htKiF-0003Qe-TE for qemu-devel@nongnu.org; Thu, 01 Aug 2019 19:42:25 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:34290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htKiF-0003Nb-80; Thu, 01 Aug 2019 19:42:23 -0400 Received: by mail-pg1-x541.google.com with SMTP id n9so28827867pgc.1; Thu, 01 Aug 2019 16:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ipr3iNyxvPc1pw+FEpkLWVBnB0CK9mROZwdZiLP7cbc=; b=uXTtlLmyGtz4fEhRzAS/eMc/qy91v4szRv/kL3zIGmtRzUbQP5zRAn2IDQdZC6j+2R wlb+/cE6XICk3UgTU5HSWCzaKtHtUIgs9gIISKqxyC5gQ+RgXUcHk0Ddz+ATKuRL27tT ofEs+F62yqBccHr1qn40g6Yd6Fm8xZkLOqoqiUkL0++jquiwhwCjlHaYT1pwS34A3A3Z nGRRWx+fvyElReTzBCIGoCvDwbgn05nrRy7sJf6165Juaa31W09DIbR5XlqvlsErb9p/ mAHj/zNSpWgZdvnGzyeev/fj/kyxctZ7Ip037bxucSEFw5uM00sXTh9wmIw2KKy0CH4v Pj0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ipr3iNyxvPc1pw+FEpkLWVBnB0CK9mROZwdZiLP7cbc=; b=LhAzsvgxeEPIKjUz+y1bsvigEhLbBflLMUrvZZcSitsE9ANsX5iWftRbbqYfuQQSVC Ln45ZKL4XkLrcZHn/zjB2LxH9s73lSClxdjFGQfIUalg0WuvWT2YNnqVJsOI51by2z64 W4c181NZwAtzcxMNbcFXwncTe06DZHmOYwtXvPcZxiZN25KYfmROt7zBlu/FUWIg8aHd Gi8aUFT75Mynlpgn05lnNqJUiM59Uyp4ZInTeMpCw6GbrZXE+nsysy1GlT4Z0jqVuygc edoW2kjZrXxPnIrSsfD7LJkI1xDkenOk0DowRcL5wjbxxfJVNI5HWyfCKi7plPCJfNU8 nN0w== X-Gm-Message-State: APjAAAVDLpXOWHj1stCDB90dfmCgKudAuEjXOvgxSARCYxnw7S/tR3tW gI7WynrET+AgFWnA9e/DU/TdRodGOnQAUQ== X-Google-Smtp-Source: APXvYqwyGgFMmkRY/U1ruYLuWPo7DAdILhS2Odyq/LqYjxPf5K7wJ9niiU4ZxWBFLSK20+WSy+xnBg== X-Received: by 2002:a65:64c4:: with SMTP id t4mr82477311pgv.298.1564702937553; Thu, 01 Aug 2019 16:42:17 -0700 (PDT) Received: from localhost.localdomain ([2402:3a80:572:3de5:765:cb16:92cd:ee3e]) by smtp.gmail.com with ESMTPSA id g18sm117975426pgm.9.2019.08.01.16.42.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 16:42:16 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Fri, 2 Aug 2019 05:10:25 +0530 Message-Id: <20190801234031.29561-12-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801234031.29561-1-mehta.aaru20@gmail.com> References: <20190801234031.29561-1-mehta.aaru20@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v9 11/17] qemu-io: adds option to use aio engine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Maxim Levitsky , Sergio Lopez , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Aarushi Mehta Reviewed-by: Stefan Hajnoczi --- qemu-io.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index f64eca6940..0abb4af134 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -130,7 +130,8 @@ static void open_help(void) " -C, -- use copy-on-read\n" " -n, -- disable host cache, short for -t none\n" " -U, -- force shared permissions\n" -" -k, -- use kernel AIO implementation (on Linux only)\n" +" -k, -- use kernel AIO implementation (Linux only, prefer use of -i)\n" +" -i, -- use AIO mode (threads, native or io_uring)\n" " -t, -- use the given cache mode for the image\n" " -d, -- use the given discard mode for the image\n" " -o, -- options to be given to the block driver" @@ -172,7 +173,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv) QDict *opts; bool force_share = false; - while ((c = getopt(argc, argv, "snCro:kt:d:U")) != -1) { + while ((c = getopt(argc, argv, "snCro:ki:t:d:U")) != -1) { switch (c) { case 's': flags |= BDRV_O_SNAPSHOT; @@ -204,6 +205,13 @@ static int open_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } break; + case 'i': + if (bdrv_parse_aio(optarg, &flags) < 0) { + error_report("Invalid aio option: %s", optarg); + qemu_opts_reset(&empty_opts); + return -EINVAL; + } + break; case 'o': if (imageOpts) { printf("--image-opts and 'open -o' are mutually exclusive\n"); @@ -291,7 +299,9 @@ static void usage(const char *name) " -n, --nocache disable host cache, short for -t none\n" " -C, --copy-on-read enable copy-on-read\n" " -m, --misalign misalign allocations for O_DIRECT\n" -" -k, --native-aio use kernel AIO implementation (on Linux only)\n" +" -k, --native-aio use kernel AIO implementation\n" +" (Linux only, prefer use of -i)\n" +" -i, --aio=MODE use AIO mode (threads, native or io_uring)\n" " -t, --cache=MODE use the given cache mode for the image\n" " -d, --discard=MODE use the given discard mode for the image\n" " -T, --trace [[enable=]][,events=][,file=]\n" @@ -489,7 +499,7 @@ static QemuOptsList file_opts = { int main(int argc, char **argv) { int readonly = 0; - const char *sopt = "hVc:d:f:rsnCmkt:T:U"; + const char *sopt = "hVc:d:f:rsnCmki:t:T:U"; const struct option lopt[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, @@ -501,6 +511,7 @@ int main(int argc, char **argv) { "copy-on-read", no_argument, NULL, 'C' }, { "misalign", no_argument, NULL, 'm' }, { "native-aio", no_argument, NULL, 'k' }, + { "aio", required_argument, NULL, 'i' }, { "discard", required_argument, NULL, 'd' }, { "cache", required_argument, NULL, 't' }, { "trace", required_argument, NULL, 'T' }, @@ -568,6 +579,12 @@ int main(int argc, char **argv) case 'k': flags |= BDRV_O_NATIVE_AIO; break; + case 'i': + if (bdrv_parse_aio(optarg, &flags) < 0) { + error_report("Invalid aio option: %s", optarg); + exit(1); + } + break; case 't': if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) { error_report("Invalid cache option: %s", optarg);