All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <Ian.Jackson@eu.citrix.com>
To: Ian Campbell <Ian.Campbell@eu.citrix.com>
Cc: Jim Fehlig <jfehlig@novell.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 2/3] RFC: libxl: API changes re event handling
Date: Wed, 13 Jul 2011 17:17:52 +0100	[thread overview]
Message-ID: <19997.50480.893938.619011@mariner.uk.xensource.com> (raw)
In-Reply-To: <1310573299.634.413.camel@zakaz.uk.xensource.com>

Ian Campbell writes ("Re: [Xen-devel] [PATCH 2/3] RFC: libxl: API changes re event handling"):
> On Wed, 2011-07-13 at 15:03 +0100, Ian Jackson wrote:
> > No; the user is supposed to pass libxl a pointer to a subsection of
> > the array which is for libxl's use.
...
> where nr is updated (+= N) and poll_fds[nr...nr+N] are initialised or is
> it:
> 	poll_fds[SOME];
> 	int nr = 0, nr_libxl;
> 	poll_fds[nr++] = blah;
> 	poll_fds[nr++] = blahbla;
> 	nr_libxl = SOME-nr;
> 	libxl_osevent_beforepoll(..., &nr_libxl, &poll_fds[nr], ....)
> 	nr += nr_libxl;

Yes.

> I think you were describing the latter but the former seems marginally
> easier on the user (or seems so to me).

The former doesn't pass SOME to libxl and has to.  And what if they
don't fit ?  You have to realloc the array, probably.

> Actually, of course it was the latter because the former requires you to
> pass the limit (==SOME) somewhere which the interface doesn't include
> (but perhaps it should).

That would be possible but it seems like leaking the caller's stuff
into the library to me.

> > Yes.  Call it with fds==NULL and *nfds_io==0.  Is this not clear ?
> 
> On second reading it's clear that nfds_io is always updated but not so
> much that you could deliberately call it with fds=NULL (although I know
> that's a common idiom and it's obvious now you mention it).

I'll add a comment about that.

> > I think this is unhelpful.  Can we change this convention ?
> 
> I think it's the norm in most other projects etc too. To be honest
> documenting functions afterwards just looks strange to me. Maybe it's a
> Linux-ism I've become used too.

I think the point is that in a C header file the function declaration
is the primary piece of information and the doc comment is subtleties
to do with the parameters.  Having a comment describing a bunch of
subtleties in something you haven't read yet is just weird.  And
comments restating the declaration is obviously EBW.

> > All things that libxl wants to do and which can be done according to
> > fds[].revents (and the time).  I should add something about this to
> > the comment, evidently.
> 
> So it'll call the hooks if you've registered them etc?

Yes.

> I wonder if libxl should internally count pollbefore/after and warn if
> libxl_event_check is called while they are unbalanced to catch this sort
> of issue.

That might be worthwhile although it's not clear to me which calling
patterns are wrong.  Calling beforepoll and then not calling poll is
fine, for example.  You might change your mind and call beforepoll
again.  What's wrong is calling poll and then not calling afterpoll
and then calling check but libxl can't see you call poll.

> > libxl_event_8 are interchangeable (and miscible) ways of getting
> > higher-level occurrences about domains out of libxl and into the
> > application.
> 
> Ah, ok that's a useful high-level thing I'd missed.
> 
> Where do the libxl_await_* functions fit in? Do they enable the
> generation of the events to which they refer or do they actually stop
> and wait? Await makes it sound like the latter but the comment preceding
> those functions says
>         * Events are only generated if they have been requested.
>         * The following functions request the generation of specific
>         events.
> which sounds like the former.

They don't wait; they enable the generation of events.  Would you care
to suggest a different name ?

> > > > +void libxl_event_register_callbacks(libxl_ctx *ctx, void *user, uint64_t mask,
> 
> Here (and in various other places) you have a "void *user" closure thing
> but I noticed in libxl_await_* you have "uint64_t user" -- is this
> inconsistency deliberate? (AIUI the void * is passed to event_occurs and
> the uint64_t is stashed in the libxl_event structure).

We don't want to put a void* in an idl type.  A "foreign" caller (eg,
one in a different process communicating by IPC) can't easily invent
pointers.

