From: Ian Jackson Subject: Re: [PATCH v2 10/15] libxl: add option to choose who executes hotplug scripts Date: Tue, 22 May 2012 18:13:50 +0100 Message-ID: <20411.51534.470771.717080@mariner.uk.xensource.com> References: <1337695365-5142-1-git-send-email-roger.pau@citrix.com> <1337695365-5142-11-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1337695365-5142-11-git-send-email-roger.pau@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: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org Roger Pau Monne writes ("[PATCH v2 10/15] libxl: add option to choose who executes hotplug scripts"): > Add and option to xl.conf file to decide if hotplug scripts are > executed from the toolstack (xl) or from udev as it used to be in the > past. > > + int hotplug_setting = libxl__hotplug_settings(gc, t); This function sometimes returns a non-negative boolean, and sometimes a (negative) libxl error code. That doesn't seem to be handled correctly here at the call site. (And it should be mentioned in a doc comment.) > diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c > index b89aef7..bdf14d5 100644 > --- a/tools/libxl/libxl_internal.c > +++ b/tools/libxl/libxl_internal.c > @@ -346,6 +346,25 @@ libxl_device_model_version libxl__device_model_version_running(libxl__gc *gc, > return value; > } > > +int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t) > +{ > + int rc = 0; > + char *val; > + > + val = libxl__xs_read(gc, t, DISABLE_UDEV_PATH); > + if (!val && errno != ENOENT) { > + LOGE(ERROR, "cannot read %s from xenstore", DISABLE_UDEV_PATH); > + rc = ERROR_FAIL; > + goto out; > + } > + if (!val) val = "0"; > + > + rc = atoi(val); This is a bit hazardous. What if the value in xenstore is "42" or "-3" ? At the very least I think you should write: rc = !!atoi(val); Thanks, Ian.