qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Amit Shah <amit.shah@redhat.com>,
	qemu list <qemu-devel@nongnu.org>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API
Date: Wed, 23 Feb 2011 14:40:49 +0200	[thread overview]
Message-ID: <4D650051.5070709@redhat.com> (raw)
In-Reply-To: <4D63FEA4.1000002@codemonkey.ws>

On 02/22/2011 08:21 PM, Anthony Liguori wrote:
> On 02/22/2011 10:21 AM, Avi Kivity wrote:
>> On 02/22/2011 05:00 PM, Anthony Liguori wrote:
>>>>
>>>> Drop the opaque, instead put the IOHandler in there (or maybe the 
>>>> CharDev?) and use container_of().
>>>
>>>
>>> You know, I'm not there that this is automatically better.
>>
>> Why not?  One less unsafe cast.
>
> It turns out there are a lot of cases in QEMU where there isn't an 
> obvious data structure to piggy back on.

Examples?

In that case you can always make a structure with a void * and a 
IOHandler, and you get your opaque.  But I don't really see how it can 
happen, the void * always points to a structure (or is ignored if 
there's a static instance), and you can add that IOHandler to the structure.

>
>>> Why is there an IOHandler and an IOEventHandler argument for init?
>
> So wouldn't you set the IOEventHandler directly in the IOHandler as 
> part of initialization?  IOW:
>
> struct MyDevice {
>     IOHandler iohandler;
> };
>
> iohandler.func = my_io_function;
> io_handler_init(&iohandler, fd, event_mask);
>
> That's the paradigm I'm used to at least.

You mean instead of passing .func to io_handler_init()?  I slightly 
prefer my version (less chance to forget the assignment) but I'm okay 
with either.

-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2011-02-23 12:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22 10:18 [Qemu-devel] [PATCH 0/7] New iohandler API Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 1/7] iohandlers: Mark current implementation as 'old' Amit Shah
2011-02-22 11:09   ` Avi Kivity
2011-02-22 11:17     ` Amit Shah
2011-02-22 13:28       ` Avi Kivity
2011-02-22 14:37         ` Amit Shah
2011-02-22 14:43           ` Avi Kivity
2011-02-22 10:18 ` [Qemu-devel] [PATCH 2/7] iohandlers: Introduce a new API Amit Shah
2011-02-22 12:39   ` Alon Levy
2011-02-22 13:09     ` Amit Shah
2011-02-22 13:28   ` Avi Kivity
2011-02-22 14:39     ` Amit Shah
2011-02-22 15:00     ` Anthony Liguori
2011-02-22 16:21       ` Avi Kivity
2011-02-22 18:21         ` Anthony Liguori
2011-02-23 12:40           ` Avi Kivity [this message]
2011-02-22 14:49   ` [Qemu-devel] " Anthony Liguori
2011-02-22 10:18 ` [Qemu-devel] [PATCH 3/7] char: tcp: Use new iohandler api Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 4/7] char: udp: " Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 5/7] char: fd: " Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 6/7] char: stdio: " Amit Shah
2011-02-22 10:18 ` [Qemu-devel] [PATCH 7/7] char: pty: " Amit Shah

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=4D650051.5070709@redhat.com \
    --to=avi@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=kraxel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).