From: Ian Jackson Subject: Re: [PATCH v2 10/10] libxl: add device backend listener in order to launch backends Date: Fri, 15 Nov 2013 17:54:05 +0000 Message-ID: <21126.24509.186907.315659@mariner.uk.xensource.com> References: <1384171831-21275-1-git-send-email-roger.pau@citrix.com> <1384171831-21275-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: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VhNaw-0003PL-2u for xen-devel@lists.xenproject.org; Fri, 15 Nov 2013 17:54:14 +0000 In-Reply-To: <1384171831-21275-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.xenproject.org, Ian Campbell List-Id: xen-devel@lists.xenproject.org Roger Pau Monne writes ("[PATCH v2 10/10] libxl: add device backend listener in order to launch backends"): > Add the necessary logic in libxl to allow it to act as a listener for > launching backends in a driver domain, replacing udev (like we already > do on Dom0). This new functionality is acomplished by watching the > domain backend path (/local/domain//backend) and reacting to > device creation/destruction. ... > + > +static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch, > + const char *watch_path, > + const char *event_path) > +{ > + libxl__ddomain *ddomain = CONTAINER_OF(watch, *ddomain, watch); > + libxl__ao *nested_ao = libxl__nested_ao_create(ddomain->ao); > + STATE_AO_GC(nested_ao); > + char *p, *path; > + const char *sstate; > + int state, rc, num_devs; > + libxl__device *dev = NULL; > + libxl__ddomain_device *ddev = NULL; > + libxl__ddomain_guest *dguest = NULL; > + bool free_ao = false; > + > + /* Check if event_path ends with "state" and truncate it */ > + if (strlen(event_path) < strlen("state")) > + goto skip; I think this error handling style leaks the nested_ao sometimes. I would suggest: rename "skip" to "out". Would it be possible to abolish the "free_ao" variable, and to change this: > + rc = add_device(egc, nested_ao, dguest, ddev); > + if (rc > 0) > + free_ao = true; To this: if (!rc) /* device callback requires, and will dispose of, * nested_ao; ddev and dguest are linked in */ return; and always free the ao on ordinary exit ? Ian.