From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJpSi-0005hB-EI for qemu-devel@nongnu.org; Thu, 04 Oct 2012 13:43:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJpSg-0005A8-W1 for qemu-devel@nongnu.org; Thu, 04 Oct 2012 13:43:52 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:42907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJpSg-00059n-PF for qemu-devel@nongnu.org; Thu, 04 Oct 2012 13:43:50 -0400 Received: by mail-ob0-f173.google.com with SMTP id wc18so705054obb.4 for ; Thu, 04 Oct 2012 10:43:50 -0700 (PDT) From: Anthony Liguori In-Reply-To: <20121004155750.GB15784@otherpad.lan.raisama.net> References: <1349270954-4657-1-git-send-email-ehabkost@redhat.com> <1349270954-4657-2-git-send-email-ehabkost@redhat.com> <877gr6jqnt.fsf@codemonkey.ws> <20121004135751.GY15784@otherpad.lan.raisama.net> <87d30yxqca.fsf@codemonkey.ws> <20121004155750.GB15784@otherpad.lan.raisama.net> Date: Thu, 04 Oct 2012 12:43:46 -0500 Message-ID: <87626qjfot.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [RFC 01/18] pc: create "PC" device class List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Igor Mammedov , Paolo Bonzini , qemu-devel@nongnu.org, Gleb Natapov , Andreas =?utf-8?Q?F=C3=A4rber?= Eduardo Habkost writes: > On Thu, Oct 04, 2012 at 09:29:57AM -0500, Anthony Liguori wrote: >> Eduardo Habkost writes: >> >> > On Thu, Oct 04, 2012 at 08:46:46AM -0500, Anthony Liguori wrote: >> >> Eduardo Habkost writes: >> >> >> >> > We can make it a child of a generic "machine" class later, but right now >> >> > a "PC" class is needed to allow global-properties to control some >> >> > details of CPU creation on the PC code. >> >> > >> >> > Signed-off-by: Eduardo Habkost >> >> > --- >> >> > hw/pc.c | 18 ++++++++++++++++++ >> >> > hw/pc.h | 6 ++++++ >> >> > 2 files changed, 24 insertions(+) >> >> > >> >> > diff --git a/hw/pc.c b/hw/pc.c >> >> > index 7e7e0e2..9b68282 100644 >> >> > --- a/hw/pc.c >> >> > +++ b/hw/pc.c >> >> > @@ -550,6 +550,24 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val) >> >> > } >> >> > } >> >> > >> >> > +typedef struct PC { >> >> > + DeviceState parent_obj; >> >> > +} PC; >> >> >> >> So the general problem with this approach is that it strays from >> >> modeling hardware. >> > >> > True, it's not modelling hardware. It's controlling the behavior of the >> > QEMU code that set APIC IDs, because we need to keep the old behavior on >> > old machine-types. >> > >> >> >> >> I guess I'm confused why we're not just adding an apic_id property to >> >> the CPU objects and setting that via the normal QOM accessors. >> >> >> >> Wouldn't that solve the problem? >> >> >> > >> > It wouldn't solve the problem (although it can make the code look >> > better). >> > >> > The problem is not setting the APIC ID, is controlling the code that >> > generates the APIC IDs. I don't care too much where that code would live >> > (it could be inside cpu.c or helper.c), but it still needs a flag where >> > old machine-types tell it "please keep the old behavior for >> > compatibility". >> >> Can you just add a flag to pc_init1 and set the apic_id property >> according to that flag? >> >> Then you simply add a pc_init_post_1_3 and pc_init_pre_1_3 that calls >> pc_init1 with the appropriate flag value. > > I wish I was told this 6 months ago! I thought we wanted to avoid that > and wanted to start using global properties instead of making the list > of pc_init1() parameters grow. > > if that's acceptable then, yes, we could fix the bug without having to > deal with class and object modelling. Yes, this is absolutely acceptable. This is how we handle this kind of stuff today (like for kvmclock). Regards, Anthony Liguori > > >> >> Regards, >> >> Anthony Liguori >> >> > >> > >> >> Regards, >> >> >> >> Anthony Liguori >> >> >> >> > + >> >> > +static const TypeInfo pc_type_info = { >> >> > + .name = TYPE_PC_MACHINE, >> >> > + .parent = TYPE_DEVICE, >> >> > + .instance_size = sizeof(PC), >> >> > + .class_size = sizeof(DeviceClass), >> >> > +}; >> >> > + >> >> > +static void pc_register_type(void) >> >> > +{ >> >> > + type_register_static(&pc_type_info); >> >> > +} >> >> > + >> >> > +type_init(pc_register_type); >> >> > + >> >> > int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) >> >> > { >> >> > int index = le32_to_cpu(e820_table.count); >> >> > diff --git a/hw/pc.h b/hw/pc.h >> >> > index e4db071..77e898f 100644 >> >> > --- a/hw/pc.h >> >> > +++ b/hw/pc.h >> >> > @@ -102,6 +102,12 @@ void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out); >> >> > /* pc.c */ >> >> > extern int fd_bootchk; >> >> > >> >> > +#define TYPE_PC_MACHINE "PC" >> >> > +#define PC(obj) \ >> >> > + OBJECT_CHECK(PC, (obj), TYPE_PC_MACHINE) >> >> > +struct PC; >> >> > +typedef struct PC PC; >> >> > + >> >> > void pc_register_ferr_irq(qemu_irq irq); >> >> > void pc_acpi_smi_interrupt(void *opaque, int irq, int level); >> >> > >> >> > -- >> >> > 1.7.11.4 >> > >> > -- >> > Eduardo > > -- > Eduardo