From: Ian Jackson Subject: Re: [PATCH v5 08/10] libxl: call hotplug scripts for disk devices from libxl Date: Thu, 7 Jun 2012 15:40:17 +0100 Message-ID: <20432.48465.656538.460862@mariner.uk.xensource.com> References: <1338383275-21315-1-git-send-email-roger.pau@citrix.com> <1338383275-21315-9-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: <1338383275-21315-9-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 v5 08/10] libxl: call hotplug scripts for disk 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 disk devices, that should be called when the device is added or > removed from a guest. ... > +static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) ... > +out: > + libxl__ev_time_deregister(gc, &aodev->ev); > + aodev->rc = rc; > + aodev->callback(egc, aodev); This little set of things - deregistering the timeout, and calling the callback, occur a few times. It would also be a good idea to check that the child has been reaped, or we may reenter this confusingly later. Perhaps it would be a good idea to have: static void device_hotplug_done(blah blah) { libxl__ev_time_deregister(gc, &aodev->ev); assert(!libxl__ev_child_inuse(&aodev->child)); aodev->callback(egc, aodev); } And this could be used on all of the completion paths. (You'll have to initialise the ev_child at the top of device_hotplug of course.) That way the whole thing has one entry and one exit. > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > index 5a2a87a..9dd2404 100644 > --- a/tools/libxl/libxl_internal.h > +++ b/tools/libxl/libxl_internal.h > @@ -72,6 +72,7 @@ > > #define LIBXL_INIT_TIMEOUT 10 > #define LIBXL_DESTROY_TIMEOUT 10 > +#define LIBXL_HOTPLUG_TIMEOUT 10 > #define LIBXL_DEVICE_MODEL_START_TIMEOUT 10 > #define LIBXL_XENCONSOLE_LIMIT 1048576 > #define LIBXL_XENCONSOLE_PROTOCOL "vt100" > @@ -1846,6 +1847,10 @@ struct libxl__ao_device { > int rc; > libxl__ev_devstate ds; > void *base; > + /* device hotplug execution */ > + char *what; `const char *what;' ? Ian.