From: Ian Jackson Subject: Re: [PATCH v2 13/15] libxl: call hotplug scripts for nic devices from libxl Date: Tue, 22 May 2012 18:45:46 +0100 Message-ID: <20411.53450.122270.834784@mariner.uk.xensource.com> References: <1337695365-5142-1-git-send-email-roger.pau@citrix.com> <1337695365-5142-14-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-14-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 13/15] libxl: call hotplug scripts for nic devices from libxl"): > Since most of the needed work is already done in previous patches, > this patch only contains the necessary code to call hotplug scripts > for nic devices, that should be called when the device is added or > removed from a guest. > +libxl_nic_type libxl__nic_type(libxl__gc *gc, libxl__device *dev) > +{ > + char *snictype, *be_path; > + libxl_nic_type nictype; > + > + be_path = libxl__device_backend_path(gc, dev); > + snictype = libxl__xs_read(gc, XBT_NULL, > + GCSPRINTF("%s/%s", be_path, "type")); > + if (!snictype) { > + LOGE(ERROR, "unable to read nictype from %s", be_path); > + return -1; Please let us not have any more functions that return -1. Do you mean ERROR_FAIL ? > @@ -806,7 +827,18 @@ static void device_hotplug_fork_cb(libxl__egc *egc, libxl__ev_child *child, > : LIBXL__LOG_WARNING, > aodev->what, pid, status); > aodev->rc = ERROR_FAIL; > + goto out; > } > + > + if (aodev->dev->backend_kind == LIBXL__DEVICE_KIND_VIF && > + libxl__nic_type(gc, aodev->dev) == LIBXL_NIC_TYPE_IOEMU && And you need to handle the error here. > + !aodev->vif_executed) { > + aodev->vif_executed = 1; > + device_hotplug(egc, aodev); > + return; > + } This logic surrounding vif_executed is rather opaque. Are you trying to run this whole lot twice so that you can run two lots of scripts ? If so then perhaps the hotplug helper should simply take a counter, so that we don't expose this vif abstraction thing ? And it would be applicable to everything, not just vifs. Ian.