Re: [Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-03 Thread Avi Kivity
On 12/03/2009 02:55 PM, Juan Quintela wrote: sorry, already allocated memory. basically -device foo requires that qdev creates foo and then it call foo_init(). Alternatives: - foo_init() allocates Foo and calls qdev_init() (how C++ works, but cumbersome here) - we put the offset of D

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-03 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Thu, Dec 03, 2009 at 12:56:57PM +0100, Juan Quintela wrote: >> "Michael S. Tsirkin" wrote: >> > On Wed, Dec 02, 2009 at 08:03:22PM +0100, Juan Quintela wrote: >> >> "Michael S. Tsirkin" wrote: >> >> >> >> > I don't understand. >> >> > container_of is just more g

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-03 Thread Michael S. Tsirkin
On Thu, Dec 03, 2009 at 12:56:57PM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > On Wed, Dec 02, 2009 at 08:03:22PM +0100, Juan Quintela wrote: > >> "Michael S. Tsirkin" wrote: > >> > >> > I don't understand. > >> > container_of is just more generic than DO_UPCAST. > >> > So why

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-03 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Wed, Dec 02, 2009 at 08:03:22PM +0100, Juan Quintela wrote: >> "Michael S. Tsirkin" wrote: >> >> > I don't understand. >> > container_of is just more generic than DO_UPCAST. >> > So why *ever* use DO_UPCAST? Let's get rid of it. >> See how you create a dev

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-03 Thread Michael S. Tsirkin
On Wed, Dec 02, 2009 at 08:03:22PM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > > I don't understand. > > container_of is just more generic than DO_UPCAST. > > So why *ever* use DO_UPCAST? Let's get rid of it. > > functions that use a PCIDevice and you pass FooState "require" th

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-02 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > I don't understand. > container_of is just more generic than DO_UPCAST. > So why *ever* use DO_UPCAST? Let's get rid of it. functions that use a PCIDevice and you pass FooState "require" that PCIDevice to be the 1st element in the struct. Notice that it is "require

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-02 Thread Michael S. Tsirkin
On Wed, Dec 02, 2009 at 07:42:35PM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > On Wed, Dec 02, 2009 at 07:19:17PM +0100, Juan Quintela wrote: > >> "Michael S. Tsirkin" wrote: > >> > On Wed, Dec 02, 2009 at 01:04:04PM +0100, Juan Quintela wrote: > >> >> virtio_common_init() creat

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-02 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Wed, Dec 02, 2009 at 07:19:17PM +0100, Juan Quintela wrote: >> "Michael S. Tsirkin" wrote: >> > On Wed, Dec 02, 2009 at 01:04:04PM +0100, Juan Quintela wrote: >> >> virtio_common_init() creates a struct with the right size, DO_UPCAST >> >> is the appropiate thing

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-02 Thread Michael S. Tsirkin
On Wed, Dec 02, 2009 at 07:19:17PM +0100, Juan Quintela wrote: > "Michael S. Tsirkin" wrote: > > On Wed, Dec 02, 2009 at 01:04:04PM +0100, Juan Quintela wrote: > >> virtio_common_init() creates a struct with the right size, DO_UPCAST > >> is the appropiate thing here > >> > >> Signed-off-by: Juan

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-02 Thread Juan Quintela
"Michael S. Tsirkin" wrote: > On Wed, Dec 02, 2009 at 01:04:04PM +0100, Juan Quintela wrote: >> virtio_common_init() creates a struct with the right size, DO_UPCAST >> is the appropiate thing here >> >> Signed-off-by: Juan Quintela > > BTW why not container_of? That one does not require > field

[Qemu-devel] Re: [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast

2009-12-02 Thread Michael S. Tsirkin
On Wed, Dec 02, 2009 at 01:04:04PM +0100, Juan Quintela wrote: > virtio_common_init() creates a struct with the right size, DO_UPCAST > is the appropiate thing here > > Signed-off-by: Juan Quintela BTW why not container_of? That one does not require field to be at the beginning of structure. >