From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7znD-0002dk-AG for qemu-devel@nongnu.org; Fri, 09 Aug 2013 23:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7zn4-00031b-DK for qemu-devel@nongnu.org; Fri, 09 Aug 2013 23:24:39 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:41083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7zn3-00031I-K2 for qemu-devel@nongnu.org; Fri, 09 Aug 2013 23:24:30 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 10 Aug 2013 13:17:28 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 1AD76357804E for ; Sat, 10 Aug 2013 13:24:23 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7A3OBLK10551564 for ; Sat, 10 Aug 2013 13:24:12 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7A3OLVJ003150 for ; Sat, 10 Aug 2013 13:24:22 +1000 Message-ID: <5205B251.2060907@linux.vnet.ibm.com> Date: Sat, 10 Aug 2013 11:24:01 +0800 From: Wenchao Xia MIME-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC] Convert AioContext to Gsource sub classes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Kevin Wolf , Paolo Bonzini , Anthony Liguori , Michael Roth , Ping Fan Liu , qemu-devel Hi folks, I'd like form a series which remove AioContext's concept and bind to glib's main loop more closely. Since changed place will be a bit much so want to know your opinion before real coding: changes: **before patch: typedef struct AioContext { GSource source; int walking_handlers; QemuMutex bh_lock; struct QEMUBH *first_bh; int walking_bh; EventNotifier notifier; GArray *pollfds; struct ThreadPool *thread_pool; } AioContext; **After patch: typedef struct BhSource { GSource source; QemuMutex bh_lock; struct QEMUBH *first_bh; int walking_bh; } BhSource; typedef struct FdSource { GSource source; int walking_handlers; EventNotifier notifier; GArray *pollfds; struct ThreadPool *thread_pool; } FdSource; Benefits: Original code have a mix of Gsource and GMainContext's concept, we may want to add wrapper functions around GMainContext's functions, such as g_main_context_acquire(), g_main_context_prepare(), which brings extra effort if you want to form a good and clear API layer. With this changes, all qemu's custom code is attached under Gsource, we have a clear GMainContext's API layer for event loop, no wrapper is needed, and the event's loop API is glib's API, a clear layer let me form a library or adding more things. before: qemu's mainloop caller, BH user, fd user | AioContext | GMainContext after: qemu's mainloop caller | BH user fd user GmainContext | | |--------------------------------|--BhSource | |-------------FdSource Note: FdSource could be split more into ThreadSource and FdSource, which distinguish more. It can be done easily if the change of this series is online, when found necessary. More reasons: When I thinking how to bind library code to a thread context, it may need to add Context's concept into API of block.c. If I use AioContext, there will need a wrapper API to run the event loop. But If I got glib's GmainContext, things become simple. -- Best Regards Wenchao Xia