From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [PATCH v2 10/10] libxl: add device backend listener in order to launch backends
Date: Mon, 18 Nov 2013 12:47:44 +0100 [thread overview]
Message-ID: <5289FE60.2010305@citrix.com> (raw)
In-Reply-To: <21126.24509.186907.315659@mariner.uk.xensource.com>
On 15/11/13 18:54, Ian Jackson wrote:
> 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/<domid>/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".
Ack, I don't mind changing it to out. I don't see any flow in which we
could leak the nested_ao right now.
>
> 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 ?
I'm not sure I follow, if instead of setting free_ao to true I just
return, who is going to free the ddev and dguest if necessary? (note
that the callback is not using ddev or dguest at all)
Also, doing it in the callback is not safe, because we are no longer
holding the "Big lock", so we would have to add another lock which I
would prefer to avoid.
next prev parent reply other threads:[~2013-11-18 11:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 12:10 [PATCH v2 00/10] libxl: add driver domain backend daemon Roger Pau Monne
2013-11-11 12:10 ` [PATCH v2 01/10] libxl: Introduce nested async operations (nested ao) Roger Pau Monne
2013-11-11 12:10 ` [PATCH v2 02/10] libxl: create a local xenstore libxl and device-model dir for guests Roger Pau Monne
2013-11-11 15:24 ` Ian Jackson
2013-11-11 16:36 ` Roger Pau Monné
2013-11-12 15:03 ` Ian Jackson
2013-11-11 12:10 ` [PATCH v2 03/10] libxl: don't remove device frontend path from driver domains Roger Pau Monne
2013-11-11 12:10 ` [PATCH v2 04/10] libxl: synchronize device removal when using " Roger Pau Monne
2013-11-11 17:02 ` Ian Jackson
2013-11-14 10:37 ` Roger Pau Monné
2013-11-14 12:42 ` Ian Jackson
2013-11-11 12:10 ` [PATCH v2 05/10] libxl: remove the Qemu bodge for driver domain devices Roger Pau Monne
2013-11-15 17:09 ` Ian Jackson
2013-11-18 10:07 ` Roger Pau Monné
2013-11-18 11:26 ` Ian Jackson
2013-11-11 12:10 ` [PATCH v2 06/10] libxl: don't launch Qemu on Dom0 for Qdisk devices on driver domains Roger Pau Monne
2013-11-15 17:11 ` Ian Jackson
2013-11-11 12:10 ` [PATCH v2 07/10] libxl: add Qdisk backend launch helper Roger Pau Monne
2013-11-15 17:34 ` Ian Jackson
2013-11-11 12:10 ` [PATCH v2 08/10] xl: put daemonize code in it's own function Roger Pau Monne
2013-11-15 17:36 ` Ian Jackson
2013-11-11 12:10 ` [PATCH v2 09/10] libxl: revert 326a7b74 Roger Pau Monne
2013-11-15 17:37 ` Ian Jackson
2013-11-15 18:16 ` Ian Jackson
2013-11-15 18:22 ` Andrew Cooper
2013-11-11 12:10 ` [PATCH v2 10/10] libxl: add device backend listener in order to launch backends Roger Pau Monne
2013-11-15 17:54 ` Ian Jackson
2013-11-18 11:47 ` Roger Pau Monné [this message]
2013-11-18 14:22 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5289FE60.2010305@citrix.com \
--to=roger.pau@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).