All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>,
	Ian Jackson <ian.jackson@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>, xen-devel@lists.xen.org
Subject: Re: [PATCH v2 for 4.5] xl: Return proper error codes for block-attach and block-detach
Date: Mon, 17 Nov 2014 12:36:53 +0000	[thread overview]
Message-ID: <5469EBE5.4070209@eu.citrix.com> (raw)
In-Reply-To: <1415963574.7113.7.camel@citrix.com>

On 11/14/2014 11:12 AM, Ian Campbell wrote:
> On Thu, 2014-11-13 at 19:04 +0000, George Dunlap wrote:
>> Return proper error codes on failure so that scripts can tell whether
>> the command completed properly or not.
>>
>> Also while we're at it, normalize init and dispose of
>> libxl_device_disk structures.  This means calling init and dispose in
>> the actual functions where they are declared.
>>
>> This in turn means changing parse_disk_config_multistring() to not
>> call libxl_device_disk_init.  And that in turn means changes to
>> callers of parse_disk_config().
>>
>> It also means removing libxl_device_disk_init() from
>> libxl.c:libxl_vdev_to_device_disk().  This is only called from
>> xl_cmdimpl.c.
>>
>> Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
>> ---
>> CC: Ian Campbell <ian.campbell@citrix.com>
>> CC: Ian Jackson <ian.jackson@citrix.com>
>> CC: Wei Liu <wei.liu2@citrix.com>
>> CC: Konrad Wilk <konrad.wilk@oracle.com>
>>
>> Release justification: This is a bug fix.  It's a fairly minor one,
>> but it's also a very simple one.
>>
>> v2:
>>   - Restructure functions to make sure init and dispose are properly
>>   called.
> Sadly this bit has somewhat reduced the truth of the second half of your
> release justification, since the patch is a fair bit more subtle though.
> Although IMHO it hasn't invalidated the case for taking the patch for
> 4.5 (modulo comments below).

Well, I think we can take the hacky short-term fix I posted before, 
which is simple, and do a proper fix after the 4.6 dev window opens up; 
or we can do a more complete fix now.

Or, if the valgrind thing is really important, I could use the change 
you suggested, and do "return rc ? 1 : 0;" but I really think that's 
going in the wrong direction...

  -George

>
>> ---
>>   tools/libxl/libxl.c      |  2 --
>>   tools/libxl/xl_cmdimpl.c | 28 +++++++++++++++++++++-------
>>   2 files changed, 21 insertions(+), 9 deletions(-)
>>
>> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
>> index f7961f6..d9c4ce7 100644
>> --- a/tools/libxl/libxl.c
>> +++ b/tools/libxl/libxl.c
>> @@ -2611,8 +2611,6 @@ int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid,
>>       if (devid < 0)
>>           return ERROR_INVAL;
>>   
>> -    libxl_device_disk_init(disk);
> _init functions are idempotent, so this is harmless, I think. Existing
> callers (including things which aren't xl) might be relying on it.
> Outside of a freeze period that might be acceptable (those callers are
> buggy) but since you are asking for a freeze exception I think this may
> be going a step too far in cleaning things up.
>
> In terms of other callers you've missed
> tools/ocaml/libs/xl/xenlight_stubs.c (which appears buggy to me) in
> tree, plus whatever use e.g. libvirt makes of it.
>
>> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
>> index 3c9f146..25af715 100644
>> --- a/tools/libxl/xl_cmdimpl.c
>> +++ b/tools/libxl/xl_cmdimpl.c
>> @@ -485,8 +485,6 @@ static void parse_disk_config_multistring(XLU_Config **config,
>>   {
>>       int e;
>>   
>> -    libxl_device_disk_init(disk);
> Likewise here, although to a lesser extent since this is xl not libxl.
>>   
>> @@ -6378,13 +6382,17 @@ int main_blockattach(int argc, char **argv)
>>           printf("disk: %s\n", json);
>>           free(json);
>>           if (ferror(stdout) || fflush(stdout)) { perror("stdout"); exit(-1); }
>> -        return 0;
> You should set rc = 0 here rather than initing it at declaration to
> catch error paths which don't set the result. (we aren't very consistent
> about this in the code today so I'm only mentioning it because other
> changes seem to be needed, if that turns out not to be the case and
> there's no need for v3 then this shouldn't block acceptance)
>
>> +        goto out;
> I'm not 100% convinced by the use of the goto out error handling style
> for a success path, but it's probably better than duplicating the exit
> path or adding !dryrun checks to all the following operations. Ian,
> since you recently posted updated coding style for things around this,
> what do you think?
>
> Ian.
>

  reply	other threads:[~2014-11-17 12:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13 19:04 [PATCH v2 for 4.5] xl: Return proper error codes for block-attach and block-detach George Dunlap
2014-11-14 11:12 ` Ian Campbell
2014-11-17 12:36   ` George Dunlap [this message]
2014-11-20 15:47     ` Ian Campbell
2014-11-20 15:51       ` George Dunlap
2014-11-20 15:56         ` Ian Campbell
2014-11-20 15:59           ` George Dunlap
2014-11-20 19:46       ` Konrad Rzeszutek Wilk

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=5469EBE5.4070209@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=ian.jackson@citrix.com \
    --cc=wei.liu2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.