From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTYa-0007oY-HP for qemu-devel@nongnu.org; Fri, 25 Sep 2015 10:01:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfTYW-0008AA-IE for qemu-devel@nongnu.org; Fri, 25 Sep 2015 10:01:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTYW-00088O-D5 for qemu-devel@nongnu.org; Fri, 25 Sep 2015 10:00:56 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id F0F0D2FAA6E for ; Fri, 25 Sep 2015 14:00:55 +0000 (UTC) From: Markus Armbruster Date: Fri, 25 Sep 2015 16:00:46 +0200 Message-Id: <1443189647-11417-6-git-send-email-armbru@redhat.com> In-Reply-To: <1443189647-11417-1-git-send-email-armbru@redhat.com> References: <1443189647-11417-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [RFC 5/6] monitor: Throttle event VSERPORT_CHANGE separately by "id" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, marcandre.lureau@redhat.com, lersek@redhat.com VSERPORT_CHANGE is emitted when the guest opens or closes a virtio-serial port. The event's member "id" identifies the port. When several events arrive quickly, throttling drops all but the last of them. Because of that, a QMP client must assume that *any* port may have changed state when it receives a VSERPORT_CHANGE event and throttling may have happened. Make the event more useful by throttling it for each port separately. Signed-off-by: Markus Armbruster --- monitor.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 9807a5b..7e21407 100644 --- a/monitor.c +++ b/monitor.c @@ -567,8 +567,13 @@ static void monitor_qapi_event_handler(void *opaque) static unsigned int qapi_event_throttle_hash(const void *key) { const MonitorQAPIEventState *evstate = key; + unsigned int hash = evstate->event * 255; - return evstate->event * 255; + if (evstate->event == QAPI_EVENT_VSERPORT_CHANGE) { + hash += g_str_hash(qdict_get_str(evstate->qdict, "id")); + } + + return hash; } static gboolean qapi_event_throttle_equal(const void *a, const void *b) @@ -576,7 +581,16 @@ static gboolean qapi_event_throttle_equal(const void *a, const void *b) const MonitorQAPIEventState *eva = a; const MonitorQAPIEventState *evb = b; - return eva->event == evb->event; + if (eva->event != evb->event) { + return FALSE; + } + + if (eva->event == QAPI_EVENT_VSERPORT_CHANGE) { + return !strcmp(qdict_get_str(eva->qdict, "id"), + qdict_get_str(evb->qdict, "id")); + } + + return TRUE; } static void monitor_qapi_event_init(void) -- 2.4.3