From patchwork Tue May 30 13:57:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9754651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D7E09602B9 for ; Tue, 30 May 2017 14:10:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C833926C9B for ; Tue, 30 May 2017 14:10:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB1272847F; Tue, 30 May 2017 14:10:02 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7A1827F07 for ; Tue, 30 May 2017 14:10:01 +0000 (UTC) Received: from localhost ([::1]:54037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFhqT-0005Rw-0W for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 May 2017 10:10:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFhfJ-0004sl-Tc for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFhfF-0007CR-Bu for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:29 -0400 Received: from mail-ve1eur01on0106.outbound.protection.outlook.com ([104.47.1.106]:21120 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFhfF-0007Bb-0D for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=m9reIvbl+GaXLW+TM5iVcQmzJM2HGH1Pw1GW8Y5wQ/E=; b=EP1F/hBVsFWadKqpw+QjUyBr73ePX9EoKcfV0HXjpYnCDub5Wv2MB2bcCbdnwGQl3iCLsz0ZQ/KoJUNt/4ugLuZhOBeDsd90HacQkONzPjknBJNZ1o1cRjxlAROdkCKWziIFZj/1df+WuNb5jzZc6nPHVqU5H9mDuseUflwaeRo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by HE1PR0801MB1993.eurprd08.prod.outlook.com (2603:10a6:3:4f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Tue, 30 May 2017 13:58:21 +0000 From: Anton Nefedov To: Date: Tue, 30 May 2017 16:57:51 +0300 Message-ID: <1496152683-102751-2-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496152683-102751-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1496152683-102751-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR02CA0033.eurprd02.prod.outlook.com (2603:10a6:6:15::46) To HE1PR0801MB1993.eurprd08.prod.outlook.com (2603:10a6:3:4f::23) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0801MB1993: X-MS-Office365-Filtering-Correlation-Id: 03023d86-c970-4570-d054-08d4a763ef77 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:HE1PR0801MB1993; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 3:wsWF35iwxAxjE70Nm1WLIwq8Gm2rwCZ0wi9c2ydo25PeKGzzNfRpRR+voWCc2JFoNkrNmnLwXbFWYSDWCU0l90Sosdj5f/G5Z+hmfWhiitXtrrEYEo32zxq4898/s2VUWWFVymkrEmGVBVO9VBIjQvJrwcYC4X869i/N6mbFcW7cU7+YPZlzF6BILPiwOMMaooA7act/1HLT9Wt6FnRs4s875vhzYxrHjMaxQLm1gJofrgA8a2cu5/WVtykjtBLBYTIDGBFKwYaMnp9TvqjZRBD3sB07Z7D3G9ggBxB8TU2EM+3fOdF7YSpUeSjf2Fln3Sc3xso4YqPJrCSqlQaNfw==; 25:WXiSajh1Ae9WxVpobWWisW2kEarOzgH27CygfoQXobJpk1Bpq8PL20/kwp994VXy3E/YI/rr+WDt6tIhYXdGe0PGpf+lE1jO7fCp5aVOZvs3VKp0f8Jh8oC+jWn7w1FLXJwBwKxn430ETjv6sJnf72iQBs2hcxctXm/JAhZ1DHSMxgbeq0O2/czLJy49lPVxGeIlSR3SOQLKsXJzQsWD20VJ6xWgLoFjIe5zqqfX4zqN0zKEnjkzvRVbLZMcJGcfm/+4hTaQehTPH84FzADn+t3YP5/zUS434WgBZbGQGcKhXORX1VKorSwceXA88eHQ/bcQPJWyTaJHnA8WWWkUC8LQrAYhcFxxgsWNEfSoIKRKmqO2Vvz/fTIzFRqk0N+R0WEiW4oX6nJWhyZ/KJWjwSkddP9N64ev3EH9WdNHGsQHnaP0nUJZ/AFWFJo4XxjdpOHI6Uq+JIzhHKncoj10pZO0icMwY9isPRwY5b3GF/U= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 31:zBs0O266OAHIhTv9yMjQWQl4RrFKCJio90TTrK5spBZMsa7r15iMgLXWTPjUiP0Vak4D3HD9APSkxfEM4Gw8aKUOcjQnlRASCBY/hrzzUddrK+TN10uqoodvzxMkdAGyd4fNja+39ijlOpEUyne6Fg2v6w6DFqWs88/LQ2C5PPDKg9jc2bwbvqZmMYjmrANGPv9b5moZl0NS1RwvPpQ4Iee/ZcP4bF6k+PecbndCU6k=; 20:ANV6y7c625wx7dMVFMFoUBYWDAs0SdUkkpPY1C/cEoyEzXbsx6vj6TsGwHiYc+enZWzJ9nvkTQTGi0QpIL/vIPopTJLTr69CcbV9ADw6TmC4YpxxOW0Aj7EQ0HjUO38bzuAw9sBwp0mX3YE1XzwLia/AgpmdxfxCGb0NW5ETiL1pCzpeSpSTWtjrSYVUncy961Kb1oj4l+CtSH29fnEth2niBB6OAdi6oPrL5gKFzWp1ltxHv7o5250UvaziSabUTIE9XdK+wUA6Hj5Dwv6+93Mm23aViYlVi3VAkDSbk/9x2/VhSgvjUP6/UUFFwx7cA/6KAf0Ls3cn7kfDNmsa/p+k/Y5Bze9WTMkj884QV23EvmYvHED5bBytmFxb1w64W51wV5/pybGBaExFCMxowWbUvyTKBCPCDKGHDg++Ijg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700073)(100105000095)(100000701073)(100105300095)(100000702073)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703073)(100105400095)(10201501046)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123558100)(20161123555025)(6072148)(100000704073)(100105200095)(100000705073)(100105500095); SRVR:HE1PR0801MB1993; BCL:0; PCL:0; RULEID:(100000800073)(100110000095)(100000801073)(100110300095)(100000802073)(100110100095)(100000803073)(100110400095)(100000804073)(100110200095)(100000805073)(100110500095); SRVR:HE1PR0801MB1993; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1993; 4:DQMztq3aPRl/u4sOBMV/xf3XL0stwPn3oPD7s5Br?= =?us-ascii?Q?oO64USmPeuYI3J3tS3PTmeZrMDpfWRd8YnXAQAqLzODkXloT9nYNXITT5j1t?= =?us-ascii?Q?eCybIa/lrAkv9yBVtk8Ui7xB6IeW2WA1PdHyrqwkxBUBHQTfTfUiETcxRUqo?= =?us-ascii?Q?INuwjfcwK8UcVkYJhpIouiQn/AeFl2g5YvhPgwL8Rx49A+msK7RS6HJBgxiC?= =?us-ascii?Q?s350HLnb5KfOVUB0RraCTljbVm/5YUvIg9mZGEICAw3fpqRqhLqrjvWsAJJH?= =?us-ascii?Q?ploD+rLc7Er3qCftXQHgjkhZDP8wY4jq6UHzNqkccAQgW+OHlU+nogTgDcH5?= =?us-ascii?Q?XqhK8CZ8aeq+PC8/211hvvdxwpnImhnurQ3WaLBNtrRPxfvHCHgxZpR0pTOq?= =?us-ascii?Q?BfRL+6P5KHAf4KRA1Qz7GZUn2mvvXvOEgp5eBINAmg81VvGmURMVl1NWRFS6?= =?us-ascii?Q?YA+Ss70E36rRbSQnWjfCxJ7ZyoHuM89OVuDHnbibyTJ3GGgnh5Zc4UQMOftf?= =?us-ascii?Q?k+KSbpTAWsoL2cEGO9K90eywKtWU7HIWVWJNhF4Da7ooTc2/BVP9xNeUymBb?= =?us-ascii?Q?nW91YD57x210bFuq/B8dHZwz1iL+tcL16C0Emz7TVXNl5RBaNsoO9Qk5Ns5A?= =?us-ascii?Q?IP7uunFYdYTvCZ55Kl2enYViugM/O2VhPYXrLdOsuSeOnrl6sdbCZwIlibTC?= =?us-ascii?Q?akPeTNPqlDK+331g++c2l1j50wsfXeE06mtoYfFvSppIP1Aq62bcDlVGQSmO?= =?us-ascii?Q?TokH9+d3SaoSq70p/D9M9TuwpJRodfc8NC/SLQZCN19P4tDgGdiEUNrh1gc5?= =?us-ascii?Q?oRoEIsodSWK9YY8m/r0dssvvwQ9ShaDqvUgTJzb6TGpmqCJ2Z42i/HAzCikK?= =?us-ascii?Q?otVqLo1/7A/oS5OSGO6G31fWlI5vS/i2jtqAVOC49+901QsCN+hYxL3YSv9w?= =?us-ascii?Q?/0a2CCWpybxYYHYbBjlLrpbb0qXaR2dTaHrk2DwuAQW85DY9tpJyEhxAnIZG?= =?us-ascii?Q?Y/yZYWmIE68JVtu8iSq0PRh5ay0N4pc/GNTgjQgRg+rXi0kTKsjnF13iW8A1?= =?us-ascii?Q?61sTz9Sf5Qltgm6c/n7h8DHhcz5TTE/Ppult5CSQyfA83h7gWN7s63nPlx6S?= =?us-ascii?Q?JZmZ5zznS550YG+Ao9HmV9vGPKTJLnpG?= X-Forefront-PRVS: 032334F434 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39830400002)(39450400003)(39410400002)(39400400002)(6506006)(6486002)(86362001)(575784001)(6916009)(2950100002)(6666003)(54906002)(38730400002)(53936002)(6512007)(25786009)(478600001)(5660300001)(47776003)(305945005)(7736002)(66066001)(107886003)(5003940100001)(110136004)(189998001)(2906002)(4326008)(50226002)(3846002)(8676002)(81166006)(6116002)(53416004)(50466002)(2351001)(48376002)(76176999)(42186005)(50986999)(33646002)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0801MB1993; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1993; 23:W0Mrtq8VqPT1zfCzNyZCg6PUrtHkEPnBvOdYI+p?= =?us-ascii?Q?IEISC3Iaesk8L3WVRFvRgqAe4sCoFtA8+MA8UJ1ihShDHvUyQ0dkQAog2DjJ?= =?us-ascii?Q?IMc5oRjFi2z0f/iLoOQMDSKukemfh9jbvbE5KbOdRWIy1MUaijqYG24rliyA?= =?us-ascii?Q?I3yQABA8F/ptgC09aaqB2yQ/0r0STUImi0DET3Yue410v/1L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XKJeoVtW6U14emsTOSKS+bxAIO+8gxRl7To0kzglCS579oCtxY2InYCNVy5TeUmXcU0ORd0a6EVjTadtUMfdFBKiGu2OGyn/azrtL4cAEOvI4; 24:Aaq9IKHm6uu2Bmukg5JZqe//sCtBrXD64ll5D+oOycJOTPj+BVSMH/Vf98NFIs8m6JykDFKgItrikBLS1gvyv/DBHRc4RLCh89BsKeK2lFM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 7:1FDF8SR2VXJwXQqKYI5Jg70IW44qW1vO/bZ/4M2s6CXiGzQVQjVPuSMl3IyGvQ3+IxnPKKk2Qn2/p+hXEcItqCLhX6XYxlbUgk8ACs9SohKCTi1ELTe6Bfg6sP2m1s2dntj8JKgEKWRqe2Tb8wkRiZVs2y34LSPWnNseNJnGEuoU9LpNNrI8Ao5XNUpmWLIRooMjL14pQbP5Cy+mmJ7OdRsVHQm2KwV4/XnKTNvavP3SehjPNmBZ9yPILJHX7XPABbnF/IwPrTiW+snVJq9jYppun3rki2UgnIVdvtNIUAGNVplYh6sxpA7hvHXZNf4c8gLZbnlu+usrOvJ/D4vWUw==; 20:axtYm4XwaTbRT/rk+C0NFmPGHtY5ve3rRiNRKAVgg/qSon3/AykCd6jHl0h4SjL2GA+T0XNB6CekMWJEmYqbGVNoPgqrIs30bLa3mrOs5iAsA4Tg1+3Csem3JxNLo/bItHqx8+1RJri5IQSKE5xdofbTyPqrzLgGmlZ3Pzv3oiY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2017 13:58:21.9523 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1993 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.1.106 Subject: [Qemu-devel] [PATCH v3 01/13] char: move QemuOpts->ChardevBackend translation to a separate func X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Anton Nefedov , den@virtuozzo.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP parse function will be used by the following patch Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy --- chardev/char.c | 70 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 4e24dc3..3a0f543 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -854,17 +854,13 @@ help_string_append(const char *name, void *opaque) g_string_append_printf(str, "\n%s", name); } -Chardev *qemu_chr_new_from_opts(QemuOpts *opts, - Error **errp) +static ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error **errp) { Error *local_err = NULL; const ChardevClass *cc; - Chardev *chr; int i; ChardevBackend *backend = NULL; const char *name = qemu_opt_get(opts, "backend"); - const char *id = qemu_opts_id(opts); - char *bid = NULL; if (name == NULL) { error_setg(errp, "chardev: \"%s\" missing backend", @@ -872,21 +868,6 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, return NULL; } - if (is_help_option(name)) { - GString *str = g_string_new(""); - - chardev_name_foreach(help_string_append, str); - - error_report("Available chardev backend types: %s", str->str); - g_string_free(str, true); - exit(0); - } - - if (id == NULL) { - error_setg(errp, "chardev: no id specified"); - return NULL; - } - for (i = 0; i < ARRAY_SIZE(chardev_alias_table); i++) { if (g_strcmp0(chardev_alias_table[i].alias, name) == 0) { name = chardev_alias_table[i].typename; @@ -902,16 +883,12 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, backend = g_new0(ChardevBackend, 1); backend->type = CHARDEV_BACKEND_KIND_NULL; - if (qemu_opt_get_bool(opts, "mux", 0)) { - bid = g_strdup_printf("%s-base", id); - } - - chr = NULL; if (cc->parse) { cc->parse(opts, backend, &local_err); if (local_err) { error_propagate(errp, local_err); - goto out; + qapi_free_ChardevBackend(backend); + return NULL; } } else { ChardevCommon *ccom = g_new0(ChardevCommon, 1); @@ -919,6 +896,47 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, backend->u.null.data = ccom; /* Any ChardevCommon member would work */ } + return backend; +} + +Chardev *qemu_chr_new_from_opts(QemuOpts *opts, Error **errp) +{ + const ChardevClass *cc; + Chardev *chr = NULL; + ChardevBackend *backend = NULL; + const char *name = qemu_opt_get(opts, "backend"); + const char *id = qemu_opts_id(opts); + char *bid = NULL; + + if (name && is_help_option(name)) { + GString *str = g_string_new(""); + + chardev_name_foreach(help_string_append, str); + + error_report("Available chardev backend types: %s", str->str); + g_string_free(str, true); + exit(0); + } + + if (id == NULL) { + error_setg(errp, "chardev: no id specified"); + return NULL; + } + + backend = qemu_chr_parse_opts(opts, errp); + if (backend == NULL) { + return NULL; + } + + cc = char_get_class(name, errp); + if (cc == NULL) { + goto out; + } + + if (qemu_opt_get_bool(opts, "mux", 0)) { + bid = g_strdup_printf("%s-base", id); + } + chr = qemu_chardev_new(bid ? bid : id, object_class_get_name(OBJECT_CLASS(cc)), backend, errp);