From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJm3C-0003mv-S5 for qemu-devel@nongnu.org; Thu, 04 Oct 2012 10:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJm30-0000gM-Pv for qemu-devel@nongnu.org; Thu, 04 Oct 2012 10:05:18 -0400 Received: from mail-oa0-f45.google.com ([209.85.219.45]:34279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJm30-0000fx-LZ for qemu-devel@nongnu.org; Thu, 04 Oct 2012 10:05:06 -0400 Received: by mail-oa0-f45.google.com with SMTP id i18so461778oag.4 for ; Thu, 04 Oct 2012 07:05:06 -0700 (PDT) From: Anthony Liguori In-Reply-To: <1349280245-16341-9-git-send-email-avi@redhat.com> References: <1349280245-16341-1-git-send-email-avi@redhat.com> <1349280245-16341-9-git-send-email-avi@redhat.com> Date: Thu, 04 Oct 2012 09:05:01 -0500 Message-ID: <87pq4yib8y.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [RFC v1 08/22] memory: provide defaults for MemoryListener operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity , qemu-devel@nongnu.org, liu ping fan , "Michael S. Tsirkin" , Paolo Bonzini , Blue Swirl Avi Kivity writes: > 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 > * I think it'd be nicer to check for NULL when invoking the functions in the memory core. Then you avoid the exported stub functions entirely. Regards, Anthony Liguori > -- > 1.7.12