From: Eduardo Habkost Subject: Re: [RFC 0/8] include qdev core in *-user, make CPU child of DeviceState Date: Wed, 22 Aug 2012 10:08:48 -0300 Message-ID: <20120822130848.GF2886@otherpad.lan.raisama.net> References: <1345563782-11224-1-git-send-email-ehabkost@redhat.com> <5034A0E8.1080507@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <5034A0E8.1080507@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org To: Avi Kivity Cc: peter.maydell@linaro.org, jan.kiszka@siemens.com, mjt@tls.msk.ru, qemu-devel@nongnu.org, armbru@redhat.com, blauwirbel@gmail.com, kraxel@redhat.com, xen-devel@lists.xensource.com, i.mitsyanko@samsung.com, mdroth@linux.vnet.ibm.com, anthony.perard@citrix.com, lersek@redhat.com, stefanha@linux.vnet.ibm.com, stefano.stabellini@eu.citrix.com, sw@weilnetz.de, imammedo@redhat.com, lcapitulino@redhat.com, rth@twiddle.net, kwolf@redhat.com, aliguori@us.ibm.com, mtosatti@redhat.com, pbonzini@redhat.com, afaerber@suse.de List-Id: xen-devel@lists.xenproject.org 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