From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaTsC-0000UY-7k for qemu-devel@nongnu.org; Tue, 13 Dec 2011 10:02:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaTs6-0000rV-Eh for qemu-devel@nongnu.org; Tue, 13 Dec 2011 10:02:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaTs6-0000rB-25 for qemu-devel@nongnu.org; Tue, 13 Dec 2011 10:02:22 -0500 Message-ID: <4EE769B4.2020403@redhat.com> Date: Tue, 13 Dec 2011 16:05:24 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <4EE657AC.7080908@codemonkey.ws> <4EE7567E.3070702@codemonkey.ws> In-Reply-To: <4EE7567E.3070702@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] QEMU Object Model status/merge plan List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , Stefan Hajnoczi , Stefan Hajnoczi , qemu-devel , Markus Armbruster , Avi Kivity , Paolo Bonzini , Gerd Hoffmann Am 13.12.2011 14:43, schrieb Anthony Liguori: > On 12/13/2011 05:35 AM, Stefan Hajnoczi wrote: >> On Mon, Dec 12, 2011 at 7:36 PM, Anthony Liguori wrote: >>> I choose the serial device to showcase what we'll eventually be able to do. >>> The three relevant files are: >>> >>> https://github.com/aliguori/qemu/blob/qom-next/hw/isa-serial.c >>> >>> https://github.com/aliguori/qemu/blob/qom-next/hw/mm-serial.c >>> >>> https://github.com/aliguori/qemu/blob/qom-next/hw/serial.c >> >> I'm not sure I understand how init functions are called for derived >> classes. > > There are three types of init functions: > > class_init > ========== > > This lives in (TypeInit) and is called when a class is first created for a type. > It is only ever called once. Within this function, you should override any > methods in your base classes and set default implementations for any methods you > implement. I guess in most cases this could be replaced by a static table and the function could be made optional? (That is, there could be a default implementation for the NULL case) > instance_init > ============= > > This is the constructor for a type. It is called when an object is created and > chained such that the base class constructors are called first to initialize the > object. Same for this one, in your serial code it looks like this doesn't do anything interesting in the common case and could be made optional (it adds an UART child device, but this is static property and should be moved anyway) I think even in the future the really interesting work will be done in realize. Kevin