xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Euan Harris <euan.harris@citrix.com>,
	xen-devel@lists.xensource.com, Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH] xl: Change output from xl -N create to be more useful
Date: Fri, 3 Jul 2015 12:25:57 +0100	[thread overview]
Message-ID: <1435922757.9447.92.camel@citrix.com> (raw)
In-Reply-To: <1435328955-19744-1-git-send-email-ian.jackson@eu.citrix.com>

On Fri, 2015-06-26 at 15:29 +0100, Ian Jackson wrote:
> Currently, xl -N create produces:
> 
>     {
>         "domid": null,
>         "config": {
>             "c_info": {
>                 "type": "pv",
>      [etc]
>     }
> 
> The domid is always NULL (as the domain has not been created at this
> stage).
> 
> This is annoying if you want to take this output and use it for some
> actually useful purpose like domain creation: either it needs to be
> massaged, or the the consuming tool needs to be taught to look inside
> the json object for the `config' element (which IMO makes no sense as
> an interface).
> 
> We would like to be able to pass libxl json configs around sensibly.
> In the future maybe xl will grow an option to create a domain from a
> json config, and this is currently something I want to be able to have
> a test tool do.
> 
> Note that this change is NOT BACKWARDS COMPATIBLE.  But it would only
> adversely affects anyone who uses `xl -N create' and then saves and
> processes the JSON.  (The output from xl list et al is not changed; it
> normally needs the domid.)  Such a user should probably have already
> have complained about the infelicitous output.  If they haven't it
> would be simple enough for them to bookend the output so as to provide
> compatible output.
> 
> If this backward compatibility problem is considered a blocker for
> this patch, then I will respin, with one of the following two
> workarounds:
>   - A new option to force sane output
>   - Generate output which contains the domain config twice,
>     once directly in the main struct, and a copy in "config"
> 
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Ian Campbell <ian.campbell@citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Euan Harris <euan.harris@citrix.com>
> ---
>  tools/libxl/xl_cmdimpl.c |   17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index c858068..9e9ee5e 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -2687,9 +2687,20 @@ static uint32_t create_domain(struct domain_create *dom_info)
>          }
>      }
>  
> -    if (debug || dom_info->dryrun)
> -        printf_info(default_output_format, -1, &d_config,
> -                    debug ? stderr : stdout);
> +    if (debug || dom_info->dryrun) {
> +        FILE *cfg_print_fh = debug ? stderr : stdout;

Did you mean to use this instead of the hardcoded stdout below?

Otherwise the debug output's location differs depending on the format,
which seems unexpected.

> +        if (default_output_format == OUTPUT_FORMAT_SXP) {
> +            printf_info_sexp(-1, &d_config, cfg_print_fh);
> +        } else {
> +            char *json = libxl_domain_config_to_json(ctx, &d_config);
> +            fputs(json, stdout);
> +            free(json);
> +            if (ferror(stdout) || fflush(stdout)) {
> +                perror("stdout"); exit(-1);
> +            }
> +        }
> +    }
> +
>  
>      ret = 0;
>      if (dom_info->dryrun)

  parent reply	other threads:[~2015-07-03 11:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 14:29 [PATCH] xl: Change output from xl -N create to be more useful Ian Jackson
2015-06-26 14:36 ` Ian Jackson
2015-06-26 15:10 ` Wei Liu
2015-06-26 15:30   ` Ian Jackson
2015-06-30 11:22     ` Ian Campbell
2015-07-03 11:10 ` Ian Jackson
2015-07-03 11:25 ` Ian Campbell [this message]
2015-07-03 11:31   ` Ian Jackson
2015-07-03 11:48     ` [PATCH 1/3] xl: Break out flush_stream Ian Jackson
2015-07-03 11:48       ` [PATCH 2/3] xl: Change output from xl -N create to be more useful Ian Jackson
2015-07-03 13:44         ` [PATCH 2/3] xl: Change output from xl -N create to be more useful [and 1 more messages] Ian Jackson
2015-07-03 11:48       ` [PATCH 3/3] xl: xl -N create -d sends json output to stdout, not stderr Ian Jackson
2015-07-03 12:06       ` [PATCH 1/3] xl: Break out flush_stream Ian Campbell

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=1435922757.9447.92.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=euan.harris@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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).