From: Wei Liu Subject: Re: [PATCH v6 for-4.5 5/5] xl: add support for 'channels' Date: Fri, 26 Sep 2014 11:22:54 +0100 Message-ID: <20140926102254.GE12753@zion.uk.xensource.com> References: <1411591685-25308-1-git-send-email-dave.scott@citrix.com> <1411591685-25308-6-git-send-email-dave.scott@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XXSfy-0005oh-Dp for xen-devel@lists.xenproject.org; Fri, 26 Sep 2014 10:22:58 +0000 Content-Disposition: inline In-Reply-To: <1411591685-25308-6-git-send-email-dave.scott@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Scott Cc: xen-devel@lists.xenproject.org, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Wed, Sep 24, 2014 at 09:48:05PM +0100, David Scott wrote: [...] > +=item C > + > +Specify the string name for this device. This parameter is mandatory. > +This should be a well-known name for the specific application (e.g. > +guest agent) and should be used by the frontend to connect the > +application to the right channel device. There is no formal registry > +of channel names, so application authors are encouraged to make their > +names unique by including domain name and version number in the string > +(e.g. org.mydomain.guestagent.1). > + > +=item C > + > +Specify how the backend will be implemented. This following options are > +available: > + > +=over 4 > + > +=item B: > + I don't think you need that ":" > +The backend will bind a Unix domain socket (at the path given by > +B), call listen and accept connections. The backend will proxy > +data between the channel and the connected socket. > + > +=item B: > + Ditto. > +The backend will create a pty and proxy data between the channel and the > +master device. The command B can be used to discover the > +assigned slave device. > + > +=back > + > +=back > + > =item B > > Specifies the host PCI devices to passthrough to this guest. Each B > diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 > index f1e95db..35aa3a4 100644 > --- a/docs/man/xl.pod.1 > +++ b/docs/man/xl.pod.1 > @@ -1215,6 +1215,16 @@ List virtual network interfaces for a domain. > > =back > > +=head2 CHANNEL DEVICES > + > +=over 4 > + > +=item B I > + > +List virtual channel interfaces for a domain. > + > +=back > + > =head2 VTPM DEVICES > > =over 4 > diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h > index 10a2e66..afc5f8b 100644 > --- a/tools/libxl/xl.h > +++ b/tools/libxl/xl.h > @@ -78,6 +78,7 @@ int main_top(int argc, char **argv); > int main_networkattach(int argc, char **argv); > int main_networklist(int argc, char **argv); > int main_networkdetach(int argc, char **argv); > +int main_channellist(int argc, char **argv); > int main_blockattach(int argc, char **argv); > int main_blocklist(int argc, char **argv); > int main_blockdetach(int argc, char **argv); > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index d6f311f..89a8697 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -530,7 +530,7 @@ static void split_string_into_string_list(const char *str, > > s = strdup(str); > if (s == NULL) { > - fprintf(stderr, "unable to allocate memory to parse bootloader args\n"); > + fprintf(stderr, "unable to allocate memory to split string\n"); > exit(-1); > } > > @@ -546,7 +546,7 @@ static void split_string_into_string_list(const char *str, > > sl = malloc((nr+1) * sizeof (char *)); > if (sl == NULL) { > - fprintf(stderr, "unable to allocate memory for bootloader args\n"); > + fprintf(stderr, "unable to allocate memory to split string\n"); > exit(-1); > } > > @@ -567,7 +567,6 @@ static void split_string_into_string_list(const char *str, > and look for CTYPE in libxl_internal.h */ > typedef int (*char_predicate_t)(const int c); > > -static void trim(char_predicate_t predicate, const char *input, char **output) __attribute__ ((unused)); > static void trim(char_predicate_t predicate, const char *input, char **output) > { > char *p, *q, *tmp; > @@ -593,10 +592,6 @@ static void trim(char_predicate_t predicate, const char *input, char **output) > static int split_string_into_pair(const char *str, > const char *delim, > char **a, > - char **b) __attribute__ ((unused)); [...] > + switch (chn->connection){ > + case LIBXL_CHANNEL_CONNECTION_UNKNOWN: > + fprintf(stderr, "channel has unknown 'connection'\n"); > + exit(1); > + case LIBXL_CHANNEL_CONNECTION_SOCKET: > + if (!path) { > + fprintf(stderr, "channel connection 'socket' requires path=..\n"); > + exit(1); > + } > + chn->u.socket.path = xstrdup(path); > + break; Don't need to do anything for 'PTY' connection? If so, please as a comment here. > + default: > + break; So this branch covers 'PTY' case? If so, please document, if not it should have exit(1). I can see from the code at this point chn->connection is limited to one of the three types defined so far, but I would rather be explicit. That is, have case LIBXL_CHANNEL_CONNECTION_PTY: /* nothing to do */ break; default: fprintf("something's wrong\n"); exit(1); Wei.