diff mbox series

[4/5] tools/xl: Merge down debug/dry-run section of create_domain()

Message ID 8f95e4a6664a24fd990cbb8162a1855c95cb6b66.1640590794.git.ehem+xen@m5p.com (mailing list archive)
State New, archived
Headers show
Series Some misc from my tree | expand

Commit Message

Elliott Mitchell Dec. 18, 2020, 1:42 a.m. UTC
create_domain()'s use of printf_info_sexp() could be merged down to a
single dump_by_config(), do so.  This results in an extra JSON dictionary
in output, but I doubt that is an issue for dry-run or debugging output.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
 tools/xl/xl_vmcontrol.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

Comments

Luca Fancellu Dec. 29, 2021, 5:19 p.m. UTC | #1
> On 18 Dec 2020, at 01:42, Elliott Mitchell <ehem+xen@m5p.com> wrote:
> 
> create_domain()'s use of printf_info_sexp() could be merged down to a
> single dump_by_config(), do so.  This results in an extra JSON dictionary
> in output, but I doubt that is an issue for dry-run or debugging output.
> 

Don’t know if the extra output is a problem, but for me looks ok
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>

> Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
> ---
> tools/xl/xl_vmcontrol.c | 14 +-------------
> 1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
> index 435155a033..4b95e7e463 100644
> --- a/tools/xl/xl_vmcontrol.c
> +++ b/tools/xl/xl_vmcontrol.c
> @@ -856,19 +856,7 @@ int create_domain(struct domain_create *dom_info)
> 
>     if (debug || dom_info->dryrun) {
>         FILE *cfg_print_fh = (debug && !dom_info->dryrun) ? stderr : stdout;
> -        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);
> -            if (!json) {
> -                fprintf(stderr,
> -                        "Failed to convert domain configuration to JSON\n");
> -                exit(1);
> -            }
> -            fputs(json, cfg_print_fh);
> -            free(json);
> -            flush_stream(cfg_print_fh);
> -        }
> +        dump_by_config(default_output_format, cfg_print_fh, &d_config, -1);
>     }
> 
> 
> -- 
> 2.30.2
> 
>
diff mbox series

Patch

diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
index 435155a033..4b95e7e463 100644
--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -856,19 +856,7 @@  int create_domain(struct domain_create *dom_info)
 
     if (debug || dom_info->dryrun) {
         FILE *cfg_print_fh = (debug && !dom_info->dryrun) ? stderr : stdout;
-        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);
-            if (!json) {
-                fprintf(stderr,
-                        "Failed to convert domain configuration to JSON\n");
-                exit(1);
-            }
-            fputs(json, cfg_print_fh);
-            free(json);
-            flush_stream(cfg_print_fh);
-        }
+        dump_by_config(default_output_format, cfg_print_fh, &d_config, -1);
     }