xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v9 06/17] libxl: convert libxl__device_disk_local_attach to an async op
Date: Fri, 20 Jul 2012 13:52:47 +0100	[thread overview]
Message-ID: <5009549F.1010006@citrix.com> (raw)
In-Reply-To: <20489.16555.897359.556419@mariner.uk.xensource.com>

Ian Jackson wrote:
>> Ian Jackson wrote:
>>>> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
>>> ...
>>>> @@ -2191,6 +2202,7 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
>>>>              default:
>>>>                  LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
>>>>                             "unrecognized disk format: %d", disk->format);
>>>> +                rc = ERROR_FAIL;
>>>>                  break;
>>> Why `break' and not `goto out' ?  (Here and later.)
>>>
>>> Perhaps this would be clear from context.
>> This is part of the original code, and I don't think it's a good idea to
>> add more patches to my series, if we want to get them in for 4.2.
> 
> Perhaps this would have been clearer in context.  Can I have a git
> branch to look at next time pretty please ? :-)  (I see you're working
> on that, great, thanks.)

Yes, I will try to send a pull request later.

>>>> +static void bootloader_finished_cb(libxl__egc *egc,
>>>> +                                   libxl__disk_local_state *dls,
>>>> +                                   int rc)
>>>> +{
>>>> +    STATE_AO_GC(dls->ao);
>>>> +    libxl__bootloader_state *bl = CONTAINER_OF(dls, *bl, dls);
>>>> +
>>>> +    free(bl->dls.diskpath);
>>>> +    bl->dls.diskpath = 0;
>>> Surely that isn't right ?  We should let the local detach machinery
>>> free this.  The doc comment in the dls struct definition doesn't say
>>> we're to mess with it like this.
>> I've changed that so the free is done inside the callback of
>> libxl__device_disk_local_initiate_detach.
> 
> Is the diskpath not from the gc ?  If it isn't then the memory
> lifetime and ownership needs to be documented by the variable
> definition (ie, the struct member definition).

No, and frankly I can't find any reason why it shouldn't be allocated
from the gc. The local attach/detach functions are internal to libxl,
and if the resulting diskpath has to survive the gc I would say this is
a problem of the caller.

>>>> +static void bootloader_disk_attached_cb(libxl__egc *egc,
>>>> +                                        libxl__disk_local_state *dls,
>>>> +                                        int rc)
>>>> +{
>>>> +    STATE_AO_GC(dls->ao);
>>>> +    libxl__bootloader_state *bl = CONTAINER_OF(dls, *bl, dls);
>>>> +    const libxl_domain_build_info *info = bl->info;
>>>> +    const char *bootloader;
>>>> +
>>>> +    if (rc) {
>>>> +        LOG(ERROR, "failed to attach local disk for bootloader execution");
>>>> +        dls->callback = bootloader_disk_failed_cb;
>>>> +        libxl__device_disk_local_initiate_detach(egc, dls);
>>>> +        return;
>>> So in line with my comments about the possible states of a dls, I
>>> think this recovery should be done by the local attach machinery, not
>>> left to the caller like this.
>> Ok, I agree this is not optimal, but I would also argue that it has the
>> same behaviour as the previous code. I will fix this by calling the
>> detach function in the attach callback if the attach failed.
> 
> I'm not sure what you mean by "I will fix this by ...", because AFAICT
> you are already calling "the detach function"
> (libxl__device_disk_local_initiate_detach) in "the attach callback"
> (bootloader_disk_attached_cb).

Yes, but this is in the attach callback provided by the user, which
means we call the user callback with an unknown disk state.

Now I've fixed this and I'm calling detach internally, so the user
doesn't have to deal with this. If the local attach fails, the
bootloader just has to exit.

> Anyway, I don't really mind whether the disk local attach exposes this
> Error state but if you do expose it you should document it.

  reply	other threads:[~2012-07-20 12:52 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13  9:44 [PATCH v9 00/15] execute hotplug scripts from libxl Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 01/17] libxl: change ao_device_remove to ao_device Roger Pau Monne
2012-07-18 16:29   ` Ian Jackson
2012-07-19 15:15     ` Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 02/17] libxl: move device model creation prototypes Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 03/17] libxl: convert libxl_domain_destroy to an async op Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 04/17] libxl: move bootloader data strucutres and prototypes Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 05/17] libxl: refactor disk addition to take a helper Roger Pau Monne
2012-07-17 16:46   ` Ian Jackson
2012-07-20 10:38     ` Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 06/17] libxl: convert libxl__device_disk_local_attach to an async op Roger Pau Monne
2012-07-19 16:16   ` Ian Jackson
2012-07-20  9:48     ` Roger Pau Monne
2012-07-20 11:27       ` Ian Jackson
2012-07-20 12:52         ` Roger Pau Monne [this message]
2012-07-20 17:45         ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 07/17] libxl: rename vifs to nics Roger Pau Monne
2012-07-19 15:12   ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 08/17] libxl: convert libxl_device_disk_add to an async op Roger Pau Monne
2012-07-19 15:58   ` Ian Jackson
2012-07-19 16:14     ` Roger Pau Monne
2012-07-20 10:43       ` Ian Jackson
2012-07-20  9:41   ` Ian Campbell
2012-07-20 10:54     ` Roger Pau Monne
2012-07-20 11:28       ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 09/17] libxl: convert libxl_device_nic_add to an async operation Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 10/17] libxl: add option to choose who executes hotplug scripts Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 11/17] libxl: rename _IOEMU nic type to VIF_IOEMU Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 12/17] libxl: set correct nic type depending on the guest Roger Pau Monne
2012-07-19 16:29   ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 13/17] libxl: use libxl__xs_path_cleanup on device_destroy Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 14/17] libxl: call hotplug scripts for disk devices from libxl Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 15/17] libxl: call hotplug scripts for nic " Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 16/17] libxl: convert libxl_device_vkb_add to an async operation Roger Pau Monne
2012-07-19 16:35   ` Ian Jackson
2012-07-19 16:41     ` Roger Pau Monne
2012-07-20 10:49       ` Ian Jackson
2012-07-20 11:00         ` Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 17/17] libxl: convert libxl_device_vfb_add " Roger Pau Monne
2012-07-26 10:42   ` 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=5009549F.1010006@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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).