From patchwork Thu Jun 19 19:39:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 361987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AFAAD140092 for ; Fri, 20 Jun 2014 05:52:40 +1000 (EST) Received: from localhost ([::1]:37582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiNy-0008TX-Tl for incoming@patchwork.ozlabs.org; Thu, 19 Jun 2014 15:52:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiCE-00053Q-4A for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxiC7-0007u8-VK for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxiC7-0007ts-Nl for qemu-devel@nongnu.org; Thu, 19 Jun 2014 15:40:23 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5JJeHQt011164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Jun 2014 15:40:18 -0400 Received: from localhost (ovpn-113-20.phx2.redhat.com [10.3.113.20]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5JJeHe5008164; Thu, 19 Jun 2014 15:40:17 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Thu, 19 Jun 2014 15:39:43 -0400 Message-Id: <1403206792-15387-32-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1403206792-15387-1-git-send-email-lcapitulino@redhat.com> References: <1403206792-15387-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 31/40] qapi event: convert BALLOON_CHANGE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Wenchao Xia Signed-off-by: Wenchao Xia Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- balloon.c | 13 ------------- docs/qmp/qmp-events.txt | 17 ----------------- hw/virtio/virtio-balloon.c | 6 ++++-- include/sysemu/balloon.h | 2 -- monitor.c | 3 +-- qapi-event.json | 13 +++++++++++++ 6 files changed, 18 insertions(+), 36 deletions(-) diff --git a/balloon.c b/balloon.c index e321f2c..b70da4f 100644 --- a/balloon.c +++ b/balloon.c @@ -81,19 +81,6 @@ static int qemu_balloon_status(BalloonInfo *info) return 1; } -void qemu_balloon_changed(int64_t actual) -{ - QObject *data; - - data = qobject_from_jsonf("{ 'actual': %" PRId64 " }", - actual); - - monitor_protocol_event(QEVENT_BALLOON_CHANGE, data); - - qobject_decref(data); -} - - BalloonInfo *qmp_query_balloon(Error **errp) { BalloonInfo *info; diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index 4fbc3de..1b0e25f 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -1,23 +1,6 @@ QEMU Machine Protocol Events ============================ -BALLOON_CHANGE --------------- - -Emitted when the guest changes the actual BALLOON level. This -value is equivalent to the 'actual' field return by the -'query-balloon' command - -Data: - -- "actual": actual level of the guest memory balloon in bytes (json-number) - -Example: - -{ "event": "BALLOON_CHANGE", - "data": { "actual": 944766976 }, - "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } - GUEST_PANICKED -------------- diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 22cd52e..2a2e58a 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -24,6 +24,7 @@ #include "sysemu/kvm.h" #include "exec/address-spaces.h" #include "qapi/visitor.h" +#include "qapi-event.h" #if defined(__linux__) #include @@ -289,8 +290,9 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, memcpy(&config, config_data, sizeof(struct virtio_balloon_config)); dev->actual = le32_to_cpu(config.actual); if (dev->actual != oldactual) { - qemu_balloon_changed(ram_size - - ((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT)); + qapi_event_send_balloon_change(ram_size - + ((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT), + &error_abort); } } diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h index bd9d395..0345e01 100644 --- a/include/sysemu/balloon.h +++ b/include/sysemu/balloon.h @@ -24,6 +24,4 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, QEMUBalloonStatus *stat_func, void *opaque); void qemu_remove_balloon_handler(void *opaque); -void qemu_balloon_changed(int64_t actual); - #endif diff --git a/monitor.c b/monitor.c index 589ae37..e82f75e 100644 --- a/monitor.c +++ b/monitor.c @@ -616,6 +616,7 @@ static void monitor_qapi_event_init(void) /* Limit guest-triggerable events to 1 per second */ monitor_qapi_event_throttle(QAPI_EVENT_RTC_CHANGE, 1000); monitor_qapi_event_throttle(QAPI_EVENT_WATCHDOG, 1000); + monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000); qmp_event_set_func_emit(monitor_qapi_event_queue); } @@ -742,8 +743,6 @@ monitor_protocol_event_throttle(MonitorEvent event, * and initialize state */ static void monitor_protocol_event_init(void) { - /* Limit RTC & BALLOON events to 1 per second */ - monitor_protocol_event_throttle(QEVENT_BALLOON_CHANGE, 1000); /* limit the rate of quorum events to avoid hammering the management */ monitor_protocol_event_throttle(QEVENT_QUORUM_REPORT_BAD, 1000); monitor_protocol_event_throttle(QEVENT_QUORUM_FAILURE, 1000); diff --git a/qapi-event.json b/qapi-event.json index 1e23549..07190c2 100644 --- a/qapi-event.json +++ b/qapi-event.json @@ -241,3 +241,16 @@ # Since: 1.3 ## { 'event': 'SPICE_MIGRATE_COMPLETED' } + +## +# @BALLOON_CHANGE +# +# Emitted when the guest changes the actual BALLOON level. This value is +# equivalent to the @actual field return by the 'query-balloon' command +# +# @actual: actual level of the guest memory balloon in bytes +# +# Since: 1.2 +## +{ 'event': 'BALLOON_CHANGE', + 'data': { 'actual': 'int' } }