Re: [PATCH kvm-unit-tests 2/4] Introduce a C++ wrapper for the kvm APIs

Avi Kivity
2010-11-24T16:59:18Z

On 11/24/2010 06:51 PM, Jes Sorensen wrote:
> On 11/24/10 17:47, Avi Kivity wrote:
> > On 11/24/2010 06:40 PM, Jes Sorensen wrote:
> >> Well the problem here is that the i8042 is in the i440fx.c file, it
> >> shouldn't be there in the first place. The gluing together things in
> >> silicon is really just a way to shorten the wires and make it easier,
> >> they are still separate devices and as long as the i8042 requires ISA
> >> access, and to be treated like an ISA device, we should glue it onto the
> >> virtual ISA bus within QEMU.
> >>
> >> What you did above is making the exact same mistake as is done with the
> >> current i440fx.c code.
> >
> > If a real life 440fx has an i8042, then an emulated 440fx should have an
> > emulated i8042. It's not complicated.
>
> It's a question of how it is accessed, if it is treated like an ISA
> device by the silicon, we should treat it like an ISA device in QEMU,
> rather than pretend it is something that it isn't.

No one is saying it shouldn't be an ISA device if that's how PIIX3
treats it. But if PIIX3 contains it, then the code that emulates PIIX3
should contain the code that emulates i8042.

> >> >>> So whereas we have this very complicate machine create function that
> >> >>> attempts to create and composite all of these devices after the
> >> >>> fact, when written in C++, partially due to good design, but
> >> >>> partially due to the fact that the languages forces you to think a
> >> >>> certain way, you get a tremendous simplification.
> >>
> >> That is clearly dependent on the eyes of the person who looks at it.
> >
> > It's independent of language. It should be done in C as well. C++ just
> > makes it easier by reducing the boilerplate.
>
> Right we need good design for our C code, which we are lacking to a
> large extend. However that has nothing to do with the language, that has
> to do with the developers.

I'm sure patches will be welcome.

C++ doesn't enforce good design. But it allows a good design to be
enforced.

--
error compiling committee.c: too many arguments to function