From: Ian Campbell Subject: Re: [PATCH v3 3/3] xl: add support for channels Date: Wed, 2 Jul 2014 16:33:32 +0100 Message-ID: <1404315212.8137.15.camel@kazak.uk.xensource.com> References: <1403512141-12283-1-git-send-email-dave.scott@citrix.com> <1403512141-12283-4-git-send-email-dave.scott@citrix.com> <21416.16448.159980.302953@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X2MXR-0007T8-Bq for xen-devel@lists.xenproject.org; Wed, 02 Jul 2014 15:33:37 +0000 In-Reply-To: <21416.16448.159980.302953@mariner.uk.xensource.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: Ian Jackson Cc: xen-devel@lists.xenproject.org, David Scott , wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Mon, 2014-06-23 at 15:57 +0100, Ian Jackson wrote: > David Scott writes ("[PATCH v3 3/3] xl: add support for channels"): > > This adds support for channel declarations of the form: > > channel = [ "name=...,kind=...[,path=...][,backend=...]" ] > > > + 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); > > I appreciate that you're just following the example of the vif > configuration here, but I think this is rather too much open-coded > string handling. FWIW I think there are a few places in xl where a precanned parser for strings of comma-separated key=value syntax would be quite valuable (the existing one is very disk specific due to the quirks for that syntax). I don't expect Dave to write one though... > > > + if (!strcmp(p, "backend")) { > > + free(chn->backend_domname); > > + chn->backend_domname = strdup(p2 + 1); > > At the very least, can we provide a macro or function or something to > do this ? I think the existing replace_string already does this. Ian