[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v3 1/5] net: introduce glib function for net
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [RFC PATCH v3 1/5] net: introduce glib function for network |
Date: |
Tue, 9 Apr 2013 16:03:11 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Apr 08, 2013 at 01:36:04PM +0800, Liu Ping Fan wrote:
> Bind each NetClientState with a GSource(ie,NetClientSource). Currently,
> these GSource attached with default context, but in future, after
> resolving the race between handlers and the interface exposed by
> NetClientInfo and other re-entrant issue, we can run NetClientState
> on different threads
>
> Signed-off-by: Liu Ping Fan <address@hidden>
> ---
> include/net/net.h | 15 +++++++++++++
> net/net.c | 61
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 76 insertions(+), 0 deletions(-)
>
> diff --git a/include/net/net.h b/include/net/net.h
> index cb049a1..cb2451d 100644
> --- a/include/net/net.h
> +++ b/include/net/net.h
> @@ -44,6 +44,7 @@ typedef ssize_t (NetReceiveIOV)(NetClientState *, const
> struct iovec *, int);
> typedef void (NetCleanup) (NetClientState *);
> typedef void (LinkStatusChanged)(NetClientState *);
> typedef void (NetClientDestructor)(NetClientState *);
> +typedef void (NetClientBindCtx)(NetClientState *, GMainContext *);
>
> typedef struct NetClientInfo {
> NetClientOptionsKind type;
> @@ -55,8 +56,20 @@ typedef struct NetClientInfo {
> NetCleanup *cleanup;
> LinkStatusChanged *link_status_changed;
> NetPoll *poll;
> + NetClientBindCtx *bind_ctx;
> } NetClientInfo;
>
> +typedef bool (*Pollable)(void *opaque);
> +
> +typedef struct NetClientSource {
> + GSource source;
> + /* fix me, to expand as array in future */
> + GPollFD gfd;
> + Pollable readable;
> + Pollable writable;
> + void *opaque;
> +} NetClientSource;
This struct has nothing to do with the net subsystem. It is a generic
utility for file descriptor read/write monitoring. It should be in a
separate file (maybe util/fdsource.c?).
NetClient should not know about the GSource at all. It's an
implementation detail of the NetClient, just like the actual fd is also
an implementation detail that net.h/net.c doesn't know about.
Stefan
- [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, Liu Ping Fan, 2013/04/08
- [Qemu-devel] [RFC PATCH v3 2/5] net: port tap onto glib, Liu Ping Fan, 2013/04/08
- [Qemu-devel] [RFC PATCH v3 1/5] net: introduce glib function for network, Liu Ping Fan, 2013/04/08
- Re: [Qemu-devel] [RFC PATCH v3 1/5] net: introduce glib function for network,
Stefan Hajnoczi <=
- [Qemu-devel] [RFC PATCH v3 3/5] net: resolve race of tap backend and its peer, Liu Ping Fan, 2013/04/08
- [Qemu-devel] [RFC PATCH v3 4/5] net: port vde onto glib, Liu Ping Fan, 2013/04/08
- [Qemu-devel] [RFC PATCH v3 5/5] net: port socket to glib, Liu Ping Fan, 2013/04/08
- Re: [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, Stefan Hajnoczi, 2013/04/09
- Re: [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, liu ping fan, 2013/04/10
- Re: [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, Stefan Hajnoczi, 2013/04/10
- Re: [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, liu ping fan, 2013/04/11
- Re: [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, Stefan Hajnoczi, 2013/04/11
- Re: [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, liu ping fan, 2013/04/11
- Re: [Qemu-devel] [RFC PATCH v3 0/5] port network layer onto glib, Stefan Hajnoczi, 2013/04/12