[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC] pc: Register machine classes directly instead of
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [RFC] pc: Register machine classes directly instead of using QEMUMachine |
Date: |
Fri, 13 Jun 2014 03:08:52 -0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Thu, Jun 12, 2014 at 10:37:29AM +0200, Igor Mammedov wrote:
> On Thu, 12 Jun 2014 11:13:49 +0300
> "Michael S. Tsirkin" <address@hidden> wrote:
>
> > On Thu, Jun 12, 2014 at 03:22:24AM -0300, Eduardo Habkost wrote:
> > > This is a (mostly) blind and mechanical conversion of the PC QEMUMachine
> > > definitions to corresponding class registration code.
> > >
> > > Having the PC code converted to pure QOM registration code will help us
> > > move PC-specific machine state that is currently held in static
> > > variables inside PC machine objects, and reduce duplication between
> > > pc_piix.c and pc_q35.c.
> > >
> > > Signed-off-by: Eduardo Habkost <address@hidden>
> > > ---
> > > hw/i386/pc.c | 13 ++
> > > hw/i386/pc_piix.c | 473
> > > +++++++++++++++++++++++++++++++++++----------------
> > > hw/i386/pc_q35.c | 171 +++++++++++++------
> > > include/hw/i386/pc.h | 20 ++-
> > > 4 files changed, 465 insertions(+), 212 deletions(-)
> >
> > Hmm amount of boilerplate code seems to have doubled.
> > Can we find a solution that does away with code duplication?
> > Here's one idea: create one giant array with all necessary data, look it
> > up by name at runtime and fill everything in.
> > Not sure it's going to work out but might be worth a try.
> It's not quite QOMish way,
> making version-ed classes nested should reduce amount of boiler plate
> and make it easier to read/write.
> And if machines are made nested then we should also rethink usage/get rid of
> PC_COMPAT_* macros-es utilizing nesting provided by class hierarchy.
>
> This patch could serve as an intermediate step to remove usage of QEMUMachine
> though.
I am working to make only one hierarchy/nesting structure (class_init
hierarchy). Today we have the same hierarchy/nesting pattern duplicated
in multiple levels:
* PC_COMPAT_* (compat_props) nesting
* pc_compat_*() function nesting
* pc_init*() function duplication (all with the same compat+pc_init1()
pattern)
* QEMUMachine/PC_*_MACHINE_OPTIONS nesting/duplication
On my work in progress branch I've moved all hierarchy/nesting to
class_init, except for pc_compat_*(), which is still necessary in a few
cases because of the CPUID compat stuff.
My goal is to get all machine-types declared using only a class_init +
TypeInfo pair, and nothing else. That should also make us stop creating
new compat global variables on every release. :)
WIP can be seen at:
https://github.com/ehabkost/qemu-hacks/commits/work/pc-machine-class
Code now looks like this:
https://github.com/ehabkost/qemu-hacks/blob/24398f32268b333354d850da7437c1db263891ff/hw/i386/pc_piix.c
I'm not submitting an RFC right now because I need some sleep first, but
I plan to send one tomorrow.
I plan to addres the piix/q35 code duplication too. It should be much
easier to eliminate duplication now that we can have PC-specific
machine-type information in a PCMachineClass struct, and PC-specific
machine state information in a PCMachineState struct.
--
Eduardo