[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-23 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Tue, Mar 23, 2010 at 11:40:46AM +, Paul Brook wrote: >> > > Right. The only real challenge is dealing with legacy save/restore and >> > > command line syntax. For save/restore, we can possibly have a dummy >> > > device that can split the VirtioPCI device sta

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-23 Thread Michael S. Tsirkin
On Tue, Mar 23, 2010 at 11:40:46AM +, Paul Brook wrote: > > > Right. The only real challenge is dealing with legacy save/restore and > > > command line syntax. For save/restore, we can possibly have a dummy > > > device that can split the VirtioPCI device state from the virtio device > > > st

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-23 Thread Paul Brook
> > Right. The only real challenge is dealing with legacy save/restore and > > command line syntax. For save/restore, we can possibly have a dummy > > device that can split the VirtioPCI device state from the virtio device > > states and do the right thing. > > > > I'm not sure what we should do

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-23 Thread Gerd Hoffmann
On 03/23/10 11:47, Michael S. Tsirkin wrote: I'm not sure what we should do for command line syntax. We can keep -drive working as is. Do we need to support -device based creation? I don't think we've really considered what to do in a situation like this. If we need to change command line b

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-23 Thread Michael S. Tsirkin
On Mon, Mar 22, 2010 at 08:16:01PM -0500, Anthony Liguori wrote: > On 03/22/2010 07:49 PM, Paul Brook wrote: >>> Solutions: >>> - VirtIOPCIBus and hang devices from there (anthony). Why? because >>> this is a simulated pci bus, we can implement the features that we >>> need (not full pci) in

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Anthony Liguori
On 03/22/2010 07:49 PM, Paul Brook wrote: Solutions: - VirtIOPCIBus and hang devices from there (anthony). Why? because this is a simulated pci bus, we can implement the features that we need (not full pci) in the three showed architectures. We will have VirtIOPCIBLock everywhere, and i

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Anthony Liguori
On 03/22/2010 04:00 PM, Paul Brook wrote: On 03/22/2010 11:16 AM, Paul Brook wrote: But look at the lguest virtio implement. We would definitely model a VirtIOBus if we implemented something like that in qemu. VirtIO really is designed to be a bus. When you say "bus" you actua

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Paul Brook
>Solutions: >- VirtIOPCIBus and hang devices from there (anthony). Why? because > this is a simulated pci bus, we can implement the features that we > need (not full pci) in the three showed architectures. We will have > VirtIOPCIBLock everywhere, and its VirtIOPCIBus implmentation will > h

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Mon, Mar 22, 2010 at 03:51:43PM +, Paul Brook wrote: >> > > It's a classic OOP problem. >> > > >> > > VirtIOBlock is-a VirtIODevice, VirtIODevice is-a DeviceState >> > > >> > > VirtIOPCI is-a PCIDevice, PCIDevice is-a Device State. >> > > >> > > But VirtIODevic

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Paul Brook
> On 03/22/2010 11:16 AM, Paul Brook wrote: > >> But look at the lguest virtio implement. We would definitely model a > >> VirtIOBus if we implemented something like that in qemu. VirtIO really > >> is designed to be a bus. > > > > When you say "bus" you actually mean point-point connection, righ

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Anthony Liguori
On 03/22/2010 11:16 AM, Paul Brook wrote: But look at the lguest virtio implement. We would definitely model a VirtIOBus if we implemented something like that in qemu. VirtIO really is designed to be a bus. When you say "bus" you actually mean point-point connection, right[1]? I don't se

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Michael S. Tsirkin
On Mon, Mar 22, 2010 at 03:51:43PM +, Paul Brook wrote: > > > It's a classic OOP problem. > > > > > > VirtIOBlock is-a VirtIODevice, VirtIODevice is-a DeviceState > > > > > > VirtIOPCI is-a PCIDevice, PCIDevice is-a Device State. > > > > > > But VirtIODevice is-a VirtIOPCI device isn't always t

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Paul Brook
> But look at the lguest virtio implement. We would definitely model a > VirtIOBus if we implemented something like that in qemu. VirtIO really > is designed to be a bus. When you say "bus" you actually mean point-point connection, right[1]? I don't see anything in virtio that allows arbitration

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Paul Brook
> > It's a classic OOP problem. > > > > VirtIOBlock is-a VirtIODevice, VirtIODevice is-a DeviceState > > > > VirtIOPCI is-a PCIDevice, PCIDevice is-a Device State. > > > > But VirtIODevice is-a VirtIOPCI device isn't always true so it can't be > > an is-a relationship. Initially, this was true and

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Anthony Liguori
On 03/22/2010 10:17 AM, Michael S. Tsirkin wrote: On Mon, Mar 22, 2010 at 10:03:29AM -0500, Anthony Liguori wrote: On 03/22/2010 09:50 AM, Michael S. Tsirkin wrote: On Mon, Mar 22, 2010 at 09:49:03AM -0500, Anthony Liguori wrote: On 03/22/2010 08:30 AM, Paul Brook wrote:

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Michael S. Tsirkin
On Mon, Mar 22, 2010 at 10:03:29AM -0500, Anthony Liguori wrote: > On 03/22/2010 09:50 AM, Michael S. Tsirkin wrote: >> On Mon, Mar 22, 2010 at 09:49:03AM -0500, Anthony Liguori wrote: >> >>> On 03/22/2010 08:30 AM, Paul Brook wrote: >>> > A VirtIOBlock device cannot be a VirtIODevice

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Anthony Liguori
On 03/22/2010 09:50 AM, Michael S. Tsirkin wrote: On Mon, Mar 22, 2010 at 09:49:03AM -0500, Anthony Liguori wrote: On 03/22/2010 08:30 AM, Paul Brook wrote: A VirtIOBlock device cannot be a VirtIODevice while being a VirtIOPCIProxy (proxy is a poor name, btw). It really ought to be:

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Michael S. Tsirkin
On Mon, Mar 22, 2010 at 09:49:03AM -0500, Anthony Liguori wrote: > On 03/22/2010 08:30 AM, Paul Brook wrote: >>> A VirtIOBlock device cannot be a VirtIODevice while being a >>> VirtIOPCIProxy (proxy is a poor name, btw). >>> >>> It really ought to be: >>> >>> DeviceState -> VirtIODevice -> VirtIO

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Anthony Liguori
On 03/22/2010 08:30 AM, Paul Brook wrote: A VirtIOBlock device cannot be a VirtIODevice while being a VirtIOPCIProxy (proxy is a poor name, btw). It really ought to be: DeviceState -> VirtIODevice -> VirtIOBlock and: PCIDevice -> VirtIOPCI : implements VirtIOBus The interface between the

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Paul Brook
> A VirtIOBlock device cannot be a VirtIODevice while being a > VirtIOPCIProxy (proxy is a poor name, btw). > > It really ought to be: > > DeviceState -> VirtIODevice -> VirtIOBlock > > and: > > PCIDevice -> VirtIOPCI : implements VirtIOBus > > The interface between the VirtIODevice and VirtIO

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-22 Thread Michael S. Tsirkin
On Mon, Mar 22, 2010 at 02:13:48AM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > On Sun, Mar 21, 2010 at 06:11:43PM +, Jamie Lokier wrote: > >> Michael S. Tsirkin wrote: > >> > That's version 1 of my patch. Version 2 removed even need for macro > >> > completely by moving alloc

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-21 Thread Anthony Liguori
On 03/21/2010 08:06 PM, Juan Quintela wrote: "Michael S. Tsirkin" wrote: On Sun, Mar 21, 2010 at 06:11:43PM +, Jamie Lokier wrote: Michael S. Tsirkin wrote: That's version 1 of my patch. Version 2 removed even need for macro completely by moving allocations to the caller

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-21 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Sun, Mar 21, 2010 at 06:11:43PM +, Jamie Lokier wrote: >> Michael S. Tsirkin wrote: >> > That's version 1 of my patch. Version 2 removed even need for macro >> > completely by moving allocations to the caller. >> >> The downside of moving allocations are: (1)

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-21 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Sun, Mar 21, 2010 at 06:11:43PM +, Jamie Lokier wrote: >> Michael S. Tsirkin wrote: >> > That's version 1 of my patch. Version 2 removed even need for macro >> > completely by moving allocations to the caller. >> >> The downside of moving allocations are: (1)

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-21 Thread Michael S. Tsirkin
On Sun, Mar 21, 2010 at 06:11:43PM +, Jamie Lokier wrote: > Michael S. Tsirkin wrote: > > That's version 1 of my patch. Version 2 removed even need for macro > > completely by moving allocations to the caller. > > The downside of moving allocations are: (1) it's one more call in the > caller,

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-21 Thread Michael S. Tsirkin
On Sun, Mar 21, 2010 at 06:11:43PM +, Jamie Lokier wrote: > Michael S. Tsirkin wrote: > > That's version 1 of my patch. Version 2 removed even need for macro > > completely by moving allocations to the caller. > > The downside of moving allocations are: (1) it's one more call in the > caller,

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-21 Thread Jamie Lokier
Michael S. Tsirkin wrote: > That's version 1 of my patch. Version 2 removed even need for macro > completely by moving allocations to the caller. The downside of moving allocations are: (1) it's one more call in the caller, to allocate the type, (2) it needs a virtual destructor for each type to f

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-21 Thread Michael S. Tsirkin
On Fri, Mar 19, 2010 at 01:41:59AM +, Jamie Lokier wrote: > Juan Quintela wrote: > > vstrucut virtio_common *create_virtio_comon(, size we really want); > > Again, this implements superclass/subclass as well as you can implemnt > > it in C. > > It would be more type-safe for create_virtio_

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Jamie Lokier
Juan Quintela wrote: > vstrucut virtio_common *create_virtio_comon(, size we really want); > Again, this implements superclass/subclass as well as you can implemnt > it in C. It would be more type-safe for create_virtio_common() to be a macro taking the subclass *type* rather than sizeof. And

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Anthony Liguori
On 03/18/2010 11:36 AM, Gerd Hoffmann wrote: Hi, But I still think that this is independent that VirtIO being 1st (or not) memer of VirtIOBlock. There is no strong reason for this other than memory allocation. As long as virtio_common_init() does the allocation there is no way around Vir

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Thu, Mar 18, 2010 at 06:08:06PM +0100, Juan Quintela wrote: >> Gerd Hoffmann wrote: > > The whole '1st place' hack is really not necessary, if we know the > offset we can use container_of. container_of() don't cut mustard. The whole point is that virtio-pci cod

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Michael S. Tsirkin
On Thu, Mar 18, 2010 at 06:08:06PM +0100, Juan Quintela wrote: > Gerd Hoffmann wrote: > > Hi, > > > >> But I still think that this is independent that VirtIO being 1st (or > >> not) memer of VirtIOBlock. > > > > There is no strong reason for this other than memory allocation. As > > long as vir

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Michael S. Tsirkin
On Thu, Mar 18, 2010 at 03:21:59PM +0100, Juan Quintela wrote: > > My patch removes lines of code. It is actually simpler than > > what we had: no casts, no assumptions. > > It is more complex. You need to add a new offset field to be able to > free it in common code. To add insult to injury, yo

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
Gerd Hoffmann wrote: > Hi, > >> But I still think that this is independent that VirtIO being 1st (or >> not) memer of VirtIOBlock. > > There is no strong reason for this other than memory allocation. As > long as virtio_common_init() does the allocation there is no way > around VirtIODevice bei

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Gerd Hoffmann
Hi, But I still think that this is independent that VirtIO being 1st (or not) memer of VirtIOBlock. There is no strong reason for this other than memory allocation. As long as virtio_common_init() does the allocation there is no way around VirtIODevice being the first member. If this cha

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
Gerd Hoffmann wrote: > Hi, > >>> I think we should move away from struct layout assumptions that >>> DO_UPCAST enforces, and to use container_of where possible. >>> I'll post a series shortly that do this for virtio. >> >> Not in this case. qdev needs it to be in that order, and that will not >

Re: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Gerd Hoffmann
Hi, I think we should move away from struct layout assumptions that DO_UPCAST enforces, and to use container_of where possible. I'll post a series shortly that do this for virtio. Not in this case. qdev needs it to be in that order, and that will not change without changing everything again

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Thu, Mar 18, 2010 at 02:43:04PM +0100, Juan Quintela wrote: >> "Michael S. Tsirkin" wrote: >> > On Thu, Mar 18, 2010 at 12:53:06PM +0100, Juan Quintela wrote: >> >> >> >> You cant. Your trick of creating of mallocking in the caller the struct >> >> don't work fo

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Michael S. Tsirkin
On Thu, Mar 18, 2010 at 02:43:04PM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > On Thu, Mar 18, 2010 at 12:53:06PM +0100, Juan Quintela wrote: > >> > >> You cant. Your trick of creating of mallocking in the caller the struct > >> don't work for qdev. qdev is the one that create

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Thu, Mar 18, 2010 at 12:53:06PM +0100, Juan Quintela wrote: >> >> You cant. Your trick of creating of mallocking in the caller the struct >> don't work for qdev. qdev is the one that creates it. Again, any other >> implementation is going to be more complex for

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Michael S. Tsirkin
On Thu, Mar 18, 2010 at 12:53:06PM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > On Thu, Mar 18, 2010 at 09:36:15AM +0100, Juan Quintela wrote: > >> "Michael S. Tsirkin" wrote: > >> > >> >> Look at the rest of hw/*. > >> > > >> > I think you mean that a similar assumption is ma

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Thu, Mar 18, 2010 at 09:36:15AM +0100, Juan Quintela wrote: >> "Michael S. Tsirkin" wrote: >> >> >> Look at the rest of hw/*. >> > >> > I think you mean that a similar assumption is made by lots of >> > other code. Does not mean it's always a good idea and that

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Michael S. Tsirkin
On Thu, Mar 18, 2010 at 09:36:15AM +0100, Juan Quintela wrote: > searching for how to use a qemu api because from only the > prototypes it is not clear, That's the issue right there: if prototype is not enough we should add documentation. > and just pick an example, and that one uses > it in a no

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Michael S. Tsirkin
On Thu, Mar 18, 2010 at 09:36:15AM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > >> Look at the rest of hw/*. > > > > I think you mean that a similar assumption is made by lots of > > other code. Does not mean it's always a good idea and that > > we need to force this assumption

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
"Michael S. Tsirkin" wrote: >> Look at the rest of hw/*. > > I think you mean that a similar assumption is made by lots of > other code. Does not mean it's always a good idea and that > we need to force this assumption everywhere. Principle of Least Surprise. as posted in the other email, rem

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Michael S. Tsirkin
On Thu, Mar 18, 2010 at 08:36:26AM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > On Tue, Mar 16, 2010 at 07:51:16PM +0100, Juan Quintela wrote: > >> Hi > >> > >> This series introduces several virtio cleanups: > >> - add comment to pci (mst) > >> - tell virtio about DO_UPCAST > >

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-18 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Tue, Mar 16, 2010 at 07:51:16PM +0100, Juan Quintela wrote: >> Hi >> >> This series introduces several virtio cleanups: >> - add comment to pci (mst) >> - tell virtio about DO_UPCAST > > I think we should move away from struct layout assumptions that > DO_UPCAST e

[Qemu-devel] Re: [PATCH 0/9] Virtio cleanups

2010-03-17 Thread Michael S. Tsirkin
On Tue, Mar 16, 2010 at 07:51:16PM +0100, Juan Quintela wrote: > Hi > > This series introduces several virtio cleanups: > - add comment to pci (mst) > - tell virtio about DO_UPCAST I think we should move away from struct layout assumptions that DO_UPCAST enforces, and to use container_of where po