> > No, it's an opaque thing used by the library to store its own
> > information about the application's interest.
> 
> So it should be:
>         typedef struct libxl__awaiting_disk_eject
>         libxl_awaiting_disk_eject;
> ? and libxl__awaiting_disk_eject will be in libxl_internal.idl (which is
> added by Anthony's QMP series).

Except that I think the extra _ is confusing rather than helpful, yes.

> > > It might be convenient to users if these structs were named so they can
> > > dispatch to handle_domain_shutdown(struct libxl_event_domain_shutdown
> > > *info) ?
> > 
> > I'm not sure I follow.
> 
> This:
>         ("disk_eject", Struct(None, [...
>         
> creates an anonymous struct (due to the None) I was wondering if:
> libxl_event_disk_eject = Struct("event_disk_eject", [
>                                         ("vdev", string)
>                                         ("disk", libxl_device_disk)])
> libxl_event = Struct("event", [
>     ...
>            ("disk_eject", libxl_event_disk_eject)
> might be convenient to users so they have a name for something they may
> want to pass around. I suppose they will probably just pass around the
> libxl_event in reality.

Oh, I see, yes, perhaps making it non-anonymous would be better.

Ian.

  reply	other threads:[~2011-07-13 16:17 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-12 18:37 [RFC 0/3] libxl event handling Ian Jackson
2011-07-12 18:37 ` [PATCH 1/3] RFC: libxl: API changes re domain type (and keyed union semantics) Ian Jackson
2011-07-12 18:37   ` [PATCH 2/3] RFC: libxl: API changes re event handling Ian Jackson
2011-07-12 18:37     ` [PATCH 3/3] RFC: libxl: internal API for " Ian Jackson
2011-07-13 10:22       ` Ian Campbell
2011-07-13 10:21     ` [PATCH 2/3] RFC: libxl: API changes re " Ian Campbell
2011-07-13 14:03       ` Ian Jackson
2011-07-13 16:08         ` Ian Campbell
2011-07-13 16:17           ` Ian Jackson [this message]
2011-07-13 16:33             ` Ian Campbell
2011-07-13 17:04               ` Ian Jackson
2011-07-13  9:19   ` [PATCH 1/3] RFC: libxl: API changes re domain type (and keyed union semantics) Ian Campbell
2011-07-15 12:45   ` Ian Campbell
2011-07-15 13:13     ` Ian Jackson
2011-07-18  9:06       ` [PATCH 0 of 6] libxl: IDL improvements Ian Campbell
2011-07-18  9:06         ` [PATCH 1 of 6] libxl: Give the HVM domain type the name "HVM" Ian Campbell
2011-07-18  9:06         ` [PATCH 2 of 6] libxl: replace libxl__domain_is_hvm with libxl__domain_type Ian Campbell
2011-07-18  9:06         ` [PATCH 3 of 6] libxl: specify HVM vs PV in build_info using libxl_domain_type enum Ian Campbell
2011-07-18  9:06         ` [PATCH 4 of 6] libxl: specify HVM vs PV in create_info " Ian Campbell
2011-07-18  9:06         ` [PATCH 5 of 6] libxl: use libxl_domain_type enum with libxl__domain_suspend_common Ian Campbell
2011-07-18  9:06         ` [PATCH 6 of 6] libxl: Keyed unions key off an enum instead of an arbitrary expression Ian Campbell
2011-07-18 13:57       ` [PATCH 0 of 6 V2] libxl: IDL improvements Ian Campbell
2011-07-18 13:57         ` [PATCH 1 of 6 V2] libxl: Give the HVM domain type the name "HVM" Ian Campbell
2011-07-18 14:56           ` Wei LIU
2011-07-18 15:20             ` Ian Jackson
2011-07-18 13:57         ` [PATCH 2 of 6 V2] libxl: replace libxl__domain_is_hvm with libxl__domain_type Ian Campbell
2011-07-18 13:57         ` [PATCH 3 of 6 V2] libxl: specify HVM vs PV in build_info using libxl_domain_type enum Ian Campbell
2011-07-18 13:57         ` [PATCH 4 of 6 V2] libxl: specify HVM vs PV in create_info " Ian Campbell
2011-07-18 13:57         ` [PATCH 5 of 6 V2] libxl: use libxl_domain_type enum with libxl__domain_suspend_common Ian Campbell
2011-07-18 13:57         ` [PATCH 6 of 6 V2] libxl: Keyed unions key off an enum instead of an arbitrary expression Ian Campbell
2011-07-18 16:11         ` [PATCH 0 of 6 V2] libxl: IDL improvements Ian Jackson

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=19997.50480.893938.619011@mariner.uk.xensource.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=jfehlig@novell.com \
    --cc=xen-devel@lists.xensource.com \
    /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.