From 5eee16776209f086099f06f5658cfe8713af9d8b Mon Sep 17 00:00:00 2001 From: Roger Pau Monne Date: Fri, 22 Dec 2017 16:45:37 +0000 Subject: [PATCH] xl: parsing code movement MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code movement in preparation for making the bootloader, bootloader_args, nested_hvm and timer_mode fields shared between all guests types. While moving the code, limit the line-length to 80 columns. No functional change. Signed-off-by: Roger Pau Monné Acked-by: Ian Jackson Ported to modify xl_cmdimpl.c (which was refactored in 4.9). --- tools/libxl/xl_cmdimpl.c | 95 +++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 45 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 7e8a8ae5c4..a6df0c9de7 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1552,6 +1552,56 @@ static void parse_config_data(const char *config_source, xlu_cfg_get_defbool(config, "driver_domain", &c_info->driver_domain, 0); xlu_cfg_get_defbool(config, "acpi", &b_info->acpi, 0); + if (b_info->type == LIBXL_DOMAIN_TYPE_PV) { + xlu_cfg_replace_string (config, "bootloader", + &b_info->u.pv.bootloader, 0); + switch (xlu_cfg_get_list_as_string_list(config, "bootloader_args", + &b_info->u.pv.bootloader_args, 1)) + { + + case 0: break; /* Success */ + case ESRCH: break; /* Option not present */ + case EINVAL: + if (!xlu_cfg_get_string(config, "bootloader_args", &buf, 0)) { + + fprintf(stderr, "WARNING: Specifying \"bootloader_args\"" + " as a string is deprecated. " + "Please use a list of arguments.\n"); + split_string_into_string_list(buf, " \t\n", + &b_info->u.pv.bootloader_args); + } + break; + default: + fprintf(stderr,"xl: Unable to parse bootloader_args.\n"); + exit(-ERROR_FAIL); + } + } else { + if (!xlu_cfg_get_long(config, "timer_mode", &l, 1)) { + const char *s = libxl_timer_mode_to_string(l); + fprintf(stderr, "WARNING: specifying \"timer_mode\" as an integer is deprecated. " + "Please use the named parameter variant. %s%s%s\n", + s ? "e.g. timer_mode=\"" : "", + s ? s : "", + s ? "\"" : ""); + + if (l < LIBXL_TIMER_MODE_DELAY_FOR_MISSED_TICKS || + l > LIBXL_TIMER_MODE_ONE_MISSED_TICK_PENDING) { + fprintf(stderr, "ERROR: invalid value %ld for \"timer_mode\"\n", l); + exit (1); + } + b_info->u.hvm.timer_mode = l; + } else if (!xlu_cfg_get_string(config, "timer_mode", &buf, 0)) { + if (libxl_timer_mode_from_string(buf, &b_info->u.hvm.timer_mode)) { + fprintf(stderr, "ERROR: invalid value \"%s\" for \"timer_mode\"\n", + buf); + exit (1); + } + } + + xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0); + + } + switch(b_info->type) { case LIBXL_DOMAIN_TYPE_HVM: kernel_basename = libxl_basename(b_info->kernel); @@ -1648,29 +1698,6 @@ static void parse_config_data(const char *config_source, exit (1); } } - if (!xlu_cfg_get_long(config, "timer_mode", &l, 1)) { - const char *s = libxl_timer_mode_to_string(l); - fprintf(stderr, "WARNING: specifying \"timer_mode\" as an integer is deprecated. " - "Please use the named parameter variant. %s%s%s\n", - s ? "e.g. timer_mode=\"" : "", - s ? s : "", - s ? "\"" : ""); - - if (l < LIBXL_TIMER_MODE_DELAY_FOR_MISSED_TICKS || - l > LIBXL_TIMER_MODE_ONE_MISSED_TICK_PENDING) { - fprintf(stderr, "ERROR: invalid value %ld for \"timer_mode\"\n", l); - exit (1); - } - b_info->u.hvm.timer_mode = l; - } else if (!xlu_cfg_get_string(config, "timer_mode", &buf, 0)) { - if (libxl_timer_mode_from_string(buf, &b_info->u.hvm.timer_mode)) { - fprintf(stderr, "ERROR: invalid value \"%s\" for \"timer_mode\"\n", - buf); - exit (1); - } - } - - xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0); xlu_cfg_get_defbool(config, "altp2mhvm", &b_info->u.hvm.altp2m, 0); @@ -1699,28 +1726,6 @@ static void parse_config_data(const char *config_source, break; case LIBXL_DOMAIN_TYPE_PV: { - xlu_cfg_replace_string (config, "bootloader", &b_info->u.pv.bootloader, 0); - switch (xlu_cfg_get_list_as_string_list(config, "bootloader_args", - &b_info->u.pv.bootloader_args, 1)) - { - - case 0: break; /* Success */ - case ESRCH: break; /* Option not present */ - case EINVAL: - if (!xlu_cfg_get_string(config, "bootloader_args", &buf, 0)) { - - fprintf(stderr, "WARNING: Specifying \"bootloader_args\"" - " as a string is deprecated. " - "Please use a list of arguments.\n"); - split_string_into_string_list(buf, " \t\n", - &b_info->u.pv.bootloader_args); - } - break; - default: - fprintf(stderr,"xl: Unable to parse bootloader_args.\n"); - exit(-ERROR_FAIL); - } - if (!b_info->u.pv.bootloader && !b_info->kernel) { fprintf(stderr, "Neither kernel nor bootloader specified\n"); exit(1); -- 2.39.5