From nobody Mon Feb 9 08:11:26 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 15099625363431018.0535637523438; Mon, 6 Nov 2017 02:02:16 -0800 (PST) Received: from localhost ([::1]:47242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBeEF-0007pE-Du for importer@patchew.org; Mon, 06 Nov 2017 05:02:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBe3A-0006Fa-IK for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:50:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBe39-00054u-Oj for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:50:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33142) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBe39-00054Z-IM for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:50:35 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BE15883D9; Mon, 6 Nov 2017 09:50:34 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-165.pek2.redhat.com [10.72.12.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A2206A028; Mon, 6 Nov 2017 09:50:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7BE15883D9 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 17:46:35 +0800 Message-Id: <20171106094643.14881-20-peterx@redhat.com> In-Reply-To: <20171106094643.14881-1-peterx@redhat.com> References: <20171106094643.14881-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 06 Nov 2017 09:50:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v3 19/27] monitor: send event when request queue full 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: Laurent Vivier , Fam Zheng , Juan Quintela , mdroth@linux.vnet.ibm.com, peterx@redhat.com, Markus Armbruster , marcandre.lureau@redhat.com, Stefan Hajnoczi , Paolo Bonzini , Jiri Denemark , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Set maximum QMP request queue length to 8. If queue full, instead of queue the command, we directly return a "request-dropped" event, telling client that specific command is dropped. Note that this flow control mechanism is only valid if OOB is enabled. If it's not, the effective queue length will always be 1, which strictly follows original behavior of QMP command handling (which never drop messages). Signed-off-by: Peter Xu --- monitor.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/monitor.c b/monitor.c index e327ae115b..f1f850f5c6 100644 --- a/monitor.c +++ b/monitor.c @@ -4029,6 +4029,8 @@ static void monitor_qmp_bh_dispatcher(void *data) } } =20 +#define QMP_REQ_QUEUE_LEN_MAX (8) + static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens, void *opaque) { @@ -4061,6 +4063,21 @@ static void handle_qmp_command(JSONMessageParser *pa= rser, GQueue *tokens, req_obj->id =3D id; req_obj->req =3D req; =20 + if (qmp_oob_enabled(mon)) { + /* Drop the request if queue is full. */ + if (mon->qmp.qmp_requests->length >=3D QMP_REQ_QUEUE_LEN_MAX) { + const char *id_str =3D qobject_get_try_str(id); + + qapi_event_send_request_dropped(id_str ? id_str : "", + REQUEST_DROP_REASON_QUEUE_FULL, + NULL); + qobject_decref(id); + qobject_decref(req); + g_free(req_obj); + return; + } + } + /* * Put the request to the end of queue so that requests will be * handled in time order. Ownership for req_obj, req, id, --=20 2.13.5