From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wfw67-0008QH-Vb for qemu-devel@nongnu.org; Thu, 01 May 2014 14:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wfw60-0003Ys-Fj for qemu-devel@nongnu.org; Thu, 01 May 2014 14:52:43 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36228 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wfw60-0003YS-8v for qemu-devel@nongnu.org; Thu, 01 May 2014 14:52:36 -0400 Message-ID: <536297F0.6050702@suse.de> Date: Thu, 01 May 2014 20:52:32 +0200 From: Alexander Graf MIME-Version: 1.0 References: <20140430194108.GB16023@ERROL.INI.CMU.EDU> <536152A0.6010104@suse.de> <20140501172226.GC16023@ERROL.INI.CMU.EDU> In-Reply-To: <20140501172226.GC16023@ERROL.INI.CMU.EDU> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3] apic: bump emulated lapic version to 0x14 on pc machines >= 2.1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gabriel L. Somlo" Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, afaerber@suse.de, mst@redhat.com On 01.05.14 19:22, Gabriel L. Somlo wrote: > On Wed, Apr 30, 2014 at 09:44:32PM +0200, Alexander Graf wrote: >>> diff --git a/hw/intc/apic.c b/hw/intc/apic.c >>> index 2f40cba..4480bc4 100644 >>> --- a/hw/intc/apic.c >>> +++ b/hw/intc/apic.c >>> @@ -32,6 +32,8 @@ >>> #define SYNC_TO_VAPIC 0x2 >>> #define SYNC_ISR_IRR_TO_VAPIC 0x4 >>> +uint8_t apic_version = 0x14; >> Is there any way to make this a qdev/qom device property rather than >> a global? > If there is, and anyone with a better understanding of qom/qdev > has an example I could follow, that would be much appreciated! > > As far as I could comprehend it since I started looking at it last > night, the apic_class_init() functions run before pci_init() in > pc_[q35|piix].c knows which machine type we have, but the > apic_realize() functions (which appear to be the actual apic > "constructors") run after that. > > The obvious alternative to having one global apic version would be > to add a field to APICCommonClass or APICCommonState, and then somehow > modify the default (set in apic_class_init()) from pci_init() > according to the machine version; After that, each apic may refer to > its private data member "version" when needed. > > So, is qom/qdev basically boiling down to a set of macros that can > translate something like "qom_set_property(apic_instance, version, 0x14);" > into "apic_instance.version = 0x14;" ? With qdev we basically had an array of constructor parameters in the qdev definition. You could set these from the outside between create and init, basically: dev = dev_create() set_prop(dev, "foo", bar); dev_init(dev) which semantically translated to dev = new dev(foo = bar); The way to do this with QOM is similar, but I keep forgetting the details. I'm sure you'll easily find out :). Alex