On Wed, Aug 22, 2012 at 12:05:44PM +0300, Avi Kivity wrote: > On 08/21/2012 06:42 PM, Eduardo Habkost wrote: > > So, here's a third suggestion to the CPU/DeviceState problem. Basically I > > split > > the qdev code into a core (that can be easily compiled into *-user), and a > > part > > specific to qemu-system-*. > > > > I'm barging in late here, so sorry if this has been suggested and shot > down: is it not possible to use composition here? > > typedef ... CPU; > > typedef struct CPUState { > DeviceState qdev; > CPU cpu; > } CPUState; > > But I guess bringing qdev to -user is inevitable.
I guess it would be OK, and almost equivalent to the suggestion by Anthony (use a different parent class for the CPU class on system-* and *-user), as most state today is in the arch-specific classes. The only problem I see is when some part of the CPU code starts using a DeviceState feature (e.g. calling x86_cpu_realize() only at qdev_init()-time). Then we have to duplicate some code to make *-user work differently (not much code, I guess, but it would still make it easier to break it if we have two implementations). -- Eduardo