From: Juan Quintela <quintela@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups
Date: Mon, 22 Mar 2010 02:06:44 +0100 [thread overview]
Message-ID: <m339ztp3kr.fsf@trasno.mitica> (raw)
In-Reply-To: <20100321191631.GA13355@redhat.com> (Michael S. Tsirkin's message of "Sun, 21 Mar 2010 21:16:31 +0200")
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Sun, Mar 21, 2010 at 06:11:43PM +0000, 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, to allocate the type, (2) it needs a virtual destructor for
>> each type to free the object, which can clutter the code if there is
>> no other reason for virtual destructors.
>>
>> I don't think those are necessarily bad, but they can remove from the
>> neatness of existing code. Personally I favour an occasional macro
>> using sizeof/offsetof/container_of if the result is a natural and
>> sensible API to all of its callers.
>>
>> -- Jamie
>
> We need to free in caller anyway because structure is used
> after cleanup. This can be changed by restructuring code ...
> I don't have a strong preference, anything is better
> than the hack relying on field being at offset 0 in structure.
It is not a hack.
Is the only sane way of sharing virtio common field without having to
export all virtio particular structs :(
I really hate how this is going :(
a- we have code that assumes that virtio is the 1st element of all
virtio structs.
b- we have a patch that codifies that virtio is used in that way (using
DO_UPCAST()) (me)
c- we arrived to the point where being it at the beggining of the struct
is the bigger cast in the universe (I present everybody thinking that
to look at rest of qemu). Patch is done that makes it possible to
alloc memory outside of virtio_common_init(). No code on virtio.c or
virtio-pci.c is changed to use this new offset. (michael).
d- Anthony arrives to the discussion stating that it should exist a
VirtIOPCIBus, that way virtio devices should be hanging of that bus
(that requires lots of changes).
e- kraxel arrives to the discussion stating that initializing in the
middle of one struct is the right thing to do, except if you are
qdev, that then it is not. I point to his suggestion that it makes
things still uglier (no answer yet, but it was weekend for him).
f- I show using kraxel example how ugly things go (sizeof (struct A) +
sizeof (struct B) - sizeof (struct C)). And here is when things fall
apart IMHO. Michael states that it is ok to have to had:
- an offset field
- a pointer in one struct to inside the same struct (vdev)
but assuming and stating and using an offset 0 is ugly.
Have I lost anything? Is there a realistic way of getting struct
VirtIODevice (and VirtIOBlock, ...) inside VirtIOPCIProxy that don't
imply using an offset + a pointer + exporting the struct definitions
only to calculate its size?
Don't get me wrong. I am the 1st one hating the relation VirtIO <->
PCI, but if we are going to change it, please do it to something that
its _simpler_ than current approach, not something that is still more
fragile and complex. I don't doubt that better solutions can exist, but
all that have been proposed are worse/more complex than what we have :(
Later, Juan.
next prev parent reply other threads:[~2010-03-22 1:06 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 18:51 [Qemu-devel] [PATCH 0/9] Virtio cleanups Juan Quintela
2010-03-16 18:51 ` [Qemu-devel] [PATCH 1/9] qemu/pci: document msix_entries_nr field Juan Quintela
2010-03-16 18:51 ` [Qemu-devel] [PATCH 2/9] virtio: Teach virtio-balloon about DO_UPCAST Juan Quintela
2010-03-18 7:29 ` [Qemu-devel] " Michael S. Tsirkin
2010-03-16 18:51 ` [Qemu-devel] [PATCH 3/9] virtio: Teach virtio-blk " Juan Quintela
2010-03-18 7:29 ` [Qemu-devel] " Michael S. Tsirkin
2010-03-16 18:51 ` [Qemu-devel] [PATCH 4/9] virtio: Teach virtio-net " Juan Quintela
2010-03-18 7:29 ` [Qemu-devel] " Michael S. Tsirkin
2010-03-16 18:51 ` [Qemu-devel] [PATCH 5/9] virtio: Use DO_UPCAST instead of a cast Juan Quintela
2010-03-18 7:30 ` [Qemu-devel] " Michael S. Tsirkin
2010-03-16 18:51 ` [Qemu-devel] [PATCH 6/9] virtio-pci: Remove duplicate test Juan Quintela
2010-03-18 7:25 ` [Qemu-devel] " Michael S. Tsirkin
2010-03-18 8:26 ` Juan Quintela
2010-03-18 8:47 ` Michael S. Tsirkin
2010-03-18 8:59 ` Juan Quintela
2010-03-18 9:11 ` Michael S. Tsirkin
2010-03-18 11:40 ` Juan Quintela
2010-03-18 13:24 ` Michael S. Tsirkin
2010-03-18 13:47 ` Juan Quintela
2010-03-16 18:51 ` [Qemu-devel] [PATCH 7/9] QLIST: Introduce QLIST_COPY_HEAD Juan Quintela
2010-03-16 18:51 ` [Qemu-devel] [PATCH 8/9] virtio-blk: change rq type to VirtIOBlockReq Juan Quintela
2010-03-18 7:27 ` [Qemu-devel] " Michael S. Tsirkin
2010-03-16 18:51 ` [Qemu-devel] [PATCH 9/9] virtio-blk: use QLIST for the list of requests Juan Quintela
2010-03-18 6:40 ` [Qemu-devel] Re: [PATCH 0/9] Virtio cleanups Michael S. Tsirkin
2010-03-18 7:36 ` Juan Quintela
2010-03-18 7:42 ` Michael S. Tsirkin
2010-03-18 8:36 ` Juan Quintela
2010-03-18 9:07 ` Michael S. Tsirkin
2010-03-18 11:53 ` Juan Quintela
2010-03-18 12:33 ` Michael S. Tsirkin
2010-03-18 13:43 ` Juan Quintela
2010-03-18 13:47 ` Michael S. Tsirkin
2010-03-18 14:21 ` Juan Quintela
2010-03-18 17:13 ` Michael S. Tsirkin
2010-03-19 1:41 ` Jamie Lokier
2010-03-21 14:31 ` Michael S. Tsirkin
2010-03-21 18:11 ` Jamie Lokier
2010-03-21 19:16 ` Michael S. Tsirkin
2010-03-22 1:06 ` Juan Quintela [this message]
2010-03-22 2:51 ` Anthony Liguori
2010-03-22 13:30 ` Paul Brook
2010-03-22 14:49 ` Anthony Liguori
2010-03-22 14:50 ` Michael S. Tsirkin
2010-03-22 15:03 ` Anthony Liguori
2010-03-22 15:17 ` Michael S. Tsirkin
2010-03-22 15:50 ` Anthony Liguori
2010-03-22 16:16 ` Paul Brook
2010-03-22 18:48 ` Anthony Liguori
2010-03-22 21:00 ` Paul Brook
2010-03-23 1:13 ` Anthony Liguori
2010-03-22 15:51 ` Paul Brook
2010-03-22 17:19 ` Michael S. Tsirkin
2010-03-22 22:16 ` Juan Quintela
2010-03-23 0:49 ` Paul Brook
2010-03-23 1:16 ` Anthony Liguori
2010-03-23 10:47 ` Michael S. Tsirkin
2010-03-23 11:11 ` Gerd Hoffmann
2010-03-23 11:40 ` Paul Brook
2010-03-23 11:58 ` Michael S. Tsirkin
2010-03-23 12:32 ` Juan Quintela
2010-03-21 19:57 ` Michael S. Tsirkin
2010-03-22 1:13 ` Juan Quintela
2010-03-22 8:37 ` Michael S. Tsirkin
2010-03-18 10:05 ` Michael S. Tsirkin
2010-03-18 15:43 ` Gerd Hoffmann
2010-03-18 16:20 ` Juan Quintela
2010-03-18 16:36 ` Gerd Hoffmann
2010-03-18 17:08 ` Juan Quintela
2010-03-18 17:21 ` Michael S. Tsirkin
2010-03-18 19:37 ` Juan Quintela
2010-03-18 20:07 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m339ztp3kr.fsf@trasno.mitica \
--to=quintela@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.