From patchwork Fri May 19 12:47:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9737153 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 AFB366034C for ; Fri, 19 May 2017 12:53:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A481228929 for ; Fri, 19 May 2017 12:53:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9924628930; Fri, 19 May 2017 12:53:33 +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 0E87828929 for ; Fri, 19 May 2017 12:53:33 +0000 (UTC) Received: from localhost ([::1]:58643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBhPQ-000422-B8 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 May 2017 08:53:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBhK0-0000Zz-95 for qemu-devel@nongnu.org; Fri, 19 May 2017 08:47:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBhJz-0004JX-3b for qemu-devel@nongnu.org; Fri, 19 May 2017 08:47:56 -0400 Received: from mail-eopbgr00136.outbound.protection.outlook.com ([40.107.0.136]:31167 helo=EUR02-AM5-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 1dBhJy-0004AG-OE for qemu-devel@nongnu.org; Fri, 19 May 2017 08:47:55 -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=KPQpIkkXAoBF7fsyEh5l4i9xcK8aicuF7sPo/z5qiyU=; b=HB6RYrXcYDtXaDrQeOJCvlzRDFqEf9+3tgGNNK99Jup0c9ttQ+EPnrGLRvmm4yjgTKb5hUgyj7vQqUhvLfeRL0dSczD3mV+j/WXUifRziFOIkR5O7oeNA/ocUIocNNO2665dvreXZxpxY8+QaCWPPeLSrHi2mnpnlazxo5dYDJo= 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 DB6PR0801MB1989.eurprd08.prod.outlook.com (10.168.85.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Fri, 19 May 2017 12:47:49 +0000 From: Anton Nefedov To: Date: Fri, 19 May 2017 15:47:17 +0300 Message-ID: <1495198042-124203-5-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495198042-124203-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1495198042-124203-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0002.EURPRD10.PROD.OUTLOOK.COM (10.171.79.12) To DB6PR0801MB1989.eurprd08.prod.outlook.com (10.168.85.150) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB6PR0801MB1989: X-MS-Office365-Filtering-Correlation-Id: 1088fc39-5d78-4f9d-0c82-08d49eb5422c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:DB6PR0801MB1989; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 3:JOxOH6mxP+7yG3pxFgOHCrMJ45txqSlKiZRFwGNwuMyJ7ktvvYqWeQz152GgsgvgEertyLDZFQLbncBEGMHbxijhlQsbjBdEyDnJtcW74EXo7d3FRP7scBKfuaA4zl6Jsufoq8vs2w678XyL9Ssn8USvkIlQwl2ykJjFuKglPICg9OJ4W/Xq+DWZioeQJQcowwcPC3LQFLbG+uDEg+tKfypOdsB1etn1LsutlsP0Gjjp4aoCfxmOZUS0hWc4ez/CEt736B5amzs0Uy/Y1bx5jYtOP0y8yS3rrX2iT0J/3lSOXOeVZTbx3Bq1iSSE+3t40vaSdZAQxm51u/bs1XO5aw==; 25:DVaCDQv+43L2awDH8yhZhtBujIAmNwO/qQKWSAhHnUWWE6vM8zFJPAQEmO/lW1PoeSAQCky+PrOzvwxSsQQ0zF6MglSfo8MD0UHK/n2p9vqgPHilpltgMIxgNYpHf0lKjkmGnwo/s91JKdY7UK/reHKiKmXGqzAY19rUkdLtg0WyZNT8M5BcVS5DLk91hnAZ/HIYV5U2F0XiPSkIpFWPD2VKfQ1CFLEyVlqhy5NFtJrq/nexrF0ZCPt7Xpqgk88wjcWp5RPNHjmZAx1BnBxZWTRQqWC3ceWqppOviA8OdObgv0bopoBil8gQGu5kL8mWbqxej2FQKPUqDky5rTd9MEE7M/mNhc79bfbChBsaODPVA7XrAT/3Hkbusk3ayYbbEzSM/HQqAF2DjwVdaLh7gJjlNTohcv0Z+6LiPsFGSuxz8ScA3GQINE2Ls6zWXkzSRiJHOkSd4f6U4mBcnZgfucDSVt/EcMPOnaGlg4AA+Pg= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 31:X7qUfJQ0kQtR1tNrK+ohMtcASdgri4366IBIlTzFb+VWWa3NaQubIPLDXtnFfyunM/BMH5Zk6GHuC205q4aG25poliWWwUai/K9NLVxSML7ZIETS1S87QkAeQ0vK4Xpt72PIPeoUtKVeAPOUAa4bLKl+MWmTLh0hvrVvpM4tJ0wlpZdSsscR6jRAywnb1d2UPAu8FLlILh5lJJIMttSqgxF1tnlO52hj6lVk0Zx4KJU=; 20:Bto28HmcHCL7W0aCmdHjyRtSIVkDwwzpuracmCua5jFTSR4GjdXx/PnH63gMRRY0nAc9+0uN/Ak25gd2n0u8TQWyg44Y56NWwnsMT1RPwtH4Evmvji/stYOd7MxoFA+jZOapWGW/ZbHYKClgBWINvPQ/Y2sPzYLWuIHBOjlBehTV/vW3p0WWM17CcZsUqLiV/RlRbZqZt/EDVtPCFfXa/phxSvizwqdiNGD6GHzTbzlaVh2vVXCIJbqhIGh6xN7LNi4+tMAcFzdiG6KT2VdsLzStnuU9EfV0dlyLiye9PMJF7Dol9hg43hBWOQCvG3WhZI2iYny1SS7Chqv/rREMeL6Fn5ri2bJ+sq/KqdrDecOjTI3s0CTb17lDLa67r9LsN8pOtkMuMv5OIwDfYsocD0HNOrx0zjzrx9JmpBzeyek= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6041248)(20161123560025)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201703061421075)(6072148); SRVR:DB6PR0801MB1989; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1989; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 4:Uo0GbTY/f5JEr2MshmxsLjEvtXKKlfh/rt311VJgzzgMp1eC6ShUKVNQ0kZAG16hi+9YzAHbgHtc743o3npv4H4/cyqQPiN09GqKvfJ/NLPtJPw0rf+DC/xB7o8xRBAt0fuoWqQjLGYtS5ILLufiLlYeGYbCx14emKkoKu8NEX1HHfBepaLH1Ukq+vZu08F6bwU+DgimSZiYekABBxCXgDk+FW0IDvjXTW9yWXa+3hM4cJSEriQ9TgtiReKyR+JR0x6YjiRmLmaVR6wUiVMGRh8NMBfVWB7WB0y6hdyhL0ofjylcJ+uGM4KmnkwaLF1y9REdYX0OQYRrkjPmn/OLQTolEq04zzRYEa+qYiR25OV7ypvrQgcvp0AXaJ4/dals83v7AxFnAaJhOjpsmPBN1pghwyPMbXeaUhvg41nalbzDlyCvDcg18B5DU+uyKPZ0DnLU8mctMcOvhSh/84FTM53mb6IRXJLd5jtKnB+4WfG+pgIteqXDdud3fYqLy6e4vwXEKra/im7V3xGm0dNZS5EunveVPsLJygsKzHD1qTNqYyHQC/QmFYwWUS5kbc/pdvD5AsSMd3tEKDLe0F0jpSJayilXa+SiplG3N/Xp5gzoX4ar//TzA12VeMrcyr3rj76AGppz47krwkvYek+FUpEK+RqslnULrZ8Zbzcs1lufRPofTIrRNSfd87ZqCZDLjZHojqrCCerOfe8I2M75Pg== X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39400400002)(39450400003)(33646002)(48376002)(230783001)(5003940100001)(53936002)(38730400002)(25786009)(2351001)(6506006)(6486002)(4326008)(110136004)(5660300001)(36756003)(7736002)(6916009)(2950100002)(305945005)(6666003)(66066001)(2906002)(189998001)(50226002)(50466002)(54906002)(508600001)(86362001)(6512007)(81166006)(8676002)(50986999)(53416004)(3846002)(76176999)(575784001)(42186005); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0801MB1989; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0801MB1989; 23:gi+hzzefPXmmoV7RTjKNVFSQAEetYgbd4QIX+ut?= =?us-ascii?Q?JK9BQMvMcgBTYapw5My8+J5wWhzD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gptFWZPaPtKKZiBfUBYuVTqFUpbJnmnvKyGSA0/YnfdLmxlWeo?= =?us-ascii?Q?WXp/hix48mRiX5B8L2wjhTMWW?= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 6:mbHKTBPoHDYiMEtMqfHEgK99LjrK5WL84hhHmjlcL50QTTzwalrUJ7yitkIFMOIUMuL5zjmQp+eUT7dbi81i84YT9yZYwf+j9Sp4Kdo0FfqPB4gZQWt+GogZ0ofDTNl95sZGu4mQcRJMnGRzEWQ9w5sXiwO7wn36f2tP+HH4ZL6r3thUlBUoFFRYm0KnKM7mpKbuBoaxkqSLN9ODdH/8mgFxFFcZLZ46SRVIP3WtLmOOtnmdnNgYQC0ki4U0jWCn/pSVauC9On24UVAJhLnwkSPj5jV1IHpR0tJpjFHaHakXY5CaGUWw2wrm4jZ8pzUWvCfIM9nsV3IvMnEBCi4uy4allEhDXdWE6+MpvCOISHovulsH6bAaZv/jiKqrSxEk/5V1ri5FOdu1Cv/ZzMq720y10Fa93B8+Unro78tPvEI9pk0XQv/sIZibx5uy8foTuUsfEPtI0tfzx/msFsi6ZMWM10kFOrgNWwq766DFEP3W8SUZGgQaBLJfzrifjUN4onpTD0b4CuUR11yf+OTxBA==; 5:/znlZk9BsBljQ/WNkqEvflvrOlLW1T6+tMY3HV6Eg90xn8Ca14Of/XnOrXI8ri/HT8hP//CFvhsUJ6SQQByJSLMdh7ya/GwTFtFfhRDToW0gjEJwYrgWFo+XPqNp9P5pySOQoCNZqq7mD3nlO4uN/g==; 24:Zg9t3bmWW0e3a01wsOQH5gpuyD37oB50JhKKrCvcl7+2hySgvyI6dMY1hBDbgbM1/TP2e5CeA8YlyacrzKVlLHe5smOPHqnB1CCs4yaj8OI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 7:e4q8lC5jvA1us4gwsqk4JPs0BHnPFA0CdgauihWO6HJskYDfvUwhkkstC07Q06RSkgyoo0dZhU0+M2VNGDWUQ52BRVTY4DgeBmhDD2styK13qzofaBVxvo1/7mLvz12XUrxKVss/cPvU1ZfTOt06uSJgaYe3BE9I8NDjdEs+OpfKIw2sa3pH1rEoF71OE08UFpCxFd0I4WDN8PUWsbafwv+piVWsYRUmX3ZgnuIGwOjxsyuCBfOQJsqtSIwLWsFAmAQIsxWfv2oW2X61wC/P41bwPP6VWUiCyA6VHKPq4xwGu4Lb5RMDvsx2w9VL1RuBr4XkiUrMOFcBPMSK0AGYEQ==; 20:i2ODsxA9gl+GPJnGO0Wui/jrbZaIpKPe2qJ8TUUGv23hYC0YyaN27s8AzExsTlaXG4TjS2C5/wziX79HQ535jjP3z33B7RWBW3zfvn4Fv2wXMDtyWOQsjpoXN/MFTN/d5j+6lkfGy1hvWCYRGwWLp+BhdT8CER4rNKQXct43Ylo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2017 12:47:49.7440 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1989 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.136 Subject: [Qemu-devel] [PATCH v2 4/9] hmp: add hmp analogue for qmp-chardev-change 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, "Dr . David Alan Gilbert" , 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 Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy CC: Dr. David Alan Gilbert --- chardev/char.c | 4 ++-- hmp-commands.hx | 16 ++++++++++++++++ hmp.c | 34 ++++++++++++++++++++++++++++++++++ hmp.h | 1 + include/sysemu/char.h | 12 ++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index bac5e1c..0483f19 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -880,8 +880,8 @@ help_string_append(const char *name, void *opaque) g_string_append_printf(str, "\n%s", name); } -static ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, - Error **errp) +ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, + Error **errp) { Error *local_err = NULL; const ChardevClass *cc; diff --git a/hmp-commands.hx b/hmp-commands.hx index 0aca984..0f2a059 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1727,6 +1727,22 @@ chardev_add accepts the same parameters as the -chardev command line switch. ETEXI { + .name = "chardev-change", + .args_type = "id:s,args:s", + .params = "id args", + .help = "change chardev", + .cmd = hmp_chardev_change, + }, + +STEXI +@item chardev-change args +@findex chardev-change +chardev_change accepts existing chardev @var{id} and then the same arguments +as the -chardev command line switch (except for "id"). + +ETEXI + + { .name = "chardev-remove", .args_type = "id:s", .params = "id", diff --git a/hmp.c b/hmp.c index 3dceaf8..f7d0b38 100644 --- a/hmp.c +++ b/hmp.c @@ -2209,6 +2209,40 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +void hmp_chardev_change(Monitor *mon, const QDict *qdict) +{ + const char *args = qdict_get_str(qdict, "args"); + const char *id; + Error *err = NULL; + ChardevBackend *backend = NULL; + ChardevReturn *ret = NULL; + QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, + true); + if (!opts) { + error_setg(&err, "Parsing chardev args failed"); + goto end; + } + + id = qdict_get_str(qdict, "id"); + if (qemu_opts_id(opts)) { + error_setg(&err, "Unexpected 'id' parameter"); + goto end; + } + + backend = qemu_chr_parse_opts(opts, &err); + if (!backend) { + goto end; + } + + ret = qmp_chardev_change(id, backend, &err); + +end: + qapi_free_ChardevReturn(ret); + qapi_free_ChardevBackend(backend); + qemu_opts_del(opts); + hmp_handle_error(mon, &err); +} + void hmp_chardev_remove(Monitor *mon, const QDict *qdict) { Error *local_err = NULL; diff --git a/hmp.h b/hmp.h index d8b94ce..23e035c 100644 --- a/hmp.h +++ b/hmp.h @@ -102,6 +102,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict); void hmp_nbd_server_add(Monitor *mon, const QDict *qdict); void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict); void hmp_chardev_add(Monitor *mon, const QDict *qdict); +void hmp_chardev_change(Monitor *mon, const QDict *qdict); void hmp_chardev_remove(Monitor *mon, const QDict *qdict); void hmp_qemu_io(Monitor *mon, const QDict *qdict); void hmp_cpu_add(Monitor *mon, const QDict *qdict); diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 68c7876..92ae57e 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -132,6 +132,18 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); /** + * @qemu_chr_parse_opts: + * + * Parse the options to the ChardevBackend struct. + * + * @opts + * + * Returns: a new backend + */ +ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, + Error **errp); + +/** * @qemu_chr_new: * * Create a new character backend from a URI.