From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Scott Subject: [PATCH v2 2/6] xl: add support for channels Date: Mon, 16 Jun 2014 10:49:51 +0100 Message-ID: <1402912195-24732-3-git-send-email-dave.scott@citrix.com> References: <1402912195-24732-1-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.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwTYO-0006oM-0G for xen-devel@lists.xenproject.org; Mon, 16 Jun 2014 09:50:16 +0000 In-Reply-To: <1402912195-24732-1-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: xen-devel@lists.xenproject.org Cc: ian.jackson@eu.citrix.com, David Scott , wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org This adds support for channel declarations of the form: channel = [ "name=...,type=...[,path=...][,backend=...]" ] where 'name' is a label to identify the channel to the frontend. If 'type = none' then the channel is connected to /dev/null If 'type = pty' then the channel is connected to a pty in the backend domain If 'type = path' then data is read from the channel and written to the file given by 'path = ...' in the backend domain. If 'type = socket' then the channel is connected to a Unix domain socket given by 'path = ...' in the backend domain. Signed-off-by: David Scott --- tools/libxl/xl_cmdimpl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 5195914..392f1a0 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -736,7 +736,7 @@ static void parse_config_data(const char *config_source, long l; XLU_Config *config; XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms; - XLU_ConfigList *ioports, *irqs, *iomem; + XLU_ConfigList *channels, *ioports, *irqs, *iomem; int num_ioports, num_irqs, num_iomem; int pci_power_mgmt = 0; int pci_msitranslate = 0; @@ -1289,6 +1289,62 @@ static void parse_config_data(const char *config_source, } } + if (!xlu_cfg_get_list (config, "channel", &channels, 0, 0)) { + d_config->num_channels = 0; + d_config->channels = NULL; + while ((buf = xlu_cfg_get_listitem (channels, + d_config->num_channels)) != NULL) { + libxl_device_channel *chn; + char *buf2 = strdup(buf); + char *p, *p2; + chn = ARRAY_EXTEND_INIT(d_config->channels, d_config->num_channels, + libxl_device_channel_init); + + p = strtok(buf2, ","); + if (!p) + goto skip_channel; + do { + while (*p == ' ') + p++; + if ((p2 = strchr(p, '=')) == NULL) + break; + *p2 = '\0'; + if (!strcmp(p, "backend")) { + free(chn->backend_domname); + chn->backend_domname = strdup(p2 + 1); + } else if (!strcmp(p, "name")) { + free(chn->name); + chn->name = strdup(p2 + 1); + } else if (!strcmp(p, "type")) { + if (chn->type != LIBXL_CHANNEL_TYPE_NONE) { + fprintf(stderr, "a channel may have only one output\n"); + exit(1); + } + if (!strcmp(p2 + 1, "none")) { + chn->type = LIBXL_CHANNEL_TYPE_NONE; + } else if (!strcmp(p2 + 1, "pty")) { + chn->type = LIBXL_CHANNEL_TYPE_PTY; + } else if (!strcmp(p2 + 1, "path")) { + chn->type = LIBXL_CHANNEL_TYPE_PATH; + } else if (!strcmp(p2 + 1, "socket")) { + chn->type = LIBXL_CHANNEL_TYPE_SOCKET; + } else { + fprintf(stderr, "unknown channel type '%s'\n", p2 + 1); + exit(1); + } + } else if (!strcmp(p, "path")) { + free(chn->path); + chn->path = strdup(p2 + 1); + } else { + fprintf(stderr, "unknown channel parameter '%s'," + " ignoring\n", p); + } + } while ((p = strtok(NULL, ",")) != NULL); +skip_channel: + free(buf2); + } + } + if (!xlu_cfg_get_list (config, "vif", &nics, 0, 0)) { d_config->num_nics = 0; d_config->nics = NULL; -- 1.7.10.4