From nobody Mon Feb 9 17:24:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499956767920813.8281390750864; Thu, 13 Jul 2017 07:39:27 -0700 (PDT) Received: from localhost ([::1]:60425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVfH3-00058n-JB for importer@patchew.org; Thu, 13 Jul 2017 10:39:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVf3H-0000om-0h for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:25:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVf3F-0002Fa-GM for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:25:11 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33485) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVf3F-0002EL-57 for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:25:09 -0400 Received: by mail-wr0-x244.google.com with SMTP id n18so1462060wrb.0 for ; Thu, 13 Jul 2017 07:25:09 -0700 (PDT) Received: from 640k.lan (94-39-191-51.adsl-ull.clienti.tiscali.it. [94.39.191.51]) by smtp.gmail.com with ESMTPSA id k75sm6042448wmh.10.2017.07.13.07.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 07:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9wZY28tcE0MESeAsNpbtqsG/z3RepfnW3rg1PEwryUA=; b=XSzbkagJe7q6EFcGK4nlT2cb9JqnotRryo7ir6+yfaotm2z6e7OlH+XN9S3SvaXcmo brcsR9HvWYJbBP8I7jL/kvvLrLDZ5gUeUHzCb68kmZLNRVDt1wKjB0KILKs6ao9Pg/YL v/oRUuvkhrmRqPg/15xBLnbgNIp4bVIsQ9ndC4oKpIBeibbQ5TPPG1Gqq9FHCSARJIcn vwoO2IOuOmewkrHrKRkeShEjA9r+m3zV2FIIwEEu+zttOvrOnkvYBpAHulBv350voh05 Mt5suA69gIo2dFSIiIGMrMXeUGldO8Nsl6/q4NsydKlYkPzmajNTK+c35AZZpwq9w0rR yL9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9wZY28tcE0MESeAsNpbtqsG/z3RepfnW3rg1PEwryUA=; b=MFMGxvKZuJjJII3tMvY2kH1/IZ+t+Sj9xal65/BAXoM8Pr7rCtWoHO4YaTGg+onsAk ptOv1rOeqqiv6rulB/C+kHjldhzp3sLoELDFHj/SasbwcUE3wfOc3xnal2NIdnlx8jO3 YUZs1nBB6Sj4Kzn9zsB/l8jEyaeRp8nRqWSsJ+YmKJHo6QHf3iUgskXJRu6UHS/nQkMA IUrRMvQvAVDMiEQyaxRbNCKNcIq1W1YxQ3xui+KeG11NGXGz3nUG8dTf5EoI1muXeg2o zVx05TC3wSR72f/1TqGKBPftVDAWaa9Uqk47Orv8m/znL1MZJlGvcUQ7TsZB5LaMp3x5 t0Gw== X-Gm-Message-State: AIVw111OaQFO17iS/TDNFwFSpR8FFuuzQsxG37Ue+mIWBxb1tQJqS33Z J3K6bS4UsCq4lKyq9vM= X-Received: by 10.223.139.218 with SMTP id w26mr1736391wra.206.1499955907115; Thu, 13 Jul 2017 07:25:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 13 Jul 2017 16:24:10 +0200 Message-Id: <1499955874-10954-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1499955874-10954-1-git-send-email-pbonzini@redhat.com> References: <1499955874-10954-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 17/41] 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: Anton Nefedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Anton Nefedov Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Acked-by: Dr. David Alan Gilbert Message-Id: <1499342940-56739-11-git-send-email-anton.nefedov@virtuozzo.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- chardev/char.c | 2 +- hmp-commands.hx | 18 +++++++++++++++++- hmp.c | 34 ++++++++++++++++++++++++++++++++++ hmp.h | 1 + include/chardev/char.h | 10 ++++++++++ tests/test-hmp.c | 1 + 6 files changed, 64 insertions(+), 2 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index d6b9d89..c34b44a 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -567,7 +567,7 @@ static const char *chardev_alias_translate(const char *= name) return name; } =20 -static ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error **errp) +ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error **errp) { Error *local_err =3D NULL; const ChardevClass *cc; diff --git a/hmp-commands.hx b/hmp-commands.hx index 275ccdf..c4c96db 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1724,7 +1724,23 @@ ETEXI STEXI @item chardev-add args @findex chardev-add -chardev_add accepts the same parameters as the -chardev command line switc= h. +chardev-add accepts the same parameters as the -chardev command line switc= h. + +ETEXI + + { + .name =3D "chardev-change", + .args_type =3D "id:s,args:s", + .params =3D "id args", + .help =3D "change chardev", + .cmd =3D hmp_chardev_change, + }, + +STEXI +@item chardev-change args +@findex chardev-change +chardev-change accepts existing chardev @var{id} and then the same argumen= ts +as the -chardev command line switch (except for "id"). =20 ETEXI =20 diff --git a/hmp.c b/hmp.c index dee4028..1b443e1 100644 --- a/hmp.c +++ b/hmp.c @@ -2228,6 +2228,40 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdic= t) hmp_handle_error(mon, &err); } =20 +void hmp_chardev_change(Monitor *mon, const QDict *qdict) +{ + const char *args =3D qdict_get_str(qdict, "args"); + const char *id; + Error *err =3D NULL; + ChardevBackend *backend =3D NULL; + ChardevReturn *ret =3D NULL; + QemuOpts *opts =3D qemu_opts_parse_noisily(qemu_find_opts("chardev"), = args, + true); + if (!opts) { + error_setg(&err, "Parsing chardev args failed"); + goto end; + } + + id =3D qdict_get_str(qdict, "id"); + if (qemu_opts_id(opts)) { + error_setg(&err, "Unexpected 'id' parameter"); + goto end; + } + + backend =3D qemu_chr_parse_opts(opts, &err); + if (!backend) { + goto end; + } + + ret =3D 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 =3D NULL; diff --git a/hmp.h b/hmp.h index 214b261..1ff4552 100644 --- a/hmp.h +++ b/hmp.h @@ -102,6 +102,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qd= ict); 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_chardev_send_break(Monitor *mon, const QDict *qdict); void hmp_qemu_io(Monitor *mon, const QDict *qdict); diff --git a/include/chardev/char.h b/include/chardev/char.h index 22fd734..1604ea9 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -81,6 +81,16 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); =20 /** + * @qemu_chr_parse_opts: + * + * Parse the options to the ChardevBackend struct. + * + * Returns: a new backend or NULL on error + */ +ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, + Error **errp); + +/** * @qemu_chr_new: * * Create a new character backend from a URI. diff --git a/tests/test-hmp.c b/tests/test-hmp.c index 6dfa0c3..d77b3c8 100644 --- a/tests/test-hmp.c +++ b/tests/test-hmp.c @@ -23,6 +23,7 @@ static const char *hmp_cmds[] =3D { "boot_set ndc", "chardev-add null,id=3Dtestchardev1", "chardev-send-break testchardev2", + "chardev-change testchardev1 ringbuf", "chardev-remove testchardev1", "commit all", "cpu-add 1", --=20 1.8.3.1