From: Ian Campbell Subject: Re: [PATCH 1/2] xl/libxl: add netdev to vif specification Date: Tue, 5 Feb 2013 11:41:10 +0000 Message-ID: <1360064470.17017.64.camel@zakaz.uk.xensource.com> References: <1359127583-32490-1-git-send-email-roger.pau@citrix.com> <1359127583-32490-2-git-send-email-roger.pau@citrix.com> <1360060806.17017.25.camel@zakaz.uk.xensource.com> <5110E563.8030604@citrix.com> <1360062659.17017.43.camel@zakaz.uk.xensource.com> <5110EF60.8010207@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5110EF60.8010207@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: Roger Pau Monne Cc: Ulf Kreutzberg , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Tue, 2013-02-05 at 11:39 +0000, Roger Pau Monne wrote: > On 05/02/13 12:10, Ian Campbell wrote: > > On Tue, 2013-02-05 at 10:56 +0000, Roger Pau Monne wrote: > >>>> @@ -98,6 +103,8 @@ static char **get_hotplug_env(libxl__gc *gc, > >>>> env[nr++] = GCSPRINTF("backend/%s/%u/%d", type, dev->domid, dev->devid); > >>>> env[nr++] = "XENBUS_BASE_PATH"; > >>>> env[nr++] = "backend"; > >>>> + env[nr++] = "netdev"; > >>>> + env[nr++] = netdev; > >>> > >>> Mightn't this be NULL? > >> > >> Yes, if we are using the vif-bridge script this will be NULL, but I > >> prefer adding this NULL here rather than having a conditional and a > >> variable array size (because we also have an assert(nr == arraysize) at > >> the end of the code block). > > > > Doesn't NULL terminate the env list? That might work right now while > > this option is last but it will confuse the hell out of whoever adds the > > next variable... > > Indeed, good catch. Also we are enforcing this (not passing NULL values > in env variables) in libxl__exec. No, finding a NULL env entry signals the end of the list: if (env != NULL) { for (int i = 0; env[i] != NULL && env[i+1] != NULL; i += 2) { if (setenv(env[i], env[i+1], 1) < 0) { LOGEV(ERROR, errno, "setting env vars (%s = %s)", env[i], env[i+1]); goto out; } } } I suppose we could treat env[i] != NULL and env[i+1] == NULL specially (e.g. ignore it and continue), but ick... Ian