From patchwork Wed Oct 3 16:03:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 188864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 303AD2C00CB for ; Thu, 4 Oct 2012 03:35:24 +1000 (EST) Received: from localhost ([::1]:51287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJRSM-0008LW-Q9 for incoming@patchwork.ozlabs.org; Wed, 03 Oct 2012 12:05:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJRR9-0006E1-OM for qemu-devel@nongnu.org; Wed, 03 Oct 2012 12:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJRR0-0007ox-6j for qemu-devel@nongnu.org; Wed, 03 Oct 2012 12:04:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJRQz-0007ot-Up for qemu-devel@nongnu.org; Wed, 03 Oct 2012 12:04:30 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q93G4RBS027764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Oct 2012 12:04:27 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q93G47Iq016728; Wed, 3 Oct 2012 12:04:25 -0400 From: Avi Kivity To: qemu-devel@nongnu.org, Anthony Liguori , liu ping fan , "Michael S. Tsirkin" , Paolo Bonzini , Blue Swirl Date: Wed, 3 Oct 2012 18:03:51 +0200 Message-Id: <1349280245-16341-9-git-send-email-avi@redhat.com> In-Reply-To: <1349280245-16341-1-git-send-email-avi@redhat.com> References: <1349280245-16341-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v1 08/22] memory: provide defaults for MemoryListener operations 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 Many listeners don't need to respond to all MemoryListener callbacks; provide suitable defaults instead. Signed-off-by: Avi Kivity --- memory.c | 15 +++++++++++++++ memory.h | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/memory.c b/memory.c index b58b97c..efefcb8 100644 --- a/memory.c +++ b/memory.c @@ -1514,6 +1514,21 @@ void memory_listener_unregister(MemoryListener *listener) QTAILQ_REMOVE(&memory_listeners, listener, link); } +void memory_listener_default_global(MemoryListener *listener) +{ +} + +void memory_listener_default_section(MemoryListener *listener, + MemoryRegionSection *section) +{ +} + +void memory_listener_default_eventfd(MemoryListener *listener, + MemoryRegionSection *section, + bool match_data, uint64_t data, EventNotifier *e) +{ +} + void address_space_init(AddressSpace *as, MemoryRegion *root) { memory_region_transaction_begin(); diff --git a/memory.h b/memory.h index 46bc5e1..0ef95cb 100644 --- a/memory.h +++ b/memory.h @@ -223,6 +223,27 @@ struct MemoryListener { QTAILQ_ENTRY(MemoryListener) link; }; +#define MEMORY_LISTENER_DEFAULT_OPS \ + .begin = memory_listener_default_global, \ + .commit = memory_listener_default_global, \ + .region_add = memory_listener_default_section, \ + .region_del = memory_listener_default_section, \ + .region_nop = memory_listener_default_section, \ + .log_start = memory_listener_default_section, \ + .log_stop = memory_listener_default_section, \ + .log_sync = memory_listener_default_section, \ + .log_global_start = memory_listener_default_global, \ + .log_global_stop = memory_listener_default_global, \ + .eventfd_add = memory_listener_default_eventfd, \ + .eventfd_del = memory_listener_default_eventfd \ + +void memory_listener_default_global(MemoryListener *listener); +void memory_listener_default_section(MemoryListener *listener, + MemoryRegionSection *section); +void memory_listener_default_eventfd(MemoryListener *listener, + MemoryRegionSection *section, + bool match_data, uint64_t data, EventNotifier *e); + /** * memory_region_init: Initialize a memory region *