From nobody Thu May 2 07:05:33 2024 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; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522046492151868.2854946930898; Sun, 25 Mar 2018 23:41:32 -0700 (PDT) Received: from localhost ([::1]:54857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lom-0003MB-9V for importer@patchew.org; Mon, 26 Mar 2018 02:41:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lml-0002Bl-6I for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Lmh-0006ge-HE for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38644 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Lmh-0006gZ-CW for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8AF2722C0 for ; Mon, 26 Mar 2018 06:39:10 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A019202322B; Mon, 26 Mar 2018 06:39:08 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:38:54 +0800 Message-Id: <20180326063901.27425-2-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 26 Mar 2018 06:39:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 26 Mar 2018 06:39:10 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 1/8] qmp: fix qmp_capabilities error regression 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When someone sents a command before QMP handshake, error was like this: {"execute": "query-cpus"} {"error": {"class": "CommandNotFound", "desc": "Expecting capabilities negotiation with 'qmp_capabilities'"}} While after cf869d5317 it becomes: {"execute": "query-cpus"} {"error": {"class": "CommandNotFound", "desc": "The command query-cpus has not been found"}} Fix it back to the nicer one. Fixes: cf869d5317 ("qmp: support out-of-band (oob) execution", 2018-03-19) Reported-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Peter Xu Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- monitor.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/monitor.c b/monitor.c index 77f4c41cfa..849fa23bf9 100644 --- a/monitor.c +++ b/monitor.c @@ -1203,8 +1203,14 @@ static bool qmp_cmd_oob_check(Monitor *mon, QDict *r= eq, Error **errp) =20 cmd =3D qmp_find_command(mon->qmp.commands, command); if (!cmd) { - error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, - "The command %s has not been found", command); + if (mon->qmp.commands =3D=3D &qmp_cap_negotiation_commands) { + error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + "Expecting capabilities negotiation " + "with 'qmp_capabilities'"); + } else { + error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + "The command %s has not been found", command); + } return false; } =20 @@ -4027,7 +4033,6 @@ static void monitor_qmp_dispatch_one(QMPRequest *req_= obj) { Monitor *mon, *old_mon; QObject *req, *rsp =3D NULL, *id; - QDict *qdict =3D NULL; bool need_resume; =20 req =3D req_obj->req; @@ -4050,18 +4055,6 @@ static void monitor_qmp_dispatch_one(QMPRequest *req= _obj) =20 cur_mon =3D old_mon; =20 - if (mon->qmp.commands =3D=3D &qmp_cap_negotiation_commands) { - qdict =3D qdict_get_qdict(qobject_to(QDict, rsp), "error"); - if (qdict - && !g_strcmp0(qdict_get_try_str(qdict, "class"), - QapiErrorClass_str(ERROR_CLASS_COMMAND_NOT_FOUND))) { - /* Provide a more useful error message */ - qdict_del(qdict, "desc"); - qdict_put_str(qdict, "desc", "Expecting capabilities negotiati= on" - " with 'qmp_capabilities'"); - } - } - /* Respond if necessary */ monitor_qmp_respond(mon, rsp, NULL, id); =20 --=20 2.14.3 From nobody Thu May 2 07:05:33 2024 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; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522046492154672.3663568348562; Sun, 25 Mar 2018 23:41:32 -0700 (PDT) Received: from localhost ([::1]:54858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Los-0003Qq-Iq for importer@patchew.org; Mon, 26 Mar 2018 02:41:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lml-0002Bn-Rt for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Lmk-0006hI-OT for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38128 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Lmk-0006hC-Jg for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 260CE813F73E for ; Mon, 26 Mar 2018 06:39:14 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C763202322B; Mon, 26 Mar 2018 06:39:11 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:38:55 +0800 Message-Id: <20180326063901.27425-3-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 26 Mar 2018 06:39:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 26 Mar 2018 06:39:14 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 2/8] qmp: cleanup qmp queues properly 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Marc-Andr=C3=A9 Lureau reported that we can have this happen: 1. client1 connects, send command C1 2. client1 disconnects before getting response for C1 3. client2 connects, who might receive response of C1 However client2 should not receive remaining responses for client1. Basically, we should clean up the request/response queue elements when: - before a session established - after a session is closed - before destroying the queues Some helpers are introduced to achieve that. We need to make sure we're with the lock when operating on those queues. Reported-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- monitor.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++------------= ---- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/monitor.c b/monitor.c index 849fa23bf9..eba98df9da 100644 --- a/monitor.c +++ b/monitor.c @@ -234,6 +234,22 @@ static struct { QEMUBH *qmp_respond_bh; } mon_global; =20 +struct QMPRequest { + /* Owner of the request */ + Monitor *mon; + /* "id" field of the request */ + QObject *id; + /* Request object to be handled */ + QObject *req; + /* + * Whether we need to resume the monitor afterward. This flag is + * used to emulate the old QMP server behavior that the current + * command must be completed before execution of the next one. + */ + bool need_resume; +}; +typedef struct QMPRequest QMPRequest; + /* QMP checker flags */ #define QMP_ACCEPT_UNKNOWNS 1 =20 @@ -310,6 +326,43 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *= readline_func, } } =20 +static void qmp_request_free(QMPRequest *req) +{ + qobject_decref(req->id); + qobject_decref(req->req); + g_free(req); +} + +static void qmp_response_free(QObject *obj) +{ + qobject_decref(obj); +} + +/* Must with the mon->qmp.qmp_queue_lock held */ +static void monitor_qmp_cleanup_req_queue_locked(Monitor *mon) +{ + while (!g_queue_is_empty(mon->qmp.qmp_requests)) { + qmp_request_free(g_queue_pop_head(mon->qmp.qmp_requests)); + } +} + +/* Must with the mon->qmp.qmp_queue_lock held */ +static void monitor_qmp_cleanup_resp_queue_locked(Monitor *mon) +{ + while (!g_queue_is_empty(mon->qmp.qmp_responses)) { + qmp_response_free(g_queue_pop_head(mon->qmp.qmp_responses)); + } +} + +static void monitor_qmp_cleanup_queues(Monitor *mon) +{ + qemu_mutex_lock(&mon->qmp.qmp_queue_lock); + monitor_qmp_cleanup_req_queue_locked(mon); + monitor_qmp_cleanup_resp_queue_locked(mon); + qemu_mutex_unlock(&mon->qmp.qmp_queue_lock); +} + + static void monitor_flush_locked(Monitor *mon); =20 static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond, @@ -497,7 +550,7 @@ static void monitor_qmp_bh_responder(void *opaque) break; } monitor_json_emitter_raw(response.mon, response.data); - qobject_decref(response.data); + qmp_response_free(response.data); } } =20 @@ -701,6 +754,8 @@ static void monitor_data_destroy(Monitor *mon) QDECREF(mon->outbuf); qemu_mutex_destroy(&mon->out_lock); qemu_mutex_destroy(&mon->qmp.qmp_queue_lock); + monitor_qmp_cleanup_req_queue_locked(mon); + monitor_qmp_cleanup_resp_queue_locked(mon); g_queue_free(mon->qmp.qmp_requests); g_queue_free(mon->qmp.qmp_responses); } @@ -4009,22 +4064,6 @@ static void monitor_qmp_respond(Monitor *mon, QObjec= t *rsp, qobject_decref(rsp); } =20 -struct QMPRequest { - /* Owner of the request */ - Monitor *mon; - /* "id" field of the request */ - QObject *id; - /* Request object to be handled */ - QObject *req; - /* - * Whether we need to resume the monitor afterward. This flag is - * used to emulate the old QMP server behavior that the current - * command must be completed before execution of the next one. - */ - bool need_resume; -}; -typedef struct QMPRequest QMPRequest; - /* * Dispatch one single QMP request. The function will free the req_obj * and objects inside it before return. @@ -4191,9 +4230,7 @@ static void handle_qmp_command(JSONMessageParser *par= ser, GQueue *tokens) qapi_event_send_command_dropped(id, COMMAND_DROP_REASON_QUEUE_FULL, &error_abort); - qobject_decref(id); - qobject_decref(req); - g_free(req_obj); + qmp_request_free(req_obj); return; } } @@ -4327,6 +4364,7 @@ static void monitor_qmp_event(void *opaque, int event) =20 switch (event) { case CHR_EVENT_OPENED: + monitor_qmp_cleanup_queues(mon); mon->qmp.commands =3D &qmp_cap_negotiation_commands; monitor_qmp_caps_reset(mon); data =3D get_qmp_greeting(mon); @@ -4335,6 +4373,7 @@ static void monitor_qmp_event(void *opaque, int event) mon_refcount++; break; case CHR_EVENT_CLOSED: + monitor_qmp_cleanup_queues(mon); json_message_parser_destroy(&mon->qmp.parser); json_message_parser_init(&mon->qmp.parser, handle_qmp_command); mon_refcount--; --=20 2.14.3 From nobody Thu May 2 07:05:33 2024 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; 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 1522046753091200.93913859639724; Sun, 25 Mar 2018 23:45:53 -0700 (PDT) Received: from localhost ([::1]:54882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0LtA-0007Li-AP for importer@patchew.org; Mon, 26 Mar 2018 02:45:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lmo-0002D3-Nt for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Lmn-0006iU-Ry for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33378 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Lmn-0006iG-O8 for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5759A402B023 for ; Mon, 26 Mar 2018 06:39:17 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADB5D202322B; Mon, 26 Mar 2018 06:39:14 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:38:56 +0800 Message-Id: <20180326063901.27425-4-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 26 Mar 2018 06:39:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 26 Mar 2018 06:39:17 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 3/8] monitor: new parameter "x-oob" 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add new parameter to optionally enable Out-Of-Band for a QMP server. An example command line: ./qemu-system-x86_64 -chardev stdio,id=3Dchar0 \ -mon chardev=3Dchar0,mode=3Dcontrol,x-oob=3Don By default, Out-Of-Band is off. It is not allowed if either MUX or non-QMP is detected, since Out-Of-Band is currently only for QMP, and non-MUX chardev backends. Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/monitor/monitor.h | 1 + monitor.c | 22 ++++++++++++++++++++-- vl.c | 5 +++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 0cb0538a31..d6ab70cae2 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -13,6 +13,7 @@ extern Monitor *cur_mon; #define MONITOR_USE_READLINE 0x02 #define MONITOR_USE_CONTROL 0x04 #define MONITOR_USE_PRETTY 0x08 +#define MONITOR_USE_OOB 0x10 =20 bool monitor_cur_is_qmp(void); =20 diff --git a/monitor.c b/monitor.c index eba98df9da..d77ccc8785 100644 --- a/monitor.c +++ b/monitor.c @@ -36,6 +36,7 @@ #include "net/slirp.h" #include "chardev/char-fe.h" #include "chardev/char-io.h" +#include "chardev/char-mux.h" #include "ui/qemu-spice.h" #include "sysemu/numa.h" #include "monitor/monitor.h" @@ -4568,12 +4569,26 @@ static void monitor_qmp_setup_handlers_bh(void *opa= que) void monitor_init(Chardev *chr, int flags) { Monitor *mon =3D g_malloc(sizeof(*mon)); + bool use_readline =3D flags & MONITOR_USE_READLINE; + bool use_oob =3D flags & MONITOR_USE_OOB; + + if (use_oob) { + if (CHARDEV_IS_MUX(chr)) { + error_report("Monitor Out-Of-Band is not supported with " + "MUX typed chardev backend"); + exit(1); + } + if (use_readline) { + error_report("Monitor Out-Of-band is only supported by QMP"); + exit(1); + } + } =20 - monitor_data_init(mon, false, false); + monitor_data_init(mon, false, use_oob); =20 qemu_chr_fe_init(&mon->chr, chr, &error_abort); mon->flags =3D flags; - if (flags & MONITOR_USE_READLINE) { + if (use_readline) { mon->rs =3D readline_init(monitor_readline_printf, monitor_readline_flush, mon, @@ -4669,6 +4684,9 @@ QemuOptsList qemu_mon_opts =3D { },{ .name =3D "pretty", .type =3D QEMU_OPT_BOOL, + },{ + .name =3D "x-oob", + .type =3D QEMU_OPT_BOOL, }, { /* end of list */ } }, diff --git a/vl.c b/vl.c index c81cc86607..5fd01bd5f6 100644 --- a/vl.c +++ b/vl.c @@ -2404,6 +2404,11 @@ static int mon_init_func(void *opaque, QemuOpts *opt= s, Error **errp) if (qemu_opt_get_bool(opts, "pretty", 0)) flags |=3D MONITOR_USE_PRETTY; =20 + /* OOB is off by default */ + if (qemu_opt_get_bool(opts, "x-oob", 0)) { + flags |=3D MONITOR_USE_OOB; + } + chardev =3D qemu_opt_get(opts, "chardev"); chr =3D qemu_chr_find(chardev); if (chr =3D=3D NULL) { --=20 2.14.3 From nobody Thu May 2 07:05:33 2024 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; 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 1522046496729889.9310487790117; Sun, 25 Mar 2018 23:41:36 -0700 (PDT) Received: from localhost ([::1]:54859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lp1-0003XT-QK for importer@patchew.org; Mon, 26 Mar 2018 02:41:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lmv-0002HU-UM for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Lmr-0006k5-3E for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:26 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38656 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Lmq-0006jy-VD for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 895A47C6DC for ; Mon, 26 Mar 2018 06:39:20 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id E011B2026E04; Mon, 26 Mar 2018 06:39:17 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:38:57 +0800 Message-Id: <20180326063901.27425-5-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 26 Mar 2018 06:39:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 26 Mar 2018 06:39:20 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 4/8] qapi: restrict allow-oob value to be "true" 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It was missed in the first version of OOB series. We should check this to make sure we throw the right error when fault value is passed in. Signed-off-by: Peter Xu Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 2c05e3c284..3e14bc41f2 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -872,7 +872,7 @@ def check_keys(expr_elem, meta, required, optional=3D[]= ): raise QAPISemError(info, "'%s' of %s '%s' should only use false valu= e" % (key, meta, name)) - if key =3D=3D 'boxed' and value is not True: + if (key =3D=3D 'boxed' or key =3D=3D 'allow-oob') and value is not= True: raise QAPISemError(info, "'%s' of %s '%s' should only use true value" % (key, meta, name)) --=20 2.14.3 From nobody Thu May 2 07:05:33 2024 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; 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 1522046501312875.8920700640945; Sun, 25 Mar 2018 23:41:41 -0700 (PDT) Received: from localhost ([::1]:54860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lp6-0003Yf-Cc for importer@patchew.org; Mon, 26 Mar 2018 02:41:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lmv-0002HV-Ue for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Lmu-0006kV-Bc for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:25 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48530 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Lmu-0006kR-5w for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEF04EC001 for ; Mon, 26 Mar 2018 06:39:23 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DB75202322B; Mon, 26 Mar 2018 06:39:20 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:38:58 +0800 Message-Id: <20180326063901.27425-6-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 26 Mar 2018 06:39:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 26 Mar 2018 06:39:23 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 5/8] tests: let qapi-schema tests detect oob 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The allow_oob parameter was passed in but not used in tests. Now reflect that in the tests, so we need to touch up other command testers with that new change. Reviewed-by: Eric Blake Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/qapi-schema/doc-good.out | 4 ++-- tests/qapi-schema/ident-with-escape.out | 2 +- tests/qapi-schema/indented-expr.out | 4 ++-- tests/qapi-schema/qapi-schema-test.out | 18 +++++++++--------- tests/qapi-schema/test-qapi.py | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 430b5a87db..63058b1590 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -28,9 +28,9 @@ object q_obj_cmd-arg member arg2: str optional=3DTrue member arg3: bool optional=3DFalse command cmd q_obj_cmd-arg -> Object - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse command cmd-boxed Object -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse doc freeform body=3D =3D Section diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/id= ent-with-escape.out index ee3b34e623..82213aa51d 100644 --- a/tests/qapi-schema/ident-with-escape.out +++ b/tests/qapi-schema/ident-with-escape.out @@ -5,4 +5,4 @@ module ident-with-escape.json object q_obj_fooA-arg member bar1: str optional=3DFalse command fooA q_obj_fooA-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index a79935e8c3..862678f8f4 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -3,6 +3,6 @@ enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'q= list', 'qbool'] prefix QTYPE module indented-expr.json command eins None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse command zwei None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 012e7fc06a..4f43370017 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -16,7 +16,7 @@ object Empty1 object Empty2 base Empty1 command user_def_cmd0 Empty2 -> Empty2 - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse enum QEnumTwo ['value1', 'value2'] prefix QENUM_TWO object UserDefOne @@ -143,29 +143,29 @@ object UserDefNativeListUnion case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper command user_def_cmd None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse object q_obj_user_def_cmd1-arg member ud1a: UserDefOne optional=3DFalse command user_def_cmd1 q_obj_user_def_cmd1-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse object q_obj_user_def_cmd2-arg member ud1a: UserDefOne optional=3DFalse member ud1b: UserDefOne optional=3DTrue command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse object q_obj_guest-get-time-arg member a: int optional=3DFalse member b: int optional=3DTrue command guest-get-time q_obj_guest-get-time-arg -> int - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse object q_obj_guest-sync-arg member arg: any optional=3DFalse command guest-sync q_obj_guest-sync-arg -> any - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse command boxed-struct UserDefZero -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse command boxed-union UserDefNativeListUnion -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse object UserDefOptions member i64: intList optional=3DTrue member u64: uint64List optional=3DTrue @@ -229,4 +229,4 @@ object q_obj___org.qemu_x-command-arg member c: __org.qemu_x-Union2 optional=3DFalse member d: __org.qemu_x-Alt optional=3DFalse command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_= x-Union1 - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 10e68b01d9..c1a144ba29 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -45,8 +45,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): gen, success_response, boxed, allow_oob): print('command %s %s -> %s' % \ (name, arg_type and arg_type.name, ret_type and ret_type.nam= e)) - print(' gen=3D%s success_response=3D%s boxed=3D%s' % \ - (gen, success_response, boxed)) + print(' gen=3D%s success_response=3D%s boxed=3D%s oob=3D%s' % \ + (gen, success_response, boxed, allow_oob)) =20 def visit_event(self, name, info, arg_type, boxed): print('event %s %s' % (name, arg_type and arg_type.name)) --=20 2.14.3 From nobody Thu May 2 07:05:33 2024 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; 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 1522046649595248.60335162407011; Sun, 25 Mar 2018 23:44:09 -0700 (PDT) Received: from localhost ([::1]:54870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0LrU-0005tF-PT for importer@patchew.org; Mon, 26 Mar 2018 02:44:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Lmy-0002Is-Fd for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Lmx-0006kx-IX for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33386 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Lmx-0006kr-D9 for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFDB54068026 for ; Mon, 26 Mar 2018 06:39:26 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53198202322B; Mon, 26 Mar 2018 06:39:24 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:38:59 +0800 Message-Id: <20180326063901.27425-7-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 26 Mar 2018 06:39:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 26 Mar 2018 06:39:26 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 6/8] tests: add oob-test for qapi-schema 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It simply tests the new OOB capability, and make sure the QAPISchema can parse it correctly. Signed-off-by: Peter Xu Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/Makefile.include | 1 + tests/qapi-schema/oob-test.err | 1 + tests/qapi-schema/oob-test.exit | 1 + tests/qapi-schema/oob-test.json | 2 ++ tests/qapi-schema/oob-test.out | 0 tests/qapi-schema/qapi-schema-test.json | 3 +++ tests/qapi-schema/qapi-schema-test.out | 2 ++ tests/test-qmp-cmds.c | 4 ++++ 8 files changed, 14 insertions(+) create mode 100644 tests/qapi-schema/oob-test.err create mode 100644 tests/qapi-schema/oob-test.exit create mode 100644 tests/qapi-schema/oob-test.json create mode 100644 tests/qapi-schema/oob-test.out diff --git a/tests/Makefile.include b/tests/Makefile.include index eb218a9539..3b9a5e31a2 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -523,6 +523,7 @@ qapi-schema +=3D missing-comma-object.json qapi-schema +=3D missing-type.json qapi-schema +=3D nested-struct-data.json qapi-schema +=3D non-objects.json +qapi-schema +=3D oob-test.json qapi-schema +=3D pragma-doc-required-crap.json qapi-schema +=3D pragma-extra-junk.json qapi-schema +=3D pragma-name-case-whitelist-crap.json diff --git a/tests/qapi-schema/oob-test.err b/tests/qapi-schema/oob-test.err new file mode 100644 index 0000000000..35b60f7480 --- /dev/null +++ b/tests/qapi-schema/oob-test.err @@ -0,0 +1 @@ +tests/qapi-schema/oob-test.json:2: 'allow-oob' of command 'oob-command-1' = should only use true value diff --git a/tests/qapi-schema/oob-test.exit b/tests/qapi-schema/oob-test.e= xit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/oob-test.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/oob-test.json b/tests/qapi-schema/oob-test.j= son new file mode 100644 index 0000000000..da9635920f --- /dev/null +++ b/tests/qapi-schema/oob-test.json @@ -0,0 +1,2 @@ +# Check against oob illegal value +{ 'command': 'oob-command-1', 'allow-oob': 'some-string' } diff --git a/tests/qapi-schema/oob-test.out b/tests/qapi-schema/oob-test.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index c72dbd8050..06e30f452e 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -139,6 +139,9 @@ { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' } { 'command': 'boxed-union', 'data': 'UserDefNativeListUnion', 'boxed': tru= e } =20 +# Smoke test on Out-Of-Band +{ 'command': 'an-oob-command', 'allow-oob': true } + # For testing integer range flattening in opts-visitor. The following sche= ma # corresponds to the option format: # diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 4f43370017..467577d770 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -166,6 +166,8 @@ command boxed-struct UserDefZero -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse command boxed-union UserDefNativeListUnion -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse +command an-oob-command None -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DTrue object UserDefOptions member i64: intList optional=3DTrue member u64: uint64List optional=3DTrue diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 93fbbb1b73..db690cc5ae 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -16,6 +16,10 @@ void qmp_user_def_cmd(Error **errp) { } =20 +void qmp_an_oob_command(Error **errp) +{ +} + Empty2 *qmp_user_def_cmd0(Error **errp) { return g_new0(Empty2, 1); --=20 2.14.3 From nobody Thu May 2 07:05:33 2024 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; 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 1522046647938400.53208086097266; Sun, 25 Mar 2018 23:44:07 -0700 (PDT) Received: from localhost ([::1]:54869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0LrT-0005sU-1R for importer@patchew.org; Mon, 26 Mar 2018 02:44:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Ln1-0002JB-Mq for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Ln0-0006mS-PW for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38658 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Ln0-0006mO-K3 for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3483F8424D for ; Mon, 26 Mar 2018 06:39:30 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85F8A2026E04; Mon, 26 Mar 2018 06:39:27 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:39:00 +0800 Message-Id: <20180326063901.27425-8-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 26 Mar 2018 06:39:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 26 Mar 2018 06:39:30 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 7/8] tests: introduce qtest_init_with_qmp_format() 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It is abstracted from qtest_init_without_qmp_handshake(). It works just like qtest_init_without_qmp_handshake() but further it would allow the caller to specify the QMP parameter. Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/libqtest.c | 14 +++++++++++--- tests/libqtest.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 200b2b9e92..d2af1b17f0 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -166,19 +166,22 @@ static const char *qtest_qemu_binary(void) return qemu_bin; } =20 -QTestState *qtest_init_without_qmp_handshake(const char *extra_args) +QTestState *qtest_init_with_qmp_format(const char *extra_args, + const char *qmp_format) { QTestState *s; int sock, qmpsock, i; gchar *socket_path; gchar *qmp_socket_path; gchar *command; + gchar *qmp_params; const char *qemu_binary =3D qtest_qemu_binary(); =20 s =3D g_new(QTestState, 1); =20 socket_path =3D g_strdup_printf("/tmp/qtest-%d.sock", getpid()); qmp_socket_path =3D g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); + qmp_params =3D g_strdup_printf(qmp_format, qmp_socket_path); =20 /* It's possible that if an earlier test run crashed it might * have left a stale unix socket lying around. Delete any @@ -199,12 +202,12 @@ QTestState *qtest_init_without_qmp_handshake(const ch= ar *extra_args) command =3D g_strdup_printf("exec %s " "-qtest unix:%s,nowait " "-qtest-log %s " - "-qmp unix:%s,nowait " + "%s " "-machine accel=3Dqtest " "-display none " "%s", qemu_binary, socket_path, getenv("QTEST_LOG") ? "/dev/fd/2" : "/de= v/null", - qmp_socket_path, + qmp_params, extra_args ?: ""); execlp("/bin/sh", "sh", "-c", command, NULL); exit(1); @@ -237,6 +240,11 @@ QTestState *qtest_init_without_qmp_handshake(const cha= r *extra_args) return s; } =20 +QTestState *qtest_init_without_qmp_handshake(const char *extra_args) +{ + return qtest_init_with_qmp_format(extra_args, "-qmp unix:%s,nowait"); +} + QTestState *qtest_init(const char *extra_args) { QTestState *s =3D qtest_init_without_qmp_handshake(extra_args); diff --git a/tests/libqtest.h b/tests/libqtest.h index 811169453a..1f3605ce73 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -62,6 +62,20 @@ QTestState *qtest_init(const char *extra_args); */ QTestState *qtest_init_without_qmp_handshake(const char *extra_args); =20 +/** + * qtest_init_with_qmp_format: + * @extra_args: other arguments to pass to QEMU. + * @qmp_format: format of QMP parameters, should contain one "%s" + * field so that the socket path will be filled later. + * + * Note that this function will work just like + * qtest_init_without_qmp_handshake(), so no QMP handshake will be done. + * + * Returns: #QTestState instance. + */ +QTestState *qtest_init_with_qmp_format(const char *extra_args, + const char *qmp_format); + /** * qtest_quit: * @s: #QTestState instance to operate on. --=20 2.14.3 From nobody Thu May 2 07:05:33 2024 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; 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 1522046761833881.1907072632076; Sun, 25 Mar 2018 23:46:01 -0700 (PDT) Received: from localhost ([::1]:54883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0LtJ-0007SY-2w for importer@patchew.org; Mon, 26 Mar 2018 02:46:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Ln6-0002NZ-NZ for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Ln3-0006nD-UT for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33390 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Ln3-0006n3-Q9 for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:39:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66C8D402B023 for ; Mon, 26 Mar 2018 06:39:33 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCFFC202322B; Mon, 26 Mar 2018 06:39:30 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:39:01 +0800 Message-Id: <20180326063901.27425-9-peterx@redhat.com> In-Reply-To: <20180326063901.27425-1-peterx@redhat.com> References: <20180326063901.27425-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 26 Mar 2018 06:39:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 26 Mar 2018 06:39:33 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.12 8/8] tests: qmp-test: add test for new "x-oob" 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: Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Test the new OOB capability. It's mostly the reverted OOB test, but differs in that: - It uses the new qtest_init_with_qmp_format() to create the monitor with the new monitor parameter "-mon x-oob" - Squashed the capability tests on greeting message - Don't use qtest_global any more, instead use self-maintained QTestState, which is the trend Signed-off-by: Peter Xu --- tests/qmp-test.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 558e83540c..4d15b0fca5 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -134,6 +134,89 @@ static void test_qmp_protocol(void) qtest_quit(qts); } =20 +/* Tests for Out-Of-Band support. */ +static void test_qmp_oob(void) +{ + QTestState *qts; + QDict *resp, *q; + int acks =3D 0; + const QListEntry *entry; + QList *capabilities; + QString *qstr; + const char *cmd_id; + const char *qmp_params =3D "-chardev socket,path=3D%s,nowait,id=3Dchar= 0 " + "-mon chardev=3Dchar0,mode=3Dcontrol,x-oob=3D= on"; + + qts =3D qtest_init_with_qmp_format(common_args, qmp_params); + + /* Ignore the greeting message. */ + resp =3D qtest_qmp_receive(qts); + q =3D qdict_get_qdict(resp, "QMP"); + g_assert(q); + capabilities =3D qdict_get_qlist(q, "capabilities"); + g_assert(capabilities && !qlist_empty(capabilities)); + entry =3D qlist_first(capabilities); + g_assert(entry); + qstr =3D qobject_to(QString, entry->value); + g_assert(qstr); + g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, "oob"); + QDECREF(resp); + + /* Try a fake capability, it should fail. */ + resp =3D qtest_qmp(qts, + "{ 'execute': 'qmp_capabilities', " + " 'arguments': { 'enable': [ 'cap-does-not-exist' ] = } }"); + g_assert(qdict_haskey(resp, "error")); + QDECREF(resp); + + /* Now, enable OOB in current QMP session, it should succeed. */ + resp =3D qtest_qmp(qts, + "{ 'execute': 'qmp_capabilities', " + " 'arguments': { 'enable': [ 'oob' ] } }"); + g_assert(qdict_haskey(resp, "return")); + QDECREF(resp); + + /* + * Try any command that does not support OOB but with OOB flag. We + * should get failure. + */ + resp =3D qtest_qmp(qts, + "{ 'execute': 'query-cpus'," + " 'control': { 'run-oob': true } }"); + g_assert(qdict_haskey(resp, "error")); + QDECREF(resp); + + /* + * First send the "x-oob-test" command with lock=3Dtrue and + * oob=3Dfalse, it should hang the dispatcher and main thread; + * later, we send another lock=3Dfalse with oob=3Dtrue to continue + * that thread processing. Finally we should receive replies from + * both commands. + */ + qtest_async_qmp(qts, + "{ 'execute': 'x-oob-test'," + " 'arguments': { 'lock': true }, " + " 'id': 'lock-cmd'}"); + qtest_async_qmp(qts, + "{ 'execute': 'x-oob-test', " + " 'arguments': { 'lock': false }, " + " 'control': { 'run-oob': true }, " + " 'id': 'unlock-cmd' }"); + + /* Ignore all events. Wait for 2 acks */ + while (acks < 2) { + resp =3D qtest_qmp_receive(qts); + cmd_id =3D qdict_get_str(resp, "id"); + if (!g_strcmp0(cmd_id, "lock-cmd") || + !g_strcmp0(cmd_id, "unlock-cmd")) { + acks++; + } + QDECREF(resp); + } + + qtest_quit(qts); +} + static int query_error_class(const char *cmd) { static struct { @@ -318,6 +401,7 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); =20 qtest_add_func("qmp/protocol", test_qmp_protocol); + qtest_add_func("qmp/oob", test_qmp_oob); qmp_schema_init(&schema); add_query_tests(&schema); =20 --=20 2.14.3